Skip to end of metadata
Go to start of metadata

With this program you can copy display variants of table control by using an existing variant of a user as a master results of copying are written to a log file

Error rendering macro 'code': Invalid value specified for parameter 'com.atlassian.confluence.ext.code.render.InvalidValueException'
*&---------------------------------------------------------------------*
*& Report: COPY OF RSTCX_COPY_TCVARIANT2 >4.6B *
*& *
*&---------------------------------------------------------------------*
*& 5.0.3 (26/04/1999)
* - 2 additional features:
* 1. a certain display variant can be used to replace with
* a newer version for all users which used this variant
* 2. deleting of variants is possible
* - minor bug fix (write protokol)*& 5.0.2 (07/04/1999)
* - copy a variant from one client into another
* - no restriction anymore to 1 source variant
*&---------------------------------------------------------------------*
*& with this programm you can copy display variants of table control by
*& using an existing variant of a user as a master
*& - results of copying are written to a log file
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
* Program : CACS_COPY_TCVARIANT_ALV *
* Date : 05/10/2005 *
* Description: *
* 1. There is no change in the report logic. All the changes are *
* related to the output format. *
* 2. The output has been shown using the reuse function Module: *
* 'BAL_DSP_LOG_DISPLAY'. *
* 3. Search String: C5056146.
*&---------------------------------------------------------------------*
REPORT zcacs_copy_tcvariant_alv MESSAGE-ID db.

TABLES: tcview, t000.
DATA: uname LIKE sy-uname.
* all target users
DATA:BEGIN OF usertab OCCURS 0,
  bname LIKE usr01-bname,
END OF usertab.
* global itab which has to be copied to user
DATA: source_variant LIKE tcview OCCURS 0.
* contains all variants which have to be copied
DATA: version_tab LIKE tcview OCCURS 0.
DATA: answer,
      number_of_versions LIKE sy-index.
*.....Data Declaration
DATA: gv_log_handle TYPE balloghndl, "Log Handle
      gv_msgtype TYPE msgty VALUE 'I', "Msg Type
      gv_str(200) TYPE c, "String for App log Msgs
      gv_var1(80) TYPE c. "For moving text elements
*definition of selection screen
****************************************
*--source---
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE t1 NO INTERVALS.
SELECT-OPTIONS:
  program FOR tcview-tcprogram ,"no-extension,
  control FOR tcview-tccontrol ,"no-extension ,
  user FOR tcview-tcuser OBLIGATORY NO-EXTENSION
        DEFAULT sy-uname ,
  variant FOR tcview-tcversion. " no-extension.
