Downtime Announcement: Please note the SAP Community Wiki will be unavailable due to a system upgrade on Thursday, September 24th between 6 and 7 AM CEST
Skip to end of metadata
Go to start of metadata

Author: Alvaro "Blag" Tejada Galindo
Submitted: 26/06/2007
Related Links:

Description

  This code gives you a list of the transport orders related to a program or transaction.

Error rendering macro 'code': Invalid value specified for parameter 'com.atlassian.confluence.ext.code.render.InvalidValueException'
REPORT ZDUMMY_ATG_3 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.

*-----------------------------------------------------------------*
*   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 <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.

  DATA: W_TRKORR TYPE E070-TRKORR.

  LOOP AT T_E070 ASSIGNING <E070>.

    CLEAR: ES_COFILE.
    REFRESH: ES_COFILE.

    CALL FUNCTION 'TR_READ_GLOBAL_INFO_OF_REQUEST'
         EXPORTING
              IV_TRKORR   = <E070>-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 = <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.

  DATA: GS_FIELDCAT_ADD TYPE LVC_S_FCAT.

  CLEAR GS_FIELDCAT.
  GS_FIELDCAT-COL_POS   = 1.
  GS_FIELDCAT-REPTEXT   = 'Order'.
  GS_FIELDCAT-FIELDNAME = 'TRKORR'.
  GS_FIELDCAT-TABNAME = 'T_REPORT'.
  GS_FIELDCAT-OUTPUTLEN = '12'.
  APPEND GS_FIELDCAT TO GT_FIELDCAT_REP.

  CLEAR GS_FIELDCAT.
  GS_FIELDCAT-COL_POS   = 2.
  GS_FIELDCAT-REPTEXT   = 'Status'.
  GS_FIELDCAT-FIELDNAME = 'DDTEXT'.
  GS_FIELDCAT-TABNAME = 'T_REPORT'.
  GS_FIELDCAT-OUTPUTLEN = '8'.
  APPEND GS_FIELDCAT TO GT_FIELDCAT_REP.

  CLEAR GS_FIELDCAT.
  GS_FIELDCAT-COL_POS   = 3.
  GS_FIELDCAT-REPTEXT   = 'Destination'.
  GS_FIELDCAT-FIELDNAME = 'SYSTEMID'.
  GS_FIELDCAT-TABNAME = 'T_REPORT'.
  GS_FIELDCAT-OUTPUTLEN = '4'.
  APPEND GS_FIELDCAT TO GT_FIELDCAT_REP.

  CLEAR GS_FIELDCAT.
  GS_FIELDCAT-COL_POS   = 4.
  GS_FIELDCAT-REPTEXT   = 'Name'.
  GS_FIELDCAT-FIELDNAME = 'AS4TEXT'.
  GS_FIELDCAT-TABNAME = 'T_REPORT'.
  GS_FIELDCAT-OUTPUTLEN = '60'.
  APPEND GS_FIELDCAT TO GT_FIELDCAT_REP.

  CLEAR GS_FIELDCAT.
  GS_FIELDCAT-COL_POS   = 5.
  GS_FIELDCAT-REPTEXT   = 'Date'.
  GS_FIELDCAT-FIELDNAME = 'DATE'.
  GS_FIELDCAT-TABNAME = 'T_REPORT'.
  GS_FIELDCAT-OUTPUTLEN = '10'.
  APPEND GS_FIELDCAT TO GT_FIELDCAT_REP.

  CLEAR GS_FIELDCAT.
  GS_FIELDCAT-COL_POS   = 5.
  GS_FIELDCAT-REPTEXT   = 'Time'.
  GS_FIELDCAT-FIELDNAME = 'TIME'.
  GS_FIELDCAT-TABNAME = 'T_REPORT'.
  GS_FIELDCAT-OUTPUTLEN = '8'.
  APPEND GS_FIELDCAT TO GT_FIELDCAT_REP.

  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.

  IF CUSTOM_CONTAINER IS INITIAL.
    CREATE OBJECT CUSTOM_CONTAINER
       EXPORTING
           CONTAINER_NAME = MYCONTAINER
       EXCEPTIONS
           CNTL_ERROR = 1
           CNTL_SYSTEM_ERROR = 2
           CREATE_ERROR = 3
           LIFETIME_ERROR = 4
           LIFETIME_DYNPRO_DYNPRO_LINK = 5.
  ENDIF.

  CREATE OBJECT GRID_ORDERS
        EXPORTING I_PARENT = CUSTOM_CONTAINER.

  CALL METHOD GRID_ORDERS->SET_TABLE_FOR_FIRST_DISPLAY
       EXPORTING I_DEFAULT        = 'X'
       CHANGING  IT_FIELDCATALOG  = GT_FIELDCAT_REP
                 IT_SORT          = GT_SORT_REP[]
                 IT_OUTTAB        = T_REPORT[].

ENDFORM.                    " CALL_ALV

1 Comment

  1. Anonymous

    Tried to run this report for version 4.7 but not getting any result. During debugging checked that program compiles the transport requests for the input T-code but in subroutine PRINT_ORDERS when calling Fun Module 'TR_READ_GLOBAL_INFO_OF_REQUEST' the importing file is blank. What could be the reason.

    Kindly help.

    thanks

    anya