Skip to Content

In our projects we may come across with complex designs having many models and many calculations which are not always easy for end users to manage. Most of the time in design phase I try to realize an approach for a single package calling all logic files in relevant models. In BPC MS version there was this option for calling logic file from a different application but in NW version as far as I know this is not standard.

Starting point of my practice was examining UJKT transactions’ coding. I thought that if I can run script logic via UJKT with giving Appset, Application, and Currentview information then why can not I use this for executing logic files in a cascading way?

A very basic function module with importing parameters can be used to achieve this:

————————————————————————
FUNCTION ZBPC_UJK_SCRIPT_LOGIC_EXECUTE.
*”———————————————————————-
*”*”Local Interface:
*”  IMPORTING
*”     REFERENCE(LV_DOCNAME) TYPE  UJ_DOCNAME
*”     REFERENCE(I_APPSET_ID) TYPE  UJ_APPSET_ID
*”     REFERENCE(I_APPL_ID) TYPE  UJ_APPL_ID
*”     REFERENCE(LT_CV) TYPE  UJK_T_CV
*”     REFERENCE(LV_USER) TYPE  UJ_USER_ID
*”  EXPORTING
*”     REFERENCE(ET_LOG) TYPE  UJK_T_SINGLE_STRING
*”———————————————————————-
  DATA: lo_dispatch TYPE REF TO cl_ujk_dispatch .
  DATA: LT_LGX TYPE  ujk_t_script_logic_scripttable .
  DATA: LV_MODE TYPE uj_run_mode .

  CREATE OBJECT lo_dispatch.

  CALL METHOD lo_dispatch->get_file
    EXPORTING
      i_appset      = I_APPSET_ID
      i_application = I_APPL_ID
      i_user        = LV_USER
      i_filename    = LV_DOCNAME
    IMPORTING
      et_lgx        = LT_LGX.

  LV_MODE = ‘EXECUTE’ .

  CALL FUNCTION ‘UJK_SCRIPT_LOGIC_EXECUTE’
    EXPORTING
      I_APPSET      = I_APPSET_ID
      I_APPLICATION = I_APPL_ID
      I_USER        = LV_USER
      I_LOGIC       = LT_LGX
      IT_CV         = LT_CV
      I_FILE_TYPE   = ‘LGF’
      I_MODULE      = uj00_c_mod_name_dm
      I_LGF         = LV_DOCNAME
      I_MODE        = LV_MODE.

  et_log = cl_ujk_logger=>get_log( ).
  CLEAR lt_lgx .

ENDFUNCTION.
————————————————————————

In UJ_CUSTOM_LOGIC you can call your logic files with the order of your process. Please spend some time on current view and filtering needs of projects’ calculations.  

————————————————————————
method IF_UJ_CUSTOM_LOGIC~EXECUTE.

  DATA: lv_docname TYPE uj_docname ,
        lv_mode TYPE uj_run_mode ,
        lv_user type UJ_USER_ID .

  DATA: ET_LOG TYPE UJK_T_SINGLE_STRING .

  DATA: wa_cv TYPE UJK_S_CV ,
        lt_cv TYPE UJK_T_CV ,
        wa_member TYPE UJ_DIM_MEMBER ,
        category TYPE UJ_DIM_MEMBER .

  DATA: lo_old_context type ref to if_uj_context ,
        lo_user type ref to CL_UJE_USER .

  DATA: lv_appset_id TYPE UJ_APPSET_ID .
  DATA: lv_appl_id TYPE UJ_APPL_ID .

  TYPES: BEGIN OF s_logic ,
         lv_docname TYPE uj_docname ,
         lv_appl_id TYPE UJ_APPL_ID ,
         END OF s_logic .
  DATA: ls_logic TYPE s_logic ,
        lt_logic TYPE TABLE OF s_logic .

  lt_CV[] = it_cv[] .

  lo_old_context = cl_uj_context=>get_cur_context( ).

  CALL METHOD lo_old_context->GET_USER_OBJ
    RECEIVING
      RO_USER = lo_user.

  lv_user = lo_user->D_OBJ_ID.
  lv_appset_id = I_APPSET_ID .

  ls_logic-lv_appl_id = ‘SALES’ .
  ls_logic-lv_docname = ’01_SALES_PLANNING.LGF’ .
  APPEND ls_logic TO lt_logic .
  ls_logic-lv_appl_id = ‘BOM’ .
  ls_logic-lv_docname = ’01_YAKITORTALAMA.LGF’  .
  APPEND ls_logic TO lt_logic .
  ls_logic-lv_appl_id = ‘PRODUCTION’ .
  ls_logic-lv_docname = ’01_PROD_TO_BALANCE.LGF’  .
  APPEND ls_logic TO lt_logic .
  ls_logic-lv_appl_id = ‘BALANCE’ .
  ls_logic-lv_docname = ’01_STOKDENGE.LGF’  .
  APPEND ls_logic TO lt_logic .
  ls_logic-lv_appl_id = ‘PROCUREMENT’ .
  ls_logic-lv_docname = ’01_SATINALMA.LGF’  .
  APPEND ls_logic TO lt_logic .
  ls_logic-lv_appl_id = ‘EXPENSE’ .
  ls_logic-lv_docname = ’00_AMORTISMAN_IMPORT.LGF’  .
  APPEND ls_logic TO lt_logic .
  ls_logic-lv_appl_id = ‘COST’ .
  ls_logic-lv_docname = ’01_COSTMIKTAR.LGF’  .
  APPEND ls_logic TO lt_logic .
  ls_logic-lv_appl_id = ‘FINANCIAL’ .
  ls_logic-lv_docname = ’01_FINANSAL_TAYINLER.LGF’ .
  APPEND ls_logic TO lt_logic .

  LOOP AT lt_logic INTO ls_logic .

    CONCATENATE ‘\ROOT\WEBFOLDERS\’ lv_appset_id ‘\ADMINAPP\’ ls_logic-lv_appl_id ‘\’ ls_logic-lv_docname INTO lv_docname .

    CALL FUNCTION ‘ZBPC_UJK_SCRIPT_LOGIC_EXECUTE’
      EXPORTING
        LV_DOCNAME  = lv_docname
        I_APPSET_ID = lv_appset_id
        I_APPL_ID   = ls_logic-lv_appl_id
        LT_CV       = lt_cv
        LV_USER     = lv_user
      IMPORTING
        ET_LOG      = ET_LOG.

  ENDLOOP .

endmethod.

I hope you find it useful in your projects,

Best Regards,

Ergin Ozturk

To report this post you need to login first.

2 Comments

You must be Logged on to comment or reply to a post.

Leave a Reply