do_read_data

  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
122
123
124
125
126
METHOD do_read_data .
DATA lo_nd_importing TYPE REF TO if_wd_context_node.
DATA lo_nd_filter_material TYPE REF TO if_wd_context_node.
DATA lo_nd_filter_mat_group TYPE REF TO if_wd_context_node.
DATA lo_el_importing TYPE REF TO if_wd_context_element.
DATA lr_be_table TYPE REF TO data.
FIELD-SYMBOLS : <ft_be> TYPE ANY TABLE.
DATA lr_finyear_table TYPE REF TO data.
FIELD-SYMBOLS : <ft_finyear> TYPE ANY TABLE.
DATA lr_mvp_table TYPE REF TO data.
FIELD-SYMBOLS : <ft_mvp> TYPE ANY TABLE.
DATA lr_docnum_table TYPE REF TO data.
FIELD-SYMBOLS : <ft_docnum> TYPE ANY TABLE.
DATA lr_docdate_table TYPE REF TO data.
FIELD-SYMBOLS : <ft_docdate> TYPE ANY TABLE.
DATA lr_doctype_table TYPE REF TO data.
FIELD-SYMBOLS : <ft_doctype> TYPE ANY TABLE.
DATA lr_nds_table TYPE REF TO data.
FIELD-SYMBOLS : <ft_nds> TYPE ANY TABLE.
* Get range table for material from helper class and bind it to context
lr_be_table = wd_this->m_handler->get_range_table_of_sel_field( 'BE' ).
ASSIGN lr_be_table->* TO <ft_be> .
lr_finyear_table = wd_this->m_handler->get_range_table_of_sel_field( i_id = 'FINYEAR' ).
ASSIGN lr_finyear_table->* TO <ft_finyear> .
lr_docnum_table = wd_this->m_handler->get_range_table_of_sel_field( i_id = 'DOCNUM' ).
ASSIGN lr_docnum_table->* TO <ft_docnum> .
lr_docdate_table = wd_this->m_handler->get_range_table_of_sel_field( i_id = 'DOCDATE' ).
ASSIGN lr_docdate_table->* TO <ft_docdate> .
lr_doctype_table = wd_this->m_handler->get_range_table_of_sel_field( i_id = 'DOCTYPE' ).
ASSIGN lr_doctype_table->* TO <ft_doctype> .
lr_nds_table = wd_this->m_handler->get_range_table_of_sel_field( i_id = 'NDS' ).
ASSIGN lr_nds_table->* TO <ft_nds> .
lr_mvp_table = wd_this->m_handler->get_range_table_of_sel_field( 'MVP' ).
ASSIGN lr_mvp_table->* TO <ft_mvp> .
********* Пункт 5.1
TYPES BEGIN OF lty_rq5_tmp.
TYPES bukrs TYPE bukrs.
TYPES gjahr TYPE gjahr.
TYPES belnr TYPE MBLNR.
TYPES budat TYPE budat.
TYPES awkey TYPE awkey.
TYPES pswsl TYPE pswsl.
TYPES dmbtr TYPE dmbtr.
TYPES END OF lty_rq5_tmp.
DATA lt_rq5_bkpf TYPE STANDARD TABLE OF bkpf.
DATA lt_rq5_bseg TYPE STANDARD TABLE OF bseg.
DATA lt_rq5_tmp_bkpf TYPE STANDARD TABLE OF lty_rq5_tmp.
DATA lt_rq5_tmp_bseg TYPE STANDARD TABLE OF lty_rq5_tmp.
DATA lt_rq5_tmp_common TYPE TABLE OF lty_rq5_tmp.
"FIELD-SYMBOLS : <ft_rq5_tmp_common> TYPE TABLE with.
DATA ls_bseg LIKE LINE OF lt_rq5_bseg.
DATA ls_tmp TYPE lty_rq5_tmp.
SELECT * INTO CORRESPONDING FIELDS OF TABLE lt_rq5_bkpf
FROM bkpf
WHERE
bukrs IN <ft_be> AND
gjahr IN <ft_finyear> AND
belnr IN <ft_docnum> AND
budat IN <ft_docdate> AND
blart IN <ft_doctype> AND
stgrd = '' AND "todo:Спросить про пустое значение в базе
stblg = '' AND
awtyp = 'RMRP'
.
CHECK sy-subrc = 0.
SELECT * INTO CORRESPONDING FIELDS OF TABLE lt_rq5_bseg
FROM bseg FOR ALL ENTRIES IN lt_rq5_bkpf
WHERE
bukrs = lt_rq5_bkpf-bukrs AND
gjahr = lt_rq5_bkpf-gjahr AND
belnr = lt_rq5_bkpf-belnr AND
mwskz IN <ft_nds>
.
MOVE-CORRESPONDING lt_rq5_bkpf TO lt_rq5_tmp_common.
LOOP AT lt_rq5_bseg INTO ls_bseg.
MOVE-CORRESPONDING ls_bseg TO ls_tmp.
APPEND ls_tmp TO lt_rq5_tmp_common.
CLEAR ls_bseg.
ENDLOOP.
DELETE ADJACENT DUPLICATES FROM lt_rq5_tmp_common.
"На выходе таблица lt_rq5_tmp_common с сохраненными промежуточными значениями
********* Пункт 5.2
data lt_ttt type standard table of ekbe.
"SELECT ekbe~ebeln ekbe~belnr ekbe~buzei ekbe~gjahr ekko~bsart ekko~ebeln
SELECT ekbe~ebeln ekbe~belnr ekbe~buzei ekbe~gjahr
FROM ( ekbe
INNER JOIN ekko
ON ekko~ebeln = ekbe~ebeln ) into CORRESPONDING FIELDS OF TABLE lt_ttt
FOR ALL ENTRIES IN lt_rq5_tmp_common
WHERE ekbe~belnr = lt_rq5_tmp_common-belnr
"AND ekbe~gjahr = lt_rq5_tmp_common-gjahr
.
ENDMETHOD.