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

question reg. Insert/Modify/Updating ztable

Former Member
0 Likes
840

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

7 REPLIES 7
Read only

Former Member
0 Likes
804

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

Read only

0 Likes
804

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)

Read only

0 Likes
804

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.

Read only

0 Likes
804

Does this 'modify' statement works with internal tables too for operations on database table?

Thanks again.

Read only

0 Likes
804

ya in both.

Read only

0 Likes
804

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)

Read only

Former Member
0 Likes
804

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