Applies to: SAP ECC 6.0, SAP BI 7.3.

Author: Komal Chandak

Company: Accenture Services Pvt. Ltd.

Created on: 16th October 2013

Author Bio: Komal is a Software Engineer Analyst in Accenture Services Private Limited. She has been involved in SAP ABAP and BW Implementation Projects.

Business Scenario:

The Business requirement is it to extract the Transport request details of any object or details of the TRs on the name of any user id with TR status and change log history. We have no such standard transaction, function module or program to display transport request details on particular criteria like on object name, object type in tabular format. So we created custom program which displays transport request details of any user id, object type or object with their tasks, objects locked into it, status and change log.

Overview:

According to the business requirement we have created custom program which displays transport request details which their tasks, objects locked into the TRs, object types and names, TR user name and any change made on particular date and time in tabular form. This is quite user friendly approach and provides flexible selection criteria to get the TR details all together.

Create program to display the Transport Request details in tabular or ALV format:

To create a generic program to display TR details in tabular form, we need to login into SAP system that can be BI/ECC/CRM and follow the below mentioned steps:

1.          Go to SE38 T-code to create a custom program.

SE38.jpg

2.          In this, specify a Program name and the Sub Objects as Source Code and click on create.

3.          Enter the title for the program and within the attributes section, select the Attribute type as Executable program and status as SAP Standard Production Program.  You can also specify the package. Press Enter.

SE38 Attributes.jpg

4.          The ABAP Editor opens up which allows us to write a program. The following program is transport request data from E071 and E070 tables.

5.          The following code explains the declarations and selection screen.

Selection screen will display user input for object type, object name, transport request, user name and date.

*&———————————————————————*

*& Report <Program Name>

*& Report will display the details of transport request in tabular form

*&———————————————————————*

REPORT <Program Name>.

*——————————————————————————-

* Tables

*——————————————————————————-

TABLES: e071,  ” Change & Transport System: Object Entries of Requests/Tasks

        e070.  ” Change & Transport System: Header of Requests/Tasks

*-To populate the E070 & E071 tables

TYPES:

       BEGIN OF ty_e7071,                                  

         trrequest      TYPE trkorr,        ” E071-Request/Task

         progrmid       TYPE pgmid,         ” E071-Program ID in Requests and Tasks

         objtype        TYPE trobjtype,     ” E071-Object Type

         objname        TYPE TROBJ_NAME,    ” E071-Object Name in Object List

         lockststus     TYPE lockflag,      ” E071-Lock status or import status of an object entry

         reqtype        TYPE trfunction,    ” E070-Request Type

         trstatus       TYPE trstatus,      ” E070-Status of TR / Task

         user           TYPE TR_AS4USER,    ” E070-User

         lastchangeon   TYPE as4date,       ” E070-Last Changed on

         lastchangat    TYPE as4time,       ” E070-Last Changed at

         mainhighertr   TYPE strkorr,       ” E070-Higher-level request

        END OF ty_e7071,

      BEGIN OF ty_final ,                                  

        username        TYPE tr_as4user,    ” User Name

        objectype       TYPE trobjtype,     ” Object Type

        objtext1        TYPE stext,         ” Text

        objname         TYPE trobj_name,    ” Object Name

        trequest        TYPE trkorr,        ” Transport Request / Task

        highertrrquest  TYPE strkorr,       ” Higher-Level Request

        status4         TYPE char20,        ” Status

        lastchangeon4   TYPE as4date,       ” Date of Last Change

        lastchangeat4   TYPE as4time,       ” Time of Last Change

       END OF ty_final.

DATA: it_finalt        TYPE TABLE OF ty_final,

      wa_final         TYPE ty_final,

      it_e7071t        TYPE TABLE OF ty_e7071,

      wa_e7071         TYPE ty_e7071,

      it_object_table  TYPE TABLE OF ko100 , ” To get the object descriptions

      wa_object_table  TYPE ko100.

*-For Field catalog

DATA: is_field_cat     TYPE slis_fieldcat_alv,             

       it_field_cat    TYPE TABLE OF slis_fieldcat_alv. ” WITH HEADER LINE.”#EC NEEDED

*-For Layout

DATA: is_layout        TYPE slis_layout_alv.                “#EC NEEDED

SELECTION-SCREEN BEGIN OF BLOCK blk1. “WITH FRAME TITLE text-t01.

