Application Development 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: 

Need help in logic

Former Member
0 Kudos

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

5 REPLIES 5

Former Member
0 Kudos

Heyy

No , your logic is not correct ,

You can not modify the table on which you are looping

Regards,

Uma Dave

0 Kudos

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

0 Kudos

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.

0 Kudos

hi sreeram

the internal tables tl_pge1 & tL_ITEM_PGE1 are having diffrent values for venum . So if i read tl_pge1 with the value from the table tL_ITEM_PGE1 it will give sy-subrc eq 4 since tl_pge1 is not having value present in tl_item_pge1 .

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

actually my requirement is to replace the VENUM value present in tl_pge1 into tl_item_pge1 .

So i should we achieve this .

thanks

pavan

0 Kudos

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.