Google Search - Blog...........

ABAP - Report Program To Fetch Transport Requests Related To A Program / Transaction, Etc....

Description
This code gives you a list of the transport orders related to a program or transaction.
REPORT Z_TRANPORT_ORDERS NO STANDARD PAGE HEADING MESSAGE-ID ZMM.

*-----------------------------------------------------------------*
* TYPES *
*-----------------------------------------------------------------*
TYPES: BEGIN OF TY_E071,
TRKORR TYPE E071-TRKORR,
OBJECT TYPE E071-OBJECT,
OBJ_NAME TYPE E071-OBJ_NAME,
END OF TY_E071.

TYPES: BEGIN OF TY_E071_ENTRY,
TRKORR TYPE E071-TRKORR,
END OF TY_E071_ENTRY.

TYPES: BEGIN OF TY_E070,
TRKORR TYPE E070-TRKORR,
TRSTATUS TYPE E070-TRSTATUS,
TARSYSTEM TYPE E070-TARSYSTEM,
AS4USER TYPE E070-AS4USER,
AS4DATE TYPE E070-AS4DATE,
AS4TIME TYPE E070-AS4TIME,
AS4TEXT TYPE E07T-AS4TEXT,
END OF TY_E070.

TYPES: BEGIN OF CTSLG_ACTION,
DATE LIKE TSTRFCOFIL-TRDATE,
TIME LIKE TSTRFCOFIL-TRTIME,
RC LIKE TSTRFCOFIL-RETCODE,
END OF CTSLG_ACTION,

CTSLG_ACTIONS TYPE SORTED TABLE OF CTSLG_ACTION
WITH UNIQUE KEY DATE TIME
INITIAL SIZE 2,
BEGIN OF CTSLG_STEP,
CLIENTID LIKE TSTRFCOFIL-TARCLIENT,
STEPID LIKE TSTRFCOFIL-FUNCTION,
RC LIKE TSTRFCOFIL-RETCODE,
ACTIONS TYPE CTSLG_ACTIONS,
END OF CTSLG_STEP,

CTSLG_STEPS TYPE CTSLG_STEP OCCURS 10,

BEGIN OF CTSLG_SYSTEM,
SYSTEMID LIKE TSTRFCOFIL-TARSYSTEM,
RC LIKE TSTRFCOFIL-RETCODE,
STEPS TYPE CTSLG_STEPS,
END OF CTSLG_SYSTEM,

CTSLG_SYSTEMS TYPE CTSLG_SYSTEM OCCURS 10,

BEGIN OF CTSLG_MERGELINE,
TRKORR TYPE TRKORR,
RC LIKE TSTRFCOFIL-RETCODE,
END OF CTSLG_MERGELINE,

CTSLG_MERGELINES TYPE CTSLG_MERGELINE OCCURS 0,

BEGIN OF CTSLG_COFILE,
EXISTS TYPE C,
IMPORTED TYPE C,
DEL_LINES_ONLY TYPE C,
SYSTEMS TYPE CTSLG_SYSTEMS,
MERGES TYPE CTSLG_MERGELINES,
RC TYPE I,
END OF CTSLG_COFILE.

*-----------------------------------------------------------------*
* INTERNAL TABLES *
*-----------------------------------------------------------------*
DATA: T_E071 TYPE STANDARD TABLE OF TY_E071 WITH HEADER LINE,
T_E070 TYPE STANDARD TABLE OF TY_E070 WITH HEADER LINE,
T_E071_ENTRY TYPE STANDARD TABLE OF TY_E071_ENTRY
WITH HEADER LINE,
DOMA_VALUES TYPE STANDARD TABLE OF RPY_DVAL WITH HEADER LINE,
ES_COFILE TYPE STANDARD TABLE OF CTSLG_COFILE WITH HEADER LINE,
ES_SYSTEMS TYPE STANDARD TABLE OF CTSLG_SYSTEM,
WA_SYSTEMS TYPE CTSLG_SYSTEMS WITH HEADER LINE,
ES_STEPS TYPE CTSLG_STEPS,
WA_STEPS TYPE CTSLG_STEPS WITH HEADER LINE,
ES_ACTIONS TYPE CTSLG_ACTIONS,
WA_ACTIONS TYPE CTSLG_ACTIONS WITH HEADER LINE.

*-----------------------------------------------------------------*
* VARIABLES *
*-----------------------------------------------------------------*
DATA: W_PGMNA TYPE TSTC-PGMNA,
W_NAME(41) TYPE C,
W_FLAG TYPE C.

*-----------------------------------------------------------------*
* FIELD-SYMBOLS *
*-----------------------------------------------------------------*
FIELD-SYMBOLS: LIKE LINE OF T_E071,
LIKE LINE OF T_E070.

*-----------------------------------------------------------------*
* SELECTION-SCREEN *
*-----------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK DATA.
PARAMETERS:
P_TCODE LIKE TSTC-TCODE,
P_PGMNA LIKE TSTC-PGMNA.
SELECTION-SCREEN END OF BLOCK DATA.

