Skip to Content

How to stop the script execution in case of error.

The exception CX_UJ_CUSTOM_LOGIC in BADI_UJ_CUSTOM_LOGIC doesn't interrupt execution of LGF script


After installation in system of support-package SAPK-81010INCPMBPC, execution of LGF scripts doesn't interrupt on raising exception CX_UJ_CUSTOM_LOGIC in code of BADI_UJ_CUSTOM_LOGIC called in scipt.

Before that execution of LGF script interrupted on raising exception CX_UJ_CUSTOM_LOGIC in code of BADI_UJ_CUSTOM_LOGIC.

It is now impossible to interrupt execution of LGF script on calculation errors in code of BADI_UJ_CUSTOM_LOGIC. The execution of LGF script continues with logging message "EXCEPTION OCCURRED IN BADI".

System information:

SAP_BASIS 740 0015 SAPKB74015 SAP Basis Component SAP_ABA 740 0015 SAPKA74015 Cross-Application Component SAP_GWFND 740 0015 SAPK-74015INSAPGWFND SAP Gateway Foundation 7.40 SAP_UI 740 0017 SAPK-74017INSAPUI User Interface Technology 7.40 PI_BASIS 740 0015 SAPK-74015INPIBASIS Basis Plug-In ST-PI 740 0004 SAPK-74004INSTPI SAP Solution Tools Plug-In BI_CONT 757 0007 SAPK-75707INBICONT Бизнес-информация и аналитика: содержимое BI_CONT_XT 757 0007 SAPK-75707INBICONTXT Business Intelligence Content for Bobj I SAP_BW 740 0015 SAPKW74015 SAP Business Warehouse CPMBPC 810 0010 SAPK-81010INCPMBPC SAP Business Planning and Consolidation POASBC 100_731 0007 SAPK-10207INPOASBC POA Shared Business Components
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

