Skip to Content

As a part of SAP Basis life, we need to import many transports at a time, which is very crucial for the project at the same time its very boring job indeed.

Some of us take help of excel and notepad and create file to import those transports at OS level like separate line for each transport

tp import SA8K901203 <SID>  client=100 u0126  pf=/usr/sap/trans/bin/TP_DOMAIN_<SID>.PFL

tp import SA8K901205 <SID>  client=100 u0126  pf=/usr/sap/trans/bin/TP_DOMAIN_<SID>.PFL

tp import SA8K901207 <SID>  client=100 u0126  pf=/usr/sap/trans/bin/TP_DOMAIN_<SID>.PFL

This solves the purpose, but there is no fun in it. Plus lets say if you want that in case of return code 8 or other error the import should stop then above method will not going to help at all. Solution is to create a script for it in Unix. I have done thousands of transport with help of this script on Solaris and Linux, and I don’t see any reason why it should not run on other flavors like AIX, HP-UX.

Lets proceed to create script file.

Create a directory where you like, I created inside trans directory with name TrnScript. Provide read write access to <sid>adm for this directory.

Inside this directory you need to create three files.

1. /usr/sap/trans/TrnScript/transport_list.txt file, this file will contain transports list, each transport in new line, which will look like below:

$ more transport_list.txt

EC6K900076

EH4K930113

EH4K900148

SA8K901203

SA8K901225

SAPKD70243

This is a simple text file and there is no limitation on number of transports you can have a list of thousand transports and they will be processed one by one in linear sequence, the transport in top will be processed first and it will move to second line and so on in downward direction. This file will needs read access rights for <sid>adm.

Now we need a executable file to add transports in buffer, it does not matter if the transports are already there in buffer or not, below script is not going to do any harm in system, run it anyway before starting the import script file.

2. /usr/sap/trans/TrnScript/trns_add2buff.sh

$ more trns_add2buff.sh

# Start of Script file

#! This script will add transports to buffer one by one sequentially.

# The list of transport should be given in transport_list.txt file where

# each transport should be in new line.

###

TPLIST=/usr/sap/trans/TrnScript/transport_list.txt

TPSTATUS=${TPLIST}.log

for i in `cat ${TPLIST}`

do

/usr/sap/DT9/SYS/exe/uc/linuxx86_64/tp addtobuffer $i DT9 u1 pf=/usr/sap/trans/bin/TP_DOMAIN_DT9.PFL

      RC=$?

    print “`date`…Transport ${i} Status RC=${RC}” >> ${TPSTATUS}

done

# End of script file

This file should have executable rights for <sid>adm. Check this file carefully for the path mentioned for

(a) TPLIST

(b) tp

(c) DOMAIN file

When above script file will execute, it will create a log file named transport_list.txt.log at same location where transport_list.txt file is present, provided <sid>adm has write access to the directory. The log file will contain information like below

$ more transport_list.txt.log

Mon Apr 30 06:49:56 CDT 2012…Transport EC6K900076 Status RC=0

Mon Apr 30 06:49:56 CDT 2012…Transport EH4K930113 Status RC=0

Mon Apr 30 06:49:56 CDT 2012…Transport SA8K901225 Status RC=0

This log file will give you chance to check if data file and cofiles are present and readable. Also, if any of the transport is imported in system without option “Leave transport Request in Queue for Later Import” then it will add it again so the request can become transportable again. If you find any other return code than zero then correct the issue rename the log file and rerun this script file again and check log file.

If everything goes fine till here then we can go for transport import script file

3. /usr/sap/trans/TrnScript/trns_import.sh

$ more trns_import.sh

# Start of Script file

#! This script will import transports one by one sequentially.

# The list of transport should be given in transport_list.txt file where

# each transport should be in new line.

###

TPLIST=/usr/sap/trans/TrnScript/transport_list.txt

TPSTATUS=${TPLIST}.RClog

for i in `cat ${TPLIST}`

do

/usr/sap/DT9/SYS/exe/uc/linuxx86_64/tp  import $i DT9  client=100 u0126 pf=/usr/sap/trans/bin/TP_DOMAIN_DT9.PFL

      RC=$?

    print “`date`…Transport ${i} Status RC=${RC}” >> ${TPSTATUS}

    if [ “$RC” -ne 0 ] && [ “$RC” -ne 4 ]; then

    break

    fi

done

# End of script file

This script file will import transports with u0126 mode which means

0 – Leave Transport Request in Queue for Later Import

1 – Import Transport Request again

2 – Overwrite Originals

6 – Overwrite Objects in Unconfirmed Repairs

Import Option.jpg

If you want to select different option then you can adjust accordingly the number appended after “u” in script.

This file will create log file transport_list.txt.RClog which will contain the timestamp and RC of each transport.

The import of transport will stop when it will get return code other than 0 or 4

Now you can read SAP tp log and resolve the issue then you need to remove those transports which are already imported through script from file transport_list.txt and execute the script again.

If you want that in case of error too, the script should move ahead with next transport then you simply need to put # in start of these 3 lines or remove them from the script file

    if [ “$RC” -ne 0 ] && [ “$RC” -ne 4 ]; then

    break

    fi

You can also use at now or cron to schedule the script as per your need.

Hope this will be of help to some of us.

LineSeparator.jpg

My other Blogs, if you have time…

What’s new in SAP NetWeaver 7.3 – A Basis perspective Part-I

What’s new in SAP NetWeaver 7.3 – A Basis perspective Part-II

Bye bye STRUSTSSO2: New Central Certificate Administration NW7.3

Escaping tough moments of SPAM or SAINT

Multiple/Bulk transports with tp script for Unix (AIX, Solaris, HP-UX, Linux)

