2006 Apr 18 9:06 AM
Hi, pls help to check why I couldn't update
Data itab like table of zz with header line.
clear ZZ.
Select * from ZZ into corresponding fields of table ITAB.
Loop at itab.
If itab-Name is initial.
select single name1 into itab-Name
from KNA1 where kunnr EQ ITAB-SOLD_TO.
elseif itab-MATL_DESC is initial.
select single maktx into itab-matl_desc
from makt where matnr EQ ITAB-MATERIAL and spras EQ SY-LANGU.
elseif itab-VTEXT is initial.
select single vtext into itab-VTEXT FROM TSPAT where SPART eq
ITAB-DIVISION and Spras EQ SY-LANGU.
endif.
modify zz from itab.
Endloop.
thanks a lot!
elly
2006 Apr 18 9:09 AM
Elly,
Are you sure the work values have changed from the original values, just check that once in debug mode.
Finally, USE COMMIT WORK.
regards,
Ravi
Note : Please mark the helpful answers
2006 Apr 18 9:09 AM
Elly,
Are you sure the work values have changed from the original values, just check that once in debug mode.
Finally, USE COMMIT WORK.
regards,
Ravi
Note : Please mark the helpful answers
2006 Apr 18 9:11 AM
HI,
Just write <b>MODIFY dbtab FROM TABLE itab</b>,
COMMIT WORK.
thanks
Sudheer
2006 Apr 18 9:18 AM
Hi, I have checked in debug mode, the work area data has changed, even I use MODIFY dbtab FROM TABLE itab,
COMMIT WORK.
it doesn't work.
thanks a lot!
elly
2006 Apr 18 9:32 AM
HI Elly,
1. Primary key
2. make sure the record u are checking
is of correct primary key.
(MODIFY works automatically based upon
the primary key field combination,
if the combination is found in dbtab (as compared to workarea),
then automatically UPDATE is done,
other wise INSERT is done
)
3. U have used many IFs.
For testing purpose,
HARDCODE some value (and do not use any if)
and put it in itab.
Then use MODIFY ZZ from itab.
COMMIT Work.
4. Then check, it should work.
(there is some minor mistake only)
regards,
amit m.
2006 Apr 18 9:13 AM
Hi Elly,
what is ZZ here. can't figure out from few of your statements like
clear ZZ.
regards,
Kinshuk
2006 Apr 18 9:14 AM
where is your update statement?
your not insert or append any record into ITAB. then how did you update into zz table?
Thanks & regards
Vasu
2006 Apr 18 9:14 AM
2006 Apr 18 9:48 AM
Hi Elly
You are getting records in the internal table work area (data is changin in the work area) i.e. itab but until and unless you dont append/insert those records into internal table body how will records be transferred to internal table body??
so in this case table itab i.e. itab[] is empty and thats why table zz is not getting updated from the table itab.
just put append/insert itab statment in your code.
Thanks
2006 Apr 18 9:49 AM
Hi Elly
You are getting records in the internal table work area (data is changin in the work area) i.e. itab but until and unless you dont append/insert those records into internal table body how will records be transferred to internal table body??
so in this case table itab i.e. itab[] is empty and thats why table zz is not getting updated from the table itab.
just put append/insert itab statment in your code.
Thanks
2006 Apr 18 10:01 AM
Hi!
You have to append or insert into your internal table else how it will work...
Regards,
Sangeeta.
2006 Apr 18 10:09 AM
Hi,
Refer this code:
IF GT_ZCO001[] IS NOT INITIAL.
* Modify the custom table ZCO001 with the entries in ZCO001.
MODIFY ZCO001 FROM TABLE GT_ZCO001.
IF SY-SUBRC NE 0.
* If the DB modification encounters an error, throw appropriate message.
ROLLBACK WORK.
MESSAGE S002(ZPS01). "Unable to insert values into the table
ELSE.
COMMIT WORK.
MESSAGE S003(ZPS01). "Records Updated.
ENDIF.
ELSE.
MESSAGE S012(ZPS01).
ENDIF.
Regards,
Gayathri
2006 Apr 18 10:19 AM
Hi Elly,
I doubt your approach to update the descriptions.
Actually the modify statement is working, but it is updating the table with the same old values again and again.
Refer the following code:
Loop at itab.
If itab-Name is initial.
select single name1 into itab-Name
from KNA1 where kunnr EQ ITAB-SOLD_TO.
endif.
if itab-MATL_DESC is initial.
select single maktx into itab-matl_desc
from makt where matnr EQ ITAB-MATERIAL and spras EQ SY-LANGU.
endif.
if itab-VTEXT is initial.
select single vtext into itab-VTEXT FROM TSPAT where SPART eq
ITAB-DIVISION and Spras EQ SY-LANGU.
endif.
modify zz from itab.
Endloop.
Your previous code updates only one of either name1 or vtext or maktx.
This code will update any text that is empty.
Hope it helps you.
Regards,
Ravi
2006 Apr 18 10:34 AM
Hi,
The following code will modify the ZZ table :-
Data: itab like table of zz,
wa_itab like line of zz.
refresh itab.
clear wa_itab.
Select *
from ZZ
into table ITAB.
check sy- subrc = 0.
Loop at itab into wa_itab.
If itab-Name is initial.
select single name1
into wa_itab-Name
from KNA1
where kunnr EQ ITAB-SOLD_TO.
elseif itab-MATL_DESC is initial.
select single maktx
into itab-matl_desc
from makt
where matnr EQ ITAB-MATERIAL
and spras EQ SY-LANGU.
elseif itab-VTEXT is initial.
select single vtext
into itab-VTEXT
FROM TSPAT
where SPART eq ITAB-DIVISION
and Spras EQ SY-LANGU.
endif.
modify itab from wa_itab.
Endloop.
<b>Modify zz from table itab.</b>
Regards,
Sameena