Posted: Mon Feb 25, 2008 7:32 pm Post subject: Transport Orders Report
Sometime, we want to know if one particular program or transaction have been transported to QAS or PRD...But we usually do is go to SE10 transaction, look for the orders and check all of them to see when and where they were transported.
That's why I decided to develop a small program that giving a program or transaction, lists all related transport orders along with they're descriptions and information about if they were either transported to QAS or PRD, when they were transported and a what time.
This is aimed for beginners or for people like me, who enjoys developing stuff using ABAP. Here's the source code...
Code:
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: <E071> LIKE LINE OF T_E071,
<E070> 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.
*&---------------------------------------------------------------------*
*& 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.
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 <E071>.
MOVE <E071> 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.
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 = <E070>-TRSTATUS.
IF W_TRKORR NE <E070>-TRKORR.
W_TRKORR = <E070>-TRKORR.
SKIP 1.
ENDIF.
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.
TYPES: BEGIN OF TY_REPORT,
TRKORR TYPE E070-TRKORR,
DDTEXT TYPE RPY_DVAL-DDTEXT,
SYSTEMID TYPE TSTRFCOFIL-TARSYSTEM,
AS4TEXT TYPE E07T-AS4TEXT,
DATE TYPE SY-DATUM,
TIME TYPE SY-UZEIT,
END OF TY_REPORT.
*-----------------------------------------------------------------*
* 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,
T_REPORT TYPE STANDARD TABLE OF TY_REPORT WITH HEADER LINE.
*-----------------------------------------------------------------*
* VARIABLES *
*-----------------------------------------------------------------*
DATA: W_PGMNA TYPE TSTC-PGMNA,
W_NAME(41) TYPE C,
W_FLAG TYPE C,
GS_FIELDCAT TYPE LVC_S_FCAT,
GT_FIELDCAT_REP TYPE LVC_T_FCAT,
CUSTOM_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
MYCONTAINER TYPE SCRFNAME VALUE 'CONTAINER',
GRID_ORDERS TYPE REF TO CL_GUI_ALV_GRID,
GS_SORT_REP TYPE LVC_S_SORT,
GT_SORT_REP TYPE LVC_T_SORT.
*-----------------------------------------------------------------*
* FIELD-SYMBOLS *
*-----------------------------------------------------------------*
FIELD-SYMBOLS: <E071> LIKE LINE OF T_E071,
<E070> 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.
*&---------------------------------------------------------------------*
*& 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.
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 <E071>.
MOVE <E071> 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.
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 = <E070>-TRSTATUS.
MOVE <E070>-TRKORR TO T_REPORT-TRKORR.
MOVE DOMA_VALUES-DDTEXT TO T_REPORT-DDTEXT.
MOVE WA_SYSTEMS-SYSTEMID TO T_REPORT-SYSTEMID.
MOVE <E070>-AS4TEXT TO T_REPORT-AS4TEXT.
MOVE WA_ACTIONS-DATE TO T_REPORT-DATE.
MOVE WA_ACTIONS-TIME TO T_REPORT-TIME.
APPEND T_REPORT.
ENDLOOP.
ENDLOOP.
ENDLOOP.
PERFORM FILL_CATALOG.
PERFORM CALL_ALV.
CALL SCREEN 0100.
ENDFORM.
*&-----------------------------------------------------------*
*& Form FILL_CATALOG *
*&-----------------------------------------------------------*
FORM FILL_CATALOG.
GS_SORT_REP-SPOS = 1.
GS_SORT_REP-FIELDNAME = 'TRKORR'.
APPEND GS_SORT_REP TO GT_SORT_REP.
ENDFORM. " FILL_CATALOG
*&-----------------------------------------------------------*
*& Form CALL_ALV *
*&-----------------------------------------------------------*
FORM CALL_ALV.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG. SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG. Every effort is made to ensure content integrity. Use information on this site at your own risk.