Holistic Basis View: BusinessObjects BI 4.0 SP 2 Installation & Configuration

How to Rename the Oracle Listener & Change Listener port for SAP

OSS1 & RFC connections SAPOSS, SAPNET_RFC, SDCC_OSS

Interrelation: SAP work process, OPS$ mechanism, oracle client & oracle shadow process

Install and configure NetWeaver PI 7.3 Decentralize Adapter part-1

Install and configure NetWeaver PI 7.3 Decentralize Adapter part-2

Holistic Basis View: BusinessObjects BI 4.0 SP 2 Installation & Configuration

List of Newly added/converted Dynamic parameter in NetWeaver 7.3

To report this post you need to login first.

28 Comments

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

  1. guo shuai

    Very helpful, I  add three command rows to delete the successful transport request number.

    # Start of Script file

    #! This script will import transports one by one sequentially.

    # The list of transport should be given in transport_list.txt file where

    # each transport should be in new line.

    ###

    TPLIST=/usr/sap/trans/TrnScript/transport_list.txt

    TPSTATUS=${TPLIST}.RClog

    for i in `cat ${TPLIST}`

    do

    /usr/sap/DT9/SYS/exe/uc/linuxx86_64/tp  import $i DT9  client=100 u0126 pf=/usr/sap/trans/bin/TP_DOMAIN_DT9.PFL

          RC=$?

        print “`date`…Transport ${i} Status RC=${RC}” >> ${TPSTATUS}

        if [ “$RC” -ne 0 ] && [ “$RC” -ne 4 ]; then

        break

        else

        ls ${TPLIST} | xargs perl -pi -e “s|${i}||g”

        echo “wq”|ex -c “g/^$/d” ${TPLIST}

        fi

    done

    # End of script file

    (0) 
  2. veeresh k r

    Hi Ahmad,

    I tried your scripts on linux but unfortunately i ended with errors as below.

    AKIOECP01:ecpadm 71> ./trns_add2buff.sh

    for: Command not found.

    do: Command not found.

    /usr/sap/ECP/SYS/exe/uc/linuxx86_64/tp: Command not found.

    RC=1: Command not found.

    RC: Undefined variable.

    Will you please able to help me on this.

    Thanks,

    Veeresh K R

    (0) 
    1. Ishteyaque Ahmad Post author

      Veeresh,

      The script should work on sh and bash

      first try to change to sh shell and execute, if it fails for db connectivity, set those db related and kernel path related envoronment variable in bash or sh.

      (0) 
  3. Kunal U Patel

    Hi Ishteyyaque,

    Very useful script…Just one question regarding the import script…In case of error, it will break the loop…but after error is corrected and we need to start from the next transport, what should be done?

    Regards,

    Kunal.

    (0) 
  4. Eric Poellinger

    Curious about your opinion on not doing imports for each individual transport, but rather creating a buffer for the set of transports you wish to import and then effectively doing an “import all” of that buffer (not the ‘big truck’ but having multiple transports selected and using the ‘little truck’). 

    Primary driver for this is the risk of relying on transport owners to order the transports perfectly.  In my experience the quasi “import all” approach will effectively pass through the transports and work on object types based on standard dependencies.

    Effectively this is accomplished via the command line for the addtobuffer, but then in STMS for the actual import (not that you could not use command line options to mark begin/end points, just keeping it simple.

    (0) 
    1. Ishteyaque Ahmad Post author

      yeah… by just adding those transports in import queue and select all of them together, then clicking the semi-loaded truck… It will definately by-pass dependency on sequence of transports.

      Definatly this will simply life!!!

      (0) 
      1. Peter Scharr

        We tested this some years ago on a ERP 6.05 platform for one of my customers and got mixed results. We had a long list of transport to be imported after EHP implementation, and used the ‘import all’ method.

        Although I didn’t expect problems, the developers stated that not all objects had the correct version in the target system, as it seemed that there were sequence problems with using ‘import all’. In the end we used a script as above to import every transport one-by-one.

        Therefore I would at least advise to test it carefully, before relying on the correct sequence using bulk import.

        (0) 
  5. Abdul Waseem Mohammed

    Hello Ishteyaque,

    i used your script but it ended up with errors. I changed from csh to sh shell and executed the script but i am getting the following error: parameter ${TPLIST} has wrong length.

    usage of command tp ADDTOBUFFER <TR> <SID> [options…]

    Could you please help me out. i have to import nearly 200 Trs

    Regards

    Abdul

    (0) 
      1. Abdul Waseem Mohammed

        Thanks ishteyaque for your response.

        As u suggested i tried in bash but still it is throwing an error but a different one

        E-TPSETTINGS could not be opened

        FYI…transdir is already set in TP profile

        (0) 
    1. Ishteyaque Ahmad Post author

      Before posting it, I have used it multiple times.

      Please try this, replace the old with new.

      ———old—————–

      # each transport should be in new line.

      ###

      TPLIST=/usr/sap/trans/TrnScript/transport_list.txt

      TPSTATUS=${TPLIST}.RClog

      ————–


      ======New=======

      # each transport should be in new line.

      ###

      TPLIST=/usr/sap/trans/TrnScript/transport_list.txt

      TPSTATUS=/usr/sap/trans/TrnScript/transport.RClog

      ===============


      We can find out which line its failing then after getting rid of that line, it will work for you as well.

      (0) 
  6. all basis

    Hello Ishteyaque Ahmad,

    Thanks for the script

    while executing the script in EHP7 netweaver 7.31 we are facing issues that

    TPLIST=/usr/sap/trans/transport_list.txt: Command not found.

    TPLIST: Undefined variable.

    Please do the needful.

    Thanks

    Prabhath

    (0) 

Leave a Reply