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

Regarding modify

Former Member
0 Likes
1,102

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

1 ACCEPTED SOLUTION
Read only

seshatalpasai_madala
Product and Topic Expert
Product and Topic Expert
0 Likes
1,084

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

13 REPLIES 13
Read only

Former Member
0 Likes
1,084

provided you are looping at itab2.

loop at itab2 into wa-itab2.
modify wa_tab1 from wa_tab2.
modify itab1 from wa_tab1.
endloop.

Read only

Former Member
0 Likes
1,084

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

Read only

seshatalpasai_madala
Product and Topic Expert
Product and Topic Expert
0 Likes
1,085

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

Read only

Former Member
0 Likes
1,084

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.

Read only

Former Member
0 Likes
1,084

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

Read only

Former Member
0 Likes
1,084

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

Read only

Former Member
0 Likes
1,084

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

Read only

Former Member
0 Likes
1,084

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

Read only

0 Likes
1,084

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.

Read only

0 Likes
1,084

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.

Read only

0 Likes
1,084

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

Read only

0 Likes
1,084

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

Read only

0 Likes
1,084

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.