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

Update in custom table from internal table....

Former Member
0 Likes
2,498

Hello,

I have custom table with following entries:

ZCUST:

A---01

B---02

C---03

Now internal table in code fetches following data:

D---04

B---02

E---05

B---01

So finally based on values of internal table, the custom table should have following

entries in end:

B---02

B---01

D---04

E---05

So if the values in custom table match with internal table then theys stay or

if they are not in internal table then it gets deleted (Like in this case its A and C)

Regards,

Rajesh.

2 REPLIES 2
Read only

former_member491305
Active Contributor
0 Likes
473

Hi ,

Do like this.Select * from zcust into table it_cust for all entriesl in ur internal table(ITAB(.

Loop at IT_CUST.

read table itab with key field1 = IT_CUST-field1.

if sy-subrc ne 0.

it_del_cust = it_cust.

append it_del_cust.

endif.

Endloop.

Modify zcust from table itab.

Delete zcust from table it_del_cust.

Regards,

Vigneswaran S

Read only

Former Member
0 Likes
473

1. Select all records from databse tale and store them into an internal table say i_tab1. It should contains

A---01

B---02

C---03

2. Now loop on the main table i_tab2 that contains

D---04

B---02

E---05

B---01

and read i_tab1, if record matches then store them in table i_tab3.And if not matches then store them in another table i_tab4. So after loop processing these tables should contain

i_tab3:

-


B---02

B---01

i_tab4:

-


D---04

E---05

3. Merge these table etries into a single table

i_final = i_tab3 + i_tab4

i_final:

-


B---02

B---01

D---04

E---05

4. Delete all records from database table ZCUST

5. Update all records from int. table i_final to table ZCUST

Regards,

joy.

Edited by: Joyjit Ghosh on Jun 23, 2008 10:07 PM