Skip to end of metadata
Go to start of metadata

Author: Chandrasekhar Jagarlamudi

Submitted:  28/03/2007

This code sample ABAP program to create the object list of a transport request automatically.

Applies to:

ECC 5.0, SAP 4.6 C

Summary

The main purpose of this article is to create the object list of a transport request automatically when there are many entries to be created. 

Author Bio

I am working as Programmer Analyst in Intelligroup Asia Pvt. Ltd. Presently my role is a Developer in SAP ABAP Module and I am in this field since the past 2 years.

Brief Description of the Code:

      Say we have to create some 100 entries to the object list of a transport request.

      It becomes a tedious task if added manually; this program creates the entries in the object list    automatically

Example:

We had created some 100 GL accounts and have to create the Transport request for the same for table SKA1.

Steps to be followed:

Say the GL Accounts created are from 100000 - 100100

Step 1:

Create a Transportable Request in SE10

 

 

Step 2:

Run the Program with the code given below and mention the Task Number and the GL Accounts created

 

 
And Select the Test checkbox for testing.

When the Program is run it displays the details of the object list

 

Now remove the checkbox Test and run again, this will update the tables E071 and E071K and creates the object list in the Transport Request

 

 

Code :

Error rendering macro 'code': Invalid value specified for parameter 'com.atlassian.confluence.ext.code.render.InvalidValueException'
REPORT ztransport_list LINE-SIZE 255 MESSAGE-ID zz.
**********************************************************************
*                    TABLES
**********************************************************************
TABLES: e071k,
        e071,
        e070,
        ska1.
**********************************************************************
*                  INTERNAL TABLES
**********************************************************************
DATA: BEGIN OF it_saknr OCCURS 0,
            saknr LIKE ska1-saknr,
      END OF it_saknr.
**********************************************************************
*                   DATA DEFINITION
**********************************************************************
DATA: v_e071k    LIKE  e071k-as4pos,
      v_e071     LIKE  e071-as4pos,
      v_tabkey1  LIKE  e071k-tabkey,
      v_tabkey2  LIKE  e071k-tabkey.
**********************************************************************
*                  SELECTION SCREEN
**********************************************************************
PARAMETER:       p_trkorr LIKE e071k-trkorr.
SELECT-OPTIONS:  p_saknr  FOR  ska1-saknr.
PARAMETER:       p_test   AS   CHECKBOX DEFAULT 'X'.
**********************************************************************
*                  AT SELECTION SCREEN
**********************************************************************
AT SELECTION-SCREEN.
* check if transport request exists
  IF p_trkorr IS INITIAL.
    MESSAGE i006(zz) WITH 'Enter an Existing Transport Request'.
  ELSE.
    SELECT SINGLE * FROM e070 WHERE trkorr EQ p_trkorr.
    IF sy-subrc EQ 0.
* to check if the transport is already released
      IF e070-trstatus EQ 'R'.
        MESSAGE i006 WITH 'Transport Request' p_trkorr 'already'
                          'released.'.
      ENDIF.
      SELECT * FROM e071 WHERE trkorr EQ p_trkorr.
      ENDSELECT.
      IF sy-subrc EQ 0.
        MESSAGE i006 WITH 'Transport rquest' p_trkorr 'is not' 'empty.'.
      ENDIF.
    ELSE.
      MESSAGE i006 WITH 'transport' 'request' p_trkorr 'does not exist.'.
    ENDIF.
  ENDIF.
* Validate GL Account
  IF p_saknr IS INITIAL.
    MESSAGE i006 WITH 'Please enter GL Account'.
  ELSE.
    SELECT * FROM ska1 WHERE saknr IN p_saknr.
      MOVE ska1-saknr TO it_saknr-saknr.
      APPEND it_saknr.
      CLEAR it_saknr.
    ENDSELECT.
    IF sy-subrc NE 0.
      MESSAGE i006 WITH 'Account number does not exist'.
    ENDIF.
  ENDIF.
**********************************************************************
*                 START OF SELECTION
**********************************************************************
START-OF-SELECTION.
  SORT it_saknr BY saknr.
  IF NOT p_test IS INITIAL.
    WRITE: / 'Test Run',/,/.
  ELSE.
    WRITE: / 'Real Run',/,/.
  ENDIF.
  WRITE: / 'G/L account  from ',p_saknr-low,' to ',p_saknr-high,/.
  CLEAR v_e071.
* Insert the values in table  E071
  WRITE: /,/ 'Entries in table E071:',/.
  v_e071 =  v_e071 + 1.
* for table SKA1
* transport task no.
  e071-trkorr = p_trkorr.
  e071-as4pos = v_e071.
  e071-pgmid  = 'R3TR'.
  e071-object = 'TABU'.
  e071-obj_name = 'SKA1'.
* object function
  e071-objfunc  = 'K'.
* Insert the data into table E071
  IF p_test IS INITIAL.
    INSERT into e071 values e071.
  ENDIF.
  WRITE: / 'E071: ', e071-trkorr, e071-pgmid, e071-object,
            e071-obj_name(40), e071-objfunc.
  v_e071 =  v_e071 + 1.
* for table SKAT
* transport task no.
  e071-trkorr = p_trkorr.
  e071-as4pos = v_e071.
  e071-pgmid  = 'R3TR'.
  e071-object = 'TABU'.
  e071-obj_name = 'SKAT'.
  e071-objfunc  = 'K'.
* Insert the data into table E071
  IF p_test IS INITIAL.
    INSERT into e071 values e071.
  ENDIF.
  WRITE: / 'E071: ',e071-trkorr, e071-pgmid, e071-object,
             e071-obj_name(40), e071-objfunc.
  WRITE: /,/ 'Entries in table E071K:',/.
  CLEAR v_e071k.
* Entries in SKA1,SKAT,
  CLEAR it_saknr.
  LOOP AT it_saknr.
    v_e071k =  v_e071k + 1.
*  Creation of the table entries for SKA1.
    MOVE '100ERC ' TO v_tabkey1.
    MOVE it_saknr-saknr TO v_tabkey1+7.
*   Entry SKA1
    e071k-trkorr = p_trkorr.
    e071k-pgmid  = 'R3TR'.
    e071k-object = 'TABU'.
    e071k-objname = 'SKA1'.
    e071k-as4pos = v_e071k.
    e071k-mastertype = 'TABU'.
    e071k-mastername = 'SKA1'.
    e071k-tabkey  = v_tabkey1.
    IF p_test IS INITIAL.
      INSERT into e071k values e071k.
    ENDIF.
*
    WRITE: / 'E071K:', e071k-trkorr, e071k-pgmid, e071k-object,
    e071k-objname, e071k-tabkey(40).
*  Creation of table entries for SKAT
    MOVE '100EERC ' TO v_tabkey2.
    MOVE it_saknr-saknr TO v_tabkey2+8.
*   Entry SKAT
    e071k-trkorr = p_trkorr.
    e071k-pgmid  = 'R3TR'.
    e071k-object = 'TABU'.
    e071k-objname = 'SKAT'.
    e071k-as4pos = v_e071k.
    e071k-mastertype = 'TABU'.
    e071k-mastername = 'SKAT'.
    e071k-tabkey  = v_tabkey2.
    IF p_test IS INITIAL.
      INSERT into e071k values e071k.
    ENDIF.
    WRITE: / 'E071K:', e071k-trkorr, e071k-pgmid, e071k-object,
    e071k-objname, e071k-tabkey(40).
    CLEAR: v_tabkey1,
           v_tabkey2.
  ENDLOOP.