Questions regarding update function module

Hello experts,
I am on customer site to help them investigate one issue: they have a background job which runs periodically.
In the report database table A is changed firstly ( new entries are inserted ), then a update function module is called via keyword CALL FUNCTION ... IN UPDATE TASK.
Inside the function module database table B is updated. ( existing entries are updated )
Customer issue:
sometimes they find A is updated as expected, however B remains unchanged at the same time.
customer could not find exact steps to reproduce the issue. However the issue does exist there and occur from time to time.
the issue could only be reproduced in their production system, but works perfectly well in dev & Q system. It is difficult to debug in their production system for trouble shooting.
After analyzing related code, I have one doubt: according to ABAP help on CALL FUNCTION aaa IN UPDATE TASK, I know the function module aaa is called in a new update work process. I wonder whether there is any possibility there this issue might be caused because the update function module fails to get called at all? ( perhaps due to heavy system load so no free update function module could serve the table B update ? )
If update function module fails to execute, is there any system utility to record this? That is to say, will it be recorded in such as SM13 or SM21?
Looking forward to your expertise on this topic!
Best regards,
Jerry

Hello friends,
Thanks a lot for your interests on this issue. I update all my findings:
1. issue background: this issue occurs in SAP CRM Channel manageement Solution, software component CRM-CHM-POS.
2. due to some limitations, the table CMSD_CI_HISTORY and history table are not updated in the same LUW. Instead the first one is updated in normal work process while the other is done in update work process. Since I am not the original developer I didn't know the whole complex scenario ( I did see this is done delibrately in note 1764006 - CMS:Sell In Release creating PB with zero available quantity ).
So for the moment we have to accept this design.
3. during our testing ,we ensure COMMIT WORK is always called.
4. So why sometimes the first table update fails, however there is no hint at all for this failure in the system like ST22 and SM21 ?? ( forget SM13, since it is updated in normal work process ).
The root cause is the flaw of SAP code below.
The code has planned to raise exception if insertion failed due to duplicate records to be inserted.
Unfortunately, the fact is if we use "INSERT db FROM TABLE xxx" to insert records into database and some record already exists with the same key, it will result in a termination but SY-SUBRC is STILL 0; Just compare it with single insertion using "INSERT db FROM <work area>", in the same error situation, processing does not terminate, and SY-SUBRC is set to 4.
As a result in this case even the insertion fails, line 29 will never be executed as sy-subrc is always 0. Since the insertion fails and the exception is caught without any notification, so customer sufferred because they do not know what has happened.
Best regards,
Jerry

