‎2010 Aug 12 10:52 AM
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.
‎2010 Aug 12 10:55 AM
‎2010 Aug 12 10:58 AM
‎2010 Aug 12 10:56 AM
‎2010 Aug 12 10:56 AM
‎2010 Aug 12 10:56 AM
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
‎2010 Aug 12 10:58 AM
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.
‎2010 Aug 12 11:01 AM
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.
‎2010 Aug 12 11:05 AM
‎2010 Aug 12 11:11 AM
{ 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.}
‎2010 Aug 12 11:29 AM
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
‎2010 Aug 12 11:30 AM
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.
‎2010 Aug 12 11:45 AM
Hi,
Try using modify outside loop and commenting the clear wa.
Regards,
Harsh.
‎2010 Aug 12 12:29 PM
Hi,
Replace your modify with.
MODIFY znc_gdsh FROM wa_znc_gdsh TRANSPORTING erdat erzet ernam.
Regards,
Gunjan.
‎2010 Aug 12 2:02 PM
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
‎2010 Aug 12 11:05 AM
‎2010 Aug 12 11:58 AM
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.
‎2010 Aug 12 12:48 PM
‎2010 Aug 12 1:23 PM
‎2010 Aug 12 1:41 PM
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
‎2010 Aug 12 1:56 PM
Hi,
Try using Insert and Update statements and check if they are working.
Thanks,
Venkat
‎2010 Aug 12 2:43 PM
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.
‎2010 Aug 12 2:53 PM
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.
‎2010 Aug 12 2:33 PM
- 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
‎2010 Aug 13 7:19 AM
Thank you everyone. I am now able to modify the database. The problem was with primary key.
Thanks you
Quresh
‎2010 Aug 13 8:28 AM
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
‎2022 May 26 3:07 PM
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