2009 Sep 15 9:30 AM
Hi All!
I have been encountering issues in updating a custom table. It would work successfully only in debug mode otherwise it won't update an entry in the table.
This is the piece of code that would update an entry in the table specifically used in a user exit. The functionality of this code is to automatically remove a transportation block:
SELECT SINGLE *
INTO wa_zblock
FROM zblock
WHERE zzblknum EQ c_tr01
AND vbeln EQ p_lvbeln
AND zzprocessed EQ space.
IF sy-subrc EQ 0.
DO.
CALL FUNCTION 'ENQUEUE_E_TABLES'
EXPORTING
MODE_RSTABLE = 'S'
TABNAME = c_lzblock
EXCEPTIONS
FOREIGN_LOCK = 1
SYSTEM_FAILURE = 2
OTHERS = 3.
IF sy-subrc EQ 0.
wa_zblock-zzprocessed = c_x.
wa_zblock-zzapproveby = sy-uname.
wa_zblock-zzapproveon = sy-datum.
MODIFY zblock FROM wa_zblock.
if sy-subrc EQ 0.
COMMIT WORK AND WAIT.
endif.
EXIT.
ENDIF.
ENDDO.
CALL FUNCTION 'DEQUEUE_E_TABLES'
EXPORTING
MODE_RSTABLE = 'S'
TABNAME = c_lzblock.
ENDIF.
How can I make this update the custom table successful in undebugged mode? Please let me know your thoughts on this.
Thanks!
2009 Sep 15 9:45 AM
Hi,
in ur code u can remove the DO Loop and do the below change
IF sy-subrc EQ 0.
wa_zblock-zzprocessed = c_x.
wa_zblock-zzapproveby = sy-uname.
wa_zblock-zzapproveon = sy-datum.
append wa_zblock to it_zblock
MODIFY zblock FROM table it_zblock.
if sy-subrc EQ 0.
COMMIT WORK AND WAIT.
endif.
endif.
Regards,
Nagaraj
2009 Sep 15 9:45 AM
Hi,
in ur code u can remove the DO Loop and do the below change
IF sy-subrc EQ 0.
wa_zblock-zzprocessed = c_x.
wa_zblock-zzapproveby = sy-uname.
wa_zblock-zzapproveon = sy-datum.
append wa_zblock to it_zblock
MODIFY zblock FROM table it_zblock.
if sy-subrc EQ 0.
COMMIT WORK AND WAIT.
endif.
endif.
Regards,
Nagaraj
2009 Sep 15 9:48 AM
Hi, did you try this without locking the table. You are doing the update in a loop without any user interruption, is there a change this table is locked? If it is a background process why do not leave the locking to the DBMS in my case with Oracle it always works fine. Succes.
2009 Sep 15 9:53 AM
The loop would keep on going if the table is not ready to be updated or other user/program updates the table. We did try to remove the loop but it would still do the same.
Edited by: jrvillacortz on Sep 15, 2009 10:53 AM
Edited by: jrvillacortz on Sep 15, 2009 10:55 AM
2009 Sep 15 10:22 AM
I also suggest you to lock only the entry that will be updated (and not the whole table!) : you will have then far less problems of conflict with updating this table.
For that, you have to create a lock object on your table (via SE11 - for example EZ_MY_TABLE). This will create 2 function modules named ENQUEUE_E<name of your lock object> (in my example ENQUEUE_EZ_MY_TABLE) and DEQUEUE_E<...>.
You can then call those FM like this :
CALL FUNCTION 'ENQUEUE_EZ_MY_TABLE'
EXPORTING
MODE_RSTABLE = 'S'
KEYFIELD1 = ld_keyfield1 " Here are the key values for the entry that you have to update
KEYFIELD2 = ld_keyfield2
EXCEPTIONS
FOREIGN_LOCK = 1
SYSTEM_FAILURE = 2
OTHERS = 3.Best regards,
Samuel
2009 Sep 15 10:24 AM
Hi,
Use wait command after modifying the data base table.
Modify zcust_table from wa_table.
wait upto 1 secand.
This will solve your problem
Regards,
Murthy