SELECTION-SCREEN END OF BLOCK b1.
*--- target user --
SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE t2.
SELECT-OPTIONS users FOR uname MATCHCODE OBJECT user_addr.
SELECTION-SCREEN END OF BLOCK b2.
*--options--
SELECTION-SCREEN BEGIN OF BLOCK b3 WITH FRAME TITLE t31.
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS p_clnt AS CHECKBOX.
SELECTION-SCREEN COMMENT (24) t32 FOR FIELD p_clnt.
SELECTION-SCREEN COMMENT (12) t33 FOR FIELD clientfr .
PARAMETERS: clientfr LIKE sy-mandt DEFAULT sy-mandt.
SELECTION-SCREEN COMMENT (12) t34 FOR FIELD clientto.
PARAMETERS clientto LIKE sy-mandt.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN ULINE.
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS p_rplc AS CHECKBOX.
SELECTION-SCREEN COMMENT (65) t37 FOR FIELD p_rplc.
SELECTION-SCREEN END OF LINE.
* selection-screen begin of line.
* selection-screen position 3.
* parameters rb_act radiobutton group rbg.
* selection-screen comment (30) t38 for field rb_act.
* selection-screen end of line.
* selection-screen begin of line.
* selection-screen position 3.
* parameters rb_all radiobutton group rbg.
* selection-screen comment (30) t39 for field rb_all.
* selection-screen end of line.
SELECTION-SCREEN ULINE.
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS p_del AS CHECKBOX.
SELECTION-SCREEN COMMENT (50) t40 FOR FIELD p_del.
SELECTION-SCREEN END OF LINE.
PARAMETERS client LIKE sy-mandt DEFAULT sy-mandt.
SELECTION-SCREEN END OF BLOCK b3.
SELECTION-SCREEN BEGIN OF BLOCK bc WITH FRAME TITLE t4." no intervals.
SELECTION-SCREEN COMMENT 1(75) t5 .
SELECTION-SCREEN COMMENT /1(75) t5a .
SELECTION-SCREEN ULINE.
SELECTION-SCREEN COMMENT /1(75) t6 .
SELECTION-SCREEN COMMENT /1(75) t7 .
SELECTION-SCREEN COMMENT /1(79) t8 .
SELECTION-SCREEN COMMENT /1(79) t9 .
SELECTION-SCREEN ULINE.
SELECTION-SCREEN COMMENT /1(79) t10 .
SELECTION-SCREEN END OF BLOCK bc.
************************************
INITIALIZATION.
************************************
* this is only in sapserv version necessary (no text elements)
  MOVE 'Copy display variant(s) of table control(s)...'(001) TO t1.
  MOVE '...to user(s)'(002) TO t2.
  t4 = 'Notes'(050).
  t5 =
  'This program generates a user variant for a set of users'(005).
  t5a =
  'For documentation see OSS note no. 140111'(051).
  t6 =
  'The users (or range of users) are selected from table SR01'(052)
  .
  t7 =
  'Existing variants with the same key may be overwritten.'(007).
  t8 =
  'If a user default variant exists for a certain control, and a new'(008)
  .
  t9 =
  'default is created, the new variant is the default.'(009).
  t10 =
  'WARNING: be careful with copying between different clients!!!'(055).
  t31 = 'Options'(031).
  t32 = 'client copy of variants:'(032).
  t33 = 'from client'(033).
  t34 = 'into client'(034).
* t36 = 'delete variants'(036).
  t37 = 'replace a certain version for all users using it'(037).
* t38 = 'in all clients'(038).
* t39 = 'actual client only'(039).
  t40 = 'delete all variants specified by key above'(040).
  PERFORM appl_log_create_alv .
*************************************
AT SELECTION-SCREEN ON BLOCK b1.
************************************
  PERFORM select_source TABLES source_variant.
*************************************
AT SELECTION-SCREEN ON BLOCK b3.
*************************************
  IF p_clnt NE space AND ( p_rplc NE space OR p_del NE space ) OR
  p_rplc NE space AND ( p_clnt NE space OR p_del NE space ) OR
  p_del NE space AND ( p_rplc NE space OR p_clnt NE space ).
    MESSAGE e000
    WITH 'sorry, only 1 option can be chosen simultaneously'.
  ENDIF.
  IF p_clnt = 'X' AND ( clientfr IS INITIAL OR clientto IS INITIAL ) .
    MESSAGE e000
    WITH 'please uncheck checkbox or fill in approp. clients'.
  ELSEIF p_clnt = 'X'.
    SELECT SINGLE * FROM t000 WHERE mandt = clientfr.
    IF sy-subrc NE 0.
      MESSAGE e000 WITH 'client' clientfr
      'does not exist in this system'.
    ENDIF.
    SELECT SINGLE * FROM t000 WHERE mandt = clientto.
    IF sy-subrc NE 0.
      MESSAGE e000 WITH 'client' clientto
      'does not exist in this system'.
    ENDIF.
  ENDIF.
  IF p_del NE space AND client NE space.
    SELECT SINGLE * FROM t000 WHERE mandt = client.
    IF sy-subrc NE 0.
      MESSAGE e000 WITH 'client' clientto
      'does not exist in this system'.
    ENDIF.
  ENDIF.
*************************************
AT SELECTION-SCREEN.
*************************************
  IF p_rplc NE space.