SELECT-OPTIONS: object   FOR e071-object,               

                obj_name FOR e071-obj_name,             

                request  FOR e070-strkorr,              

                tr_reqst FOR e071-trkorr,               

                username FOR e070-as4user OBLIGATORY,   

                date     FOR sy-datum.                                     

SELECTION-SCREEN END OF BLOCK blk1.

6.           The below code fetch the data from e071 and e070 table on the basis of selection criteria entered by user on selection screen and display all the TR data in ALV format.

START-OF-SELECTION.

  PERFORM fetch_data.

  PERFORM prepare_final_table.

  PERFORM display_output.

*&———————————————————————*

*&      Form  fetch_data

*&———————————————————————*

*       Fetch data from E070 and E071 table

*———————————————————————-*

FORM fetch_data .

* Get the data from E071 & E070 tables

    SELECT       e71~trkorr

               e71~pgmid

               e71~object

               e71~obj_name

               e71~lockflag

               e70~trfunction

               e70~trstatus

               e70~as4user

               e70~as4date

               e70~as4time

               e70~strkorr

      FROM e070 AS e70 INNER JOIN e071 AS e71 ON e70~trkorr = e71~trkorr

      INTO TABLE it_e7071t

      WHERE    e70~trkorr   IN tr_reqst

           AND e70~strkorr  IN request

           AND e70~as4user  IN username

           AND e70~as4date  IN date

           AND e71~object   IN object

           AND e71~obj_name IN obj_name.

  IF sy-subrc EQ 0.

    DELETE  it_e7071t WHERE mainhighertr IS INITIAL AND trstatus EQ ‘R’ .”and trstatus eq ‘N’ .

  ELSE.

    IF tr_reqst IS NOT INITIAL.

      MESSAGE text-020 TYPE ‘I’ DISPLAY LIKE ‘E’. “Please enter task instead of higher level TR

      LEAVE LIST-PROCESSING.

    ENDIF.

  ENDIF.

  DELETE  it_e7071t WHERE mainhighertr IS INITIAL AND trstatus EQ ‘R’.

* select values for pgmid/object/text from database

  CALL FUNCTION ‘TR_OBJECT_TABLE’

    TABLES

      wt_object_text = it_object_table.

ENDFORM.                    ” FETCH_DATA

*&———————————————————————*

*&      Form  prepare_final_table

*&———————————————————————*

FORM prepare_final_table .

  LOOP AT it_e7071t INTO wa_e7071.

    wa_final-username        = wa_e7071-user.

    wa_final-objectype       = wa_e7071-objtype.

    wa_final-objname         = wa_e7071-objname.

    wa_final-trequest        = wa_e7071-trrequest.

    wa_final-highertrrquest  = wa_e7071-mainhighertr.

    wa_final-lastchangeon4   = wa_e7071-lastchangeon.

    wa_final-lastchangeat4   = wa_e7071-lastchangat.

    READ TABLE it_object_table INTO wa_object_table WITH KEY

pgmid = wa_e7071-progrmid

      object = wa_e7071-objtype.

    IF sy-subrc = 0.

      wa_final-objtext1 = wa_object_table-text.

    ENDIF.

    IF wa_e7071-trstatus = text-002.     “D

      wa_final-status4 = ‘Modifiable'(001).

    ELSEIF wa_e7071-trstatus = text-019. “L

      wa_final-status4 = ‘Modifiable, Protected'(003).

    ELSEIF wa_e7071-trstatus = text-004. “O

      wa_final-status4 = ‘Release Started'(005).

    ELSEIF wa_e7071-trstatus = text-006. “R

      wa_final-status4 = ‘Released'(007).

    ELSEIF wa_e7071-trstatus = text-008. “N

      wa_final-status4 = ‘Released (with Import Protection for Repaired Objects)'(009).

    ENDIF.

    APPEND wa_final TO it_finalt.

   CLEAR wa_final.

  ENDLOOP.

  SORT it_finalt BY trequest.

ENDFORM.                    ” PREPARE_FINAL_TABLE

*&———————————————————————*

*&      Form  display_output

*&———————————————————————*

FORM display_output .

  PERFORM populate_fieldcat.

  PERFORM populate_layout.

  PERFORM call_alv_grid.

