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: 

Call function starting new task

bharath_padmanabhan
Participant
0 Kudos
2,531

Experts,

I have a requirement to SUBMIT a program from a standard BADI that is called from a Flexible workflow. I tried submit inside a update FM using call function in update task. I learnt that SUBMIT is an illegal statement to be used in update task. So I changed my custom FM from update to remote enabled. Also in my code, I made a change to use call function starting new task.

When I debug my code by enabling update debugging in debugger profile, I see that submit program is working as expected. When I remove update debugging and external breakpoints, I see that workitem get approved. But submit program functionality didn't happen.

I have to push data from S/4 to SCP whenever Purchase Order flexible workflow is approved. I have a custom program which pushes data from S4 to SCP as expected. I am simply calling this program using SUBMIT statement inside my ARFC. This ARFC is working in debugger mode but not when I simply run the scenario without breakpoint.

I did search the forums before posting. That helped me to get the idea that ARFC should work for my requirement. But I am not still not successful.

I have done an enhancement in class CL_MM_PUR_PO_APPR_ACTIONS_BADI, method /IWWRK/IF_WF_WI_BEFORE_UPD_IB~BEFORE_UPDATE. Inside this enhancement, I have written below code:

DATA: lv_bukrs    TYPE bukrs,
          lv_parentpo TYPE ebeln.
    SELECT SINGLE bukrs, zz_master_po
            FROM ekko
            INTO ( @lv_bukrs, @lv_parentpo )
          WHERE procstat = '05' AND
                frgrl = '' AND
                ebeln = @lv_object_id AND
                bsart IN ('ZSVO', 'ZSCA').
    IF sy-subrc EQ 0.
      SET UPDATE TASK LOCAL.
      CALL FUNCTION 'ZMM_PUSHDATAFROMS4TOCLOUD' STARTING NEW TASK lv_object_id
        EXPORTING
          im_ebeln    = lv_object_id
          im_bukrs    = lv_bukrs
          im_parentpo = lv_parentpo.
    ENDIF.<br>

NOTE: My requirement is to simply call the custom program asynchronously. I am not interested in doing any parallel processing or to wait to get any feedback from the submitted program whether its successful or not. So that is why I am not waiting for results from the ARFC call. Its a custom program with a selection screen for which I am passing values via SUBMIT exportling list and return statement.

I checked whether any commit statement or wait statement in my custom program is messing up with LUW. There is no commit or wait statement.

Thanks

Bharath

11 REPLIES 11

manfred_reinart
Product and Topic Expert
Product and Topic Expert
0 Kudos
2,138

Have you tried starting the program from SUBMIT in a JOB?

0 Kudos
2,138

Hi Manfred,

Thanks a lot for your reply. I didn't try this option. Let me do it now and post the feedback here.

Sandra_Rossi
Active Contributor
2,138

Your code doesn't show up correctly. Let me suggest you to edit your question, and paste the code using Ctrl+Shift+V instead of Ctrl+V.

roberto_forti
Contributor
0 Kudos
2,138

Hi, SAP has official information on the following link.

https://help.sap.com/doc/abapdocu_752_index_htm/7.52/en-US/abapsubmit.htm

0 Kudos
2,138

Thank a lot for this link, Roberto.

0 Kudos
2,138

Hi Bharath Padmanabhan, let me know the results; Therefore, I can help searching different references.

Ulrich_Schmidt
Product and Topic Expert
Product and Topic Expert
0 Kudos
2,138

The FM "ZMM_PUSHDATAFROMS4TOCLOUD" is already running asynchronously (in a separate work process). So perhaps instead of using SUBMIT in that FM to start another Report, you could move the code from the Report directly into ZMM_PUSHDATAFROMS4TOCLOUD? Perhaps that is already enough to fulfill your requirement of making the call to the Cloud asynchronously.

(This of course requires, that you don't need this Report in other situations. Otherwise you would have duplicate code, once in the FM and once in the FM, which is of course undesirable...)

(BTW: Can it be that the SET UPDATE TASK LOCAL is still somehow interfering with the subsequent SUBMIT? )

0 Kudos
2,138

Hi Ulrich,

Thanks a lot for your reply. That report has around 3000 lines of code. There are situations where the user will manually execute this report to push data from S4 to Cloud. So as you rightly said it will be undesirable to move the report code to FM.

Set update task local is something I added recently as part of several things that I was trying. Even without it, I see that the asynchronous call works in debugging mode and fails when I execute the program without breakpoints.

I am trying the approach to create a job and submit the program. I will keep everyone posted with the results.

Thanks

Bharath

0 Kudos
2,138

Yes, I already suspected that... 🙂

Another idea I just had, which might be a possibility, if all else fails: if you also own the Report, you could do a bit of "refactoring".

Current behavior: main functionality is in Report, FM calls Report via SUBMIT
Afterwards: main functionality is in FM, Report calls FM via CALL FUNCTION

In that case, the users of the Report would not notice any difference, and the FM can easily be used in new task / ARFC.

bharath_padmanabhan
Participant
0 Kudos
2,138

Hi Sandra,

Thanks a lot for this tip. I have done ctrl+shift+v now.

matt
Active Contributor
0 Kudos
2,138

If the program you're submitting is a z program, then you should rewrite it so that the business functionality is in a class that you can then call directly from the BADI.