* itab source_variant already filled at PAI block b1
    PERFORM build_version_tab .
    DESCRIBE TABLE version_tab LINES number_of_versions.
    IF number_of_versions > 1.
      MESSAGE e000 WITH 'please specify exactly 1 variant to exchange'.
    ENDIF.
  ENDIF.
*************************************
START-OF-SELECTION.
*************************************
*///////////////////
*//option: exchange variants for all users, which have a certain v
*///////////////////
  IF p_rplc NE space.
* already filled at PAI: source_variant[] , version_tab[]
    PERFORM get_all_users. "find users of the variant and fill user_tab
    PERFORM delete_old_versions.
    PERFORM copy_variants. "distribute new version
    IF NOT gv_log_handle IS INITIAL .
      PERFORM appl_log_display_fullscreen.
    ENDIF.
    STOP.
  ENDIF.
*///////////////////
*// option: delete variants
*///////////////////
  IF p_del NE space.
    PERFORM build_version_tab .
    PERFORM delete_versions.
    IF NOT gv_log_handle IS INITIAL .
      PERFORM appl_log_display_fullscreen.
    ENDIF.
    STOP.
  ENDIF.
*///////////////////
*// option: "normal" copying
*///////////////////
  IF users[] IS INITIAL.
    CALL FUNCTION 'POPUP_TO_CONFIRM_STEP'
      EXPORTING
        defaultoption  = 'N'
        textline1      = 'Do You want to create a variant for ALL users?'(054)
        titel          = 'Confirm Step'(023)
        cancel_display = space
      IMPORTING
        answer         = answer.
    IF answer = 'N'.
      STOP.
    ENDIF.
  ENDIF.
* get all users the users from table usr01 according to ranges tab
  PERFORM user_selection TABLES usertab.
  IF p_clnt = 'X'.
    PERFORM write_logfile
    USING 'Copying from client >&1< into client >&2<'(053)
    clientfr clientto space 1.
  ENDIF.
*
  PERFORM build_version_tab.
  PERFORM write_versions.
  PERFORM copy_variants .
  IF NOT gv_log_handle IS INITIAL .
    PERFORM appl_log_display_fullscreen.
  ENDIF.
************************************************************************
*------------------------- Forms -------------------------------- *
************************************************************************
*&---------------------------------------------------------------------*
*& Form user_selection
*&---------------------------------------------------------------------*
FORM user_selection TABLES p_usertab STRUCTURE usertab.
  IF p_clnt = space.
    SELECT bname FROM usr01 INTO TABLE p_usertab
    WHERE bname IN users.
    IF sy-subrc NE 0.
      FORMAT INTENSIFIED OFF COLOR COL_TOTAL.
* write: / 'no valid users selected'(004).
      CLEAR : gv_str.
      MOVE :text-004 TO gv_str.
      PERFORM msg_add USING gv_str gv_msgtype.
      IF NOT gv_log_handle IS INITIAL .
        PERFORM appl_log_display_fullscreen.
      ENDIF.
*****End of Coding By C5056146 on 05.10.2005***********************
      STOP. "no further processing
    ENDIF.
  ELSE.
    SELECT bname FROM usr01 CLIENT SPECIFIED INTO TABLE p_usertab
    WHERE mandt = clientfr
    AND bname IN users.
    IF sy-subrc NE 0.
      FORMAT INTENSIFIED OFF COLOR COL_TOTAL.
* write: / 'no valid users selected'(004).
      CLEAR : gv_str.
      MOVE :text-004 TO gv_str.
      PERFORM msg_add USING gv_str gv_msgtype.
      IF NOT gv_log_handle IS INITIAL .
        PERFORM appl_log_display_fullscreen.
      ENDIF.
      STOP. "no further processing
    ENDIF.
  ENDIF.
