COMMIT WORK within an user exit

Hi every one,
     I got a lill question here, can i use COMMIT WORK (AND WAIT ) within a user
exit FM, if yes is do i need any thing extra. Please help.
Thanks in advance
Jahan.

Hi Jahan,
although your question has been answered, just a few words on COMMIT WORK.
During a LUW (logical unit of work, i.e. transaction) all changes of database records are done within a so-called rollback segment of the database. That means they are visible within the current LUW but invisible to other users.
This makes it easy to do all necessary changes to all tables step by step. And if any step fails, all changes can be thrown away. Thats what we call a rollback - A rollback will just dump the rollback segment.
The reason you should not COMMIT WORK in a user exit is simply you have no idea what other database changes have already been done and what other database changes may follow after the user exit. If in one of the following steps a severe error is detected, all prior changes cannot be rolled back. COMMIT WORK means that all changes still in the rollback segment of the database will be applied and finalized to the database. The rollback segment will also be dumped that there is no chance to find out details about the changes.
An Error message (Type E or A) will automatically finish the LUW without commiting the data in the rollback segment -  implicit rollback.
The end of a report not caused by any error will commit the rollback segment to the database -  implicit commit.
All function modules called IN UPDATE TASK will be executed in their own update process after COMMIT or DUMPED after rollback.
All form routines called as PERFORM ... ON COMMIT or PERFORM ... ON ROLLBACK will be executed only after explicit COMMIT WORK or ROLLBACK WORK.
The addition 'AND WAIT' just means that the next program statement is not executed before all update processes started with COMMIT WORK have finished.
The general rule derived from this can be:
Never do a commit or rollback in a process which is called by another process. The only place for COMMIT or ROLLBACK is at the end of reports and transactions using CALL ... IN UPDATE TASK or PERFORM ... ON COMMIT - if you call any functions you should be aware that function modules may initiate update calls and/or form calls ...ON COMMIT/ROLLBACK. An explicit COMMIT WORK at the end of a process (or ROLLBACK WORK in case of error) will be OK.
Regards,
Clemens

