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

Modify database table

Former Member
0 Likes
477

hi all,

Please check the below code

MOVE p_wa_vbap_kkunnr TO p_wa_ygvdebireg-zkunnr.

MOVE p_wa_vbap_yygfkto TO p_wa_ygvdebireg-zfktov.

MOVE '0101' TO p_wa_ygvdebireg-zvkoku.

MOVE '72' TO p_wa_ygvdebireg-zvtwku.

MOVE '01' TO p_wa_ygvdebireg-zspaku.

MOVE p_wa_vbap_kunnr TO p_wa_ygvdebireg-zregu3.

MODIFY ygvdebireg FROM p_wa_ygvdebireg.

IF t_modus EQ 'X'.

IF sy-subrc = 0.

WRITE:/ 'YGVDEBIREG',text-005,'ZKUNNR:',wa_ygvdebireg-zkunnr,'ZREGU3:',wa_ygvdebireg-zregu3.

ELSE.

WRITE:/ 'YGVDEBIREG',text-008,'ZKUNNR:',wa_ygvdebireg-zkunnr,'ZREGU3:',wa_ygvdebireg-zregu3.

ENDIF.

ENDIF.

here the modify alwys gives a sy-subrc 0 even when the primary keys are not changing .

whts the problem?

i dnt know if this is possible?

Please let me know?

4 REPLIES 4
Read only

Former Member
0 Likes
454

Hi,

Modify always results in sy-subrc eq 0 if the record is there.

If the record is not there,modify will lead to abap dump error.

if the primary key changes,the records can only be appended and cannot be modified.

Reward if helpful

Regards

Vodka.

Read only

Former Member
0 Likes
454

Also check for other fields if they are changing and not only

primary keys.

or check if any record is inserted ...

Read only

Former Member
0 Likes
454

Hi,

Modify always gives sy-subrc = 0.

If a record is found in the table with the same key it modifies the same record else it will insert a new record. So there will be no option of sy-subrc ne 0.

In your case check if the record data has been changing for every execution or not, dont only rely on key field values also check non-key values.

Regards

Sunil Kumar P

Read only

Former Member
0 Likes
454

Hi

if you use modify statement, then it wont allow you to change the primary keys

only non numeriic fields will updated

so get all the data of the corresponding record change

then use INsert command

regards

Shiva