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: 

I need to have COMMit WORK with in a FM, which is calling in UPDATE task

Former Member
0 Kudos

Hello

I am sending out the custom IDOC from SAP to partner application by writing a custom my_OB_IDOC_FM, well.

With in this my_OB_IDOC_FM, for some functionality, i am using a standard SAP FM and I need to use a COMMIT WORK immediately after this standard SAP FM call.

But, all my IDOC is calling in update task, so once am triggering IDOC (inturn my_OB_IDOC_FM is calling in UPDATE task) am getting dump because of that inside used COMIT WORK statement!

So, pls. let me know how can replace this COMMIT WORK or hoe can i fix my issue? can i do like CALL FUNCTION standard_SAP_FM in background task/seperate task? so that i can use COMMIT WORK?

Thank you

1 ACCEPTED SOLUTION

Clemenss
Active Contributor
0 Kudos

Hi,

you can call the function in separate work process using

CALL FUNCTION... DESTINATION 'NONE'
...

This function is started as RFC in own process allowing the commit work.

But: Commit work inside a function is wrong by principle. Only the calling process is allowed to decide to commit or roll back database changes.

Regards,

Clemens

7 REPLIES 7

Former Member
0 Kudos

Any inputs pls

Thank you

Former Member
0 Kudos

I've dealt with something similar before.

You could make a new z-program and run in a background job... like this:



* create the job
CALL FUNCTION 'JOB_OPEN'
      EXPORTING
          JOBNAME          = mv_JOBNAME
      IMPORTING
          JOBCOUNT         = mv_JOBCOUNT
      EXCEPTIONS
          CANT_CREATE_JOB  = 1
          INVALID_JOB_DATA = 2
          JOBNAME_MISSING  = 3
          OTHERS           = 4.

* submit the program to the job
    SUBMIT ZPROGRAM
      WITH i_ebeln in mr_ebeln
      WITH updall = 'X'
      WITH wq_simul = ''
      TO SAP-SPOOL
        DESTINATION sv_output_device
        IMMEDIATELY ''
        KEEP IN SPOOL 'X'
        WITHOUT SPOOL DYNPRO
      USER sy-uname
      VIA JOB mv_jobname NUMBER mv_jobcount
      AND RETURN.

* submit the job
CALL FUNCTION 'JOB_CLOSE'
    EXPORTING
        JOBCOUNT             = mv_JOBCOUNT
        JOBNAME              = mv_JOBNAME
        STRTIMMED            = 'X'
    EXCEPTIONS
        CANT_START_IMMEDIATE = 1
        INVALID_STARTDATE    = 2
        JOBNAME_MISSING      = 3
        JOB_CLOSE_FAILED     = 4
        JOB_NOSTEPS          = 5
        JOB_NOTEX            = 6
        LOCK_FAILED          = 7
        OTHERS               = 8.

0 Kudos

Thank you, guess, its similar some thing like "CALL FUNCTION standard_SAP_FM in background task/seperate task" right?

Former Member
0 Kudos

Can you elaborate your requirement? Does your IDOC FM and the standard FM that the IDOC is calling needs to be in Same LUW?

Meaning if for some reason, your IDOC posting fails, should your standard FM also fail (or vice versa).. Depending on that , only we can provide a proper answer...

What is the standard FM that you are calling and what documents are your posting via your IDOC fm?

0 Kudos

Thank you.

Sales orders are posting. If IDOC fails, i need to create a work-flow event (FM 'SWE_EVENT_CREATE'), which inturn sends email to SAP inbox.

0 Kudos

Can you check out the following link,

http://help.sap.com/saphelp_di46c2/helpdata/en/c5/e4af4a453d11d189430000e829fbbd/content.htm

SWE_EVENT_CREATE_FOR_UPD_TASK

The event is created in the update task. (The function module is not called with the addition of IN UPDATE TASK .)

Clemenss
Active Contributor
0 Kudos

Hi,

you can call the function in separate work process using

CALL FUNCTION... DESTINATION 'NONE'
...

This function is started as RFC in own process allowing the commit work.

But: Commit work inside a function is wrong by principle. Only the calling process is allowed to decide to commit or roll back database changes.

Regards,

Clemens