ENDFORM. " user_selection
*&---------------------------------------------------------------------*
*& Form select_source
*&---------------------------------------------------------------------*
FORM select_source TABLES p_variant LIKE source_variant.
  IF ( p_clnt = space AND p_del = space ) OR
  ( p_del NE space AND client = sy-mandt ).
    SELECT * FROM tcview INTO TABLE p_variant
    WHERE tcprogram IN program
    AND tcuser IN user
    AND tccontrol IN control
    AND tcversion IN variant.
    IF sy-subrc NE 0.
      MESSAGE e000 WITH 'no variant found according to selections'.
    ENDIF.
  ELSEIF p_clnt NE space AND p_del = space.
    SELECT * FROM tcview CLIENT SPECIFIED INTO TABLE p_variant
    WHERE mandant = clientfr
    AND tcprogram IN program
    AND tcuser IN user
    AND tccontrol IN control
    AND tcversion IN variant.
    IF sy-subrc NE 0.
      MESSAGE e000 WITH 'no variant found according to selections'.
    ENDIF.
  ELSE.
    IF client IS INITIAL.
      client = sy-mandt.
    ENDIF.
    SELECT * FROM tcview CLIENT SPECIFIED INTO TABLE p_variant
    WHERE mandant = client
    AND tcprogram IN program
    AND tcuser IN user
    AND tccontrol IN control
    AND tcversion IN variant.
    IF sy-subrc NE 0.
      MESSAGE e000 WITH 'no variant found according to selections'.
    ENDIF.
  ENDIF.
ENDFORM. " select_source
*&---------------------------------------------------------------------*
*& Form copy_variant
*&---------------------------------------------------------------------*
FORM copy_variants.
  DATA: source_copy LIKE tcview OCCURS 0.
  DATA: wa_copy LIKE tcview.
  DATA: wa_version LIKE tcview,
  l_flag_existing(1),
  l_def_variant LIKE tcview-tcversion.
* make a clone of source_tab with the new user as tcuser
* and value of deflt
  source_copy[] = source_variant[].
  LOOP AT usertab.
* modify source_copy first
    CLEAR wa_copy.
    LOOP AT source_copy INTO wa_copy.
      MOVE usertab-bname TO wa_copy-tcuser.
      MOVE 'B' TO wa_copy-tcusertype. "sicherheitshalber
      CLEAR wa_copy-tcsdefault. "sicherheitshalber
      IF p_clnt = 'X'.
        wa_copy-mandant = clientto.
      ENDIF.
      MODIFY source_copy FROM wa_copy
      TRANSPORTING mandant tcusertype tcuser tcudefault tcsdefault.
    ENDLOOP.
* check if a user has already a default variant for a control variant
* which is default
    LOOP AT version_tab INTO wa_version WHERE tcudefault NE space.
      PERFORM check_udefault_exists USING wa_version-tcprogram
      wa_version-tccontrol
      usertab-bname
      l_flag_existing
      l_def_variant.
      CHECK l_flag_existing = 'X'.
* rule: the existing variant is no longer user default
      PERFORM modify_udefault USING wa_version-tcprogram
      wa_version-tccontrol
      usertab-bname
      l_def_variant.
    ENDLOOP.
* delete existing entrances in tcview with the same key as source vari
    DELETE tcview CLIENT SPECIFIED FROM TABLE source_copy.
    IF sy-subrc = 0.
      PERFORM write_logfile
      USING
      'deleted already existing variants of user >&2< with same key'(010)
      wa_version-tcversion
      usertab-bname
      space
      6.
    ENDIF.
* write new entrances in tcview
    INSERT tcview CLIENT SPECIFIED FROM TABLE source_copy.
    IF sy-subrc = 0.
      LOOP AT version_tab INTO wa_version.
        IF wa_version-tcudefault = 'UD'.
          PERFORM write_logfile
          USING
          'created variant >&1< for user >&2< (as user default)'(011)
          wa_version-tcversion
          usertab-bname
          space
          2.
        ELSE.
          PERFORM write_logfile
          USING 'created variant >&1< for user >&2<'(012)
          wa_version-tcversion
          usertab-bname
          space
          2.
        ENDIF.
      ENDLOOP. "at version_tab
    ENDIF.
  ENDLOOP. "at usertab
