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

doubt in updating database table

Former Member
0 Likes
680

hi all

i want to modify values ztable from a internal table ....

for eg : the ztable contains matnr and accept_qty

matnr qty

mat01

mat02

i need to modify qty of the table .. i am using where condition (ie modify where matnr = ) but where condition is not working for database tables .... how to proceed with this ..

thanks

lokesh

hi all

i want to modify values ztable from a internal table ....

for eg : the ztable contains matnr and accept_qty

matnr qty

mat01

mat02

i need to modify qty of the table .. i am using where condition (ie modify where matnr = ) but where condition is not working for database tables .... how to proceed with this ..

thanks

lokesh

4 REPLIES 4
Read only

andreas_mann3
Active Contributor
0 Likes
647

hi,

try this command:

update ztab
  set f1 = 1
...
  where f2 = 'X'.

A.

Message was edited by: Andreas Mann

Read only

Former Member
0 Likes
647

Hi Lokesh Chander,

Can you show your code?

It should be something like this:

data: begin of itab occurs 0.

include structure ztab.

data: end of itab.

itab-matnr = 'mat1'.

itab-accept_qty = 1.

append itab.

clear itab.

itab-matnr = 'mat2'.

itab-accept_qty = 1.

append itab.

clear itab.

modify ztab from table itab. "itab must be of the same type as ztab.

Read only

Former Member
0 Likes
647

Use conversion exit to convert the Material into SAP internal format before modify/update statement.

Normally this will fails when you are passing MATNR directly without conversion. Just have a look in debug.

Thanks

eswar

Read only

anversha_s
Active Contributor
0 Likes
647

hi,

before that :- modify statemnt will modify a record if there is record having the same key like that of record in work area.

if there is no record in itab with key of work area record, it will insert a new record in itab.

look this sample code.

*modify internal table

loop at itab into wa.

wa-field1 = data1.

wa-field2 = data2.

wa-field 3= data3.

modify itab from wa transporting field1 field2 field3 where key_field = wa-keyfield. "there shuld not be any chang in key field.

endloop.

*now update database table

*work area and data base structure shuld be same type

if itab[] is not initial.

modify ztable from table itab.

endif.

rgds

anver

if hlped pls mark points