Simple Transport Request Report

Berikut adalah program sederhana untuk menampilkan report transport request beserta informasi object yang termasuk dalam TR tersebut.


REPORT  ZABP_TR.

*&---------------------------------------------------------------------*
*&      GLOBAL DATA
*&---------------------------------------------------------------------*
TYPE-POOLS: slis.
DATA: t_fieldcat TYPE slis_t_fieldcat_alv,
      t_sort TYPE	slis_t_sortinfo_alv.
DATA: x_layout TYPE slis_layout_alv,
      x_sort TYPE	slis_sortinfo_alv.

TYPES: BEGIN OF ty_trans.
INCLUDE TYPE e070.
TYPES:  pgmid TYPE e071-pgmid,
        object TYPE e071-object,
        obj_name TYPE e071-obj_name,
        as4text TYPE e07t-as4text,
      END OF ty_trans.

DATA: t_data TYPE TABLE OF ty_trans WITH HEADER LINE,
      x_data LIKE LINE OF t_data.

*&---------------------------------------------------------------------*
*&      SELECTION SCREEN
*&---------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
SELECT-OPTIONS: s_trkorr FOR t_data-trkorr OBLIGATORY,
                s_userid FOR t_data-as4user OBLIGATORY,
                s_datum  FOR t_data-as4date OBLIGATORY,
                s_pgmid  FOR t_data-pgmid,
                s_object FOR t_data-object,
                s_obname FOR t_data-obj_name.
SELECTION-SCREEN END OF BLOCK b1.

*&---------------------------------------------------------------------*
*&      EVENT
*&---------------------------------------------------------------------*
INITIALIZATION.

START-OF-SELECTION.
  PERFORM f_get_data.

END-OF-SELECTION.
  PERFORM f_write_data.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_pgmid-low.
  PERFORM f_f4_pgmid USING s_pgmid-low.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_pgmid-high.
  PERFORM f_f4_pgmid USING s_pgmid-high.

*&---------------------------------------------------------------------*
*&      Form  f_get_data
*&---------------------------------------------------------------------*
FORM f_get_data.
  DATA: ld_as4text TYPE e07t-as4text,
        lt_item LIKE TABLE OF t_data WITH HEADER LINE.

  SELECT a~trkorr trfunction trstatus tarsystem korrdev as4user as4date
         as4time strkorr pgmid object obj_name as4text
    FROM e070 AS a INNER JOIN e071 AS b ON a~trkorr = b~trkorr
    INNER JOIN e07t AS c ON a~trkorr = c~trkorr
    INTO TABLE t_data
    WHERE a~trkorr IN s_trkorr
      AND as4user IN s_userid
      AND as4date IN s_datum
      AND strkorr = space
      and pgmid in s_pgmid
      and object in s_object
      and obj_name in s_obname.

  CHECK sy-subrc = 0.

  SELECT a~trkorr trfunction trstatus tarsystem korrdev as4user as4date
         as4time strkorr pgmid object obj_name
    FROM e070 AS a INNER JOIN e071 AS b ON a~trkorr = b~trkorr
    INTO TABLE lt_item
    FOR ALL ENTRIES IN t_data
    WHERE strkorr = t_data-trkorr
      and pgmid in s_pgmid
      and object in s_object
      and obj_name in s_obname.

  SORT t_data BY trkorr.
  LOOP AT lt_item.
    READ TABLE t_data WITH KEY trkorr = lt_item-strkorr BINARY SEARCH.
    IF sy-subrc = 0.
      ld_as4text = t_data-as4text.
      CLEAR t_data.
      MOVE-CORRESPONDING lt_item TO t_data.
      t_data-trkorr = lt_item-strkorr.
      t_data-as4text = ld_as4text.

      CLEAR t_data-strkorr.
      INSERT t_data INDEX sy-tabix.
    ENDIF.
  ENDLOOP.

  SORT t_data BY trkorr pgmid object obj_name.
  DELETE ADJACENT DUPLICATES FROM t_data
    COMPARING trkorr pgmid object obj_name.
  DELETE t_data WHERE pgmid = 'CORR'. "delete comment item

ENDFORM.                    "f_get_data

*&---------------------------------------------------------------------*
*&      Form  f_write_data
*&---------------------------------------------------------------------*
FORM f_write_data.

  PERFORM f_build_fieldcat USING:
  'TRKORR'      'E070'  'TRKORR',
  'AS4TEXT'     'E07T'  'AS4TEXT',
* 'TRFUNCTION'  'E070'  'TRFUNCTION',
  'TRSTATUS'    'E070'  'TRSTATUS',
* 'TARSYSTEM'   'E070'  'TARSYSTEM',
  'KORRDEV'     'E070'  'KORRDEV',
  'AS4USER'     'E070'  'AS4USER',
  'AS4DATE'     'E070'  'AS4DATE',
  'AS4TIME'     'E070' 'AS4TIME',
* 'STRKORR'     'E070'  'STRKORR',
  'PGMID'       'E071'  'PGMID',
  'OBJECT'      'E071'  'OBJECT',
  'OBJ_NAME'    'E071'  'OBJ_NAME'.

  CLEAR x_layout.
  x_layout-colwidth_optimize = 'X'.

  CLEAR x_sort.
  x_sort-fieldname  = 'TRKORR'.
  x_sort-tabname    = 'T_DATA'.
  x_sort-up         = 'X'.
  x_sort-group      = 'X'.
  APPEND x_sort TO t_sort.

  CLEAR x_sort.
  x_sort-fieldname  = 'AS4TEXT'.
  x_sort-tabname    = 'T_DATA'.
  x_sort-up         = 'X'.
  x_sort-group      = 'X'.
  APPEND x_sort TO t_sort.

  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      i_callback_program = sy-repid
      it_fieldcat        = t_fieldcat
      is_layout          = x_layout
      it_sort            = t_sort
      i_save             = 'A'
    TABLES
      t_outtab           = t_data
    EXCEPTIONS
      program_error      = 1
      OTHERS             = 2.

ENDFORM.                    "f_write_data

*&---------------------------------------------------------------------*
*&      Form  f_build_fieldcat
*&---------------------------------------------------------------------*
FORM f_build_fieldcat USING fu_fieldname
                            fu_reftable
                            fu_reffield.

  DATA : lx_fieldcat TYPE slis_fieldcat_alv.

  CLEAR lx_fieldcat.
  lx_fieldcat-fieldname     = fu_fieldname.
  lx_fieldcat-ref_tabname   = fu_reftable.
  lx_fieldcat-ref_fieldname = fu_reffield.
  APPEND lx_fieldcat TO t_fieldcat.

ENDFORM. "F_ALV_ASSIGN_FIELDCAT
*&---------------------------------------------------------------------*
*&      Form  F_F4_PGMID
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_S_PGMID_LOW  text
*----------------------------------------------------------------------*
FORM f_f4_pgmid  USING  fu_pgmid.
  DATA: lt_pgmids  TYPE TABLE OF ko101.

  CALL FUNCTION 'TR_PGMID_TABLE'
    TABLES
      wt_pgmid_text = lt_pgmids.
  CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
    EXPORTING
      retfield        = 'PGMID'
      value_org       = 'S'
      dynpprog        = 'ZABP_TR'
      dynpnr          = '1000'
      dynprofield     = 'S_PGMID-LOW'
    TABLES
      value_tab       = lt_pgmids
    EXCEPTIONS
      parameter_error = 1
      no_values_found = 2
      OTHERS          = 3.
ENDFORM.                    " F_F4_PGMID
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s