*----------------------------------------------------------------------*
* START-OF-SELECTION *
*----------------------------------------------------------------------*
START-OF-SELECTION.

PERFORM VALIDATE_ENTRY.
IF W_FLAG EQ SPACE.
PERFORM GET_ORDERS.
PERFORM PRINT_ORDERS.
ENDIF.

*&---------------------------------------------------------------------*
*& Form VALIDATE_ENTRY *
*&---------------------------------------------------------------------*
FORM VALIDATE_ENTRY.

IF P_TCODE NE SPACE.
SELECT SINGLE PGMNA
INTO W_PGMNA
FROM TSTC
WHERE TCODE EQ P_TCODE.
IF SY-SUBRC EQ 0.
W_FLAG = SPACE.
ELSE.
MESSAGE S008 WITH 'Requested transacction don''t exist'.
W_FLAG = 'X'.
ENDIF.
ELSEIF P_PGMNA NE SPACE.
SELECT SINGLE PGMNA
INTO W_PGMNA
FROM TSTC
WHERE PGMNA EQ P_PGMNA.
IF SY-SUBRC EQ 0.
W_FLAG = SPACE.
ELSE.
MESSAGE S008 WITH 'Requested program don''t exist'.
W_FLAG = 'X'.
ENDIF.
ENDIF.

ENDFORM.

*&----------------------------------------------------------------*
*& Form GET_ORDERS *
*&----------------------------------------------------------------*
FORM GET_ORDERS.

CALL FUNCTION 'RPY_DOMAIN_READ'
EXPORTING
DOMA_NAME = 'TRSTATUS'
LANGUAGE = SY-LANGU
TABLES
DOMA_VALUES = DOMA_VALUES
EXCEPTIONS
CANCELLED = 1
NOT_FOUND = 2
PERMISSION_ERROR = 3
ILLEGAL_TYPE = 4
OTHERS = 5.

CONCATENATE W_PGMNA '%'
INTO W_NAME.

SELECT TRKORR OBJECT OBJ_NAME
INTO TABLE T_E071
FROM E071
WHERE OBJ_NAME LIKE W_NAME
AND OBJECT EQ 'REPS'.

IF NOT T_E071[] IS INITIAL.
LOOP AT T_E071 ASSIGNING .
MOVE TO T_E071_ENTRY.
APPEND T_E071_ENTRY.
ENDLOOP.

SORT T_E071_ENTRY.
DELETE ADJACENT DUPLICATES FROM T_E071_ENTRY.

IF NOT T_E071_ENTRY[] IS INITIAL.
SELECT E070~TRKORR TRSTATUS TARSYSTEM
AS4USER AS4DATE AS4TIME
AS4TEXT
INTO TABLE T_E070
FROM ( E070 INNER JOIN E07T
ON E070~TRKORR EQ E07T~TRKORR )
FOR ALL ENTRIES IN T_E071_ENTRY
WHERE E070~TRKORR EQ T_E071_ENTRY-TRKORR
AND LANGU EQ SY-LANGU.

SORT T_E070 BY AS4DATE AS4TIME DESCENDING.

ENDIF.
ENDIF.

ENDFORM.

*&----------------------------------------------------------------*
*& Form PRINT_ORDERS *
*&----------------------------------------------------------------*
FORM PRINT_ORDERS.

DATA: W_TRKORR TYPE E070-TRKORR.

WRITE:1 'Order',12 'Status',22 'Destination',
35 'Name',96 'Date',108 'Time'.

LOOP AT T_E070 ASSIGNING .

CLEAR: ES_COFILE.
REFRESH: ES_COFILE.

CALL FUNCTION 'TR_READ_GLOBAL_INFO_OF_REQUEST'
EXPORTING
IV_TRKORR = -TRKORR
IV_DIR_TYPE = 'T'
IMPORTING
ES_COFILE = ES_COFILE.

APPEND ES_COFILE.
READ TABLE ES_COFILE INDEX 1.
MOVE ES_COFILE-SYSTEMS TO ES_SYSTEMS.
LOOP AT ES_SYSTEMS INTO WA_SYSTEMS.
MOVE WA_SYSTEMS-STEPS TO ES_STEPS.
LOOP AT ES_STEPS INTO WA_STEPS WHERE STEPID EQ 'G'.
MOVE WA_STEPS-ACTIONS TO ES_ACTIONS.
LOOP AT ES_ACTIONS INTO WA_ACTIONS.
ENDLOOP.
READ TABLE DOMA_VALUES
WITH KEY DOMVALUE_L = -TRSTATUS.

IF W_TRKORR NE -TRKORR.
W_TRKORR = -TRKORR.
SKIP 1.
ENDIF.

WRITE:/1 -TRKORR,12 DOMA_VALUES-DDTEXT,
22 WA_SYSTEMS-SYSTEMID,35 -AS4TEXT,
96 WA_ACTIONS-DATE,108 WA_ACTIONS-TIME.
ENDLOOP.
ENDLOOP.

ENDLOOP.

ENDFORM.

No comments:

Post a Comment