‎2007 May 22 5:04 AM
Hi,
I have two internal tables.itab1 and itab2.
The sturcture of both the tables are as:
begin of itab1
kunnr
name1
end of itab1.
begin of itab2
ort01
name1
land1
end of itab2.
now, i have data in both the tables using select statement.
Requiement is like this :
i want to check if value of field name1 is availabe in itab1. if itab1-name1 is not having any values then i want to update this field of itab1 with name1 of tale itab2.
i.e. in place of blank values of field itab1-name1 , i want to replcae this null value with values from itab2-name1.
Any help will be appricitated.
Thanks
‎2007 May 22 5:24 AM
HI HUssain,
There shud be 1 common field between iatb1 and itab2.
if possible add kunnr also in itab2 ... or any other common key. otherwise it is difficult which record name1 from itab2 to be inserted in itab1 record.
Both itabs shud have kunnr or any other field.
logic shud be like...
<b>loop at itab1.
if itab1-name1 is initial.
read table itab2 with key kunnr = itab1-kunnr. (or any other common field in DB table)
if sy-subrc = 0.
itab1-name1 = itab2-name1.
modify itab1 transporting name1.
endif.
endloop.</b>
Regards
SAB
‎2007 May 22 5:07 AM
Hi,
The first thing is there should be some common key in your two internal tables.
As you want to update NAME1 in ITAB1 from ITAB2, you need to compare it on something.
As you are having KUNNR in ITAB1, then you should have KUNNR in ITAB2 also so that you can compare and modify the values.
Revert back if you have further query.
Reward points if useful.
Regards,
Atish
‎2007 May 22 5:07 AM
Hi,
U can try the following code.
loop at itab1 into wa1.
if wa1-name1 eq space.
read table itab2 into wa2 with key ort01 = kunnr.
wa1-name1 = wa2-name1.
modify table itab1 from wa1 transporting name1.
endif.
clear: wa1,wa2.
endloop.
reward points if helpful.
regards,
Ravi G
‎2007 May 22 5:11 AM
hi,
code like this,
loop at itab1.
if itab1-name1 is initial.
itab1-name1 = itab2-name1. or [move itab2-name1 itab1-name1]
endloop.
if helpful reward some points.
with regards,
sureshbabu aluri.
‎2007 May 22 5:24 AM
HI HUssain,
There shud be 1 common field between iatb1 and itab2.
if possible add kunnr also in itab2 ... or any other common key. otherwise it is difficult which record name1 from itab2 to be inserted in itab1 record.
Both itabs shud have kunnr or any other field.
logic shud be like...
<b>loop at itab1.
if itab1-name1 is initial.
read table itab2 with key kunnr = itab1-kunnr. (or any other common field in DB table)
if sy-subrc = 0.
itab1-name1 = itab2-name1.
modify itab1 transporting name1.
endif.
endloop.</b>
Regards
SAB