The following article shows a procedure of implementing user-exit in standard SAP HR program HSKCREC0 (Transaction PC00_M31_REKAPI - Recapitulation of payment types).
Program HSKCREC0 is used for Slovakia, but the procedure itself may be carried out for other HR reports as well.
Firstly, let me show you the exact spot, where the implemented user-exit will be called.
The form AT_GET_PERNR is used to retrieve data for the relevant personnel number from cluster. From this place a form FILL_FROM_CLUSTER is called. This is the place, where data from cluster are read. Form FILL_RESTAB1 is a place, where the retrieved payment types are processed. From FILL_RESTAB1 a form UEXIT_AND_ADD is called.
*---------------------------------------------------------------------*
* Form Uexit_And_Add
*---------------------------------------------------------------------*
FORM UEXIT_AND_ADD.
PERFORM (FRM_NAME_UE) IN PROGRAM (PRG_NAME_UE) IF FOUND. " user-exit
...
ENDFORM. " Uexit_And_Add
As it is show, on the example above. A certain form is called from a subroutine pool.
This settings is maintained in dB T7SK4F (Reports - user-exits). There is maintenance available, so feel free to call transaction SM30.
This is the example implementation of the called form SET_PSPNR_ZL customized in table T7SK4F. The example shows, how to fill PAR18 of the enhanced report with a value relevant for certain payment types.
*&---------------------------------------------------------------------*
*& Modulpool Z_HSKCREC0_UE
*&
*&
*&---------------------------------------------------------------------*
*&
*& User-Exits for report HSKCREC0.
*&
*&---------------------------------------------------------------------*
PROGRAM zmp_hr_sm_hskcrec0_ue.
* -> Declaration of the locally used tables
- copy the COMMON-PART from the beginning of the enhanced report
* in order to gain access to infotype data
DATA: BEGIN OF COMMON PART it.
INFOTYPES: 0000, 0001, 0002.
DATA: END OF COMMON PART it.
* -> Include COMMON PART, with the desired structure
INCLUDE hsklxxl4.
* -> Form used to fill field POSNR for payment types:
* -> Payment types /333 & /354
FORM set_pspnr_zl.
**********************************************************************
DATA:
lv_pernr TYPE p0001-pernr, "personnel number
ls_p0015 TYPE p0015, "infotype 15 - add.payment
ls_assob TYPE assob_hr. "relationship to assignm.objects
CONSTANTS:
lc_333 TYPE char04 VALUE '/333', "payment type /333
lc_354 TYPE char04 VALUE '/354', "payment type /354
lc_m96v TYPE subty VALUE 'M96V', "payment type M96V
lc_it15 TYPE infty VALUE '0015'. "Infotype 15
**********************************************************************
* -> Set POSNR field for payment types /333 a /354
IF ( comm-par15+0(4) = lc_333 ) OR
( comm-par15+0(4) = lc_354 ).
CLEAR: lv_pernr.
lv_pernr = p0001-pernr.
* -> Read the last relevant entry from infotype 0015
CLEAR: ls_p0015.
SELECT *
INTO CORRESPONDING FIELDS OF ls_p0015
UP TO 1 ROWS
FROM pa0015
WHERE pernr = lv_pernr
AND subty = lc_m96v
ORDER BY endda DESCENDING.
ENDSELECT.
CHECK sy-subrc = 0.
* -> Get the assignment objects based on infotype 0015
CLEAR: ls_assob.
SELECT SINGLE *
INTO CORRESPONDING FIELDS OF ls_assob
FROM assob_hr
WHERE pernr = ls_p0015-pernr
AND infty = lc_it15
AND subty = ls_p0015-subty
AND objps = ls_p0015-objps
AND sprps = ls_p0015-sprps
AND endda = ls_p0015-endda
AND begda = ls_p0015-begda
AND seqnr = ls_p0015-seqnr.
CHECK sy-subrc = 0.
* -> Conversion of PONSR to external format
CALL FUNCTION 'PSPNUM_INTERN_TO_EXTERN_CONV'
EXPORTING
int_num = ls_assob-posnr
IMPORTING
ext_num = comm-par18
EXCEPTIONS
not_found = 1
OTHERS = 2.
IF sy-subrc <> 0.
comm-par18 = ls_assob-posnr. "set POSNR field
ENDIF.
ENDIF.
ENDFORM. "set_pspnr_zl
FaNoReS - BloG
Blog containing a useful info (tips / tricks) from SAP world.
streda 10. októbra 2012
utorok 9. októbra 2012
How to read personnel number COST (account) assignment data
The following article shows a way, how to read personnel number COST (account) assignment data.
First the most relevant and valid entry must be read from the infotype 0015, with the focus on a proper payment type (This is crucially essential!)!
Afterwards a selection from a view ASSOB_HR can be made by using the obtained entry from infotyp 0015.
- Call transaction PA20 (Display HR Master data) and enter a relevant personnel number with the direct selection of infotype 0015 - Additional Payments.
- Hit DISPLAY button (F7) . And click on the COST ASSIGNMENT button .
- The list of relevant ACCOUNT ASSIGNMENT data.
First the most relevant and valid entry must be read from the infotype 0015, with the focus on a proper payment type (This is crucially essential!)!
Afterwards a selection from a view ASSOB_HR can be made by using the obtained entry from infotyp 0015.
Menovky:
account assignment,
ASSOB_HR,
cost assignment,
infotype 0015,
SAP HR
štvrtok 4. októbra 2012
Review transport request import status
Following example shows a ALV report displaying transport requests with the focus on the import status of the relevant transport request. The aim was to find out, whether the transport request was imported into the desired system (production). User has the option to double click the line from ALV in order to display relevant transport request + transport log.
*&---------------------------------------------------------------------*
*& Report ZSM_BC_TRIMPORT_VIEW_LIST
*&
*& Stevo Misik
*&
*&---------------------------------------------------------------------*
*&
*& Report is used to list relevant transport requests, with the focus
*& on their import status to the production system.
*&
*& Following objects were used in the report:
*& -> FM: TR_READ_GLOBAL_INFO_OF_REQUEST - reads import data of tran.
*& request.
*& -> FM: TR_DISPLAY_REQUEST - displays tran.request on a double click.
*& -> dB: E070 a E07T - transport request head data + text.
*&
*&---------------------------------------------------------------------*
REPORT zsm_bc_trimport_view_list.
*--- GLOBAL DECLARATIONS --------------------------------------------*
TYPE-POOLS:
ctslg, "Type of the function group TR_LOG_OVERVIEW
slis. "Global types for generic ALV list reports
TABLES:
e070. "Transport system: Transport request/task data
TYPES:
BEGIN OF ts_tr_head_data,
trkorr TYPE e070-trkorr, "tr.request
trfunction TYPE e070-trfunction, "tr.req.type
trstatus TYPE e070-trstatus, "tr.req.status
tarsystem TYPE e070-tarsystem, "target system
korrdev TYPE e070-korrdev, "tr.req.category
as4user TYPE e070-as4user, "tr.req.owner
as4date TYPE e070-as4date, "date
as4time TYPE e070-as4time, "time
END OF ts_tr_head_data,
tt_tr_head_data TYPE STANDARD TABLE OF ts_tr_head_data,
BEGIN OF ts_tr_head_text,
trkorr TYPE e07t-trkorr, "tr.request
as4text TYPE e07t-as4text, "tr.request text
END OF ts_tr_head_text,
tt_tr_head_text TYPE STANDARD TABLE OF ts_tr_head_text.
DATA:
BEGIN OF gt_tr_data OCCURS 100,
light LIKE alv_s_layo-val_data, "light
trkorr LIKE e070-trkorr, "tr.request
as4text LIKE e07t-as4text, "tr.request text
trfunction LIKE e070-trfunction, "tr.req.type
trstatus LIKE e070-trstatus, "tr.req.status
tarsystem LIKE e070-tarsystem, "target system
korrdev LIKE e070-korrdev, "tr.req.category
as4user LIKE e070-as4user, "owner
as4date LIKE e070-as4date, "date
as4time LIKE e070-as4time, "time
stepid LIKE tstrfcofil-function, "import flag (I)
trdate LIKE tstrfcofil-trdate, "import date
trtime LIKE tstrfcofil-trtime, "import time
trrc LIKE tstrfcofil-retcode, "import return code (0/8)
END OF gt_tr_data.
DATA:
gv_subrc TYPE sy-subrc. "return code for retrieving data
*--- SELECTION SCREEN -----------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE ct1.
SELECT-OPTIONS:
so_trreq FOR e070-trkorr, "request(s)
so_trfun FOR e070-trfunction, "request type
so_trsts FOR e070-trstatus, "request status
so_trtgt FOR e070-tarsystem, "target system
so_trusr FOR e070-as4user, "owner
so_trdat FOR e070-as4date. "date of a last change
PARAMETERS:
pa_sysnm TYPE tmssysnam DEFAULT 'XXX' OBLIGATORY. "prod.system
SELECTION-SCREEN END OF BLOCK b1.
*--- INITIALIZATION -------------------------------------------------*
INITIALIZATION.
ct1 = 'Selection screen:'(ct1).
*--- START OF SELECTION ---------------------------------------------*
START-OF-SELECTION.
* -> DATA SELECTION - BASED ON A SELECTION SCREEN
PERFORM get_tr_data
CHANGING gv_subrc.
*--- END OF SELECTION -----------------------------------------------*
END-OF-SELECTION.
* -> DATA DISPLAY
IF gv_subrc = 0.
PERFORM show_data.
ELSE.
MESSAGE s398(00) WITH 'Requests not found!'(e01).
ENDIF.
*--- FORMS ----------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Form GET_TR_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* <--P_GV_SUBRC text
*----------------------------------------------------------------------*
FORM get_tr_data
CHANGING cv_subrc TYPE sy-subrc.
**********************************************************************
DATA:
lt_tr_head_data TYPE tt_tr_head_data, "tr.req.head data
lt_tr_head_text TYPE tt_tr_head_text. "tr.req.texts
CONSTANTS:
lc_error TYPE sy-subrc VALUE '4'.
**********************************************************************
* -> (0.) Initialization of exporting parameters
REFRESH: gt_tr_data.
CLEAR: cv_subrc.
* -> (1.) Selection of transport request head data
PERFORM get_tr_head_data
CHANGING lt_tr_head_data
cv_subrc.
CHECK cv_subrc = 0.
* -> (2.) Selection of transport request additional data
PERFORM get_tr_add_data
USING lt_tr_head_data
CHANGING lt_tr_head_text.
* -> (3.) Processing of output table + retrieving import status data
PERFORM set_tr_data
USING lt_tr_head_data
lt_tr_head_text.
* -> (4.) Check if output table is not empty
IF gt_tr_data[] IS INITIAL.
cv_subrc = lc_error.
ENDIF.
ENDFORM. " GET_TR_DATA
*&---------------------------------------------------------------------*
*& Form GET_TR_HEAD_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* <--P_LT_TR_HEAD_DATA text
* <--P_CV_SUBRC text
*----------------------------------------------------------------------*
FORM get_tr_head_data
CHANGING ct_tr_head_data TYPE tt_tr_head_data
cv_subrc TYPE sy-subrc.
**********************************************************************
**********************************************************************
* -> (0.) Initialization of exporting parameters
REFRESH: ct_tr_head_data.
CLEAR: cv_subrc.
* -> (1.) Selection of tr.request head data from dB E070
SELECT trkorr trfunction trstatus tarsystem korrdev as4user
as4date as4time
INTO CORRESPONDING FIELDS OF TABLE ct_tr_head_data
FROM e070
WHERE trkorr IN so_trreq
AND trfunction IN so_trfun
AND trstatus IN so_trsts
AND tarsystem IN so_trtgt
AND as4user IN so_trusr
AND as4date IN so_trdat
AND strkorr = ''. "only main requests
cv_subrc = sy-subrc.
ENDFORM. " GET_TR_HEAD_DATA
*&---------------------------------------------------------------------*
*& Form GET_TR_ADD_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_LT_TR_HEAD_DATA text
* <--P_LT_TR_HEAD_TEXT text
*----------------------------------------------------------------------*
FORM get_tr_add_data
USING it_tr_head_data TYPE tt_tr_head_data
CHANGING ct_tr_head_text TYPE tt_tr_head_text.
**********************************************************************
* -> (0.) Initialization of exporting parameters
REFRESH: ct_tr_head_text.
* -> (1.) Selection of all tr.request texts. Do not take language into
* an account. Texts were not maintained properly!!!
SELECT trkorr as4text
INTO CORRESPONDING FIELDS OF TABLE ct_tr_head_text
FROM e07t
FOR ALL ENTRIES IN it_tr_head_data
WHERE trkorr = it_tr_head_data-trkorr.
SORT ct_tr_head_text BY trkorr.
ENDFORM. " GET_TR_ADD_DATA
*&---------------------------------------------------------------------*
*& Form SET_TR_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_LT_TR_HEAD_DATA text
* -->P_LT_TR_HEAD_TEXT text
*----------------------------------------------------------------------*
FORM set_tr_data
USING it_tr_head_data TYPE tt_tr_head_data
it_tr_head_text TYPE tt_tr_head_text.
**********************************************************************
DATA:
ls_tr_head_data TYPE ts_tr_head_data,
ls_tr_data_out LIKE LINE OF gt_tr_data,
ls_tr_head_text TYPE ts_tr_head_text.
CONSTANTS:
lc_error TYPE sy-subrc VALUE '8',
lc_red TYPE char01 VALUE '1',
lc_green TYPE char01 VALUE '3'.
**********************************************************************
* -> (0.) Initialization of exporting parameters
* REFRESH: gt_tr_data. "Initialization was carried out!!!
* -> (1.) Creation of output table with transport request data
CLEAR: ls_tr_head_data.
LOOP AT it_tr_head_data INTO ls_tr_head_data.
CLEAR: ls_tr_data_out.
* -> (2.) Set tr.request head data + text
MOVE-CORRESPONDING: ls_tr_head_data TO ls_tr_data_out.
CLEAR: ls_tr_head_text.
READ TABLE it_tr_head_text INTO ls_tr_head_text
WITH KEY trkorr = ls_tr_head_data-trkorr
BINARY SEARCH.
IF sy-subrc = 0.
ls_tr_data_out-as4text = ls_tr_head_text-as4text.
ENDIF.
* -> (3.) Get tr.request import status
PERFORM get_tr_import_data
USING ls_tr_data_out-trkorr
CHANGING ls_tr_data_out-stepid
ls_tr_data_out-trdate
ls_tr_data_out-trtime
ls_tr_data_out-trrc.
IF ( ls_tr_data_out-stepid IS INITIAL ) OR
( ls_tr_data_out-trrc = lc_error ).
* NO IMPORT
ls_tr_data_out-light = lc_red.
ELSE.
* IMPORT OK
ls_tr_data_out-light = lc_green.
ENDIF.
* -> (4.) Insert tr.request into output table
APPEND ls_tr_data_out TO gt_tr_data.
ENDLOOP.
ENDFORM. " SET_TR_DATA
*&---------------------------------------------------------------------*
*& Form GET_TR_IMPORT_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_LS_TR_DATA_OUT_TRKORR text
* <--P_LS_TR_DATA_OUT_STEPID text
* <--P_LS_TR_DATA_OUT_TRDATE text
* <--P_LS_TR_DATA_OUT_TRTIME text
* <--P_LS_TR_DATA_OUT_TRRC text
*----------------------------------------------------------------------*
FORM get_tr_import_data
USING iv_trkorr TYPE e070-trkorr
CHANGING cv_stepid TYPE tstrfcofil-function
cv_trdate TYPE tstrfcofil-trdate
cv_trtime TYPE tstrfcofil-trtime
cv_trrc TYPE tstrfcofil-retcode.
**********************************************************************
DATA:
lt_comm_systems TYPE tmscsyslst_typ,
ls_comm_systems TYPE tmscsyslst,
ls_cofile TYPE ctslg_cofile,
lv_user TYPE e070-as4user,
lv_project TYPE trkorr.
DATA:
lt_systems TYPE ctslg_systems,
ls_systems TYPE ctslg_system,
lt_steps TYPE ctslg_steps,
ls_steps TYPE ctslg_step,
lt_actions TYPE ctslg_actions,
ls_actions TYPE ctslg_action,
lv_lines TYPE i.
CONSTANTS:
lc_dir_t TYPE char_lg_01 VALUE 'T', "dir.type
lc_checked TYPE flag VALUE 'X', "checked
lc_import_step TYPE trbatfunc VALUE 'I', "step import
lc_error TYPE sy-subrc VALUE '8'. "error
**********************************************************************
* -> (0.) Initialization of exporting parameters
CLEAR: cv_stepid,
cv_trdate,
cv_trtime,
cv_trrc.
* -> (1.) Get tr.request import status
REFRESH: lt_comm_systems.
CLEAR: ls_comm_systems.
ls_comm_systems-sysnam = pa_sysnm.
APPEND ls_comm_systems TO lt_comm_systems.
CLEAR: ls_cofile,
lv_user,
lv_project.
CALL FUNCTION 'TR_READ_GLOBAL_INFO_OF_REQUEST'
EXPORTING
iv_trkorr = iv_trkorr
iv_dir_type = lc_dir_t
it_comm_systems = lt_comm_systems
IMPORTING
es_cofile = ls_cofile
ev_user = lv_user
ev_project = lv_project.
* -> tr.request MUST EXIST and MUST BE IMPORTED
IF ( ls_cofile-exists <> lc_checked ) OR
( ls_cofile-imported <> lc_checked ).
* error during import processing
cv_trrc = lc_error.
EXIT. "exit
ENDIF.
* -> get data from production system
REFRESH: lt_systems.
lt_systems = ls_cofile-systems.
SORT lt_systems BY systemid.
CLEAR: ls_systems.
READ TABLE lt_systems INTO ls_systems
WITH KEY systemid = pa_sysnm
BINARY SEARCH.
IF sy-subrc <> 0.
* error during import processing
cv_trrc = lc_error.
EXIT. "exit
ENDIF.
* -> get data from the processed import steps
REFRESH: lt_steps.
lt_steps = ls_systems-steps.
SORT lt_steps BY stepid.
CLEAR: ls_steps.
READ TABLE lt_steps INTO ls_steps
WITH KEY stepid = lc_import_step
BINARY SEARCH.
IF sy-subrc <> 0.
* error during import processing
cv_trrc = lc_error.
EXIT. "exit
ENDIF.
IF ls_steps-rc = lc_error. "error during import processing
cv_stepid = ls_steps-stepid.
cv_trrc = ls_steps-rc.
EXIT. "exit
ENDIF.
* -> get date/time/return code from import process
REFRESH: lt_actions.
lt_actions = ls_steps-actions.
CLEAR: lv_lines.
DESCRIBE TABLE lt_actions LINES lv_lines.
CLEAR: ls_actions.
READ TABLE lt_actions INTO ls_actions
INDEX lv_lines.
IF sy-subrc = 0.
* entry exists -> last import is relevant (there may be more)
cv_stepid = ls_steps-stepid.
cv_trdate = ls_actions-date.
cv_trtime = ls_actions-time.
cv_trrc = ls_actions-rc.
ELSE.
* no entry, get data from STEPS table + set error return code
cv_stepid = ls_steps-stepid.
cv_trrc = lc_error.
ENDIF.
ENDFORM. " GET_TR_IMPORT_DATA
*&---------------------------------------------------------------------*
*& Form SHOW_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM show_data.
**********************************************************************
DATA:
lt_fieldcat TYPE slis_t_fieldcat_alv,
ls_layout TYPE slis_layout_alv.
CONSTANTS:
lc_itab_name TYPE slis_tabname VALUE 'GT_TR_DATA',
lc_light_fname TYPE slis_fieldname VALUE 'LIGHT', "field name
lc_checked TYPE flag VALUE 'X', "checked
lc_display TYPE sy-ucomm VALUE 'ZDISP', "display
lc_user_command TYPE slis_formname VALUE 'USER_COMMAND',
lc_save_a TYPE char01 VALUE 'A'. "save
**********************************************************************
* -> (1.) Create field catalog for ALV
REFRESH: lt_fieldcat.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = sy-repid
i_internal_tabname = lc_itab_name
i_inclname = sy-repid
i_bypassing_buffer = lc_checked
CHANGING
ct_fieldcat = lt_fieldcat
EXCEPTIONS
inconsistent_interface = 1
program_error = 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.
* -> (2.) Set layout for ALV
CLEAR: ls_layout.
ls_layout-lights_fieldname = lc_light_fname.
ls_layout-zebra = lc_checked.
ls_layout-colwidth_optimize = lc_checked.
ls_layout-f2code = lc_display.
* -> (3.) Display ALV
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
i_callback_user_command = lc_user_command
is_layout = ls_layout
it_fieldcat = lt_fieldcat
i_save = lc_save_a
TABLES
t_outtab = gt_tr_data
EXCEPTIONS
program_error = 1
OTHERS = 2.
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. " SHOW_DATA
*---------------------------------------------------------------------*
* FORM USER_COMMAND *
*---------------------------------------------------------------------*
FORM user_command
USING iv_ucomm TYPE sy-ucomm
is_selfield TYPE slis_selfield.
**********************************************************************
DATA:
ls_tr_data LIKE LINE OF gt_tr_data.
CONSTANTS:
lc_display TYPE sy-ucomm VALUE 'ZDISP'.
**********************************************************************
CASE iv_ucomm.
WHEN lc_display. "user_command for double click
CLEAR: ls_tr_data.
READ TABLE gt_tr_data INTO ls_tr_data
INDEX is_selfield-tabindex. "pozicia kurzora
IF sy-subrc = 0.
* -> display transport request
PERFORM display_tr
USING ls_tr_data-trkorr.
ELSE.
MESSAGE e398(00) WITH 'Double click table line.'(e02).
ENDIF.
ENDCASE.
ENDFORM. "user_command
*&---------------------------------------------------------------------*
*& Form DISPLAY_TR
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_LS_TR_DATA_TRKORR text
*----------------------------------------------------------------------*
FORM display_tr
USING iv_trkorr TYPE e070-trkorr.
**********************************************************************
CONSTANTS:
lc_display TYPE sy-ucomm VALUE 'DISPLAY'.
**********************************************************************
* -> (1.) Display transport request
CALL FUNCTION 'TR_DISPLAY_REQUEST'
EXPORTING
i_trkorr = iv_trkorr
i_operation = lc_display.
ENDFORM. " DISPLAY_TR
*&---------------------------------------------------------------------*
*& Report ZSM_BC_TRIMPORT_VIEW_LIST
*&
*& Stevo Misik
*&
*&---------------------------------------------------------------------*
*&
*& Report is used to list relevant transport requests, with the focus
*& on their import status to the production system.
*&
*& Following objects were used in the report:
*& -> FM: TR_READ_GLOBAL_INFO_OF_REQUEST - reads import data of tran.
*& request.
*& -> FM: TR_DISPLAY_REQUEST - displays tran.request on a double click.
*& -> dB: E070 a E07T - transport request head data + text.
*&
*&---------------------------------------------------------------------*
REPORT zsm_bc_trimport_view_list.
*--- GLOBAL DECLARATIONS --------------------------------------------*
TYPE-POOLS:
ctslg, "Type of the function group TR_LOG_OVERVIEW
slis. "Global types for generic ALV list reports
TABLES:
e070. "Transport system: Transport request/task data
TYPES:
BEGIN OF ts_tr_head_data,
trkorr TYPE e070-trkorr, "tr.request
trfunction TYPE e070-trfunction, "tr.req.type
trstatus TYPE e070-trstatus, "tr.req.status
tarsystem TYPE e070-tarsystem, "target system
korrdev TYPE e070-korrdev, "tr.req.category
as4user TYPE e070-as4user, "tr.req.owner
as4date TYPE e070-as4date, "date
as4time TYPE e070-as4time, "time
END OF ts_tr_head_data,
tt_tr_head_data TYPE STANDARD TABLE OF ts_tr_head_data,
BEGIN OF ts_tr_head_text,
trkorr TYPE e07t-trkorr, "tr.request
as4text TYPE e07t-as4text, "tr.request text
END OF ts_tr_head_text,
tt_tr_head_text TYPE STANDARD TABLE OF ts_tr_head_text.
DATA:
BEGIN OF gt_tr_data OCCURS 100,
light LIKE alv_s_layo-val_data, "light
trkorr LIKE e070-trkorr, "tr.request
as4text LIKE e07t-as4text, "tr.request text
trfunction LIKE e070-trfunction, "tr.req.type
trstatus LIKE e070-trstatus, "tr.req.status
tarsystem LIKE e070-tarsystem, "target system
korrdev LIKE e070-korrdev, "tr.req.category
as4user LIKE e070-as4user, "owner
as4date LIKE e070-as4date, "date
as4time LIKE e070-as4time, "time
stepid LIKE tstrfcofil-function, "import flag (I)
trdate LIKE tstrfcofil-trdate, "import date
trtime LIKE tstrfcofil-trtime, "import time
trrc LIKE tstrfcofil-retcode, "import return code (0/8)
END OF gt_tr_data.
DATA:
gv_subrc TYPE sy-subrc. "return code for retrieving data
*--- SELECTION SCREEN -----------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE ct1.
SELECT-OPTIONS:
so_trreq FOR e070-trkorr, "request(s)
so_trfun FOR e070-trfunction, "request type
so_trsts FOR e070-trstatus, "request status
so_trtgt FOR e070-tarsystem, "target system
so_trusr FOR e070-as4user, "owner
so_trdat FOR e070-as4date. "date of a last change
PARAMETERS:
pa_sysnm TYPE tmssysnam DEFAULT 'XXX' OBLIGATORY. "prod.system
SELECTION-SCREEN END OF BLOCK b1.
*--- INITIALIZATION -------------------------------------------------*
INITIALIZATION.
ct1 = 'Selection screen:'(ct1).
*--- START OF SELECTION ---------------------------------------------*
START-OF-SELECTION.
* -> DATA SELECTION - BASED ON A SELECTION SCREEN
PERFORM get_tr_data
CHANGING gv_subrc.
*--- END OF SELECTION -----------------------------------------------*
END-OF-SELECTION.
* -> DATA DISPLAY
IF gv_subrc = 0.
PERFORM show_data.
ELSE.
MESSAGE s398(00) WITH 'Requests not found!'(e01).
ENDIF.
*--- FORMS ----------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Form GET_TR_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* <--P_GV_SUBRC text
*----------------------------------------------------------------------*
FORM get_tr_data
CHANGING cv_subrc TYPE sy-subrc.
**********************************************************************
DATA:
lt_tr_head_data TYPE tt_tr_head_data, "tr.req.head data
lt_tr_head_text TYPE tt_tr_head_text. "tr.req.texts
CONSTANTS:
lc_error TYPE sy-subrc VALUE '4'.
**********************************************************************
* -> (0.) Initialization of exporting parameters
REFRESH: gt_tr_data.
CLEAR: cv_subrc.
* -> (1.) Selection of transport request head data
PERFORM get_tr_head_data
CHANGING lt_tr_head_data
cv_subrc.
CHECK cv_subrc = 0.
* -> (2.) Selection of transport request additional data
PERFORM get_tr_add_data
USING lt_tr_head_data
CHANGING lt_tr_head_text.
* -> (3.) Processing of output table + retrieving import status data
PERFORM set_tr_data
USING lt_tr_head_data
lt_tr_head_text.
* -> (4.) Check if output table is not empty
IF gt_tr_data[] IS INITIAL.
cv_subrc = lc_error.
ENDIF.
ENDFORM. " GET_TR_DATA
*&---------------------------------------------------------------------*
*& Form GET_TR_HEAD_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* <--P_LT_TR_HEAD_DATA text
* <--P_CV_SUBRC text
*----------------------------------------------------------------------*
FORM get_tr_head_data
CHANGING ct_tr_head_data TYPE tt_tr_head_data
cv_subrc TYPE sy-subrc.
**********************************************************************
**********************************************************************
* -> (0.) Initialization of exporting parameters
REFRESH: ct_tr_head_data.
CLEAR: cv_subrc.
* -> (1.) Selection of tr.request head data from dB E070
SELECT trkorr trfunction trstatus tarsystem korrdev as4user
as4date as4time
INTO CORRESPONDING FIELDS OF TABLE ct_tr_head_data
FROM e070
WHERE trkorr IN so_trreq
AND trfunction IN so_trfun
AND trstatus IN so_trsts
AND tarsystem IN so_trtgt
AND as4user IN so_trusr
AND as4date IN so_trdat
AND strkorr = ''. "only main requests
cv_subrc = sy-subrc.
ENDFORM. " GET_TR_HEAD_DATA
*&---------------------------------------------------------------------*
*& Form GET_TR_ADD_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_LT_TR_HEAD_DATA text
* <--P_LT_TR_HEAD_TEXT text
*----------------------------------------------------------------------*
FORM get_tr_add_data
USING it_tr_head_data TYPE tt_tr_head_data
CHANGING ct_tr_head_text TYPE tt_tr_head_text.
**********************************************************************
* -> (0.) Initialization of exporting parameters
REFRESH: ct_tr_head_text.
* -> (1.) Selection of all tr.request texts. Do not take language into
* an account. Texts were not maintained properly!!!
SELECT trkorr as4text
INTO CORRESPONDING FIELDS OF TABLE ct_tr_head_text
FROM e07t
FOR ALL ENTRIES IN it_tr_head_data
WHERE trkorr = it_tr_head_data-trkorr.
SORT ct_tr_head_text BY trkorr.
ENDFORM. " GET_TR_ADD_DATA
*&---------------------------------------------------------------------*
*& Form SET_TR_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_LT_TR_HEAD_DATA text
* -->P_LT_TR_HEAD_TEXT text
*----------------------------------------------------------------------*
FORM set_tr_data
USING it_tr_head_data TYPE tt_tr_head_data
it_tr_head_text TYPE tt_tr_head_text.
**********************************************************************
DATA:
ls_tr_head_data TYPE ts_tr_head_data,
ls_tr_data_out LIKE LINE OF gt_tr_data,
ls_tr_head_text TYPE ts_tr_head_text.
CONSTANTS:
lc_error TYPE sy-subrc VALUE '8',
lc_red TYPE char01 VALUE '1',
lc_green TYPE char01 VALUE '3'.
**********************************************************************
* -> (0.) Initialization of exporting parameters
* REFRESH: gt_tr_data. "Initialization was carried out!!!
* -> (1.) Creation of output table with transport request data
CLEAR: ls_tr_head_data.
LOOP AT it_tr_head_data INTO ls_tr_head_data.
CLEAR: ls_tr_data_out.
* -> (2.) Set tr.request head data + text
MOVE-CORRESPONDING: ls_tr_head_data TO ls_tr_data_out.
CLEAR: ls_tr_head_text.
READ TABLE it_tr_head_text INTO ls_tr_head_text
WITH KEY trkorr = ls_tr_head_data-trkorr
BINARY SEARCH.
IF sy-subrc = 0.
ls_tr_data_out-as4text = ls_tr_head_text-as4text.
ENDIF.
* -> (3.) Get tr.request import status
PERFORM get_tr_import_data
USING ls_tr_data_out-trkorr
CHANGING ls_tr_data_out-stepid
ls_tr_data_out-trdate
ls_tr_data_out-trtime
ls_tr_data_out-trrc.
IF ( ls_tr_data_out-stepid IS INITIAL ) OR
( ls_tr_data_out-trrc = lc_error ).
* NO IMPORT
ls_tr_data_out-light = lc_red.
ELSE.
* IMPORT OK
ls_tr_data_out-light = lc_green.
ENDIF.
* -> (4.) Insert tr.request into output table
APPEND ls_tr_data_out TO gt_tr_data.
ENDLOOP.
ENDFORM. " SET_TR_DATA
*&---------------------------------------------------------------------*
*& Form GET_TR_IMPORT_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_LS_TR_DATA_OUT_TRKORR text
* <--P_LS_TR_DATA_OUT_STEPID text
* <--P_LS_TR_DATA_OUT_TRDATE text
* <--P_LS_TR_DATA_OUT_TRTIME text
* <--P_LS_TR_DATA_OUT_TRRC text
*----------------------------------------------------------------------*
FORM get_tr_import_data
USING iv_trkorr TYPE e070-trkorr
CHANGING cv_stepid TYPE tstrfcofil-function
cv_trdate TYPE tstrfcofil-trdate
cv_trtime TYPE tstrfcofil-trtime
cv_trrc TYPE tstrfcofil-retcode.
**********************************************************************
DATA:
lt_comm_systems TYPE tmscsyslst_typ,
ls_comm_systems TYPE tmscsyslst,
ls_cofile TYPE ctslg_cofile,
lv_user TYPE e070-as4user,
lv_project TYPE trkorr.
DATA:
lt_systems TYPE ctslg_systems,
ls_systems TYPE ctslg_system,
lt_steps TYPE ctslg_steps,
ls_steps TYPE ctslg_step,
lt_actions TYPE ctslg_actions,
ls_actions TYPE ctslg_action,
lv_lines TYPE i.
CONSTANTS:
lc_dir_t TYPE char_lg_01 VALUE 'T', "dir.type
lc_checked TYPE flag VALUE 'X', "checked
lc_import_step TYPE trbatfunc VALUE 'I', "step import
lc_error TYPE sy-subrc VALUE '8'. "error
**********************************************************************
* -> (0.) Initialization of exporting parameters
CLEAR: cv_stepid,
cv_trdate,
cv_trtime,
cv_trrc.
* -> (1.) Get tr.request import status
REFRESH: lt_comm_systems.
CLEAR: ls_comm_systems.
ls_comm_systems-sysnam = pa_sysnm.
APPEND ls_comm_systems TO lt_comm_systems.
CLEAR: ls_cofile,
lv_user,
lv_project.
CALL FUNCTION 'TR_READ_GLOBAL_INFO_OF_REQUEST'
EXPORTING
iv_trkorr = iv_trkorr
iv_dir_type = lc_dir_t
it_comm_systems = lt_comm_systems
IMPORTING
es_cofile = ls_cofile
ev_user = lv_user
ev_project = lv_project.
* -> tr.request MUST EXIST and MUST BE IMPORTED
IF ( ls_cofile-exists <> lc_checked ) OR
( ls_cofile-imported <> lc_checked ).
* error during import processing
cv_trrc = lc_error.
EXIT. "exit
ENDIF.
* -> get data from production system
REFRESH: lt_systems.
lt_systems = ls_cofile-systems.
SORT lt_systems BY systemid.
CLEAR: ls_systems.
READ TABLE lt_systems INTO ls_systems
WITH KEY systemid = pa_sysnm
BINARY SEARCH.
IF sy-subrc <> 0.
* error during import processing
cv_trrc = lc_error.
EXIT. "exit
ENDIF.
* -> get data from the processed import steps
REFRESH: lt_steps.
lt_steps = ls_systems-steps.
SORT lt_steps BY stepid.
CLEAR: ls_steps.
READ TABLE lt_steps INTO ls_steps
WITH KEY stepid = lc_import_step
BINARY SEARCH.
IF sy-subrc <> 0.
* error during import processing
cv_trrc = lc_error.
EXIT. "exit
ENDIF.
IF ls_steps-rc = lc_error. "error during import processing
cv_stepid = ls_steps-stepid.
cv_trrc = ls_steps-rc.
EXIT. "exit
ENDIF.
* -> get date/time/return code from import process
REFRESH: lt_actions.
lt_actions = ls_steps-actions.
CLEAR: lv_lines.
DESCRIBE TABLE lt_actions LINES lv_lines.
CLEAR: ls_actions.
READ TABLE lt_actions INTO ls_actions
INDEX lv_lines.
IF sy-subrc = 0.
* entry exists -> last import is relevant (there may be more)
cv_stepid = ls_steps-stepid.
cv_trdate = ls_actions-date.
cv_trtime = ls_actions-time.
cv_trrc = ls_actions-rc.
ELSE.
* no entry, get data from STEPS table + set error return code
cv_stepid = ls_steps-stepid.
cv_trrc = lc_error.
ENDIF.
ENDFORM. " GET_TR_IMPORT_DATA
*&---------------------------------------------------------------------*
*& Form SHOW_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM show_data.
**********************************************************************
DATA:
lt_fieldcat TYPE slis_t_fieldcat_alv,
ls_layout TYPE slis_layout_alv.
CONSTANTS:
lc_itab_name TYPE slis_tabname VALUE 'GT_TR_DATA',
lc_light_fname TYPE slis_fieldname VALUE 'LIGHT', "field name
lc_checked TYPE flag VALUE 'X', "checked
lc_display TYPE sy-ucomm VALUE 'ZDISP', "display
lc_user_command TYPE slis_formname VALUE 'USER_COMMAND',
lc_save_a TYPE char01 VALUE 'A'. "save
**********************************************************************
* -> (1.) Create field catalog for ALV
REFRESH: lt_fieldcat.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = sy-repid
i_internal_tabname = lc_itab_name
i_inclname = sy-repid
i_bypassing_buffer = lc_checked
CHANGING
ct_fieldcat = lt_fieldcat
EXCEPTIONS
inconsistent_interface = 1
program_error = 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.
* -> (2.) Set layout for ALV
CLEAR: ls_layout.
ls_layout-lights_fieldname = lc_light_fname.
ls_layout-zebra = lc_checked.
ls_layout-colwidth_optimize = lc_checked.
ls_layout-f2code = lc_display.
* -> (3.) Display ALV
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
i_callback_user_command = lc_user_command
is_layout = ls_layout
it_fieldcat = lt_fieldcat
i_save = lc_save_a
TABLES
t_outtab = gt_tr_data
EXCEPTIONS
program_error = 1
OTHERS = 2.
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. " SHOW_DATA
*---------------------------------------------------------------------*
* FORM USER_COMMAND *
*---------------------------------------------------------------------*
FORM user_command
USING iv_ucomm TYPE sy-ucomm
is_selfield TYPE slis_selfield.
**********************************************************************
DATA:
ls_tr_data LIKE LINE OF gt_tr_data.
CONSTANTS:
lc_display TYPE sy-ucomm VALUE 'ZDISP'.
**********************************************************************
CASE iv_ucomm.
WHEN lc_display. "user_command for double click
CLEAR: ls_tr_data.
READ TABLE gt_tr_data INTO ls_tr_data
INDEX is_selfield-tabindex. "pozicia kurzora
IF sy-subrc = 0.
* -> display transport request
PERFORM display_tr
USING ls_tr_data-trkorr.
ELSE.
MESSAGE e398(00) WITH 'Double click table line.'(e02).
ENDIF.
ENDCASE.
ENDFORM. "user_command
*&---------------------------------------------------------------------*
*& Form DISPLAY_TR
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_LS_TR_DATA_TRKORR text
*----------------------------------------------------------------------*
FORM display_tr
USING iv_trkorr TYPE e070-trkorr.
**********************************************************************
CONSTANTS:
lc_display TYPE sy-ucomm VALUE 'DISPLAY'.
**********************************************************************
* -> (1.) Display transport request
CALL FUNCTION 'TR_DISPLAY_REQUEST'
EXPORTING
i_trkorr = iv_trkorr
i_operation = lc_display.
ENDFORM. " DISPLAY_TR
Prihlásiť na odber:
Príspevky (Atom)