Code: Alles auswählen.
" Fill essr tab
lv_counter = lines( gt_ekko ).
LOOP AT gt_ekko ASSIGNING <gs_ekko>.
CLEAR: gs_essr_tab.
SELECT txz01 AS txz01_essr packno AS essr_packno "essr~ebeln essr~ebelp
lblni erdat bldat lwert knttp
loekz waers AS essr_waers xblnr user1
INTO CORRESPONDING FIELDS OF gs_essr_tab "ok
FROM essr
WHERE ebeln = <gs_ekko>-ebeln
AND ebelp = <gs_ekko>-ebelp
AND lblni IN s_lblni.
lv_counter_essr = lv_counter_essr + 1.
CASE sy-subrc.
WHEN '0'.
IF lv_counter_essr = lv_counter.
<gs_ekko>-lblni = gs_essr_tab-lblni.
<gs_ekko>-erdat = gs_essr_tab-erdat.
<gs_ekko>-bldat = gs_essr_tab-bldat.
IF gs_essr_tab-loekz = ' '.
<gs_ekko>-lwert = gs_essr_tab-lwert.
ELSE.
CLEAR gs_essr_tab-lwert.
ENDIF.
<gs_ekko>-txz01_essr = gs_essr_tab-txz01_essr.
<gs_ekko>-knttp = gs_essr_tab-knttp.
<gs_ekko>-ebeln = gs_essr_tab-ebeln.
<gs_ekko>-ebelp = gs_essr_tab-ebelp.
<gs_ekko>-essr_packno = gs_essr_tab-essr_packno.
<gs_ekko>-loekz = gs_essr_tab-loekz.
<gs_ekko>-essr_waers = gs_essr_tab-essr_waers.
<gs_ekko>-xblnr = gs_essr_tab-xblnr.
<gs_ekko>-user1 = gs_essr_tab-user1.
APPEND <gs_ekko> TO gt_essr.
ELSE.
APPEND INITIAL LINE TO gt_essr ASSIGNING <gs_essr>.
<gs_essr>-lifnr = <gs_ekko>-lifnr.
<gs_essr>-name1 = <gs_ekko>-name1.
<gs_essr>-bsart = <gs_ekko>-bsart.
<gs_essr>-bedat = <gs_ekko>-bedat.
<gs_essr>-txz01 = <gs_ekko>-txz01.
<gs_essr>-commitment = <gs_ekko>-commitment.
<gs_essr>-waers = <gs_ekko>-waers.
<gs_essr>-actvalue = <gs_ekko>-actvalue.
<gs_essr>-ekorg = <gs_ekko>-ekorg.
<gs_essr>-ekgrp = <gs_ekko>-ekgrp.
<gs_essr>-bukrs = <gs_ekko>-bukrs.
<gs_essr>-matkl = <gs_ekko>-matkl.
<gs_essr>-loekz_ekpo = <gs_ekko>-loekz_ekpo.
<gs_essr>-lblni = gs_essr_tab-lblni.
<gs_essr>-erdat = gs_essr_tab-erdat.
<gs_essr>-bldat = gs_essr_tab-bldat.
IF gs_essr_tab-loekz = ' '.
<gs_essr>-lwert = gs_essr_tab-lwert.
ELSE.
CLEAR gs_essr_tab-lwert.
ENDIF.
<gs_essr>-txz01 = <gs_ekko>-txz01.
<gs_essr>-knttp = gs_essr_tab-knttp.
<gs_essr>-ebeln = gs_essr_tab-ebeln.
<gs_essr>-ebelp = gs_essr_tab-ebelp.
<gs_essr>-essr_packno = gs_essr_tab-essr_packno.
<gs_essr>-loekz = gs_essr_tab-loekz.
<gs_essr>-essr_waers = gs_essr_tab-essr_waers.
<gs_essr>-xblnr = gs_essr_tab-xblnr.
<gs_essr>-user1 = gs_essr_tab-user1.
ENDIF.
ENDCASE.
ENDSELECT.
ENDLOOP. "gt_dtab
Code: Alles auswählen.
ASSIGN COMPONENT ... OF STRUCTURE ... TO ...
Code: Alles auswählen.
DATA: gs_essr_tab TYPE ZNPM_CONTI_ALV.
data: gt_essr type TABLE OF ZNPM_CONTI_ALV.
DATA: gt_ekko TYPE TABLE OF ZNPM_CONTI_ALV.
FIELD-SYMBOLS: <gs_ekko> TYPE any,
<gv_dyn_field> type any,
<gs_essr_tab> type any table.
data: lv_ebeln type ebeln.
data: lv_ebelp type ebelp.
DATA: lv_counter TYPE i,
lv_counter_essr type i.
lv_counter = lines( gt_ekko ).
BREAK-POINT.
LOOP AT gt_ekko ASSIGNING <gs_ekko>.
ASSIGN COMPONENT 'EBELN'
OF STRUCTURE <gs_ekko> TO <gv_dyn_field>.
lv_ebeln = <gv_dyn_field>.
ASSIGN COMPONENT 'EBELP'
OF STRUCTURE <gs_ekko> TO <gv_dyn_field>.
lv_ebelp = <gv_dyn_field>.
* CLEAR: gt_essr_tab.
SELECT lblni erdat bldat lwert txz01 knttp
ebeln ebelp packno
INTO CORRESPONDING FIELDS OF gs_essr_tab
FROM essr
WHERE ebeln = lv_ebeln
AND ebelp = lv_ebelp.
lv_counter_essr = lv_counter_essr + 1.
CASE sy-subrc.
WHEN '0'.
IF lv_counter_essr = lv_counter.
* ASSIGN COMPONENT sy-index OF STRUCTURE gs_essr_tab TO <gs_ekko>.
* <gs_ekko>-lblni = gs_essr_tab-lblni.
* <gs_ekko>-erdat = gs_essr_tab-erdat.
* <gs_ekko>-bldat = gs_essr_tab-bldat.
* <gs_ekko>-lwert = gs_essr_tab-lwert.
* <gs_ekko>-txz01 = gs_essr_tab-txz01.
* <gs_ekko>-knttp = gs_essr_tab-knttp.
* <gs_ekko>-ebeln = gs_essr_tab-ebeln.
* <gs_ekko>-ebelp = gs_essr_tab-ebelp.
* <gs_ekko>-packno = gs_essr_tab-packno.
* APPEND <gs_ekko> TO gt_essr.
* ELSE.
* APPEND INITIAL LINE TO gt_essr ASSIGNING <gs_essr>.
* <gs_essr>-lifnr = <gs_ekko>-lifnr.
* <gs_essr>-name1 = <gs_ekko>-name1.
* <gs_essr>-bsart = <gs_ekko>-bsart.
* <gs_essr>-bedat = <gs_ekko>-bedat.
* <gs_essr>-txz01 = <gs_ekko>-txz01.
* <gs_essr>-commitment = <gs_ekko>-commitment.
* <gs_essr>-waers = <gs_ekko>-waers.
* <gs_essr>-actvalue = <gs_ekko>-actvalue.
* <gs_essr>-lblni = gs_essr_tab-lblni.
* <gs_essr>-erdat = gs_essr_tab-erdat.
* <gs_essr>-bldat = gs_essr_tab-bldat.
* <gs_essr>-lwert = gs_essr_tab-lwert.
* <gs_essr>-txz01 = gs_essr_tab-txz01.
* <gs_essr>-knttp = gs_essr_tab-knttp.
* <gs_essr>-ebeln = gs_essr_tab-ebeln.
* <gs_essr>-ebelp = gs_essr_tab-ebelp.
* <gs_essr>-packno = gs_essr_tab-packno.
endif.
endselect.
endloop.