ENDFORM. " copy_variant
*&---------------------------------------------------------------------*
*& Form check_udefault_exists
*&---------------------------------------------------------------------*
* -->P_USERTAB_BNAME text
*----------------------------------------------------------------------*
FORM check_udefault_exists USING p_prog
p_control
p_user
p_flag_existing
p_def_variant.
  DATA wa_tcview LIKE tcview.
  CLEAR: p_flag_existing,
  p_def_variant.
  IF p_clnt = space.
    SELECT * FROM tcview INTO wa_tcview
    WHERE tcprogram = p_prog
    AND tccontrol = p_control
    AND tcuser = p_user
    AND tcusertype = 'B'
    AND tcudefault = 'UD'.
      IF sy-subrc = 0.
        p_flag_existing = 'X'.
        p_def_variant = wa_tcview-tcversion.
        EXIT.
      ENDIF.
    ENDSELECT.
  ELSE.
    SELECT * FROM tcview CLIENT SPECIFIED INTO wa_tcview
    WHERE mandant = clientto
    AND tcprogram = p_prog
    AND tccontrol = p_control
    AND tcuser = p_user
    AND tcusertype = 'B'
    AND tcudefault = 'UD'.
      IF sy-subrc = 0.
        p_flag_existing = 'X'.
        p_def_variant = wa_tcview-tcversion.
        EXIT.
      ENDIF.
    ENDSELECT.
  ENDIF.
ENDFORM. " check_udefault_exists
*&---------------------------------------------------------------------*
*& Form modify_udefault
*&---------------------------------------------------------------------*
FORM modify_udefault USING p_prog
p_control
p_user
p_def_variant.
  DATA: wa_tcview LIKE tcview.
  DATA: l_flag_log.
  IF p_clnt = 'X'.
    SELECT * FROM tcview CLIENT SPECIFIED
    INTO wa_tcview WHERE mandant = clientto
    AND tcprogram = p_prog
    AND tcusertype ='B'
    AND tcuser = p_user
    AND tccontrol = p_control
    AND tcversion = p_def_variant
    AND tcudefault = 'UD'.
      CLEAR wa_tcview-tcudefault.
      UPDATE tcview CLIENT SPECIFIED FROM wa_tcview.
      IF sy-subrc = 0 AND l_flag_log = space.
        l_flag_log = 'X'.
        PERFORM write_logfile USING
        'modified variant >&1< of user >&2<'(013)
        p_def_variant
        p_user
        space
        6.
      ENDIF.
    ENDSELECT.
  ELSE.
    SELECT * FROM tcview INTO wa_tcview WHERE tcprogram = p_prog
    AND tcusertype ='B'
    AND tcuser = p_user
    AND tccontrol = p_control
    AND tcversion = p_def_variant
    AND tcudefault = 'UD'.
      CLEAR wa_tcview-tcudefault.
      UPDATE tcview FROM wa_tcview.
      IF sy-subrc = 0 AND l_flag_log = space.
        l_flag_log = 'X'.
        PERFORM write_logfile USING
        'modified variant >&1< of user >&2<'(013)
        p_def_variant
        p_user
        space
        6.
      ENDIF.
    ENDSELECT.
  ENDIF.
ENDFORM. " modify_udefault
*&---------------------------------------------------------------------*
*& Form write_logfile
*&---------------------------------------------------------------------*
* replace &1, &2; &3 in string and write string in color p_col
*----------------------------------------------------------------------*
FORM write_logfile USING p_string
p_var1
p_var2
p_var3
p_col. "color of line
  DATA result(254).
  result = p_string.
