Skip to Content
avatar image
Former Member

Need help in logic

i have 2 internal tables tl_item_pge1 & tl_pge1. In both the internal tables tl_item_pge1 & tl_pge1 there are 2 fields with field name VENUM . I want to replace the values of tl_item_pge1-venum with tl_pge1-venum .

I wrote the following logic .

As i dont have test data now, I 'm not able to test . so Please tell me if the below logic is correct .

loop at tl_item_pge1 into wl_item_pge1 .
      loop at tl_pge1 into wl_pge1.
        Move wl_pge1-INT_ID to wl_item_pge1-INT_ID .
        modify  tl_item_pge1 index sy-tabix from wl_item_pge1 transporting INT_ID .
      endloop.
    endloop.

Thanks& Regards

Pavan

Moderator message: please use more descriptive subject lines and code tags from now on.

Edited by: Thomas Zloch on Jun 21, 2010 11:27 AM

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • avatar image
    Former Member
    Jun 21, 2010 at 09:18 AM

    Heyy

    No , your logic is not correct ,

    You can not modify the table on which you are looping

    Regards,

    Uma Dave

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Pavan,

      Below code will solve your requierment...

      * Loop at 1st table
        LOOP AT tl_pge1 INTO wl_pge1.
      * Read the corresponding record from 2nd table
          READ TABLE tl_item_pge1 INTO wl_item_pge1 WITH KEY <field> = <wl_pge1-field>.
      * hold the row no of the corresponding record
          lw_tabix = sy-tabix.
          IF sy-subrc = 0.
      * If corresponding record found
            MOVE wl_pge1-int_id TO wl_item_pge1-int_id .
      * Modify the record
            MODIFY tl_item_pge1 INDEX lw_tabix FROM wl_item_pge1 TRANSPORTING int_id .
          ENDIF.
        ENDLOOP.
      

      Regards

      DKS

  • avatar image
    Former Member
    Jun 21, 2010 at 09:23 AM

    Please try with below code.

    what u wrote is correct but we shouldn't write loop with in loop. Instead of that we can write read statement with binary addition for performance issue

    loop at tl_item_pge1 into wl_item_pge1 .

    READ TABLE tl_pge1 into wl_pge1 WITH KEY VENUM = WL_ITEM_PGE1-VENUM.

    Move wl_pge1-INT_ID to wl_item_pge1-INT_ID .

    modify tl_item_pge1 index sy-tabix from wl_item_pge1 transporting INT_ID .

    endloop.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      READ TABLE tl_pge1 into wl_pge1 index sy-index(sy-tabix).

      pass the tl_pge1 venum value to tl_item_pge1 venumvalue

      and modify internal table.