‎2013 Jan 21 10:32 PM
Hello gurus,
I have been facing an issue with the code which I wrote in the user exit to do a look up for a field ZZENDCTY. My requirement was to write the code as well as write return handling code. My code is looking syntaxically right but when I run the job the back ground job in sm37 is failing. when I have commented the last two lines ( Highlighted in black ) of the code then back ground job was successful and records were gettign populated into the new field (ZZENDCTY) but the return code handling requirement is not satisfied., I request you to help and let me know If I need to make any changes to the existing code.
My requirement :
If the first block returns a "not-found" ( RC-4) then the second block of logic needs to be executed
if the second block gives a "NOT-FOUND" return code then spaces have to be moved to the field ( to be populated)
Any return code other than 0 or 4 should generate a hard error
My code :
FORM FORM_1_CO_PA_AAFI1 TABLES I_T_DATA.
FIELD-SYMBOLS: <FS> LIKE ZOXDEV0201.
Data: l_msgv TYPE symsgv,
l_subrc LIKE sy-subrc.
LOOP AT I_T_DATA ASSIGNING <FS>.
IF <FS>-WWEND IS NOT INITIAL.
SELECT SINGLE LAND1
INTO (<FS>-ZZENDCY)
FROM KNA1
WHERE KUNNR = <FS>-WWEND AND
LAND1 NE 'SPACE'.
ELSE.
SELECT SINGLE LAND1
INTO (<FS>-ZZENDCY)
FROM KNA1
WHERE KUNNR = <FS>-KUNWE AND
LAND1 NE 'SPACE'.
CASE SY-SUBRC.
WHEN 0.
WHEN OTHERS.
CLEAR: <FS>-ZZENDCY.
L_SUBRC = SY-SUBRC.
L_MSGV = <FS>-WWEND.
L_MSGV = <FS>-KUNWE.
MESSAGE ID 'ZBW' TYPE 'X' NUMBER '000'
WITH 'KUNNR' l_msgv l_subrc.
ENDCASE.
ENDIF.
‎2013 Jan 21 11:55 PM
If you run background job, the message cannot be issued. That's why program run failed. You can store errors in structure BDCMSGCOLL and view it later.
‎2013 Jan 21 11:55 PM
If you run background job, the message cannot be issued. That's why program run failed. You can store errors in structure BDCMSGCOLL and view it later.
‎2013 Jan 22 12:44 AM
Thank you Thien, the job which runs transfers the data into a middle ware system ( BW ) . we do not have issue in the BW. but the back ground job itself is failing in the ECC when this program is run.
When I comment the last two lines then the back ground job is running successfully. I believe I am making some mistake in the code of the last 2 lines which is resulting in the job getting failed. could you please let me know the right way if my code is wrong ?
‎2013 Jan 22 3:37 AM
Your code is totally right. But practically, SAP ECC will stop background processing when you issue message type 'E', 'A' or 'X'. So, the idea is that you write the log application to store the errors and display to users after the background job. or you can specify the conditional checking
If sy-batch <> 'X'. "do not enter background job
* show the message
MESSAGE ID 'ZBW' TYPE 'X' NUMBER '000'
WITH 'KUNNR' l_msgv l_subrc.
endif.
‎2013 Jan 22 3:55 AM
Hello sri harsha,
The job may be getting cancelled because you are raising a message with type 'X'. Type x messages will always result in short dump MESSAGE_TYPE_X.
Please check the respective error entry in ST22. See if the origin of error is being pointed to the message that you have written. If that is the case, then you may have to look for other ways to handle it.
Hope this helps
Regards,
Athreya
‎2013 Jan 24 10:16 PM