Skip to Content

loop inside loop with fieldsymbols

in my logic field symnol data is not mapping correctly .

field symbols overwriting with new values.

please provide me solution .


SELECT * from  z30lo_t001w

     INTO CORRESPONDING FIELDS OF TABLE  lt_tkey.

   if lt_tkey is not INITIAL.

     LOOP at lt_tkey ASSIGNING <ls_key>.

        <ls_key>-STORE_INTERNAL_ID =  <ls_key>-werks.

** update  internal store id

      LOOP AT <ls_ref> ASSIGNING  <ls_ref_line>.

           <ls_key>-STORE_INTERNAL_ID = <ls_ref_line>-store_internal_id .

                ENDLOOP.

     ENDLOOP.



Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • avatar image
    Former Member
    Nov 02, 2015 at 07:16 AM

    Hi Sree,

    At both the place you are transferring data to <ls_key>-STORE_INTERNAL_ID , that's why it is overwriting with new values

    Regards,

    Ashish

    Add comment
    10|10000 characters needed characters exceeded

    • Hi Asish

      thanks for reply

      now i changed to below logic , but still updating on last record  for records in lt_key

      if lt_tkey is not INITIAL.

           LOOP at lt_tkey ASSIGNING <ls_key>.

      ** update  internal store id

            LOOP AT <ls_ref> ASSIGNING  <ls_ref_line>.

                 <ls_key>-STORE_INTERNAL_ID = <ls_ref_line>-store_internal_id .

                      ENDLOOP.

           ENDLOOP.


  • Nov 02, 2015 at 07:26 AM

    What are you trying to do, there is no where clause in the second loop, so the last execution of loop will overwrite any previous value. it_tkey  will always contain value of last record of <ls_ref> ???

    Regards,

    Raymond

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Sree A

      Hi Sree,

      If there is no common field in 2 tables then there is no meaning of loop inside loop.

      Please explain what is expected output.

      As data is getting assigned inside loop field <ls_key>-STORE_INTERNAL_ID will be always gets updated with last value.

      Regards,

      Ashish