2006 Sep 29 5:59 AM
I have a ztable with fields matnr and flag. I also have a work area with these fields. Now I want to insert/modify/update database table ztable in such a way that:
1. If the entry matnr already exists in the ztable, just convert the flag from ' ' to 'X'.
2. If the entry matnr does n't exist in the ztable, insert both matnr and flag (with value 'X').
How do you do that?
Can you give me a sample code?
Thanks,
Krishen
I have a ztable with fields matnr and flag. I also have a work area with these fields. Now I want to insert/modify/update database table ztable in such a way that:
1. If the entry matnr already exists in the ztable, just convert the flag from ' ' to 'X'.
2. If the entry matnr does n't exist in the ztable, insert both matnr and flag (with value 'X').
How do you do that?
Can you give me a sample code?
Thanks,
Krishen
2006 Sep 29 6:02 AM
Hi,
ZTABLE-FLAG = 'X'.
ZTABLE-MATNR = 'ASDNF'.
MODIFY ZTABLE.
If the record is there in it will update the flag with 'X'. otherwise it will insert a new record to the ZTABLE with the flag as 'X'.
MODIFY statement will insert record if there is no record available in the table..
Thanks,
Naren
2006 Sep 29 6:07 AM
hi,
one important ABAP ip.
NEver use update statement, to update a data base.
in u case use MODIFY.
behaviour of MODIFY - > If the recod is there it will update the flag field.
if the record is no there it will insert anew record with matnr and lag.
regards,
anver
pls mark points if hlped( when the point system comes back)
2006 Sep 29 6:08 AM
modify use as a both insert ans update command..
if recored is there it update the record
if recored is not there than it works as a insert command.
2006 Sep 29 6:16 AM
Does this 'modify' statement works with internal tables too for operations on database table?
Thanks again.
2006 Sep 29 6:18 AM
2006 Sep 29 6:30 AM
final question reg. this thread:
Suppose if the work area contains only 2 fields (matnr, flag) and where as the z database table contains 3 fields (matnr, field A, flag), does our coding still apply correctly for the requirement mentioned?
Thanks a lot for your helpful answers.
(btw, I am getting some error while rewarding points)
2006 Sep 29 6:32 AM
Hi,
Make the work area similar to that of the ZTABLE..based on the keys of the ZTABLE it will update or insert...
Please reward the points once the points awarding is working corretly..
Thanks,
Naren
Message was edited by: Narendran Muthukumaran
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |