Code: Alles auswählen.
TYPES: BEGIN OF gt_bsid,
BUKRS like BSID-bukrs,
KUNNR like BSID-KUNNR,
BLDAT like BSID-BLDAT,
DMBTR like BSID-DMBTR,
ZFBDT like bsid-zfbdt,
ZBD1T like BSID-zbd1t,
ZBD2T like BSID-zbd2t,
ZBD3T like BSID-zbd3t,
SHKZG like BSID-shkzg,
faedt like RFPOS-FAEDT,
DMBTR5S like BSID-DMBTR,
DMBTR5H like BSID-DMBTR,
VBELN like BSID-vbeln,
END OF gt_bsid.
Code: Alles auswählen.
select * from bsid into CORRESPONDING FIELDS OF TABLE it_bsid
where bukrs in s_bukrs
and kunnr in s_kunde.
Code: Alles auswählen.
loop at it_bsid into it_wabsid.
CALL FUNCTION 'NET_DUE_DATE_GET'
EXPORTING
i_zfbdt = it_wabsid-zfbdt
i_zbd1t = it_wabsid-zbd1t
i_zbd2t = it_wabsid-zbd2t
i_zbd3t = it_wabsid-zbd3t
i_shkzg = it_wabsid-shkzg
i_rebzg = it_wabsid-vbeln
* I_KOART = 'D'
IMPORTING
e_faedt = i_faedt.
move i_faedt to it_wabsid-faedt.
MODIFY it_bsid from it_wabsid.
endloop.
Code: Alles auswählen.
loop at it_bsid into it_wabsid.
sort it_wabsid by kunnr.
IF it_wabsid-faedt >= sy-datum and it_wabsid-shkzg = 'S'.
at end of kunnr.
sum.
move it_wabsid-dmbtr to it_wabsid-dmbtr5s.
endat.
endif.
MODIFY it_bsid from it_wabsid.
endloop.
1. dein Namensschema ist bescheiden. Da gibt es deutlich bessere, dann wird es deutlich lesbarer. (z.B.: gt = global itab; gs = global structure: gw = global workarea)neptun277 hat geschrieben:Code: Alles auswählen.
loop at it_bsid into it_wabsid. sort it_wabsid by kunnr.
Code: Alles auswählen.
* Hilfsvariable für die Summierung:
DATA: gv_sum TYPE dmbtr.
* ITAB nach KUNNR für Summierung vor dem LOOP sortieren (du versuchst in deinem Code eine Struktur innerhalb des LOOPs zu sortieren)
SORT gt_bsid BY kunnr.
LOOP AT gt_bsid INTO gs_bsid.
AT NEW kunnr.
CLEAR: gv_sum. "Summe initialisieren
ENDAT.
* Bedingte Summierung
IF gs_bsid-dmbtr >= sy-datum AND gs_bsid-shkzg = 'S'.
gv_sum = gv_sum + gs_bsid-dmbtr.
ENDIF.
* Summe in ITAB übernehmen!
AT END OF kunnr.
gs_bsid-dmbtr5s = gv_sum.
MODIFY gt_bsid FROM gs_bsid TRANSPORTING dmbtr5s WHERE kunnr = gs_bsid-kunnr. "WICHTIG: Nur die Summe in die ITAB übernehmen
ENDAT.
ENDLOOP.