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

modifying a table not working

Former Member
0 Likes
1,127

hi i am using the below statement to modiby a ztable created by me but it is not working

the record is not modified but ADDED TO THE TABLE PLS SUGGEST ON THE PROBLEM

if not t_zcust_em_modify[] is initial.

loop at t_zcust_em_modify.

modify zcustemail from table t_zcust_em_modify.

message s001 with 'Data saved'(004).

refresh:t_zcust_em_modify.

**nv modify problem

  • clear:t_zcust_em_modify.

**Nv

endloop.

REGARDS

NISHANT

8 REPLIES 8
Read only

Former Member
0 Likes
925

Hi,

if not t_zcust_em_modify[] is initial.

try with this alone

<b>modify zcustemail from table t_zcust_em_modify.</b>

if sy-subrc eq 0.

endif.

<b>no need of this</b>

loop at t_zcust_em_modify.

modify zcustemail from table t_zcust_em_modify.

message s001 with 'Data saved'(004).

refresh:t_zcust_em_modify.

**nv modify problem

  • clear:t_zcust_em_modify.

**Nv

endloop.

regards,

Venkatesh

Read only

0 Likes
925

hi you are removing the refresh and loop what if there are several records?

in the internal table

in that case loop is necessary?

Read only

Former Member
0 Likes
925

Hi,

The data what you enter in the table might not be there so it has got inserted.so check the key fields and get the data from the table and modify the data by means of your data.

Thanks

Yogesh

Read only

0 Likes
925

hi t hat data is obviously there which i am modifying

Read only

0 Likes
925

hi yogesh the data in the temp table is the data which i am mofifying

but how to match it with the data which i have modified? so that is is modified

Read only

gopi_narendra
Active Contributor
0 Likes
925

Hi Nishant,

There is no need to do a loop for modifying the database. There would be a need for loop only if you modify any values of the internal table before you update the Z table.

Because the data base table is being modified from the table <internal table itself> which contains all the records which is specified in the modify syntax itself

More over you have been using refresh in your code which will delete all the entries of the internal table. Just for your info you should always use a clear statement inside a loop to clear the internal table headerline, but not refresh. See the ABAP Syntax fro more information by pressing F1 on it.

so just write ur modify statement like this.

if not t_zcust_em_modify[] is initial.
  modify zcustemail from table t_zcust_em_modify.
    if sy-subrc = 0.
      message s001 with 'Data saved'(004).
    endif.
endif.

Regards

Gopi

Read only

0 Likes
925

hi gopi

this statement is not working as the modified record is not in the

t_zcust_em_modify[] but it is inserting in the database table rather then modifying

pls suggsest

as this recored is modified one obviously it does not exists in the database table

i want to use modify using index

how to use it?

regards

Nishant

Read only

asik_shameem
Active Contributor
0 Likes
925

Hi Nishant,

u r modifying the database table from the work area (header line in ur case) only. thats why u wrote modify statement inside the loop. then why r u using modify statement with TABLE keyword. take the keyword 'table' off. n then try.