2006 Jun 20 2:49 PM
Hi Guys,
I have the following condition i have to update the DB table from the Internal table but i will be having only 4 fields to update from Internal table depending on the match on the first field that is the key field. Its urgent and its a small query..
Thanks,
David.
2006 Jun 20 2:53 PM
Hi david,
1. i will be having only 4 fields to update from Internal table depending on the match on the first field that is the key field
Use this kind of logic.
LOOP AT ITAB.
CLEAR WORKAREA.
select single * from DBTAB
INTO WORKAREA
where primarykey = itab-field1.
if sy-subrc = 0.
WORKAREA-FIELD1 = ITAB-FIELD1.
WORKAREA-FIELD2 = ITAB-FIELD2.
WORKAREA-FIELD3 = ITAB-FIELD3.
WORKAREA-FIELD4 = ITAB-FIELD4.
MODIFY DBTAB FROM WORKAREA
ENDIF
ENDLOOP.
regards,
amit m.
2006 Jun 20 2:53 PM
Hi david,
1. i will be having only 4 fields to update from Internal table depending on the match on the first field that is the key field
Use this kind of logic.
LOOP AT ITAB.
CLEAR WORKAREA.
select single * from DBTAB
INTO WORKAREA
where primarykey = itab-field1.
if sy-subrc = 0.
WORKAREA-FIELD1 = ITAB-FIELD1.
WORKAREA-FIELD2 = ITAB-FIELD2.
WORKAREA-FIELD3 = ITAB-FIELD3.
WORKAREA-FIELD4 = ITAB-FIELD4.
MODIFY DBTAB FROM WORKAREA
ENDIF
ENDLOOP.
regards,
amit m.
2006 Jun 20 2:55 PM
Hi David,
This should work for updating the DB table.
UPDATE ztable SET: firstfield = '003',
secondfield = '0621/444444'
thirdfield = '0621/4444'
fourthfield = '0621/44'
WHERE primaryfield = '00017777'.
Regards,
Vicky
PS: Award points if helpful
2006 Jun 20 3:00 PM
Hi David
Loop at itab into wa_itab
update dbtbase set f1 = wa_itab-f1
f2 = wa_itab-f2
f3 = wa_itab-f3
f4 = wa_itab-f4
where key field = wa_itab-keyfield
Endloop.
commit work.
Award points if helpful
2006 Jun 20 3:56 PM
Hi there,
Its working for me but my only concern is i will have nearly 4000 records to update..So will it be a performance issue to loop thru them??..
Thanks in advance,
David.
2006 Jun 20 4:30 PM
If there are only 4000 records it will not be a problem.
Just make sure that the <b>COMMIT WORK</b> is outside the loop so that the database is not updated inside the loop.