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

MODIFY statement problem

Former Member
0 Likes
779

Hi experts..

I want to modify the database table , by using internal table.

but we can use this modify statement "modify database_table from internal_table" when bothe tables are of same structure.

but my internal table has different structure, means i have built my internal table by using some fields not all fields from database table.

so i want to modify the database table by using internal table.

how to do this?

6 REPLIES 6
Read only

Former Member
0 Likes
664

Hi,

Declare a new internal table SAY B with the structure same as that of database table to be modified.

transfer the contents of the old internal table say A to the new table B.You can use Loop and Move Corresponding statements.

Then Modify the database table from internal table B.

Regards,

Vimal.

Read only

Former Member
0 Likes
664

Hi,

You cannot directly modify the db table from an internal table whose structure is not same as the db table.

What you will have to do is to copy the internal table to another table which has the same structure as the db table and then write the modify statement. There is no other way.

BR,

Advait

Read only

viquar_iqbal
Active Contributor
0 Likes
664

Hi

In an alternate way you can try this.

MODIFY DBTAB FROM wa .

in the work area put the values of the internal table work area for that you have use loop or real table statement.

This is the example taken from help.sap.com.

DATA message_wa TYPE t100. 

message_wa-sprsl = 'EN'. 
message_wa-arbgb = 'MYMSGCLASS'. 
message_wa-msgnr =  '100'. 
message_wa-text =  'Some new message ...'. 

MODIFY t100 FROM message_wa.

Thanks&Regards,

Viquar Iqbal

Read only

sridhar_meesala
Active Contributor
0 Likes
664

Hi,

Declare a internal table of type database table.

DATA itab1 TYPE <database table> OCCURS 10.

LOOP AT itab.
MOVE-CORRESPONDING itab1 TO itab1.
ENDLOOP.

Now you can modify your database tabel using the itab1.

Thanks,

Sri.

Read only

Former Member
0 Likes
664

if u want to modify database table from internal table the structure of internal table should be same as database table therefore define one more internal table with same structure like database table that u want to modify and move data of first internal table to second internal table then u can modify database table from second internal table.

Read only

Former Member
0 Likes
664

loop at it_tab1.

modify ztab1 from it_tab1.

endloop.