METHOD load_btd DATA lo_nd_btd TYPE REF TO if_wd_context_node DATA lt_

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
METHOD load_btd .
DATA lo_nd_btd TYPE REF TO if_wd_context_node.
DATA lt_btd TYPE wd_this->elements_btd.
DATA ls_btd TYPE wd_this->element_btd.
DATA ls_ctx TYPE /ain/dm_doc_ctx.
DATA ls_ctx2 TYPE /ain/dm_doc_ctx.
DATA lt_ctx TYPE TABLE OF /ain/dm_doc_ctx.
DATA lt_btd_header TYPE /ain/pub_btd_header_tab.
DATA ls_btd_header LIKE LINE OF lt_btd_header.
DATA lv_str TYPE string.
DATA ls_input TYPE wd_this->element_input.
DATA: ls_btd_intid TYPE /ain/pub_btd_intid_str,
lt_btd_intid TYPE /ain/pub_btd_intid_tab,
lt_btd_othattr TYPE /ain/pub_btd_othattr_cre_tab,
ls_btd_othattr TYPE /ain/pub_btd_othattr_cre_str,
lt_btd_obj_act TYPE /ain/pub_btd_obj_act_tab,
ls_btd_obj_act TYPE /ain/pub_btd_obj_act_str.
DATA: lt_return TYPE bapirettab.
* 08.09.2014 ReprintsevSV TZone support added
DATA: date TYPE d,
time TYPE t,
ts TYPE /ain/dm_timestamp.
DATA: str TYPE string.
DATA:
lt_tzone TYPE /ain/pub_btd_header_tzone_tab,
ls_tzone LIKE LINE OF lt_tzone,
lv_tzone TYPE tznzone.
lo_nd_btd = wd_context->get_child_node( name = wd_this->wdctx_input ).
lo_nd_btd->get_static_attributes( IMPORTING static_attributes = ls_input ).
lo_nd_btd = wd_context->get_child_node( name = wd_this->wdctx_btd ).
SELECT * INTO CORRESPONDING FIELDS OF TABLE lt_ctx FROM /ain/dm_doc_ctx WHERE field_name IN ('ZMS').
IF sy-subrc = 0.
LOOP AT lt_ctx INTO ls_ctx.
* select SINGLE * INTO LS_CTX2 from /AIN/DM_DOC_CTX where field_name = 'ZMBLNR' and doc_guid = LS_CTX-DOC_GUID.
* IF sy-subrc <> 0.
ls_btd_intid-btd_intid = ls_ctx-doc_guid.
APPEND ls_btd_intid TO lt_btd_intid.
* ENDIF.
ENDLOOP.
lv_str = text-drk.
IF lines( lt_btd_intid ) > 0.
CALL FUNCTION '/AIN/PUB_BO_BUFFER_REFRESH'.
CALL FUNCTION '/AIN/PUB_BTD_BY_INTIDS'
TABLES
it_btd_intid = lt_btd_intid
et_btd_header = lt_btd_header
* ET_BTD_ITM = ET_BTD_ITM
* ET_BTD_ITM_ACT = lt_btd_obj_act
* ET_BTD_ITM_EXP = ET_BTD_ITM_EXP
et_btd_obj_act = lt_btd_obj_act
* ET_BTD_OBIT_ACT =
* ET_BTD_OBJ_EXP = lt_btd_obj_exp
* ET_BTD_OBIT_EXP =
et_btd_othattr = lt_btd_othattr
* ET_BTD_STATUS =
et_return = lt_return
* ET_BTD_ITM_OTHATTR =
* IT_BTD_INTID_ACTP =
* ET_BTD_OBIT_ACT_AGGR =
* ET_BTD_OBJ_ACT_AGGR =
* ET_QCHAR_COMB =
* IT_POBJ_INTID =
et_btd_header_tzone = lt_tzone
EXCEPTIONS
technical_level_error = 1
business_level_error_input = 2
OTHERS = 3.
IF sy-subrc = 0.
LOOP AT lt_ctx INTO ls_ctx.
CLEAR ls_btd-amount.
IF ls_ctx-field_name = 'ZMS' AND ls_ctx-field_value IS NOT INITIAL.
LOOP AT lt_btd_obj_act INTO ls_btd_obj_act WHERE btd_intid = ls_ctx-doc_guid.
ADD 1 TO ls_btd-amount.
ENDLOOP.
READ TABLE lt_btd_header INTO ls_btd_header WITH KEY btd_intid = ls_ctx-doc_guid.
IF sy-subrc = 0.
ls_btd-doc_extid = ls_btd_header-btd_extid.
ENDIF.
READ TABLE lt_tzone WITH KEY btd_intid = ls_ctx-doc_guid INTO ls_tzone.
IF sy-subrc = 0 AND ls_tzone-tzone IS NOT INITIAL.
lv_tzone = ls_tzone-tzone.
ELSE.
lv_tzone = sy-zonlo.
ENDIF.
CONVERT TIME STAMP ls_ctx-create_time TIME ZONE lv_tzone INTO DATE date TIME time.
CONCATENATE date time INTO str.
ts = str.
ls_btd-time = ts. "LS_CTX-CREATE_TIME.
ls_btd-user = ls_ctx-create_uname.
ls_btd-zms = ls_ctx-field_value.
ls_btd-doc_guid = ls_ctx-doc_guid.
* IF LS_BTD-PLANT = LS_INPUT-WERKS.
* 05.09.2014 ReprintsevSV добавил фильтрацию по заводу с СЭ
IF ls_btd-zms = ls_input-lgort.
APPEND ls_btd TO lt_btd.
ENDIF.
**********************************************************************
* ENDIF.
ENDIF.
ENDLOOP.
ENDIF.
ENDIF.
ENDIF.
SORT lt_btd BY time DESCENDING.
lo_nd_btd->bind_table( new_items = lt_btd set_initial_elements = abap_true ).
ENDMETHOD.