2023 Nov 22 9:52 AM
Hi. i've got a problem with Commit work and wait.
I have a list of Distribution Document Number i need to storn.
And i have 2 tables for sy-subrc = 0 and sy-subrc ne 0 after calling 'WS_REVERSE_GOODS_ISSUE'
The programm starts in backround every working day, but in sm37 it shows that my task is rejected ( it shows that the programm had worked a few seconds, but in fact it had worked more ).
The table zstorn_mistakes is empty it means that for every material in a list sy-subrc = 0.
But NOT ALL of vbelns are shown in mine zstorn_logs table. And some of the vbelns will be in a list at next day.
So i think the problem is with connection WS_REVERSE_GOOD_ISSUE and COMMIT WORK AND WAIT.
so i have 2 questions :
1) Is i need to use commit work and wait here?
2) why at sm37 it shows that programm has worked a few second, but in fact it has worked much more?
call function 'MESSAGES_INITIALIZE'
exporting
i_identification = sy-uzeit
importing
e_identification = ident
exceptions
others = 0.
CALL FUNCTION 'MESSAGES_ACTIVE'
EXCEPTIONS
OTHERS = 1.
loop at vbeln_user into ls_vbeln_user.
CALL FUNCTION 'WS_REVERSE_GOODS_ISSUE'
EXPORTING
I_VBELN = ls_vbeln_user-vbeln
I_BUDAT = ls_vbeln_user-budat
I_COUNT = 1
I_TCODE = 'VL09'
I_VBTYP = ls_vbeln_user-vbtyp
TABLES
T_MESG = XMESG
EXCEPTIONS
ERROR_REVERSE_GOODS_ISSUE = 1
OTHERS = 2.
IF SY-SUBRC IS INITIAL.
COMMIT WORK and WAIT.
if sy-subrc = 0.
loop at otpusk_tab into ls_otpusk WHERE vbeln = ls_vbeln_user-vbeln.
MODIFY zstorn_logs from ls_otpusk.
endloop.
ls_user_msg-usnam = ls_vbeln_user-usnam.
insert ls_user_msg into TABLE user_msg.
endif.
ELSE.
CALL FUNCTION 'MESSAGES_GIVE'
TABLES
T_MESG = TMESG
EXCEPTIONS
OTHERS = 0.
loop at tmesg into ls_tmesg.
ls_mistakes-vbeln = ls_vbeln_user-vbeln.
ls_mistakes-ZEILE = ls_tmesg.
ls_mistakes-MSGTY = ls_tmesg-MSGTY.
ls_mistakes-TEXT = ls_tmesg-text.
ls_mistakes-ARBGB = ls_tmesg-ARBGB.
ls_mistakes-TXTNR = ls_tmesg-TXTNR.
ls_mistakes-MSGV1 = ls_tmesg-MSGV1.
ls_mistakes-MSGV2 = ls_tmesg-MSGV2.
ls_mistakes-MSGV3 = ls_tmesg-MSGV3.
ls_mistakes-MSGV4 = ls_tmesg-MSGV4.
MODIFY zstorn_mistakes from ls_mistakes.
endloop.
CONTINUE. "*--lТuft hier extern
ENDIF.
endloop.
2023 Nov 22 4:36 PM
if otpusk_tab is empty, it's normal that nothing is written to zstorn_logs.
I don't understand how you can think that COMMIT WORK can be the culprit (NB: and wait can't be a problem in your case).
Only you can analyze and solve this problem.
2023 Nov 23 5:21 AM
It's not empty,and it's doesn't matter here
i've got like 100 vbelns inside vbeln_user.
And i've got a loop which need to storn them one by one and if sy-subrc = 0 it should write them to
zstorn_logs, otherwise to zstorn_mistakes.
But zstorn_mistakes is empty and NOT ALL of the vbelns inside of table vbeln_users are storning.
The problem is with 'commit work and wait' cause some of vbelns which should have been strorn are repeating at next day.
I think the problem is that some of vbeln are not in time and the programm starts the new vbeln when the previous is not storn yet.
Or mb 'commit work and wait' is not eq to 0 whe program runs in background
And i cannot analyze it cause the programm running in background job and if i start it as usual it would work well.
2023 Nov 23 9:39 AM
So, the problem is about background versus not background.
Quick possibilities to check: different user (so different settings and different authorizations), or running in different application server (files and so on).
You must add code in your program to help you analyze what's going on when running in background.
I don't understand "which should have been ST(r)ORN", please use common terms like "inserted in the table", "updated in the table", etc.
I can only tell you for sure that COMMIT WORK AND WAIT is not responsible of your problem, it's something else, but I can't tell more because it seems you cannot or you are not willing to explain better.
2023 Nov 23 9:44 AM
The only potential impact of COMMIT WORK AND WAIT would be related to any process running in the update task, in connection to your logic, but we can't tell you anything about it, only you can check that on your system.
2023 Nov 23 10:17 AM
sry, i think in english there is no such notion like 'Storn' that means cancelled document, which are stored at LIKP table.
So i have an list of this LIKP-Vbeln deliveries.
And function 'WS_REVERSE_GOODS_ISSUE'alows to cancel them.
mine zstorn_mistakes table is empty and not all of the deliveries are inserting into zstorn_logs
That means that problem is smth here
COMMIT WORK and WAIT.
if sy-subrc = 0.
loop at otpusk_tab into ls_otpusk WHERE vbeln = ls_vbeln_user-vbeln.
MODIFY zstorn_logs from ls_otpusk.
endloop.
ls_user_msg-usnam = ls_vbeln_user-usnam.
insert ls_user_msg into TABLE user_msg.
endif.
2023 Nov 23 11:49 AM
It's simple. SY-SUBRC <> 0 means that one of the function modules in the update task fails. If that's the case, you have them listed in SM13.
Note that SY-SUBRC is set only for COMMIT WORK AND WAIT, not for COMMIT WORK without AND WAIT.
Otherwise, it's otpusk_tab.
Why don't you "add code in your program to help you analyze what's going on when running in background"? (as I said previously)
2023 Nov 24 9:28 AM
Solved with this.
loop at vbeln_user into ls_vbeln_user.
perform storn.
endloop.
FORM storn.
call function 'MESSAGES_INITIALIZE'
EXPORTING
i_identification = sy-uzeit
IMPORTING
e_identification = ident
EXCEPTIONS
others = 0.
CALL FUNCTION 'MESSAGES_ACTIVE'
EXCEPTIONS
OTHERS = 1.
CALL FUNCTION 'WS_REVERSE_GOODS_ISSUE'
EXPORTING
I_VBELN = ls_vbeln_user-vbeln
I_BUDAT = ls_vbeln_user-budat
I_COUNT = 1
I_TCODE = 'VL09'
I_VBTYP = ls_vbeln_user-vbtyp
TABLES
T_MESG = XMESG
EXCEPTIONS
ERROR_REVERSE_GOODS_ISSUE = 1
OTHERS = 2.
IF SY-SUBRC IS INITIAL.
commit work and wait.
if sy-subrc = 0.
loop at otpusk_tab into ls_otpusk WHERE vbeln = ls_vbeln_user-vbeln.
ls_otpusk-ztime = sy-uzeit.
MODIFY zstorn_logs from ls_otpusk.
endloop.
ls_user_msg-usnam = ls_vbeln_user-usnam.
insert ls_user_msg into TABLE user_msg.
endif.
ELSE.
CALL FUNCTION 'MESSAGES_GIVE'
TABLES
T_MESG = TMESG
EXCEPTIONS
OTHERS = 0.
loop at tmesg into ls_tmesg.
ls_mistakes-vbeln = ls_vbeln_user-vbeln.
ls_mistakes-ZEILE = ls_tmesg.
ls_mistakes-MSGTY = ls_tmesg-MSGTY.
ls_mistakes-ztime = sy-uzeit.
ls_mistakes-TEXT = ls_tmesg-text.
ls_mistakes-ARBGB = ls_tmesg-ARBGB.
ls_mistakes-TXTNR = ls_tmesg-TXTNR.
ls_mistakes-MSGV1 = ls_tmesg-MSGV1.
ls_mistakes-MSGV2 = ls_tmesg-MSGV2.
ls_mistakes-MSGV3 = ls_tmesg-MSGV3.
ls_mistakes-MSGV4 = ls_tmesg-MSGV4.
MODIFY zstorn_mistakes from ls_mistakes.
endloop.
ENDIF.
clear tmesg.
endform. "storn
I need to start 'MESSAGES_INITIALIZE' 'MESSAGES_ACTIVE'
for every item in a loop.
2023 Nov 24 9:33 AM
Well done, good to know that you have solved it. You may convert your comment into an answer, and then click on Accept (on the answer).