Commit for Asynchronous Function Module

Halo Experts,
I am working on an Perfomance Optimization project . I am trying to optimize the program by scehduling the individual methods inside the program via asynchronous function modules . By this way I can run this independent methods parallely ( and not sequentailly) . for eg
if the program has
me->m1( ).
me->m2( ).
me->m3( )
if m2 and m3 are independent of each other I schedule them parallely by
me->run_m2_m3_parallely(  ) see the below code
CALL FUNCTION 'ZM2'
    STARTING NEW TASK 'FUNC1'
    DESTINATION 'NONE'
    CALLING ZCLASS=>set_flag_4_m2 ON END OF TASK.
CALL FUNCTION 'ZM3'
    STARTING NEW TASK 'FUNC2'
    DESTINATION 'NONE'
    CALLING ZCLASS=>set_flag_4_m3 ON END OF TASK.
  WAIT UNTIL l_m2_flag = 'X' AND
             l_m3_flag = 'X'.
the FMs ZM2 and ZM3 are updating Z Database tables( say ZM2  and  ZM3 ) . Do I need an explicit commit work for Individual FMs or a single commit work for both the FMs.
How can I roll back both the updates to the database if a dump occurs ?
How should the commit work statement be in this case ?
Regards
Arshad

I think you can solve your issue by using the KEEPING TASK addition.
In your ZCLASS=>set_flag_4_m2 method try this:
METHOD set_flag_4_m2.
  RECEIVE RESULTS FROM FUNCTION 'ZM2 ' KEEPING TASK.
ENDMETHOD.
METHOD set_flag_4_m3.
  RECEIVE RESULTS FROM FUNCTION 'ZM3 ' KEEPING TASK.
ENDMETHOD.
And after your wait you can try to do this:
WAIT UNTIL l_m2_flag = 'X' AND
             l_m3_flag = 'X'.
* In set_func2_commited you must receive results from BAPI_tRANSACTION_COMMIT and set global flag g_func2_commit
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
    STARTING NEW TASK 'FUNC2'
    DESTINATION 'NONE'
    CALLING ZCLASS=>set_func2_commited ON END OF TASK.
* In set_func3_commited you must receive results from BAPI_tRANSACTION_COMMIT and set global flag g_func3_commit
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
    STARTING NEW TASK 'FUNC3'
    DESTINATION 'NONE'
    CALLING ZCLASS=>set_func3_commited ON END OF TASK.
WAIT UNTIL g_func3_commit EQ 'X' and g_func2_commit EQ 'X'.