6 Answers

  • Feb 02, 2017 at 05:58 AM

    Hi Mark,

    The calculated package is used in the tooled system, which generates all calculations, written on the logic of the script.
    Please have a look at the example below:

    Beginning of the file (RUN_ALL.LGF):

    *START_BADI
    LOP  // Calculation 1
    QUERY=OFF
    WRITE=OFF 
    APPL=REV
    PARAMETER DIM SELECTION=%SELECTION% 
    PACKAGE1=CALC_PP_MB
    *END_BADI
    
    *START_BADI LOP // Calculation 2 
    QUERY=OFF
    WRITE=OFF
    APPL=OPEX
    PARAMETER DIM SELECTION=%SELECTION%
    *END_BADI
    
    ---------------- // Calculation N

    End of the file (RUN_ALL.LGF)

    Before support package installation script logic RUN_ALL.LGF has been interrupted due to the mistake in Calculation 1

    The status of package launching script logic became "Failed". Working process of the script was not interrupted after the support package installation. This kind of action do not allow the system to understand whether all attached calculations completed successfully or not

    I suggest it is the result of note 2263229 installation. The note is included in the support package SAPK-81010INCPMBPC.

    Now the execution interrupt of LGF scripts is stopped to proceed when the exception CX_UJ_CUSTOM_LOG occurs in BADI_UJ_CUSTOM_LOGIC handler.

    The note, canceling operation notes 2263229 (Regression fix) is needed or some other solution required.

    System information:

    SAP_BASIS 740 0015 SAPKB74015 SAP Basis Component

    SAP_ABA 740 0015 SAPKA74015 Cross-Application Component

    SAP_GWFND 740 0015 SAPK-74015INSAPGWFND SAP Gateway Foundation 7.40

    SAP_UI 740 0017 SAPK-74017IN

    SAPUI User Interface Technology 7.40

    PI_BASIS 740 0015 SAPK-74015INPIBASIS Basis Plug-In

    ST-PI 740 0004 SAPK-74004INSTPI SAP Solution Tools Plug-In

    BI_CONT 757 0007 SAPK-75707IN

    BICONT Бизнес-информация и аналитика: содержимое

    BI_CONT_XT 757 0007 SAPK-75707INBICONTXT Business Intelligence Content for Bobj I SAP_BW 740 0015 SAPKW74015 SAP Business Warehouse

    CPMBPC 810 0010 SAPK-81010INCPMBPC SAP Business Planning and Consolidation

    POASBC 100_731 0007 SAPK-10207INPOASBC POA Shared Business Components

    Add comment
    10|10000 characters needed characters exceeded

    • Not sure that this note will help! Look on the code changes:

      CATCH cx_root.
        cl_ujk_logger=>log( i_object = 'EXCEPTION OCCURRED IN BADI.' ).
      *>>>> START OF DELETION <<<<<
      ENDTRY.
      *>>>> END OF DELETION <<<<<<<
      *>>>> START OF INSERTION <<<<
        " begin MFA20161116 note 2391076
        data: ls_message type uj0_s_message.
             ls_message-msgty = 'E'.
             ls_message-message = 'EXCEPTION OCCURRED IN BADI.'.
             append ls_message to et_message.
         " end MFA20161116 note 2391076
      ENDTRY.
      *>>>> END OF INSERTION <<<<<<
  • Jan 26, 2017 at 01:51 PM

    Please provide the abap code sample used to interrupt script execution!

    Add comment
    10|10000 characters needed characters exceeded

    • Something like this:

      method IF_UJ_CUSTOM_LOGIC~EXECUTE.
      
        DATA: l_mytext LIKE IF_T100_MESSAGE=>T100KEY.
      
        l_mytext-msgid = 'UJ0_EXCEPTION'.
        l_mytext-msgno = '147'.
        l_mytext-attr1 = 'Error Generated!'.
      
        RAISE EXCEPTION TYPE CX_UJ_CUSTOM_LOGIC
                   EXPORTING
                      textid      = l_mytext.
      endmethod.
  • Jan 30, 2017 at 03:36 PM

    Hi Evgeniy,

    thank you for your post as it relates directly to an issue I am having.

    I am utilising the BPC DM script to invoke the UJ_CUSTOM_LOGIC BADI. My BADI implementation task is to reset / change Work Status for multiple Entity, Category, Time combinations.

    All the validation / data base updates take place using the cl_ujw_work_status_mgr->update_work_status_locks method and this is working fine and returns the correct file update if successful or various different work status error messages if some validation error's occur.

    Some of these combinations may be successful, others not e.g. Owner / Manager not set up for a particular Entity, and I write all of these messages to the DM Formula Log using the standard (as I have found searching forums) the

    cl_ujk_logger=>log( i_object = l_log ) method.

    The DM package status always ends succeeded. I want to be able to change this to warning or error which prompts the user to look at the Formula log to find what errors occurred.

    Is there any way of doing this? I really need to make this work as this is the final issue I have had with this project task I was assigned. Everything else up to this package status issue is working fine.

    I am writing comprehensive success and error messages to the DM Formula Log, but if any error does occur I want the status of the DM package NOT to say 'Succeeded'. I want it to say Warning or Error or something.

    Thanks for your help / suggestions.

    Kind regards

    Mark Dean

    Add comment
    10|10000 characters needed characters exceeded

  • May 04, 2017 at 02:10 PM

    Hello,

    SAP Note 2391076 - "DM Package status show "success" when exception occurs in BADI execution" is correcting this behavior:

    Symptom:

    DM Package status show "success" when exception occurs in BADI execution in package.

    By applying note, the status should show as "Fail".

    Regards,

    Pierre

    Add comment
    10|10000 characters needed characters exceeded

    • The effect of this note was already discussed in the comments on the answer to this question. Unfortunately it will not stop script execution after failing the badi. But the status will be failed :)

  • May 18, 2017 at 07:42 AM

    Hi,

    abap code sample used to interrupt script execution

    IF l_error = abap_true.
    log2( |Processing aborted due to an error run the package/script| ).

    RAISE EXCEPTION TYPE cx_uj_custom_logic.

    EXIT.

    ENDIF.

    Add comment
    10|10000 characters needed characters exceeded

    • Just tested the code of badi provided in my previous message with BPC 10.1 integrated in BW 7.50 SP06 (more resent then SAPK-81010INCPMBPC).

      STOPSCRIPT is the filter value of the badi.

      *XDIM_MEMBERSET P_ACCOUNT= A_600000
      *XDIM_MEMBERSET TIME=2013.02
      *XDIM_MEMBERSET FUNCTIONAL_AREA=FA_NONE
      *XDIM_MEMBERSET COST_CENTER=CC_NONE
      *XDIM_MEMBERSET CATEGORY=ACT
      *XDIM_MEMBERSET COMPANY_CODE=CO_NONE
      *XDIM_MEMBERSET PROFIT_CENTER=PC_NONE
      *XDIM_MEMBERSET AUDIT_TRAIL=AT_BPC_INPUT
      *XDIM_MEMBERSET COORDER=IO_NONE
      *XDIM_MEMBERSET TRADING_PARTNER=TP_NONE
      
      *WHEN P_ACCOUNT
      *IS *
      *REC(EXPRESSION=%VALUE%)
      *ENDWHEN
      
      *START_BADI STOPSCRIPT
      QUERY=OFF
      WRITE=OFF 
      *END_BADI
      
      *XDIM_MEMBERSET P_ACCOUNT= A_600000
      *XDIM_MEMBERSET TIME=2013.02
      *XDIM_MEMBERSET FUNCTIONAL_AREA=FA_NONE
      *XDIM_MEMBERSET COST_CENTER=CC_NONE
      *XDIM_MEMBERSET CATEGORY=ACT
      *XDIM_MEMBERSET COMPANY_CODE=CO_NONE
      *XDIM_MEMBERSET PROFIT_CENTER=PC_NONE
      *XDIM_MEMBERSET AUDIT_TRAIL=AT_BPC_INPUT
      *XDIM_MEMBERSET COORDER=IO_NONE
      *XDIM_MEMBERSET TRADING_PARTNER=TP_NONE
      
      *WHEN P_ACCOUNT
      *IS *
      *REC(EXPRESSION=%VALUE%)
      *ENDWHEN

      Resulting log shows that script execution is not stopped!

      LOG BEGIN TIME:2017-05-18 10:55:27
      FILE:\ROOT\WEBFOLDERS\XXXXXXX\ADMINAPP\PLANNING\TEST.LGF
      USER:KALININV
      APPSET:XXXXXXX
      APPLICATION:PLANNING
      [INFO] GET_DIM_LIST(): I_APPL_ID="PLANNING", #dimensions=12 
      AUDIT_TRAIL,CATEGORY,COMPANY_CODE,COORDER,COST_CENTER,CURRENCY,FUNCTIONAL_AREA,MEASURES,PROFIT_CENTER,P_ACCOUNT,TIME,TRADING_PARTNER
      
      #dim_memberset=10 
      P_ACCOUNT:A_600000,1 in total.
      TIME:2013.02,1 in total.
      FUNCTIONAL_AREA:FA_NONE,1 in total.
      COST_CENTER:CC_NONE,1 in total.
      CATEGORY:ACT,1 in total.
      COMPANY_CODE:CO_NONE,1 in total.
      PROFIT_CENTER:PC_NONE,1 in total.
      AUDIT_TRAIL:AT_BPC_INPUT,1 in total.
      COORDER:IO_NONE,1 in total.
      TRADING_PARTNER:TP_NONE,1 in total.
      
      REC :%VALUE%
      
      CALCULATION BEGIN:
      QUERY PROCESSING DATA
      QUERY TIME : 0.00 ms. 0  RECORDS QUERIED OUT.
      QUERY REFERENCE DATA
      CALCULATION TIME IN TOTAL :0.00 ms.
      NO RECORDS GENERATED.
      CALCULATION END.
      
      ENDWHEN ACCUMULATION: 0  RECORDS ARE GENERATED.
      EXECUTION BADI:STOPSCRIPT
      QUERY: OFF
      WRITE: OFF
      EXCEPTION OCCURRED IN BADI.
      BADI EXECUTION TIME IN TOTAL :0.00 ms.
      [INFO] GET_DIM_LIST(): I_APPL_ID="PLANNING", #dimensions=12 
      AUDIT_TRAIL,CATEGORY,COMPANY_CODE,COORDER,COST_CENTER,CURRENCY,FUNCTIONAL_AREA,MEASURES,PROFIT_CENTER,P_ACCOUNT,TIME,TRADING_PARTNER
      
      #dim_memberset=10 
      P_ACCOUNT:A_600000,1 in total.
      TIME:2013.02,1 in total.
      FUNCTIONAL_AREA:FA_NONE,1 in total.
      COST_CENTER:CC_NONE,1 in total.
      CATEGORY:ACT,1 in total.
      COMPANY_CODE:CO_NONE,1 in total.
      PROFIT_CENTER:PC_NONE,1 in total.
      AUDIT_TRAIL:AT_BPC_INPUT,1 in total.
      COORDER:IO_NONE,1 in total.
      TRADING_PARTNER:TP_NONE,1 in total.
      
      REC :%VALUE%
      
      CALCULATION BEGIN:
      QUERY PROCESSING DATA
      QUERY TIME : 1.00 ms. 0  RECORDS QUERIED OUT.
      QUERY REFERENCE DATA
      CALCULATION TIME IN TOTAL :0.00 ms.
      NO RECORDS GENERATED.
      CALCULATION END.
      
      ENDWHEN ACCUMULATION: 0  RECORDS ARE GENERATED.
      
      SCRIPT RUNNING TIME IN TOTAL:1.00 s.
      LOG END TIME:2017-05-18 10:55:28

      You can see that the script code after badi call is executed!

  • Jun 14, 2017 at 08:36 AM

    SAP has released еру note 2487016 - New parameter is introduced to control BADI exception handling in logic script:

    New parameter "K2_BADI_EXCEPTION_HANDLING" is introduced to control BADI exception handling in logic script.

    Add comment
    10|10000 characters needed characters exceeded