Similar Messages

  • How to turn greyish/disable a field in ME52N/ME53N (working on a user exit)

    Hi experts,
    simple question: I'm working on an user exit that is used by ME5?N, and I'd like to do something like:
    "looping on the items of a purchase req., if position X has a particular value as attribute, then don't allow any change to the field PSTYP".
    I can easily implement the check in the code of the user exit; I don't know how to turn grey/disable for any change the field PSTYP at screen as a consequence of a positive check. Can anybody guide me thru this - I hope simple - operation? Thanks in advance

    You will not get any answer here, Post your question in correct section after mark this thread as answered
    Oracle Discussion Forums » Oracle Database » Application Express

  • Commit work in the customer exit

    Hi ,
    Iam getting this dump in my system.
    Exception condition
    "DUMP_STATUS_INCONSYSTENCY_FRE" raised. 
    As per this dump one note is there saying you should not use commit work in user exit or customer exit .
    But i need to update the table at that point so please tell me with out using commit work can i update the table at that point.
    Please help me its imp.
    Thank you .

    Use the function Modules ENQUEUE_E_TABLEE and DEQUEUE_E_TABLEE.Update the table between these function modules.
    Example :
    CALL FUNCTION 'ENQUEUE_E_TABLEE'
        EXPORTING
          mode_rstable   = c_e
          tabname        = c_sold_table
        EXCEPTIONS
          foreign_lock   = 1
          system_failure = 2
          OTHERS         = 3.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    *********End Lock********
      IF i_del_sold[] IS NOT INITIAL.
        DELETE ztsa_ft_soldtp FROM TABLE i_del_sold.
      ENDIF.
      IF i_del_ship[] IS NOT INITIAL.
        DELETE ztsa_ft_shiptp FROM TABLE i_del_ship.
      ENDIF.
      IF i_db_ship[] IS NOT INITIAL.
        MODIFY ztsa_ft_shiptp FROM TABLE i_db_ship.
      ENDIF.
      IF i_db_sold[] IS NOT INITIAL.
        MODIFY ztsa_ft_soldtp FROM TABLE i_db_sold.
      ENDIF.
    *Sold to Party Table
      CALL FUNCTION 'DEQUEUE_E_TABLEE'
        EXPORTING
          mode_rstable = c_e
          tabname      = c_sold_table.

  • Hr_infotype_operation errors when called within a user exit

    Hi there.
    I am doing an enhancement in userexit PBAS0001 for CE using the enhancement framework.Whenever I am trying to change the payroll area in IT0001 by PA30 it has to give a message saying that 'all the assignments will change to new payroll areas do you want to continue?'if i say yes then the payroll areas for all the assignments should be chnaged to the current payroll area which I am trying to change.So after the pop up I am looping at all the assignments and calling the function module hr_infotype_operation.It gives an error Complex Application error.I debugged and saw that when it calls the function module the user exit gets triggered again and goes to the starting within the function call and hits the function module again and keep going like this.I checked the structure and all the parameters.looks fine below is the code where I am using the function module.I am trying to update IT0001 when somebody tries to change the IT0001(is that an issue??) i tried by submitting a program by calling the function module in the program.Didnt work too.Is there any way we can do it by BDC??
    Check if the payroll areas are equal
        IF ls_i0001-abkrs NE new_p0001-abkrs.
    If the payroll areas are not equal then generate a message pop-up with 'YES' and 'NO' buttons
          CALL FUNCTION 'POPUP_TO_CONFIRM'
            EXPORTING
              titlebar       = 'Warning'
              text_question  = 'Payroll Area specified is different with other assignments.Do you want to move all the other assignments to the same payroll area?'
              text_button_1  = 'Yes'
              icon_button_1  = ' '
              text_button_2  = 'No'
              icon_button_2  = ' '
              default_button = '1'
              start_column   = 25
              start_row      = 6
            IMPORTING
              answer         = lv_case
            EXCEPTIONS
              text_not_found = 1
              OTHERS         = 2.
          CASE lv_case.
            WHEN '2'.                                 "For 'NO' button
              LEAVE TO SCREEN '2010'.
            WHEN 'A'.                                 "For 'CANCEL' button
              LEAVE TO SCREEN '2010'.
            WHEN '1'.                                 "For 'YES' button
    Second Pop-up confirm
              CALL FUNCTION 'POPUP_TO_CONFIRM'
                EXPORTING
                  titlebar              = 'Warning'
                  text_question         = 'System will update all other assignments to the new payroll area'
                  text_button_1         = 'Yes'
                  icon_button_1         = ' '
                  text_button_2         = 'No'
                  icon_button_2         = ' '
                  default_button        = '1'
                  display_cancel_button = 'X'
                  start_column          = 25
                  start_row             = 6
                IMPORTING
                  answer                = lv_case1
                EXCEPTIONS
                  text_not_found        = 1
                  OTHERS                = 2.
              CASE  lv_case1.
                WHEN '2'.                             "For 'NO' button
                  LEAVE TO SCREEN '2010'.
                WHEN 'A'.                             "For 'CANCEL' button
                  LEAVE TO SCREEN '2010'.
                WHEN '1'.                             "For 'YES' button
    For all the assignments read the infotype 0001 and update the payroll area
                  LOOP AT lt_pernr INTO ls_pernr.
                    CLEAR:lt_i0001,ls_i0001.
                    REFRESH lt_i0001.
                    CALL FUNCTION 'HR_READ_INFOTYPE'
                      EXPORTING
                        tclas           = 'A'
                        pernr           = ls_pernr
                        infty           = '0001'
                        begda           = new_p0001-begda
                        endda           = new_p0001-endda
                        bypass_buffer   = 'X'
                      IMPORTING
                        subrc           = lv_subrc
                      TABLES
                        infty_tab       = lt_i0001
                      EXCEPTIONS
                        infty_not_found = 1
                        OTHERS          = 2.
                    SORT lt_i0001 BY endda DESCENDING.
                    READ TABLE lt_i0001 INTO ls_i0001 INDEX 1.
                    ls_i0001-abkrs = new_p0001-abkrs.
                   lv_record = ls_i0001.
    Lock the employee
                      CALL FUNCTION 'BAPI_EMPLOYEE_ENQUEUE'
                        EXPORTING
                          number = ls_i0001-pernr
                        IMPORTING
                          return = lv_return.
                      CALL FUNCTION 'HR_INFOTYPE_OPERATION'
                        EXPORTING
                          infty         = '0001'
                          number        = ls_i0001-pernr
                          validityend   = '12302006'
                          validitybegin = '12012006'
                          record        = ls_i0001
                          operation     = 'INS'
                         IMPORTING
                          return        = return.
    *unlock the employee
                      CALL FUNCTION 'BAPI_EMPLOYEE_DEQUEUE'
                        EXPORTING
                          number = ls_i0001-pernr
                        IMPORTING
                          return = lv_return.
                   SUBMIT zhr_infotype_operation_py_area USING SELECTION-SCREEN '1000'
                   WITH p_infty  = '0001'
                   WITH p_pernr  = ls_i0001-pernr
                   WITH p_endda  = new_p0001-endda
                   WITH p_begda  = new_p0001-begda
                   WITH p_record = lv_record
                   WITH p_opera  = 'INS'
                   WITH p_tclas  = 'A'
                   AND RETURN.
                  ENDLOOP.
              ENDCASE.
          ENDCASE.
    ENDIF.

    maybe a little late, but I had found this message today (searching for different problem) but maybe the date for HR_infotype_operation might do a little problem, cause you are filling it with: DDMMYYYY but it should be YYYYMMDD so it just translate it that this is really far in the past so that might be a problem. Try sy-datum instead and for the end of validity try '99991231' dont worry, when you will update the same infotype again, the FM will end the previous infotype to previous day and the new one will get validity from sy-datum till the end ....

  • Commit statement in user exit

    Hi All,
    We found that while doing PGI , it takes some time to COMMIT the table VBUK. Due to which we are getting old values of VBUK-KOSTK field while executing select query at later point of time in the flow.
    My question --
    Can I use COMMIT WORK statement in user exit MV50AFZ1 --> FORM USEREXIT_SAVE_DOCUMENT so that all the related tables
    get committed immediately.
    Thanks
    Saurabh

    Hi Saurabh ,
    Normally , you shoud not specify COMMIT stmt in any user exit , badi etc..
    SAP has its own COMMIT statement while execuiting the standard transactions .
    Addition of a COMMIT might lead to problems elsewhere .
    Thanks
    Supriya

  • BAPI_PR_CHANGE within user-exit

    Hi friends am using the BAPI_PR_CHANGE within a user-exit while doing transfer posting in MIGO.
    since its within the user-exit i am not able to write commit work or transaction commit . Is ther any other way to commit the BAPI.
    Even once the documents are posted the PR changes are not updated.
    Please suggest a suitable solution for this issues.

    Iam using the EXIT_SAPLMBMB_001. As per my requirement in the exit am doing changes to PR's and updating the same in R/3 and also it should be updated in APO server so am using the particular BAPI. But its not updating the PR changes in r/3 or APO.

  • Use of CL_BCS to send email in user exit

    Hi,
    I need some help from experts in this forum.
    I use CL_BCS to send email if a certain condition is met inside a customer exit.
    This exit is called before a confirmation dialog pop up asking whether we want to save or cancel.
    I did not put commit work statement in this exit since it will commit all database update even though the transaction can still be canceled. Email will also be sent if the transaction is save. Hence, I'm relying on commit statement that come from the transaction itself.
    However, this logic has create one problem for me.
    If user hit cancel in the confirmation dialog that pop up after the exit is called, no commit will be executed. Hence, no email will be sent.
    The problem is when the user change the data and re-save the data, there will be 2 email sent. One email come from the save action from the user and the other come from previous email that was not sent before due to no commit statement executed.
    Is there any way to prevent this to happen? Please help.
    PS: Points will be rewarded for those with helpful answer
    Message was edited by:
            Abraham Bukit

    Hi,
    May be you use commit this way.
    Create a custom function moudle , with you CL_BCS class codes and with comitt work inside and call the function in your userexit like
    call function 'Y_CL_BCS_TRIGGER'     " << Your function module name
    starting new task yscchdr-docno
    exporting
       xxxxx     = xxxxx
    aRs

  • Update termination error on coding in user exit EXIT_SAPLCOIH_009

    HI All,
    I am working on approval of a work order in IW32 for which I am coding within a user exit EXIT_SAPLCOIH_009 which gets triggerred at the time of saving the work order. This will update the AUFK table and send a mail to a recipient. But when I save the work order after approving it, it gives me an error saying "Update Termination error". I checked within the SM13 transaction and ST22 for dump analysis, it says "The ABAP/4 Open SQL array insert results in duplicate database records.". Can anyone tell me what could have gone wrong and how I can rectify this. Your help is greatly appreciated.
    Thanks in Advance

    Hello
    This type of error will appear in three cases
    1.when there is a record in the database and trying to insert another with the same number
    2.If there is any inconsistencies in number ranges  (check this only if you have changed the number ranges very recently)
    3. If the output type and the output device is wrongly selected ( not the prescribed)
    Analyse yourself.
    Regards,
    Prakash

  • User exit for ME21N (Not functional or customer exit)

    Hi Guys,
    I want to get a user exit for PO as my requirement is to call  custom screen before the PO is getting saved.
    I have the functional exits and badi's list which will not fulfill my requirement as because on my custom screen i have cancel button.
    On clicking the control needs to come back to the me21n second screen with the data entered with out order getting created.
    The screen number for the second screen in ME21N  is 14.
    if i call screen 14 it will work in a user exit where as in customer exit(functional exit) we have limitations with the exporting and importing as so the screen number will not be recognised.
    I am able to do the same calling of cust screen in Sales order creation and is sucessfull, the same should happen with PO also.
    Probably if the user exit triggers at the time of syntax check i can achive my requirement rather than at save as the call back to the screen will not harm and database commits will not take place.
    I also tried with all most of the enahancement points but the call screen statement is not working at any point of time which worked with Sales order exits. So i tried with making the validation fail but still by that time the PO number is getting generated and so if i try to cancel the PO before save and trying to get PO in edit mode but the sequence number is getting missed by by 1.
    Please help.
    Regards,
    Amar.
    Edited by: amar srinivas on Feb 11, 2011 10:16 AM
    Edited by: amar srinivas on Feb 14, 2011 4:56 PM

    Hi,
    You can try it this way.
    Check badi ME_PROCESS_PO_CUST , method - CHECK.
    This badi/method gets triggered when the "CHeck" button and "SAVE" button is pressed.
    It consists of a changing parameter CH_FAILED . Pass X to it when cancel button is hit in your custom screen.
    Donot use any commit in this method. Read the documentation before doing it.

  • Taxware User Exit ECC 6.0

    Moderator message: do not offer points
    Hi Experts,
    Working on FYTX0002 user Exit.
    I am tyin to write code inside the include within a function module EXIT_SAPLFYTX_USER_001.
    Depending upon some condition i need to decide whether or not to call the Taxware RFC,,,,
    While creating or changing sales order & purchase orders.
    Do Someone know the name of the RFC being called in ECC 6.0.
    How do i restrict the RFC from geting called.?
    <<Text removed>>
    Regards,
    Kevin.
    Edited by: Matt on Feb 1, 2009 9:17 PM

    You can find all function module related to tax calculation in External system under the function group FYTX.
    PS : But i don't much info whether these will be used for  TAXWARE or VERTEX
    Restirct RFC from being called
      if condition eq okay
         call function 'XXXX'
    else.
        do nothing
    endif.
    Is this was you are looking for ?
    , a®

  • ALV + User Exit

    Hi all,
    One of my friends here is facing a small issue in using ALV(Classic) within a user exit.
    In the existing ALV display, he is using a form for setting the PF-Status as  follows.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
             I_CALLBACK_PROGRAM          = report_name
             I_CALLBACK_PF_STATUS_SET    = 'F100_PF_STATUS_SET' n so on n so forth ...
    But since this is being written within an exit, it does not permit the use of FORM…ENDFORM for the dynamic call of the subroutine 'F100_PF_STATUS_SET'.
    Anybody who has worked on Exits and ALV, your inputs would be of great help.
    Hope my question is clear …!!
    Many Thanks,
    Gayathri.

    Hi, try my solution.
    Create a new report, assume name it ZCALLBACK, and write your F100_PF_STATUS_SET form in it, like following:
    report ZCALLBACK.
    FORM F100_PF_STATUS_SET.
    your logic
    ENDFORM.
    And in your user-exit, call the ALV function like following:
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
         I_CALLBACK_PROGRAM        = 'ZCALLBACK'
         I_CALLBACK_PF_STATUS_SET  = 'F100_PF_STATUS_SET'
    Hope it will be useful to your scenario.
    And thanks a lot

  • Taxware User Exit.

    Hi Experts,
    Working on FYTX0002 user Exit.
    I am tyin to write code inside the include within a function module EXIT_SAPLFYTX_USER_001.
    Depending upon some condition i need to decide whether or not to call the Taxware RFC,,,,
    While creating or changing sales order & purchase orders.
    Do Someone know the name of the RFC being called in ECC 6.0.
    How do i restrict the RFC from geting called.?
    <removed_by_moderator>
    Regards,
    Kevin.
    Edited by: Julius Bussche on Jan 30, 2009 9:41 PM

    You can find all function module related to tax calculation in External system under the function group FYTX.
    PS : But i don't much info whether these will be used for  TAXWARE or VERTEX
    Restirct RFC from being called
      if condition eq okay
         call function 'XXXX'
    else.
        do nothing
    endif.
    Is this was you are looking for ?
    , a®

  • Deriving Planning Folder Technical Name From User-Exit

    Dear Colleagues,
    For those of you who know ABAP, do you know if it is possible to determine the technical name of a planning folder from within a user-exit (i.e. planning function that has been executed from within a planning folder)?
    Customer states: They would like to use a Planning Folder, and invoke a planning function of type user-exit (i.e. via button in folder), which will execute an ABAP that has a case statement for conditional execution of steps, based upon the technical name of the planning folder that invoked the call.
    Thank you in advance for any guidance or feedback you may be able to offer.
    -M

    Hi Michael,
    Write this code in the exit function
    FIELD-SYMBOLS: <fsl_class> TYPE REF TO cl_upb_pm_applc.
      DATA:          name(50),
                     plan_folder TYPE upb_y_ps_name.
      name = '(SAPLUPB_PM)gr_applc'.
      ASSIGN (name) TO <fsl_class>.
      IF sy-subrc = 0.
        CALL METHOD <fsl_class>->get_active_pm
          RECEIVING
            r_pm = plan_folder.
      ENDIF.
    Glad I could be of help to the mastero.
    Let me know if it worked.
    thanks

  • User Exit - VA41

    How Do everyone.
    I have written some code within the user exit for VA41
    within the FORM USEREXIT_SAVE_DOCUMENT_PREPARE.
    It bascially asks for some user input. If the user
    answers 'Y' I carry on as normal with the document save.
    However, if the user answers 'N' how can I force the
    system to reject everything the user has entered? So
    that he/she can start again.

    Hi Andy,
    The user answer 'N' will itself cancels the user inputs, and will not save anything.
    If you have access to OSS , read consulting notes 7688 /
    582767 / 313440 .
    Check OSS 178328 It will answer all your queries
    XV*** structure will hold the current values of the Sales Order.
    YV*** structure will hold the previous values of the Sales Order.
    For Example,
    Sales Order is created with two line items say 10 and 20.
    During the sales order change an item is added say 30.
    XVBAP holds all the three line items(10, 20 and 30).
    YVBAP holds only 10 and 20.
    All the values in XV*** will be updated to the tables V*** repectively during COMMIT.
    Using XV*** and YV*** you can determine the changes made for the sales order while change is processed.
    Regards,
    Raj

  • How to access variables outside user exit

    Hi,
    I'm working with a user exit and my problem is that in a particular moment I have to access variables located outside the scope of the user exit (they are in a standard program)
    How can I reach these variables?
    thanks in advance

    Hi,
    If they are global variables then you can access them using Global assign technique,
    For example,
    FIELD-SYMBOLS: <fs_value> TYPE ANY.
    ASSIGN ('(SAPMV45A)XVBAK') TO <fs_value>.
    It is basically,
    ASSIGN ('(<Std. Program Name>)<Variable name>') TO <field symbol>.
    NOTE: To make sure they are accessible in your user exit, just put a break-point in the user exit and once you are there in debugging, type in,
    (<Std. Program Name>)<Variable name> in the Field names section and if it does not show it in RED then it is accessible..
    Hope this helps.. 
    Sri
    Message was edited by: Srikanth Pinnamaneni

Maybe you are looking for

  • Where is the testModules folder?

    I have this error message. Sorry, something went wrong The file path is too long: 'testModules\Files\Workflows\B Email External people when Meeting item is created or changed\B Email External people when Meeting item is created or changed.xoml'. Plea

  • FSCM- Collections UDD_GEN_Worklist Error

    I have configured Collections management and I am now trying to generate work list for the first time and I am getting an ABAP Error : Runtime Errors         SAPSQL_ARRAY_INSERT_DUPREC Except.                CX_SY_OPEN_SQL_DB Short text     The ABAP/

  • Change size of Pace Display; Pace Feedback

    I already have a watch to tell the time. How can I change the nano display so that the pace numbers are the largest? Likewise, it would be good to get feedback on pace at km intervals as in a race.

  • How do I turn off CSS Minify in DreamWeaver CS6?

    This is very disruptive during site development. I've looked everywhere.

  • RSTP question...

    With RSTP, my slide says that its portfast (among other things) is building into RSTP.  I dont understand that statement, shouldnt we still have to use the spanning-tree portfast for the sw to know if its an edge port or not? Thank you