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 statement not working

Former Member
0 Likes
13,066

Hi All,

I am using a modify statement in my report to update a 'Z' table , SY_SUBRC is returned as 0 but data is not updated.

MODIFY znc_gdsh FROM wa_znc_gdsh.

Any idea why data is not updated?

Thanks in Advance.

26 REPLIES 26
Read only

Former Member
0 Likes
6,220

Hi,

Check if it is overwriting same record.

Regards,

Harsh.

Read only

0 Likes
6,220

It is not overwriting same record.

Read only

Former Member
0 Likes
6,220

use commit work after modify statement

Thanks

Bala Duvvuri

Read only

Former Member
0 Likes
6,220

Hello

COMMIT WORK will help you.

Read only

Former Member
6,220

Hi,

wa_znc_gdsh is only work area or internal table?

Yo can use the synatx as belwo also.


  DATA: it_znc_gdsh TYPE STANDARD TABLE OF znc_gdsh.

  MODIFY  znc_gdsh FROM TABLE it_znc_gdsh.

  IF sy-subrc = 0.
    COMMIT WORK.
  ENDIF

Regards,

Pravin

Edited by: pravin s. on Aug 12, 2010 11:57 AM

Read only

Former Member
0 Likes
6,220

Hi,

Check if your are updating with the same work area into which the data s being collected. There is every chance of making such minor mistakes

Dev.

Read only

0 Likes
6,220

Before modify statement, I am able to see the updated data in the work area. but after modify, new values dont get updated into the data base table.

Read only

0 Likes
6,220

Hi,

Can you paste your program snippet here.\

Regards,

Harsh.

Read only

0 Likes
6,220

{ LOOP AT t_rept INTO v_rept FROM 2

WHERE si_002(2) NE '--'

AND si_004(2) NE '--'.

.

CLEAR wa_znc_gdsh.

MOVE-CORRESPONDING v_rept TO wa_znc_gdsh.

wa_znc_gdsh-si_007 = v_rept-si_007.

wa_znc_gdsh-matnr = v_rept-si_315.

wa_znc_gdsh-langu = v_rept-si_005.

wa_znc_gdsh-vkorg = p_vkorg.

wa_znc_gdsh-meinh = v_rept-si_003.

wa_znc_gdsh-aedat = sy-datum.

wa_znc_gdsh-aezet = sy-uzeit.

wa_znc_gdsh-aenam = sy-uname.

READ TABLE i_gdsh WITH KEY matnr = v_rept-si_315

langu = v_rept-si_005

meinh = v_rept-si_003

si_001 = v_rept-si_001

BINARY SEARCH.

IF sy-subrc = 0.

wa_znc_gdsh-erdat = i_gdsh-erdat.

wa_znc_gdsh-erzet = i_gdsh-erzet.

wa_znc_gdsh-ernam = i_gdsh-ernam.

ELSE.

wa_znc_gdsh-erdat = sy-datum.

wa_znc_gdsh-erzet = sy-uzeit.

wa_znc_gdsh-ernam = sy-uname.

ENDIF.

MODIFY znc_gdsh FROM wa_znc_gdsh.

Endloop.}

Read only

0 Likes
6,220

Hi ,

Check are you trying to pass the Primary key values same as Database table.

if so chcek the sy-subrc after Modify statement.

and use Commit statement after Modify statemnt.

Regards,

Prabhudas

Read only

0 Likes
6,220

hi try to append the work area in an internal table, and after the loop, use that internal table for the modify statement, MODIFY z_table from it_tab, double check again if the values you are updating are unique, and you can also try to use the commit work statement after the modify statement. if the return subrc = 0, then it most likely did a change in the table.

Read only

0 Likes
6,220

Hi,

Try using modify outside loop and commenting the clear wa.

Regards,

Harsh.

Read only

0 Likes
6,220

Hi,

Replace your modify with.

MODIFY znc_gdsh FROM wa_znc_gdsh TRANSPORTING erdat erzet ernam.

Regards,

Gunjan.

Read only

0 Likes
6,220

Hi Quresh,

{ LOOP AT t_rept INTO v_rept FROM 2

WHERE si_002(2) NE '--'

AND si_004(2) NE '--'.

.

CLEAR wa_znc_gdsh.

MOVE-CORRESPONDING v_rept TO wa_znc_gdsh.

wa_znc_gdsh-si_007 = v_rept-si_007.

wa_znc_gdsh-matnr = v_rept-si_315.

wa_znc_gdsh-langu = v_rept-si_005.

wa_znc_gdsh-vkorg = p_vkorg.

wa_znc_gdsh-meinh = v_rept-si_003.

wa_znc_gdsh-aedat = sy-datum.

wa_znc_gdsh-aezet = sy-uzeit.

wa_znc_gdsh-aenam = sy-uname.

READ TABLE i_gdsh WITH KEY matnr = v_rept-si_315

langu = v_rept-si_005

meinh = v_rept-si_003

si_001 = v_rept-si_001

BINARY SEARCH.

IF sy-subrc = 0.

wa_znc_gdsh-erdat = i_gdsh-erdat.

wa_znc_gdsh-erzet = i_gdsh-erzet.

wa_znc_gdsh-ernam = i_gdsh-ernam.

ELSE.

wa_znc_gdsh-erdat = sy-datum.

wa_znc_gdsh-erzet = sy-uzeit.

wa_znc_gdsh-ernam = sy-uname.

ENDIF.

MODIFY znc_gdsh FROM wa_znc_gdsh.

Endloop.}

In the above code there are diff ways of possibilities for your error.

There may be some thing you are passing without matching Primary keys

Or

There may be chance The commit work executing after all the loop Is finished