Similar Messages

  • Regarding update function module

    Hi all,
    This is regrding update function module
    How to handle errors in update function module
    Can exception be used in Update function modules
    while calling in update Task
    if we can use please let me know how to do so while calling in Update task.
    Regards,
    siva chalasani.

    Hi Vinod,
    Just wanted to say...
    your answer solved my problem.
    I needed to pass my error records into a internal table and from there to notepad using GUI_DOWNLOAD.
    The following is my function module....
    RHPP_Q_PROFILE_WRITE
    It has under  TABLES-- 'err_profile' to capture error records.
    So, I passed a internal table in " err_profile" to capture the errors.
    And then passed this internal table in GUI_DOWNLOAD.
    Regards,
    Hari Kiran
    Edited by: HARI KIRAN REDDY on Aug 12, 2008 12:20 PM

  • Doubt in update function module

    dear friends..
    i have created an UPDATE function module with Processing type- Update Module, Start Immediate. i have handled the exceptions using Raise statement in the function module..
    the call function looks as..
      CALL FUNCTION 'ZFI_LCTXN_TABLES_UPDATE'
        in update task
        EXPORTING
          ZLCTMB1  = p_lctmb1
          NU_ENTRY = p_global-ins_zlctmb1
        TABLES
          UPD_PO   = UPD_PO
          UPD_SH   = UPD_SH
        EXCEPTIONS
          ERROR    = 1
          OTHERS   = 2.
      p_subrc = sy-subrc.
      commit work.
    but if the update fails, and even though the RAISE ERROR works, and update termination message is registered in SM13, i dont get the value for sy-subrc as 1 .
    is it the right way..if yes please tell me how to generate an error message within the transaction..so that the user knows the update has failed..
    thank you for your time
    Nivin

    Hi,
    Maybe it's usefull  for you.
    <b>
      IF sy-subrc EQ 4.
        MESSAGE e001 RAISING not_found.
      ELSEIF sy-subrc EQ 8.
        MESSAGE e002 RAISING not_found.
      ELSE.
      ENDIF.</b>
    Using this to create a message and raise in the same time !
    Regards.
    Marcelo Ramos

  • Checking the contents of update function module log table

    Dear experts,
    I created several CALL FUNCTION ... IN UPDATE TASK lines and is curious about the contents of the update function module log table. How can I see its contents?
    Thanks in advance.
    Regards,
    Haris

    Hi Hari,
    Use transaction SM13. This gives all the details
    To view the details in SM13 switch on Update debugging before you call your update function module.
    In debugger Settings --> Display / change Debugger settings --> Use the check box "Update Debugging" --> Press save button
    So after COMMIT WORK statement, debugging will start with the update function module
    During this time check the entries in SM13
    Once the update is complete the entries will be removed from SM13 (Unless there is a failure)
    I am not sure if there is option to view records in SM13 for which update is complete (No authorization to change settings in SM13). So i cannot check this
    Regards
    Rajvansh
    Edited by: Rajvansh Ravi on Jul 24, 2011 3:52 PM

  • Invalid COMMIT WORK in an update function module. in VKM1 Tcode

    Hi All,
    I am getting the short dump with message "Invalid COMMIT WORK in an update function module. "
    Calling a COMMIT WORK in an update process is not allowed
    because the function modules triggered in a Logical Unit
    of Work cannot then be processed correctly.
    in FM : SO_DOCUMENT_SEND_API1
    Prev. it was giving error in one of my driver program where I had written the commi Work after calling FM for sending fax :
    "CONVERT_OTF_AND_FAX" .
    call function 'CONVERT_OTF_AND_FAX'
        exporting
          FAXOPTIONS = W_ITCPP
          USER       = NAST-USNAM
        importing
          MSGID      = W_MSGID
          MSGNO      = W_MSGNO
          MSGV1      = W_MSGV1
          MSGV2      = W_MSGV2
          MSGV3      = W_MSGV3
          MSGV4      = W_MSGV4
        tables
          OTF        = IT_OTF.
    if sy-subrc eq 0.
      commit work.
      submit RSCONN01 with MODE = 'FAX' and return.
    endif.
    Please explain me where and how I can change my code so that this error should not come?
    Rgds.
    MAdhuri

    Hello, Suhas!
    I am getting the short dump with message "Invalid COMMIT WORK in a COMMIT WORK or ROLLBACK WORK."
    Short text
        Invalid COMMIT WORK in a COMMIT WORK or ROLLBACK WORK.
    What happened?
        Error in the ABAP Application Program
        The current ABAP program "CL_FDT_CC_SERVICES============CP" had to be
         terminated because it has
        come across a statement that unfortunately cannot be executed.
    Error analysis
        The call of a COMMIT WORK in a FORM, that will not be executed until
        the commit or rollback point of the caller using the variant
        PERFORM ... ON COMMIT or PERFORM ... ON ROLLBACK is not permitted.
    etc.
    Could you help me to solve the issue?
    Regards,
    Kseniya Tsyganchuk

  • How to exit from an update Function Module

    Hi Friends,
    I am using an Update Function Module in my program.The Program also has various other logics implemented in it. The Update Function Module gets triggered only when it finds COMMIT WORK statement. Now, I want that when the FM gets triggered and inside it, sy-subrc <> 0 at any stage, it should exit the complete processing and come to my main screen.
    I tried to use Exit, STOP commands in the FM, but they only make the processing to exit from the FM.
    Please suggest what shud I do.
    Helpful suggestions will be surely rewarded.
    Thanks in advance.
    Regards,
    Himanshu

    hi hemansu,
    after coming out from function module check value of sy-subrc
    and
    if sy-subrc ne 0
      exit.  or leave to screen 0 [module pool progarm] or stop.
    endif.
    if helpful reward some points.
    with regards,
    suresh babu aluri.

  • Does Update function module gets executed after Commit Work?

    Hi Gurus,
    I have a BAPI with a Commit work. Does update function module V1 , V2 - i need mainly about the sequence of V2, gets executed after Commit work or before Commit work.
    Thanks

    Pl refer to SAP help on the same as follows.
    https://help.sap.com/saphelp_nw04/helpdata/en/e5/de86e135cd11d3acb00000e83539c3/content.htm
    Regards,
    Naveen Vishal

  • Multiple call of update function module

    Hi Everybody,
    I have made implementation to the definition MB_DOCUMENT_BADI( material Document creation).
    While executing this BADI I am getting short dum with this error  Multiple call of update function module.
    Here is the short dump--
    In the FORM routine Buchen_Ausfuehren (program SAPMM07M), an error
    message was issued by a Business Add-In (BAdI) or function module.
    This is not permitted, because it could lead to data             
    inconsistencies. For this reason, the update of the material     
    document was also terminated with a termination message (dump).  
    Note that this message (M7 372) is not the responsible error     
    message.                                                         
    Please any body suggest the way forward.
    Regards,
    Sandeep.

    Hi Kiran,
    Thanks for the reply.
    I have created one implementation to the BADI MB_DOCUMENT_BADI. This badi will hit while creation of material document.I have write the code in method MB_DOCUMENT_BEFORE_UPDATE such that it will act only for certain movement types specially for t-codeMb1a and MB31.
    What problem I am facing i have used a error message "MB_DOCUMENT_BEFORE_UPDATE" in this method.If we got the erroe message then we dont need to post the material dcoument,but here problem is that if the material document could not posted then it corrupt the material and when we performing 261/101 we got error message like " Inconsistency between MM and ML for material and plant"
    I have used following things like-
    1-while updating the customized table using " Commit Work".
    2-Call function vb_change_batch for updating the batch and not in update task.
    3. Dequeue the table after updating the table.
    Will thos things can create any inconsistency to  the MM and ML.
    Please suggest me uor thoughts.
    Thanks
    sandeep.
    Thanks ,
    sandeep.

  • WHAT ARE THE UPDATED FUNCTION MODULES

    Hi Friends,
    Can anybody explain me about UPDATED FUNCTION MODULES (types of function modules)

    Hi
    Update Function Module
    Unlike transactions and executable programs, dialog modules do not start a new SAP LUW. Calls to update-task function modules from a dialog module use the same update key as the ones in the calling program. The result is that calls to update function modules from a dialog module are executed only if a COMMIT WORK statement occurs in the calling program.
    If you place a COMMIT WORK in a dialog module, it does commit changes to the database (for example, with UPDATE).However, it does not start the update task. The function modules are not actually executed until a COMMIT WORK statement occurs in the calling program.
    If you use dialog modules, try to avoid including calls to update function modules in subroutines called with PERFORM ON COMMIT. In general, any occurrence of PERFORM ON COMMIT(with or without update-task function calls) in a dialog module can be problematic.
    This is because dialog modules have their own roll area, which disappears when the module finishes. Consequently, all local data (including data used for parameter values when calling an update function module) disappears as soon as the commit in the main program is reached.
    If you must use this method in a dialog module (i.e. include the call to an update-task function in a subroutine), you must ensure that the values of the actual parameters still exist when the update-task function actually runs. To do this, you can store the required values with EXPORT TO MEMORY and then import them back into the main program (IMPORT FROM MEMORY) before the COMMIT WORK statement
    Creating Update Function Modules
    To create a function module, you first need to start the Function Builder. Choose Tools ® ABAP Workbench, Function Builder. For more information about creating function modules, refer to the ABAP Workbench Tools documentation.
    To be able to call a function module in an update work process, you must flag it in the Function Builder. When you create the function module, set the Process Type attribute to one of the following values:
    Update with immediate start
    Set this option for high priority ("V1") functions that run in a shared (SAP LUW). These functions can be restarted by the update task in case of errors.
    Update w. imm. start, no restart
    Set this option for high priority ("V1") functions that run in a shared (SAP LUW). These functions may not be restarted by the update task.
    Update with delayed start
    Set this option for low priority ("V2") functions that run in their own update transactions. These functions can be restarted by the update task in case of errors.
    To display the attributes screen in the Function Builder, choose Goto ® Administration.
    Defining the Interface
    Function modules that run in the update task have a limited interface:
    Result parameters or exceptions are not allowed since update-task function modules cannot report on their results.
    You must specify input parameters and tables with reference fields or reference structures defined in the ABAP Dictionary.
    http://help.sap.com/saphelp_nw70/helpdata/en/41/7af4daa79e11d1950f0000e82de14a/frameset.htm
    Regards,
    Harish

  • Regarding the functional modules

    hi,
    there are three types of function modules are there.
    1)normal functional modules
    2)remote functional modules
    3)update functional modules
    what is the update functional modules?
    please provide me the information regarding this functiional modules

    Hi,
    go through following ,material:
    http://sapmaterial.com/RFCmaterial.html
    http://sapmaterial.com/bapi.html
    Reward points if helpful
    Srikanta Gope

  • Errors in Update Function Modules

    Hi Gurus,
    Please provide me the ways to handle Errors in Update Function Modules.
    (I.e. I should export errors from Update Function Module)
    Warm Regards,

    Use Raise statement ...
    FUNCTION-POOL CSTR.
    FUNCTION STRING_SPLIT.
      IF STRING NA DELIMITER.
        RAISE NOT_FOUND.
      ENDIF.
    ENDFUNCTION.
    Regards,
    Santosh

  • Question about the function module (RFC_READ_TABLE)

    Dear everyone
    Could I ask you a question about the function module (RFC_READ_TABLE)?
    I was asked if it's possible to create a report which compares the data between different SAP systems (both production systems).
    Now, the easiest way would be to use the function module (RFC_READ_TABLE) within a SAP infoset query (SQ01 type query).
    But I heard the rumor that using the function module (RFC_READ_TABLE) is not advisable due to the security reason.
    However, I am not exactly sure what sort of security problems this function module can possibly have...
    Would you help me on this?
    I also would like to know if using "remote enabled module" type function module can always overcome this possible security issue.
    Or, are there any points that I need to be careful about even when I use "remote enabled module" function module?
    Thank you very much in advance.
    Takashi

    Dear Fred-san
    Thank you very much for your support on this.
    But, may I double check about what you mentioned above?
    So, what you were mentioning was that if some user executes the query with
    the function module (RFC_READ_TABLE), under the following conditions, he can access to
    the HR data even when he does not have the authorizations for HR transactions?
    <Conditions>
    1. the user has the authorization for HR database tables themselves
    2. RFC_READ_TABLE is called to retrieve the data from HR database
    <example>
    Data: LF_HR_TABLE like  DD02L-TABNAME value 'PA0000'.
    CALL FUNCTION 'RFC_READ_TABLE'
       EXPORTING
        query_table                = LF_HR_TABLE
      TABLES
       OPTIONS                    =
       fields                     =
       data                       =    .
    But then, as long as we call this function module for a non-critical tables such as
    VBAP (sales order) or EKKO (purchase order) within our query, it wouldn't seem to be
    so security risk to use RFC_READ_TABLE...
    Besides, each query (infoset query) has got the concept of user groups, which limits
    the access to the queries within the user group.
    ※If someone does not belong to the user group, he cannot execute the queries within that
       user group, etc
    So, my feeling is that even infoset queries does have authorization concept...
    Would you give me your thought on this?
    I also thank you for your information for SCU0.
    That is an interesting transaction
    Kind regards,
    Takashi

  • Short dump for update function module

    Hi Folks,
       If I try to raise exception in Update Task function module which is in turn called in Custom BAPI function module. When I test the BAPI stand-alone using explicit COMMIT WORK (For testing)I can see the error in SM13 and it processes further in BAPI. Now when I am using this BAPI for ALE Inbound processing function module to SAP, when I test using testing tool WE19 it crashes when it passes the update FM inside BAPI, and encounteres BAPI_TRANSACTION_COMMIT, the update Function module is executed as encountered and gives me dump at the raised exception and does not show error in SM13. Please suggest how I could overcome this dump.
    Regards,
    Tim

    Hi there,
    Yes. I know that I can details from ST22 Analysis. And I did go through that.
    Here's the Section that explains:
    How to correct the error
        Try to find out why the number of decimal places of the field should be
        2.
        There are various possible options:
        1. The number of decimal places of the imported field has changed in the
           Data Dictionary. Make sure that the number of decimal places of the
           imported field matches the number of decimal places of the field in
           the Data Dictionary.
           If the data cannot be restored from another source, the data of the
           'old' structure must be read by the 'old' structure, converted und
           again eported with the new structure, so that future IMPORTs will
           always function with the new structure.
        2. A new program version is active, which no longer fits the dataset.
           Try to solve the error generating the program
         "ZFI_FM_GET_STD_COSTS==========FT" again. This
           works as follows: Select transaction SE38 in the SAP system. Enter
           the program name "Z_GET_COSTS==========FT". Then activate the
         function 'Generate'.
    1. I made sure that the decimal places matches.
    2. I did re-generate the program.
    But still got the same dump. Interestingly, the program where I am using this FM is working absolutely fine.
    Thanks.

  • CALL TRANSACTION in Update Function module

    Hi all
    AFIK, it is not possible to trigger a CALL TRANSACTION for BDC update in an update function module. Yet, i jus wanna to confirm it with the xperts. what are other options for posting a BDC data in an update function module?
    thkx
    Prabhu

    Hi,
    Try this..
    Create a new RFC function module and in the function module do all the coding for the BDC and CALL TRANSACTION..
    Inside the update module call the RFC function module IN BACKGROUND TASK.
    I believe this should work..
    Thanks
    Naren

  • How two create UPDATE FUNCTION MODULE

    Hi,
    I have 2 tables to update one after the other...
    I have geard it is advisable to use update function module for this..
    can any1 tell me how to create and work with update function modules...
    Answers will be rewarded....

    Abhay,
    How an update function module works is, the execution of the FM is delayed to until when a COMMIT WORK statement is executed.
    Hence if you have the data available for updating the two DB tables at the time of calling the FM, you can pass the tables to the same FM and program the DB update for both in the same FM.
    However the COMMIT WORK should be outside the FM further down in the calling program.
    This link is very good and easy to follow
    http://help.sap.com/saphelp_erp2005vp/helpdata/en/41/7af4daa79e11d1950f0000e82de14a/frameset.htm
    Hope it helps
    Aditya[url=http://help.sap.com/saphelp_erp2005vp/helpdata/en/41/7af4daa79e11d1950f0000e82de14a/frameset.htm]
    Message was edited by:
            Aditya

Maybe you are looking for