ENDFORM.                    ” DISPLAY_OUTPUT

*&———————————————————————*

*&      Form  populate_fieldcat

*&———————————————————————*

*       text

*———————————————————————-*

FORM populate_fieldcat .

  PERFORM field_cat USING  ‘1’ ‘IT_FINALT’ ‘USERNAME’ ‘User Name'(010) ’10’.

  PERFORM field_cat USING  ‘2’ ‘IT_FINALT’ ‘OBJECTYPE’ ‘Object Type'(011)    ’15’.

  PERFORM field_cat USING  ‘3’ ‘IT_FINALT’ ‘OBJNAME’ ‘Object Name'(012) ’10’.

  PERFORM field_cat USING  ‘4’ ‘IT_FINALT’ ‘OBJTEXT1’ ‘Object Description'(013) ’10’.

  PERFORM field_cat USING  ‘5’ ‘IT_FINALT’ ‘HIGHERTRRQUEST’ ‘Higher-Level Request'(015) ’25’.

  PERFORM field_cat USING  ‘6’ ‘IT_FINALT’ ‘TREQUEST’ ‘Transport Request/Task'(014) ’25’.

  PERFORM field_cat USING  ‘7’ ‘IT_FINALT’ ‘STATUS4’ ‘Status'(016) ’20’.

  PERFORM field_cat USING  ‘8’ ‘IT_FINALT’ ‘LASTCHANGEON4’ ‘Date of Last Change'(017) ’15’.

  PERFORM field_cat USING  ‘9’ ‘IT_FINALT’ ‘ LASTCHANGEAT4’ ‘Last changed at'(018) ’10’.

ENDFORM.                    “populate_fieldcat

*&———————————————————————*

*&      Form call_alv_grid

*&———————————————————————*

FORM call_alv_grid .

  CALL FUNCTION ‘REUSE_ALV_GRID_DISPLAY’

    EXPORTING

      i_callback_program      = SY-REPID

      i_callback_user_command = ‘USER_COMMAND’

      is_layout               = is_layout

      it_fieldcat             = it_field_cat[]

    TABLES

      t_outtab                = it_finalt.

ENDFORM.                    “call_alv_grid

*&———————————————————————*

*&      Form  field_cat

*&———————————————————————*

*       text

*———————————————————————-*

*      –>VALUE      text

*      –>(P_0281)   text

*      –>VALUE      text

*      –>(P_0282)   text

*      –>VALUE      text

*      –>(P_0283)   text

*      –>VALUE      text

*      –>(P_0284)   text

*      –>VALUE      text

*      –>(P_0285)   text

*———————————————————————-*

FORM field_cat  USING    value(p_0281) TYPE any

                         value(p_0282) TYPE any

                         value(p_0283) TYPE any

                         value(p_0284) TYPE any

                         value(p_0285) TYPE any.

  is_field_cat-col_pos   = p_0281.

  is_field_cat-tabname   = p_0282.

  is_field_cat-fieldname = p_0283.

  is_field_cat-seltext_l = p_0284.

  is_field_cat-outputlen = p_0285.

  APPEND is_field_cat TO it_field_cat .

  CLEAR is_field_cat.

ENDFORM.                    “field_cat

*&———————————————————————*

*&      Form  populate_layout

*&———————————————————————*

*       text

*———————————————————————-*

FORM populate_layout .

  is_layout-no_input   = ‘X’.

  is_layout-zebra      = ‘X’.

ENDFORM.                    “populate_layout

7.          Execute the program and you will get the selection screen ,based on your requirement ,put the User

name (Put * if you want to see the entire TR list).

Selection Screen:

Selection_screen.jpg

Once the user enters the values in selection screen, transport details will get pulled on the basis of user entered selection input.

/wp-content/uploads/2013/10/selection_screen_input_298678.jpg

Now all the Transport requests in which 0PLANT is locked get displayed with their tasks, user name, status, date and time change log.

TR_output_ALV.jpg

To report this post you need to login first.

5 Comments

You must be Logged on to comment or reply to a post.

  1. Suhas Saha

    Hello,

    I’m not quite sure why did you create a custom program for this? You can use the transaction SE03 –> Search for Objects in Requests/Tasks. The standard report offers even more functionality than your program.

    In future please do not post such redundant & basic content.

    – Suhas

    (0) 

Leave a Reply