Similar Messages

  • Wait in Asynchronous Function Module

    Hello,
    We are creating calling Asynchronous function module in the Delivery User Exist to create Invoice. Invoice creation needs to wait until delivery change is commited. For this purpose, we have placed ENQUEUE_SLEEP FM in the asynchronous FM with a wait time of 1 second. We have written a logic in such a way that ENQUEUE_SLEEP is called in a loop causing a delay of one second until delivery can be locked successfully.
    But we cant let it wait for one second. Delivery should be locked as soon as delivery is committed in the main program. How can we achieve this in asynchronously called FM.
    Thanks

    >
    Rohit Malik wrote:
    > I am following the exact approach of calling remote enabled FM in background task in seperate unit to create invoice.
    Bear in mind that asynch RFC(aRFC) & RFC as BACKGROUND TASK(transactional RFC or tRFC) are completely different. While the former is generally used for parallel processing, the latter is used to maintain the "atomicity" of an SAP LUW.
    tRFC calls are registered in special DB tables(ARFCSSTATE & ARFCSDATA) & are executed once the COMMIT WORK statement is executed in the particular LUW.
    Further read available on the F1 help.
    BR,
    Suhas

  • Performance issue for this function-module(HR_TIM_REPORT_ABSENCE_DATA)

    Hi Friends
    I am having performance issue for this function-module(HR_TIM_REPORT_ABSENCE_DATA) and one my client got over 8 thousend employees . This function-module taking forever to read the data. is there any other function-module to read the absences data IT2001 .
    I did use like this .if i take out this F.M 'HR_TIM_REPORT_ABSENCE_DATA_INI' its not working other Function-module.please Suggest me .
    call function 'HR_TIM_REPORT_ABSENCE_DATA_INI'
    exporting "Publishing to global memory
    option_string = option_s "string of sel org fields
    trig_string = trig_s "string of req data
    alemp_flag = sw_alemp "all employee req
    infot_flag = space "split per IT neccessary
    sel_modus = sw_apa
    importing
    org_num = fdpos_lines "number of sel org fields
    tables
    fieldtab = fdtab "all org fields
    field_sel = fieldnametab_m. "sel org fields
    To Read all infotypes from Absences type.
    RP_READ_ALL_TIME_ITY PN-BEGDA PN-ENDDA.
    central function unit to provide internal tables: abse orgs empl
    call function 'HR_TIM_REPORT_ABSENCE_DATA'
    exporting
    pernr = pernr-pernr
    begda = pn-begda
    endda = pn-endda
    IMPORTING
    SUBRC = SUBRC_RTA
    tables
    absences = absences_01
    org_fields = orgs
    emp_fields = empl
    REFTAB =
    APLTAB =
    awart_sel_p = awart_s[]
    awart_sel_a = awart_s[]
    abstp_sel = abstp_s[]
    i0000 = p0000
    i0001 = p0001
    i0002 = p0002
    i0007 = p0007
    i2001 = p2001
    i2002 = p2002
    i2003 = p2003.
    Thanks & Regards
    Reddy

    guessing will not help you much, check with SE30 to get a better insight
    SE30
    The ABAP Runtime Trace (SE30) -  Quick and Easy
    what is the total time, what are the Top 10 in the hitlist.
    Siegfried

  • How to check for a function module with its description and functionality

    Hi all,
    How to check for a function module,with its description and its functionality,in detail how can I know the purpose of a particular function module,how to search for a function module which suits my requirement .

    Hi,
    You can search a FM of your requirement by putting in the Key words and searching for a FM. Like * KEYWORD * and then pressing F4.
    Say for example you need to search something regarding converstion.
    Search for * CONVERT * and press F4.
    If there is something specfic like converting date to something you can give
    DATE * CONVERT *
    OR
    CONVERT * DATE *  and press F4.
    Once you narrow down your search you will have a Function module documentation inside the Function module. Please note that all the FMs willl not have documentation.
    Regards,
    Pramod

  • Test web service for a function module

    Hello,
    I have created web service for a functiona module. I can see the same service in SE80 in Enterprise Services.
    How do I test this service?
    I can see the URL in WSDL tab but when I try to execute it give me following error,
    What has happened?
    URL http://emhbssap15.domain.local:8027/sap/bc/srt/wsdl/sdef_service_name/wsdl11/ws_policy/document call was terminated because the corresponding service is not available.
    Note
    The termination occurred in system BDV with error code 403 and for the reason Forbidden.
    The selected virtual host was 0 .
    What can I do?
    Please select a valid URL.
    If you do not yet have a user ID, contact your system administrator.
    ErrorCode:ICF-NF-http-c:000-u:SAPSYS-l:E-i:EMHBSSAP15_BDV_27-v:0-s:403-r:Forbidden
    HTTP 403 - Forbidden
    Your SAP Internet Communication Framework Team
    The URL I am trying is
    http://emhbssap15.domainname:8027/sap/bc/srt/wsdl/sdef_servicename/wsdl11/ws_policy/document?sap-client=400
    Can anyone help me?
    Regards,,,
    Sunil Joyous
    Edited by: Sunil Joyous on Dec 2, 2009 1:52 PM

    Thanks Venu for your input.
    Unfortunetly we do not have Java stack on our development system. You said we can test it by SOAP UI tool. Where do I see the WSDL file for the service?
    I used WSDL from SE80 --> Service --> WSDL tab, but SOAP UI does not accept this format ?
    What are the other ways I can test this web service? I think about SAP PI, importing RFC & creating web service or creating ABAP proxies... Which is the best way to go forward in case you do not have Java stck.
    Regards,,,
    Sunil Joyous

  • How to use Exceptions for a function module

    Hi folks,
            I have created  a new function module.Its working fine, but i am not aware of using exceptions for a function module. I hav just declared an exception in the 'exception' tab. Could any body explain me how to use that in my FM source code....Thanks...

    Hi Shyam,
    Have a look at this,
    START-OF-SELECTION.
      gd_file = p_infile.
      CALL FUNCTION 'GUI_UPLOAD'
        EXPORTING
          filename                = gd_file
          has_field_separator     = 'X'  "file is TAB delimited
        TABLES
          data_tab                = it_record
        EXCEPTIONS
          file_open_error         = 1
          file_read_error         = 2
          no_batch                = 3
          gui_refuse_filetransfer = 4
          invalid_type            = 5
          no_authority            = 6
          unknown_error           = 7
          bad_data_format         = 8
          header_not_allowed      = 9
          separator_not_allowed   = 10
          header_too_long         = 11
          unknown_dp_error        = 12
          access_denied           = 13
          dp_out_of_memory        = 14
          disk_full               = 15
          dp_timeout              = 16
          OTHERS                  = 17.
        IF sy-subrc NE 0.
          write: 'Error ', sy-subrc, 'returned from GUI_UPLOAD FM'.
          skip.
        endif.
    Regards,
    Sai

  • Search for a function module for deleting document originals (DMS)

    Hi,
    I'm searching for a function module to delete originals in documents (like manually with transaction cv02n). I'm only able to set an delete mark with the module 'BAPI_DOCUMENT_DELETE'.
    The module 'BAPI_DOCUMENT_CHANGE2' can only add new originals to an existing document. I need a possibility to delete all originals in an document without deleting the document itself.
    Has anyone an idea?
    Thanks.
    Jan-Christian Treusch

    Many thanks!
    That's especially the method I've searched for so long....
    best regards.
    Jan-Christian Treusch

  • Need help for the Function Module 'PFL_GET_PARAMETER_INFO'

    Hi Experts,
    The FM 'PFL_GET_PARAMETER_INFO'  returns the value for Profile Parameters for a system .
    The inputs required for this FM are :
      1.   Parameter name  : ( eg . login/min_password_lng etc. )                   
      2 . Parameter Type
    I am not sure about what the value of Parameter Type should be .
    Its a mandatory field.
    I have tried to search but could not find anything.
    Can you please help me on this?
    Thanks in Advance,
    Harshit Rungta
    Edited by: harshit rungta on May 27, 2011 8:15 AM

    What exactly is the use-case for this?
    Many developers "c-call" the params and neglect this feature of the type - also whether it is static or dynamic. Some params are even dynamic as system profiles in one direction but static as instance parameters in the other direction when changing the value.
    As you cannot create your own system profile parameters, I do not see the use-case for why you are wanting to check it in advance, because the application APIs should do this.
    What you are possibly looking for is function module SUSR_GENERATE_PASSWORD in this case. It will respect "the rules" in the params.
    Do not use the legacy function RSEC_GENERATE_PASSWORD directly.
    Cheers,
    Julius

  • Alternative for STRING_CENTER function module

    Hi,
    Can any one give me the Alternative for STRING_CENTER function module.
    it is there in 4.7 when i am using the same  in ecc 6.0 it is giving as absolute statement .
    Please give the solution for this.

    Hi,
      C147_STRING_SPLIT_AT_POSITION
    STRING_SPLIT
    STRING_SPLIT_AT_POSITION
    check this sample code
    DATA: text(10) TYPE c VALUE '0123456789',
    text1(6) TYPE c,
    text2(6) TYPE c.
    PARAMETERS position TYPE i.
    CALL FUNCTION 'STRING_SPLIT_AT_POSITION'
    EXPORTING
    string = text
    pos = position
    IMPORTING
    string1 = text1
    string2 = text2
    EXCEPTIONS
    string1_too_small = 1
    string2_too_small = 2
    pos_not_valid = 3
    OTHERS = 4.
    Regards

  • Creating a Structure for BAPI Function Module

    Hi,
           I need to create an RFC for a BAPI call. For that I have to create a structure for the function module. Now, do I need to specify both import and export parameters in the same structure or do I need to create two different structures for Import as well as export parameters? If the import and export parameters are specified aleady, Do I need to supply this structures again under "TABLES"?
    Thanks,
    John.

    if u have/get more one records , then u have to use tables ?
    Regards
    Prabhu

  • How to find suitable( existing) function group for a Function Module ?

    How to find suitable( existing) function group for a Function Module to be created?
    This is FM for converting amounts to text.

    Hi,
            If you are not sure into which Function group your FM should go in then its advised to create a Function group of your own. Its not advised to create a function module in any other function group unless its owned by you since your FM can get deleted by others or it can get changed.
    Create your own Function group. But if you want to create in an existing FG then best way is to find out the Function Group by searching for suitable existing Function module then see their function group
    Regards,
    Sesh

  • How to schedule a background jobs for a function module

    HI all,
    I have created a function module (zrfc_test). Now I need to schedule it daily around 8am . the 2 tcodes used is sm36 & sm37. But I need a detail description for a function module.
    Points will be rewarded
    thanks in advance

    As there is no direct way of scheduling a function module, you may write a online program (program type 1) and call this function module in side it and schedule the program using SM36. Or you may record a CATT procedure for the function module and schedule it using SCAT transaction.Hope this helps
    Krishna

  • How to execute Se30(performance check) for a function module

    can anyone please let me know hot to execute perofrmance check for a function module.

    In SE30 below the program option you have Function Module option.
    Give the FM name there >execute, It will lead to the SE37 for Function Module execution screen, enter the values>Execute.
    The ctrl will return back to SE30.
    Press Evaluate to know the analysis.
    Hope this answers.
    Regards
    Vinayak

  • How to insert a code for a function module into a Customer Exit Variable?

    I have two Key Figures viz., Net Prchs Rtl, and Net Prchs Unt. Both these Key figures have This Week (TW) and Last Week (LW). There is a variable for This week but there is no variable defined for Last week.
    I need to get data in the column LW (Last Week) for both the key figures.
    In function module EXIT_SAPLRRS0_001 one of the functions I have is:
    Get the previous Fiscal Week
              CALL FUNCTION 'DATE_TO_PERIOD_CONVERT'
    I need to create a new variable to get values in the Last week column for different key figures and use function “'DATE_TO_PERIOD_CONVERT'” in that variable.
    Can anyone please explain me the steps as to how to use a function module in a variable so that when the variable is used in a key figure it shows the output.
    In other words what I want to know is after creating a Customer exit variable of type Characteristic value how do I refer the above mentioned function moduel and insert the code for the function module into the Customer exit variable that I created.
    Thank you.
    TR.

    Hi Wond,
    Thanks a lot for your reply. I understand what you mean but I have never done this before so can you please explain it in a detailed manner. I have the following code:
    Get the previous Fiscal Week
              CALL FUNCTION 'DATE_TO_PERIOD_CONVERT'
                EXPORTING
                  i_date         = ld_date
                  i_periv        = lc_periv
                IMPORTING
                  e_buper        = ln_poper
                  e_gjahr        = ln_bdatj
                EXCEPTIONS
                  input_false    = 1
                  t009_notfound  = 2
                  t009b_notfound = 3
                  OTHERS         = 4.
              IF sy-subrc <> 0.
                MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
              ELSE.
                lc_poper = ln_poper.
                CONCATENATE ln_bdatj lc_poper+1(2) INTO wa_e_t_range-low.
                wa_e_t_range-sign = 'I'.
                wa_e_t_range-opt = 'EQ'.
                APPEND wa_e_t_range TO e_t_range.
              ENDIF.
            ENDIF.
          ENDIF.
        ENDIF.
    I believe I should now use the above code in my customer exit variable. If that's right can you please explain me the steps as to how should I do this so that the variable gets populated.
    Thank you.
    Regards,
    TR.

  • How to add Test data for a function module

    Hi experts,
    i want to add test data for a function module . i don't know how to proceed on it . please help me...
    with regards,
    James...
    Valuable answers will be rewarded...

    Hi,
    - Go to SE37 and execute your FM
    - Enter the data you want to pass to FM
    - Hit 'Save' button. Enter the meaningful name for your test scenario and save. That's it you have saved the test data.
    You can also enter some other test data and save that also. In short, you can save multiple test scenario. Also, you can give multiple test scenario a same name and they do not overwrite each other ( but normally you give different name to differentiate them)
    Next time you come to execute the FM again, hit the "test data" button and it will show you all the test scenario you have stored before. Select the one you want to use and it will load the data in FM parameters.
    Let me know if you need any other information.
    Regards,
    RS

Maybe you are looking for