* sonderlogik falls mehrere kopiert werden sollen (VARIANT ist leer)
  IF p_var1 IS INITIAL.
    REPLACE '>&1<' WITH space INTO result.
  ELSE.
    REPLACE '&1' WITH p_var1 INTO result.
  ENDIF.
  IF p_var2 IS INITIAL.
    REPLACE '&2' WITH '***' INTO result.
  ELSE.
    REPLACE '&2' WITH p_var2 INTO result.
  ENDIF.
  IF p_var3 IS INITIAL.
    REPLACE '&2' WITH '***' INTO result.
  ELSE.
    REPLACE '&3' WITH p_var3 INTO result.
  ENDIF.
  FORMAT COLOR = p_col INTENSIFIED ON.
  CONDENSE result.
* WRITE /: result .
  CLEAR : gv_str.
  MOVE :result TO gv_str.
  PERFORM msg_add USING gv_str gv_msgtype.
*****End of Coding By C5056146 on 05.10.2005***********************
  FORMAT RESET.
ENDFORM. " write_logfile
*&---------------------------------------------------------------------*
*& Form build_version_tab
*&---------------------------------------------------------------------*
* -> global itab version_tab is built
* (contains 1 entrance for each table control variant which has to be
* copied)
*&---------------------------------------------------------------------*
FORM build_version_tab.
  version_tab[] = source_variant[].
  SORT version_tab[] BY tcprogram tccontrol tckontext tcversion.
  DELETE ADJACENT DUPLICATES FROM version_tab
  COMPARING mandant tcprogram tcusertype tcuser
  tccontrol tckontext tcversion.
ENDFORM. "build_version_tab
*&---------------------------------------------------------------------*
*& Form write_versions
*&---------------------------------------------------------------------*
FORM write_versions .
  DATA: l_lines LIKE sy-tabix.
  DATA: wa_version LIKE tcview.
  DESCRIBE TABLE version_tab LINES l_lines.
  IF l_lines > 1.
    LOOP AT version_tab INTO wa_version.
      PERFORM write_logfile USING
      'source variants to copy: variant >&1<, program >&2<, tcontrol >&3<'
      wa_version-tcversion
      wa_version-tcprogram
      wa_version-tccontrol
      2.
    ENDLOOP.
  ENDIF.
ENDFORM. "
*&---------------------------------------------------------------------*
*& Form get_all_users
*&---------------------------------------------------------------------*
* find all different users in tcview using a certain variant
*----------------------------------------------------------------------*
FORM get_all_users.
  DATA l_user LIKE tcview-tcuser.
  DATA wa_version LIKE tcview.
  CLEAR: usertab, usertab[]. "sicherheitshalber
  READ TABLE version_tab INTO wa_version INDEX 1.
* if rb_act = 'X'. "only actual client
  SELECT tcuser FROM tcview INTO TABLE usertab
  WHERE tcprogram = wa_version-tcprogram
  AND tcversion = wa_version-tcversion
  AND tccontrol = wa_version-tccontrol
  AND tckontext = wa_version-tckontext
  GROUP BY tcuser.
* else. "all clients
*
* select tcuser from tcview client specified
* into table usertab
* where tcprogram = wa_version-tcprogram
* and tcversion = wa_version-tcversion
* and tccontrol = wa_version-tccontrol
* and tckontext = wa_version-tckontext
* group by tcuser.
*
* endif.
* remove "master" user from usertab.
  DELETE usertab WHERE bname = wa_version-tcuser.
ENDFORM. " get_all_users
*&---------------------------------------------------------------------*
*& Form delete_old_versions
*&---------------------------------------------------------------------*
FORM delete_old_versions.
  DATA wa_version LIKE tcview.
  READ TABLE version_tab INTO wa_version INDEX 1.
  LOOP AT usertab. "(FOR ALL ENTRIES... not possible because of
    " different fieldnames)
