Application Development 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: 

Updating a Z-table

Former Member
0 Kudos

Hi

I want to INSERT a record in a Z-Table if a material belongs to a particular plant.

My Code is:-

IF plant is not initial and plant = say 'ABC'.

INSERT ztable with material number

ENDIF.

Please corerct it if it is wrong at any place

Thank You

5 REPLIES 5

Former Member
0 Kudos

Hi,

Correct. Also add a commit work to write the record to the database.

Try to use MODIFY instead of INSERT.

MODIFY will insert the record if the record is not present, otherwise it will be modify the record..

Thanks,

naren

Message was edited by: Narendran Muthukumaran

Former Member
0 Kudos

Hi Subhash,

This will work fine.

egards,

Pragya

Former Member
0 Kudos

use MODIFY instead of INSERT

0 Kudos

plant='ABC' means it is not initial. Then y to use the condition plant is not initial? Try testing by removing the redundant code

Former Member
0 Kudos

Hi,

lets say you`re checking the existence of the plant data, try the following code --- it should work much better.

IF PLANT = 'XXX'.

MODIFY ZTABLE.

ENDIF.

You can use modify if you would want to change already existing entries, else use INSERT and check for sy-subrc.

Reward if helpful.

Regards