2023 Jun 12 12:01 PM
Can anybody tell me the alternative method to avoid query in loop.
Code: (Alternative Method is required).DATA: vstlnr LIKE mast-stlnr.
ENDLOOP.
Regards,
2023 Jun 12 6:51 PM
Dear Shahzaib,
Can you please try the following:
DATA: lt_mast TYPE TABLE OF mast,
ls_mast LIKE LINE OF lt_mast.
SELECT matnr stlnr FROM mast INTO TABLE lt_mast FOR ALL ENTRIES IN stb1 WHERE matnr = stb1-idnrk.
LOOP AT stb1 INTO wa_stb1.
READ TABLE lt_mast INTO ls_mast WITH KEY matnr = wa_stb1-idnrk.
IF sy-subrc = 0.
wa_mast-stlnr = ls_mast-stlnr.
APPEND wa_mast TO it_mast.
ENDIF.
ENDLOOP.
2023 Jun 12 6:51 PM
Dear Shahzaib,
Can you please try the following:
DATA: lt_mast TYPE TABLE OF mast,
ls_mast LIKE LINE OF lt_mast.
SELECT matnr stlnr FROM mast INTO TABLE lt_mast FOR ALL ENTRIES IN stb1 WHERE matnr = stb1-idnrk.
LOOP AT stb1 INTO wa_stb1.
READ TABLE lt_mast INTO ls_mast WITH KEY matnr = wa_stb1-idnrk.
IF sy-subrc = 0.
wa_mast-stlnr = ls_mast-stlnr.
APPEND wa_mast TO it_mast.
ENDIF.
ENDLOOP.
2023 Jun 13 10:09 AM
2023 Jun 13 11:58 AM