cancel
Showing results for 
Search instead for 
Did you mean: 

Triggering Terminating Event when BDC method fails

Former Member
0 Kudos

Hello experts,

Due to the restriction of the standard BAPI (incapable of changing qty/date of PurReq with subcontracting item), I have to use BDC in an object method. The method is defined as asynchronous and thus requires terminating events. Two such events were defined to indicate the 'success' or 'failure' of the BDC. The Pur Req's change document is used to raise the 'success' terminating event once the BDC has successfully updated the Pur Req and it seems to work in the desired way.

Now my question is: <b>what is the best approach to capture failure of the BDC</b>? I tried to use Deadline Monitoring Requested End/Process Control combination to raise the 'failure' event when the time limit exceeds. However, SAP does not recommend having a task in one branch of the fork raising an event for another branch in the same fork.

Another question is: <b>whether it is possible to pass error messages from BDC back to the task container</b>.

Thank you in advance for any help.

Regards,

Nelson

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

1) SAP Cannot provide everything. If they could have then there was no Custom Wflow ever build:)))). Your approach is sufficing your requirement so go ahead.

Regarding second question yes you can send message in Task container also. Suppose the message will be thrown in the method that gets called from the respective task and you can store the message in the task container as well as the Wflow container.

<b>Reward point if useful</b>

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

You can get back the messtab value (of structure BDCMSGCOLL) from your BDC into you method and then pass it back to your workflow through bindings.

For terminating event you can read the contents and raise the failure terminating event whevere a type "E" message exist in messtab and raise a success terminating event when a type "S" or "W" message exists in messtab.

But as Glauco pointed out what is the problem in having a synchronous method?

Thanks,

Prasath N

Former Member
0 Kudos

Thank you all for your prompt reply.

The BAPI I tried was BAPI_REQUISITION_CHANGE and SAP Note 526214 says using the BAPI to change subcontracting items will cause data inconsistencies, so the note just add an error message which implies that SAP is not planning to fix it.

At first, I used the Batch Input recorder to generate a function module and incorporated it in a non-dialog synchronous method which return the update status Success/Error together with the messages returned from the BDC. Both the update status and messages are defined in the task as well as wf container. But the work item hangs and remains in status IN PROCESS. I also tried the task in foreground and background, but none of them works.

Below is the function module I put in the object method:

e_status = 'E'. "Error

REFRESH et_messages.

...... perform bdc_field ....

PERFORM bdc_transaction TABLES messtab

USING 'ME52'

gc_ctu_x

gc_mode_n

gc_update_syn.

  • Set status

IF sy-subrc IS INITIAL.

e_status = 'S'. "Successful

ENDIF.

PERFORM close_group USING gc_ctu_x.

  • Store messages

LOOP AT messtab INTO ls_mess.

MESSAGE ID ls_mess-msgid TYPE ls_mess-msgtyp NUMBER ls_mess-msgnr

WITH ls_mess-msgv1 ls_mess-msgv2 ls_mess-msgv3 ls_mess-msgv4

INTO et_messages-tdline.

APPEND et_messages.

ENDLOOP.

But the problem was it didn't seem to return anything within the workflow although it works perfectly when I test it in SE37.

That's why I decide to use asyn method and at least it stop when the change document trigger the terminating event, but it still doesn't return any messages. In general, I find it difficult to pass info back from terminating event because of the loss of context.

Thanks again for your help.