* if rb_act = 'X'.
    DELETE FROM tcview WHERE tcprogram = wa_version-tcprogram
    AND tcuser = usertab-bname
    AND tccontrol = wa_version-tccontrol
    AND tckontext = wa_version-tckontext
    AND tcversion = wa_version-tcversion.
    IF sy-subrc = 0.
      PERFORM write_logfile USING
      'deleted existing variant >&1< of user >&2< '
      wa_version-tcversion
      usertab-bname
      space
      2.
    ENDIF.
* else.
* delete from tcview client specified
* where tcprogram = wa_version-tcprogram
* and tcuser = usertab-bname
* and tccontrol = wa_version-tccontrol
* and tcKontext = wa_version-tckontext
* and tcversion = wa_version-tcversion.
* endif.
  ENDLOOP.
ENDFORM. " delete_old_versions
*&---------------------------------------------------------------------*
*& Form delete_versions
*&---------------------------------------------------------------------*
FORM delete_versions.
  DATA wa_version LIKE tcview.
* always ensured: source_variant-mandant = client
  DELETE tcview CLIENT SPECIFIED FROM TABLE source_variant.
  LOOP AT version_tab INTO wa_version.
    PERFORM write_logfile USING
    'deleted variant >&1< of program >&2< of user >&3<'
    wa_version-tcversion
    wa_version-tcprogram
    wa_version-tcuser
    6.
  ENDLOOP.
ENDFORM. " delete_versions
************* Start of ALV coding by c5056146 on 05/10/2005 ******
*&-------------------------------------------------------------------*
*& Form appl_log_create_alv
*&-------------------------------------------------------------------*
* This Subroutine Creates an internal log file .
*--------------------------------------------------------------------*
FORM appl_log_create_alv .
  DATA : ls_log TYPE bal_s_log. "log variable
* Create an internal log file
  CALL FUNCTION 'BAL_LOG_CREATE'
    EXPORTING
      i_s_log      = ls_log
    IMPORTING
      e_log_handle = gv_log_handle
    EXCEPTIONS
      OTHERS       = 1.
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.
ENDFORM. " appl_log_create_alv
*----------------------------------------------------------------------*
* Form msg_add
*----------------------------------------------------------------------*
* Add the message in application log
*----------------------------------------------------------------------*
* -->IV_TEXT IV_MSGTYP text
*----------------------------------------------------------------------*
FORM msg_add USING value(iv_text) TYPE any value(iv_msgtyp) TYPE c.
* Function for adding text to the application log
  CALL FUNCTION 'BAL_LOG_MSG_ADD_FREE_TEXT'
    EXPORTING
      i_log_handle     = gv_log_handle
      i_msgty          = iv_msgtyp
      i_text           = iv_text
    EXCEPTIONS
      log_not_found    = 1
      msg_inconsistent = 2
      log_is_full      = 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.
  ENDIF.
ENDFORM. " msg_add
*&---------------------------------------------------------------------*
*& Form appl_log_display_fullscreen
*&---------------------------------------------------------------------*
* Display Application Logs in full screen
*----------------------------------------------------------------------*
FORM appl_log_display_fullscreen.
  DATA : ls_display_profile TYPE bal_s_prof, "For display profile
  lv_title TYPE sy-title.
  CONSTANTS:
  lc_use_grid TYPE c VALUE 'X'. "use_grid parameter in profile
  lv_title = sy-title.
* To suppress the tree structure on the top of the output
  CALL FUNCTION 'BAL_DSP_PROFILE_NO_TREE_GET'
    IMPORTING
      e_s_display_profile = ls_display_profile
    EXCEPTIONS
      OTHERS              = 1.
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.
  MOVE : lv_title TO ls_display_profile-title.
* To show application logs in grid
  MOVE lc_use_grid TO ls_display_profile-use_grid.
  CALL FUNCTION 'BAL_DSP_LOG_DISPLAY'
    EXPORTING
      i_s_display_profile  = ls_display_profile
    EXCEPTIONS
      profile_inconsistent = 1
      internal_error       = 2
      no_data_available    = 3
      no_authority         = 4
      OTHERS               = 5.
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.
ENDFORM. " appl_log_display_fullscreen