which means at last row, the value of WA is nill.

Possible solution,

1. Please tell the table structure & its primary keys & what record you are updating, & its values & Exixting table values

2. Else take a Dummy internal table & Pass all values in it, now write code like this

Do (original Internal table records Count) times

Loop at (Dummy Internal table ) to wa.

Your all code.

delete at sy-index

exit

endloop.

Modify your record.

Enddo.

Try this & See, if you dont find solution reply back.

Thanks & regards,

Dileep .C

Read only

Former Member
0 Likes
6,220

Hi,

Try to add option TRANSPORTING...

Read only

Former Member
0 Likes
6,220

Hi,

Try below code..

{ LOOP AT t_rept INTO v_rept FROM 2

WHERE si_002(2) NE '--'

AND si_004(2) NE '--'.

v_tabix = sy-tabix.

MOVE-CORRESPONDING v_rept TO wa_znc_gdsh.

wa_znc_gdsh-si_007 = v_rept-si_007.

wa_znc_gdsh-matnr = v_rept-si_315.

wa_znc_gdsh-langu = v_rept-si_005.

wa_znc_gdsh-vkorg = p_vkorg.

wa_znc_gdsh-meinh = v_rept-si_003.

wa_znc_gdsh-aedat = sy-datum.

wa_znc_gdsh-aezet = sy-uzeit.

wa_znc_gdsh-aenam = sy-uname.

READ TABLE i_gdsh WITH KEY matnr = v_rept-si_315

langu = v_rept-si_005

meinh = v_rept-si_003

si_001 = v_rept-si_001

BINARY SEARCH.

IF sy-subrc = 0.

wa_znc_gdsh-erdat = i_gdsh-erdat.

wa_znc_gdsh-erzet = i_gdsh-erzet.

wa_znc_gdsh-ernam = i_gdsh-ernam.

ELSE.

wa_znc_gdsh-erdat = sy-datum.

wa_znc_gdsh-erzet = sy-uzeit.

wa_znc_gdsh-ernam = sy-uname.

ENDIF.

MODIFY znc_gdsh FROM wa_znc_gdsh INDEX v_tabix.

CLEAR wa_znc_gdsh.

clear v_rept.

Endloop.}

Regards,

Raj.

Read only

0 Likes
6,220

not working

Read only

0 Likes
6,220

Check for your table keys properly.

Regards,

Sai Prasad

Read only

0 Likes
6,220

Hi,

Check the below code it works:

DATA : lt_vbak TYPE STANDARD TABLE OF vbak.

DATA : lwa_vbak LIKE LINE OF lt_vbak.

SELECT vbeln erdat erzet ernam

UP TO 2 ROWS INTO CORRESPONDING FIELDS OF TABLE lt_vbak

FROM vbak.

LOOP AT lt_vbak INTO lwa_vbak.

IF lwa_vbak-erdat <> sy-datum AND lwa_vbak-erzet <> sy-uzeit.

lwa_vbak-erdat = sy-datum.

lwa_vbak-erzet = sy-uzeit.

MODIFY lt_vbak FROM lwa_vbak TRANSPORTING erdat erzet.

ENDIF.

ENDLOOP.

MODIFY vbak FROM TABLE lt_vbak.

IF sy-subrc = 0.

COMMIT WORK.

ENDIF.

Regards,

Gunjan

Read only

0 Likes
6,220

Hi,

Try using Insert and Update statements and check if they are working.

Thanks,

Venkat

Read only

0 Likes
6,220

Hi

Some times this may happen..start using field symbols and there is no need to use the modify statment.

FIELD-SYBMOLS : <FS_TYPE> type (Your table )

Move the entries directly to the <FS_TYPE>-FIELDS.

No need to use modify statements in this case.

Revert if this doesnt works,

Thanks,

Arun.

Read only

0 Likes
6,220

Hi

Some times this may happen..start using field symbols and there is no need to use the modify statment.

FIELD-SYBMOLS : <FS_TYPE> type (Your table )

Move the entries directly to the <FS_TYPE>-FIELDS.

No need to use modify statements in this case.

Revert if this doesnt works,

Thanks,

Arun.

He is trying to modify a database table, not an internal table.

Read only

RaymondGiuseppi
Active Contributor
0 Likes
6,220

- The data will be updated after the next database-commit, so after a COMMIT-WORK or call of FM DB_COMMIT and other events, but depending your configuration and server characteristics there can be some delay (not too much, but an immediate SELECT may fail even bypassing buffer.

- What is the value of sy-dbcnt after MODIFY

Regards,

Raymond

Read only

Former Member
0 Likes
6,220

Thank you everyone. I am now able to modify the database. The problem was with primary key.

Thanks you

Quresh

Read only

0 Likes
6,220

In the above code there are diff ways of possibilities for your error.

There may be some thing you are passing without matching Primary keys

Or

There may be chance The commit work executing after all the loop Is finished

which means at last row, the value of WA is nill.

There you go.

As Expected my doubt was correct.

Cheers Buddy,

Dileep. C

Read only

0 Likes
6,220

Hi Everyone,

Im experiencing an abnormal issue, That I have used Update statement to write a custom field in a standard table (Append Structure). The Update Statement is not Working, I used above suggested way like Commit work, Commit Work and wait, Wait up to 20 seconds nothing helped me. So I tried to change it to modify statement like work area to the table fields. Before that I used the select statement to fetch the appropriate value for the document, after that I have used Sy-subrc check, then Modify [standard table] from the (work area), Then commit work statement. Even after this the field is not getting updated. But if I use debugger, the value is getting populated.

Kindly suggest what might be the issue.

The system is Hana system 1809 version. ABAP Version 7.53