You are on page 1of 4

*&---------------------------------------------------------------------*

*& Report ERP_ORG_UNIT_EXTRACT


*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT
INCLUDE
INCLUDE
INCLUDE

cod_erp_org_unit_extract.
cod_erp_org_unit_extract_d01."Include for global data declaration.
cod_erp_org_unit_extract_s01."Include for selection screen
cod_erp_org_unit_extract_f01."Include for form subroutine declaration

START-OF-SELECTION.
* Fetching org unit hierarchy details for preparing idoc structure
PERFORM fill_idoc_details CHANGING gt_return.
END-OF-SELECTION.
* Create application log
PERFORM add_appl_log USING gt_return
CHANGING gv_loghndl.
IF gs_org_idoc IS NOT INITIAL AND p_test IS INITIAL AND gv_stop IS INITIAL.
*
Creating IDOC
PERFORM call_idoc CHANGING gs_org_idoc gt_return.
MESSAGE s243(cod_byd_erp_int).
ENDIF.
*
Add application log
PERFORM add_idoc_log USING gt_return
CHANGING gv_loghndl.
*
Display log
PERFORM display_log USING gv_loghndl.
IF gs_org_idoc IS INITIAL.
MESSAGE s247(cod_byd_erp_int).
ENDIF.

*&---------------------------------------------------------------------*
*&
Form ADD_APPL_LOG
*&---------------------------------------------------------------------*
*
This subroutine is for creating application log data

*----------------------------------------------------------------------*
*
-->pi_t_return Error table
*
<--pc_v_loghandl log handle object
*----------------------------------------------------------------------*
FORM add_appl_log USING
pi_t_return LIKE gt_return
CHANGING pc_v_loghndl TYPE balloghndl.
DATA: ls_msg
TYPE bal_s_msg,
lv_index
TYPE c,
lv_index1
TYPE c,
ls_loghdr
TYPE bal_s_log,
lv_loghndl TYPE balloghndl.
FIELD-SYMBOLS: <ls_error>
TYPE gty_return,
<ls_return>
TYPE bapiretc.
ls_loghdr-aluser
= sy-uname.
ls_loghdr-aldate
= sy-datlo.
ls_loghdr-altime
= sy-timlo.
ls_loghdr-alprog
= sy-repid.
ls_loghdr-object
= 'CODERP'.
ls_loghdr-subobject = 'ORGUNITS'.
* Creating log object
CALL FUNCTION 'BAL_LOG_CREATE'
EXPORTING
i_s_log
= ls_loghdr
IMPORTING
e_log_handle
= lv_loghndl
EXCEPTIONS
log_header_inconsistent = 1
error_message
= 2
OTHERS
= 3.
IF sy-subrc IS INITIAL.
CLEAR lv_index.
LOOP AT pi_t_return ASSIGNING <ls_error> WHERE unit = 'C'.
CLEAR: lv_index1.
LOOP AT <ls_error>-return[] ASSIGNING <ls_return> WHERE type = gv_infom.
IF lv_index EQ 0.
ls_msg-msgty = gv_infom.
ls_msg-msgid = gv_msgclas.
ls_msg-msgno = '252'.
ls_msg-detlevel = 1.
ls_msg-probclass = 3.
PERFORM add_message USING lv_loghndl ls_msg.
ENDLOOP.
ENDIF.
pc_v_loghndl = lv_loghndl.

*&---------------------------------------------------------------------*
*&
Form ADD_MESSAGE
*&---------------------------------------------------------------------*
*
This subroutine is for adding messae to log
*----------------------------------------------------------------------*
*
-->pi_v_loghndl loghandle object
*
-->pi_s_msg
error structure
*----------------------------------------------------------------------*
FORM add_message USING pi_v_loghndl TYPE balloghndl
pi_s_msg
TYPE bal_s_msg.
CALL FUNCTION 'BAL_LOG_MSG_ADD'
EXPORTING
i_log_handle = pi_v_loghndl
i_s_msg
= pi_s_msg
EXCEPTIONS
OTHERS
= 0.
ENDFORM.
" ADD_MESSAGE

*&---------------------------------------------------------------------*
*&
Form DISPLAY_LOG
*&---------------------------------------------------------------------*
*
This subroutine is for displaying log
*----------------------------------------------------------------------*
*
--> pi_v_loghandle Log handle object
*----------------------------------------------------------------------*
FORM display_log USING pi_v_loghandl TYPE balloghndl.
DATA:ls_display_profile TYPE bal_s_prof,
lt_log_handle
TYPE bal_t_logh.
IF sy-batch IS INITIAL.
*
calling the fm for getting the profile
CALL FUNCTION 'BAL_DSP_PROFILE_STANDARD_GET'
IMPORTING
e_s_display_profile = ls_display_profile.
ls_display_profile-use_grid
= 'X'.
ls_display_profile-show_all
= 'X'.
ls_display_profile-head_size = 100.
ls_display_profile-bydetlevel = 'X'.
ls_display_profile-exp_level = '2'.
ls_display_profile-langu
= sy-langu.
ls_display_profile-not_empty = 'X'.
ls_display_profile-disvariant-handle = 'LOG'.
ls_display_profile-disvariant-report = sy-repid.
INSERT pi_v_loghandl INTO TABLE lt_log_handle.
CALL FUNCTION 'BAL_DSP_LOG_DISPLAY'
EXPORTING
i_s_display_profile = ls_display_profile
i_t_log_handle
= lt_log_handle

EXCEPTIONS
profile_inconsistent = 1
internal_error
= 2
no_data_available
= 3
no_authority
= 4
OTHERS
= 5.
IF sy-subrc IS NOT INITIAL.
MESSAGE s242(cod_byd_erp_int).
ENDIF.
ENDIF.
ENDFORM.
" DISPLAY_LOG

You might also like