Hi guru,
In my report i want to use loop outside, bec i i use inside the main loop means dump will coming, i cant modify if i use outside bec for one order N number of material will created, I send the Loop coding plz help me.
SORT gt_mseg BY aufnr bwart mblnr.
*LOOP AT gt_aufk INTO gs_aufk.
LOOP at gt_afvc into gs_afvc.
gs_final-aufpl = gs_afvc-aufpl.
gs_final-ltxa1 = gs_afvc-ltxa1.
READ TABLE gt_afko INTO gs_afko WITH key aufpl = gs_afvc-aufpl.
if sy-subrc = 0.
gs_final-aufnr = gs_afko-aufnr.
endif.
READ TABLE gt_aufk INTO gs_aufk with key aufnr = gs_afko-aufnr.
if sy-subrc = 0.
gs_final-erdat = gs_aufk-erdat.
gs_final-aufnr = gs_aufk-aufnr.
gs_final-auart = gs_aufk-auart.
gs_final-ernam = gs_aufk-ernam.
gs_final-ktext = gs_aufk-ktext.
gs_final-stort = gs_aufk-stort.
ENDIF.
READ TABLE gt_afih INTO gs_afih WITH KEY aufnr = gs_aufk-aufnr.
IF sy-subrc = 0.
gs_final-equnr = gs_afih-equnr.
ENDIF.
READ TABLE gt_equi INTO gs_equi WITH KEY equnr = gs_afih-equnr matnr = gs_afih-sermat.
IF sy-subrc = 0.
gs_final-sernr = gs_equi-sernr.
ENDIF.
READ TABLE gt_ebkn INTO gs_ebkn WITH KEY aufnr = gs_aufk-aufnr.
IF sy-subrc EQ 0.
gs_final-banfn = gs_ebkn-banfn.
ENDIF.
READ TABLE gt_eban INTO gs_eban with key banfn = gs_ebkn-banfn.
if sy-subrc = 0.
gs_final-afnam = gs_eban-afnam.
endif.
READ TABLE gt_ekpo INTO gs_ekpo WITH KEY banfn = gs_ebkn-banfn.
IF sy-subrc EQ 0.
gs_final-ebeln = gs_ekpo-ebeln.
gs_final-aedat = gs_ekpo-aedat.
gs_final-menge = gs_ekpo-menge.
gs_final-meins = gs_ekpo-meins.
gs_final-netpr = gs_ekpo-netpr.
gs_final-bednr = gs_ekpo-bednr.
ENDIF.
READ TABLE gt_ekko INTO gs_ekko with key ebeln = gs_ekpo-ebeln.
if sy-subrc = 0.
gs_final-lifnr = gs_ekko-lifnr.
ENDIF.
READ TABLE gt_lfa1 into gs_lfa1 with key lifnr = gs_ekko-lifnr.
if sy-subrc = 0.
gs_final-name1 = gs_lfa1-name1.
endif.
if i use like this means dump is coming ..........
*LOOP at gt_resb into gs_resb where rsnum = gs_afko-rsnum AND aufnr = gs_afko-aufnr AND aufpl = gs_afko-aufpl.
*READ TABLE gt_resb into gs_resb with key rsnum = gs_afko-rsnum aufnr = gs_afko-aufnr aufpl = gs_afko-aufpl.
*if sy-subrc = 0.
* gs_final-matnr = gs_resb-matnr.
*ENDIF.
** APPEND gs_resb to gt_resb.
** ENDLOOP.
*
*READ TABLE gt_makt INTO gs_makt with key matnr = gs_resb-matnr spras = 'E'.
*if sy-subrc = 0.
* gs_final-maktx = gs_makt-maktx.
*ENDIF.
LOOP AT gt_mseg INTO gs_mseg WHERE ebeln = gs_ekpo-ebeln .
gs_final-MBLNR = gs_mseg-MBLNR.
IF gs_mseg-bwart = '541'.
gs_final-t541 = gs_mseg-mblnr.
READ TABLE gt_mkpf INTO gs_mkpf WITH KEY mblnr = gs_final-t541.
IF sy-subrc = 0.
gs_final-t541d = gs_mkpf-budat.
ENDIF.
READ TABLE gt_zdocdetails INTO gs_zdocdetails WITH KEY mblnr = gs_mseg-mblnr.
IF sy-subrc EQ 0.
gs_final-gpassno = gs_zdocdetails-gpassno.
gs_final-status = gs_zdocdetails-status.
ENDIF.
ELSEIF gs_mseg-bwart = '542'.
gs_final-t542 = gs_mseg-mblnr.
READ TABLE gt_mkpf INTO gs_mkpf WITH KEY mblnr = gs_final-t542.
IF sy-subrc = 0.
gs_final-t542d = gs_mkpf-budat.
ENDIF.
ENDIF.
ENDLOOP.
* APPEND gs_final to gt_final.
* clear :gs_final.
LOOP AT gt_essr INTO gs_essr WHERE ebeln = gs_ekpo-ebeln.
gs_essr1-ebeln = gs_essr-ebeln.
gs_essr1-erdat = gs_essr-erdat.
gs_essr1-lblni = gs_essr-lblni.
gs_essr1-packno = gs_essr-packno.
APPEND gs_essr1 TO gt_essr1.
ENDLOOP.
CLEAR gs_essr.
IF gt_essr1 IS INITIAL.
SHIFT gs_final-lifnr LEFT DELETING LEADING '0'.
APPEND gs_final TO gt_final.
ELSE.
LOOP AT gt_essr1 INTO gs_essr1 WHERE ebeln = gs_ekpo-ebeln.
gs_final-lblni = gs_essr1-lblni.
gs_final-sesdat = gs_essr1-erdat.
gs_final-packno = gs_essr1-packno.
SHIFT gs_final-lifnr LEFT DELETING LEADING '0'.
READ TABLE gt_eskl INTO gs_eskl with key hpackno = gs_essr1-packno.
if sy-subrc = 0.
gs_final-menge1 = gs_eskl-menge.
gs_final-netwr = gs_eskl-netwr.
endif.
APPEND gs_final TO gt_final.
ENDLOOP.
CLEAR gt_essr1.
CLEAR gs_essr1.
ENDIF.
CLEAR : gs_final,gs_essr,gs_ekko,gs_ekpo,gs_mseg,gs_aufk,gs_afih,gs_lfa1,gs_makt,gs_ebkn,gs_eskl.
ENDLOOP.
I try this not working.
lOOP at gt_final INTO gs_final.
loop at gt_resb into gs_resb wherersnum = gs_afko-rsnum and aufnr = gs_afko-aufnr and aufpl = gs_afko-aufpl.
gs_final-matnr = gs_resb-matnr.
READ TABLE gt_makt INTO gs_makt with key matnr = gs_final-matnr spras = 'E'.
if sy-subrc = 0.
gs_final-maktx = gs_makt-maktx.
ENDIF.
MODIFY gt_final FROM gs_final TRANSPORTING matnr maktx.
CLEAR gs_final.
ENDLOOP.
endloop.