Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

How to assign multiple field values using read statement inside FOR loop in ABAP 7.4

Former Member
0 Likes
2,871

Hi All,

Please help me to understand how to assign values to multiple fields using READ inside FOR , eg. for P_NAME1, PCITY1,PSTREET.... it is from same LT_ADRCP table am trying to read ADDRNUMBER and populate those 5 fields, but here if I use the below syntax, the Read statement is used 5 times which is not a good practice, with one read statement can I fill all 5 fields once?

          et_entityset = VALUE lxt_entity( FOR lw_order IN lt_ekkn (
              aufnr = lw_order-aufnr
              ktext = lw_order-ktext
              parnr = lw_order-parnr
              aenam = lw_order-aenam
              gstrp = lw_order-gstrp
              gltrp = lw_order-gltrp
              p_name1 = lt_adrcp[ addrnumber = lw_order-adrnr ]-p_name1
              p_city1  = lt_adrcp[ addrnumber = lw_order-adrnr ]-p_city1
*              p_street = 'STREETP1'.
*              p_po_box_reg = 'STATEP1'.
*              p_post_code1 = '10011'.
              matnr = lw_order-matnr
              maktx = lw_order-maktx
              bdmng = lw_order-bdmng
              meins = lw_order-meins
              verpr = lw_order-verpr
              waers = lw_order-waers
              bdter = lw_order-bdter
              ebeln = lw_order-ebeln
              ebelp = lw_order-ebelp
  ) ).

Thanks in advance.

1 ACCEPTED SOLUTION
Read only

s1252
Product and Topic Expert
Product and Topic Expert
1,919

Have you tried using LET and VALUE combination, here is a ref https://help.sap.com/doc/abapdocu_752_index_htm/7.52/en-US/abaplet.htm

5 REPLIES 5
Read only

s1252
Product and Topic Expert
Product and Topic Expert
1,920

Have you tried using LET and VALUE combination, here is a ref https://help.sap.com/doc/abapdocu_752_index_htm/7.52/en-US/abaplet.htm

Read only

Sandra_Rossi
Active Contributor
1,919

s1252 please convert it into an answer, I guess it's a good answer, don't you?

Read only

Former Member
0 Likes
1,919

Hi Krishna, Thank you...I tried with LET and BASE too, but getting the syntax error if I use with the FOR .....it is allowing me to use only any one of those..may be am missing the proper syntax...let me try still more with it...

Read only

Sandra_Rossi
Active Contributor
1,919
et_entityset = VALUE lxt_entity( 
        FOR lw_order IN lt_ekkn 
        LET <adrcp> = lt_adrcp[ addrnumber = lw_order-adrnr ]
        IN ( 
        aufnr = lw_order-aufnr
        ...
        p_name1 = <adrcp>-p_name1
        ...
Read only

Former Member
0 Likes
1,919

Hi Sandra,

Thanks for example.

Hi Krishna,

Thank you...

Thank you both for the answer......