‎2007 May 11 10:24 AM
Hi frnds,
I want a clarification.
Earlier i had a code as :
modify itab1 from itab2.
Now i hav my explicit work area created for both the tables .
and coding as
loop....
modify wa_tab1 from wa_tab2.
modify itab1 from wa_tab1.
endloop...
suggest me if at all i hav to make any changes..
regards,
sanjay
‎2007 May 11 10:28 AM
Hi,
Use
LOOP....
MOVE-CORRESPONDING FROM wa_tab2 to wa_tab1.
MODIFY itab1 from wa_tab1.
ENDLOOP.
Even better is
FIELD-SYMBOLS: <wa_tab1> like wa_tab1.
LOOP.. ITAB1 ASSGINING <wa_tab1>.
MOVE-CORRESPONDING FROM wa_tab2 to <wa_tab1>.
ENDLOOP.
In the second case you dont need modify as its the record of the internal table you are modifying when you change the FIELD-SYMBOL.
Best Regards,
Sesh
‎2007 May 11 10:26 AM
provided you are looping at itab2.
loop at itab2 into wa-itab2.
modify wa_tab1 from wa_tab2.
modify itab1 from wa_tab1.
endloop.
‎2007 May 11 10:27 AM
Hi Sanjay,
it is good that you are using the workarea.....
One more thing that will suggest which willhepl you is use tranporting .. it will make your code more fast ...rest all is fine.... both the way you are using will work well...
Regards,
Jayant
‎2007 May 11 10:28 AM
Hi,
Use
LOOP....
MOVE-CORRESPONDING FROM wa_tab2 to wa_tab1.
MODIFY itab1 from wa_tab1.
ENDLOOP.
Even better is
FIELD-SYMBOLS: <wa_tab1> like wa_tab1.
LOOP.. ITAB1 ASSGINING <wa_tab1>.
MOVE-CORRESPONDING FROM wa_tab2 to <wa_tab1>.
ENDLOOP.
In the second case you dont need modify as its the record of the internal table you are modifying when you change the FIELD-SYMBOL.
Best Regards,
Sesh
‎2007 May 11 10:30 AM
when looping at itab2
loop at itab2.
modify wa_tab1 from wa_tab2.
modify itab1 from wa_tab1.
endloop.
reward some points if helpful.
with regards,
suresh babu aluri.
‎2007 May 11 10:30 AM
Hi,
You need to have same structure for itab1 & itab2.
No need to use work area for itab1 in loop, bcoz there is no modify for wa.
loop at itab2 to wa_tab2.
modify itab1 from wa_tab2.
endloop.
Thanks
Sandeep
‎2007 May 11 10:31 AM
hi sanjay
the code is fine now it depends upon how many fields are there in the wa and how many do want to change if you want to change only few then better use TRANSPORTING abc FIELDS
reward if useful
‎2007 May 11 10:36 AM
Hi Sanjay,
In the sample code that u have given is absolutely ok. But, thing is that if the structures of itab1 and itab2 are similar, then no need to write the statement "modify wa_tab1 from wa_tab2." and the second Modify statement will become "modify itab1 from wa_tab2.". Now, If the structure of itab1 and itab2 are not similar, at that time u need to specify Elements that whose values you are "Transporting" from one work-area to another work-area. If helpful, reward with some points. Eagerly waiting for your reply.
Regards,
Pulokesh
‎2007 May 11 10:51 AM
FRNDS,
Thnks for replying.
Its giving earlier unicde error.
modify itab1 to itab2.
plzz suggest.
now when i hav used work area now i m getting error as
modify wa_tab1 from wa_tab2.
the error is wa_tab1 is not an internal table,occurs n is missing.
plzz suggest.
regards,
sanjay
‎2007 May 11 10:59 AM
Hi Sanjay,
u can't modify a work area(in ur case <b>wa_tab1</b>) using a <b>MODIFY</b> statement, u can only modify a internal table using <b>MODIFY</b> statement.
‎2007 May 11 11:02 AM
Oops!!! everyone went wrong
try this
loop at itab2 into wa-itab2.
move-corresponding wa_tab1 to wa_tab2.
modify itab1 from wa_tab1.
endloop.
‎2007 May 11 11:02 AM
Hi,
"modify wa_tab1 from wa_tab2." stratement is absolutely wrong since we cannot use Modify statement for work-area. So instead of this u can use the statement " Move-corresponding wa_tab2 to wa_tab1". if helpful reward some points.
Regards,
Pulokesh
‎2007 May 11 11:07 AM
Opps Please check the code once more:
Wrong Code:
loop at itab2 into wa-itab2.
move-corresponding wa_tab1 to wa_tab2.
modify itab1 from wa_tab1.
endloop.
Correct Code:
loop at itab2 into wa-itab2.
move-corresponding wa_tab2 to wa_tab1.
modify itab1 from wa_tab1.
endloop.
Regards,
Pulokesh
‎2007 May 11 11:34 AM
Hi Sanjay,
If your question is still not solved then please tell us what exactly your requirement is? If you think that the answers are helpful, then please reward with some points.
Regards,
Pulokesh.