Application Development 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: 

How to prevent the termination when message type E in Daemon occurs?

friendlycoder
Participant
0 Kudos
1,403

Dear SAP,

We use ABAP daemon for processing a huge amount of data and indeed can run for a couple of hours. It is a very heavy workload.

In the daemon, we call the function module BAPI_ACC_DOCUMENT_CHECK for checking invoices before they get booked.

Inside the BAPI_ACC_DOCUMENT_CHECK a functional module FI_COBL_CHECK gets called which can throw MESSAGE of type E as follows:

CASE SUBRC.
WHEN 0.
WHEN 1.
MESSAGE E165 WITH I_COBL-BUKRS RAISING COMPANY_CODE.
WHEN 2.
MESSAGE E162 WITH I_COBL-GSBER RAISING BUISNESS_AREA.
WHEN 3.
MESSAGE E505 WITH T001-KTOPL T001-BUKRS RAISING CHART_OF_ACCOUNT.
WHEN 4.
MESSAGE E507 WITH HKONT T001-KTOPL RAISING GL_ACCOUNT_A.
WHEN 5.
MESSAGE E506 WITH HKONT I_COBL-BUKRS RAISING GL_ACCOUNT_B.
WHEN 6.
MESSAGE E210 WITH I_COBL-BUKRS I_COBL-WAERS RAISING CURRENCY.
WHEN 7.
MESSAGE E508 WITH I_COBL-ANLN1 I_COBL-ANLN2 I_COBL-BUKRS
RAISING ASSET.
WHEN 8.
MESSAGE E562 WITH HKONT I_COBL-BUKRS.

WHEN 9.
MESSAGE E262(GZ) WITH I_COBL-RMVCT.
WHEN 10.
MESSAGE E098(GM) WITH I_COBL-FKBER.
WHEN 11.
MESSAGE E162 WITH I_COBL-PARGB RAISING BUISNESS_AREA.
WHEN 12. "note 1744468
MESSAGE E351 WITH HKONT I_COBL-BUKRS. "note 1744468

WHEN OTHERS.

According to the ABAP Daemons Programming Model documentation on

https://help.sap.com/docs/ABAP_PLATFORM_NEW/753088fc00704d0a80e7fbd6803c8adb/3d31e40f220d4904ad3a54f...

when an error occurs of type E/A/X message during the execution then the hook ON_ERROR will get called, and function module execution will be aborted immediately.

For us, it is important to get all the messages back from function module BAPI_ACC_DOCUMENT_CHECK which it is provided as a table parameter:

RETURN LIKE BAPIRET2 Return Parameter

for showing users what went wrong that they can take reaction.

The question is how to prevent the termination of the function module execution when a message of type E/A/X occurs inside the function module.

Best regards

11 REPLIES 11

DominikTylczyn
Active Contributor
0 Kudos
1,115

Hello bifunctor

Check my answer to the question Suppressing errors in WS_DELIVERY_UPDATE_2

I guess call the function with

        EXCEPTIONS
          error_message           = 1
          OTHERS                  = 2.<br>

should work as well at least for E type messages.

Best regards

Dominik Tylczynski

0 Kudos
1,115

Hi

I have tried

 CALL FUNCTION 'BAPI_ACC_DOCUMENT_CHECK'
EXPORTING
documentheader = ls_header
TABLES
accountgl = lt_line_items
accountreceivable = lt_customer_ar_item_list
accountpayable = lt_vendor_ap_item_list
currencyamount = lt_amount
accounttax = lt_tax_item_list
return = lt_return
extension2 = lt_extension_02
EXCEPTIONS
error_message = 1
OTHERS = 2.

Unfortunately, it does not help. The daemon is still calling the ON_ERROR hook.

Best regards

1,115

It's MESSAGE ... RAISING ... so I guess it's more about catching it with EXCEPTIONS ... Not sure whether the analysis done by the OP is correct.

1,115

sandra.rossi I see that during the execution in the function module FI_COBL_CHECK the line 126 get called. Then the daemon catch up as an error and call the ON_ERROR hook.

Do you get it what I mean?

Best regards

Sandra_Rossi
Active Contributor
0 Kudos
1,115

You didn't say what you exactly see, why you think it's due to a "message of type E", but in fact it's a classic exception which is raised and probably it's not caught by EXCEPTIONS, because of the addition RAISING.

Right? What did you exactly see?

friendlycoder
Participant
1,115

sandra.rossi I see that during the execution in the function module FI_COBL_CHECK the line 126 get called. Then the daemon catch up as an error and call the ON_ERROR hook.

I see that the daemon abort the execution suddenly when encounter the statement MESSAGE E262(GZ) WITH I_COBL-RMVCT.

Do you get it what I mean?

Best regards

Sandra_Rossi
Active Contributor
0 Kudos
1,115

Thanks, sorry most of MESSAGE had the word RAISING, I didn't see that few of them were missing RAISING. Weird that the standard is mixing RAISING and not RAISING!

It should be caught by the special exception ERROR_MESSAGE if BAPI_ACC_DOCUMENT_CHECK is in the call stack.

Could you please share a screenshot of the call stack to see both FI_COBL_CHECK and BAPI_ACC_DOCUMENT_CHECK?

matt
Active Contributor
1,115

You began with "Dear SAP".

answers.sap.com has many many contributors who do not work for SAP.

Anyway, there are two things you should do:

  1. Before calling the BAPI check for the error condition being encountered, don't call the BAPI, but return errors in the handled way.
  2. Raising a note to SAP via support.sap.com, asking for them to fix FI_COBL_CHECK.

friendlycoder
Participant
0 Kudos
1,115

Hi sandra.rossi

I made several printscreens.

1. Here is where is started. The system reaches the point where the message type is E.

2. The daemon context got called.

3. The ON_ERROR hook got called

friendlycoder
Participant
1,115

3. ON_ERROR hook got called from daemon

Sandra_Rossi
Active Contributor
0 Kudos
1,115

The error is about the classic exception ACCOUNT raised by FI_GL_ACCOUNT_DATA which is not handled by SUBST_SINGLE_HKONT in SAPLFACI:

As you said, FI_GL_ACCOUNT_DATA is raising the exception ACCOUNT:

The only solution is to add "EXCEPTIONS account = 1" (or OTHERS = 1) in SUBST_SINGLE_HKONT.

If you don't do it, it will end in an exception in the Daemon.

That's an abnormal situation that FI_GL_ACCOUNT_DATA exception is not caught so I think that you may contact the SAP support.

NB: you can't handle the error with ERROR_MESSAGE because the MESSAGE statement has the RAISING word.