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

Updating Custom Table Only in Debug Mode

Former Member
0 Likes
3,297

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!

1 ACCEPTED SOLUTION
Read only

former_member404244
Active Contributor
0 Likes
2,110

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

5 REPLIES 5
Read only

former_member404244
Active Contributor
0 Likes
2,111

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

Read only

Former Member
0 Likes
2,110

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.

Read only

Former Member
0 Likes
2,110

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

Read only

Former Member
0 Likes
2,110

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

Read only

Former Member
0 Likes
2,110

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