Skip to Content
Author's profile photo Ishteyaque Ahmad

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

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

Assigned tags

      32 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member

      High sophisticated alternative to the vi-approach "1,$ s /^/tp pf= <...>" I used so far.

      Like this!

      Author's profile photo Sadiq Iqbal
      Sadiq Iqbal

      Hi

      ishtiyaq good work,

      Thanks

      Sadiq

      Author's profile photo Former Member
      Former Member

      Nice work with a detailed explanation Ishteyaque Ahmad

      Thanks,

      Medha

      Author's profile photo Former Member
      Former Member

      Very helpful .Although I had a different script,but this is lot simpler.Thanks for sharing.

      Author's profile photo Former Member
      Former Member

      nice and very help ful..thanks for posting..

      Author's profile photo Former Member
      Former Member

      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

      Author's profile photo Former Member
      Former Member

      Nice Script.

      How to add extension of files only need to delete from directory which are older as per age ?

      Author's profile photo Himanshu sharma
      Himanshu sharma

      Very useful doc!!!

      BR-

      Himanshu Sharma

      Author's profile photo Former Member
      Former Member

      Thanks

      Was very helpfull to create a scipt with similar functions

      Author's profile photo Former Member
      Former Member

      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

      Author's profile photo Former Member
      Former Member

      Hi,

      which shell u were in ?

      best regards

      ashish

      Author's profile photo Former Member
      Former Member

      Hi Ashish,

      I am in CSH however i tried to change the shell to bash but i ended with the db connect failed error.

      Regards,

      Veeresh K R

      Author's profile photo Ishteyaque Ahmad
      Ishteyaque Ahmad
      Blog 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.

      Author's profile photo Former Member
      Former Member

      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.

      Author's profile photo Ishteyaque Ahmad
      Ishteyaque Ahmad
      Blog Post Author

      Kunal!
      one need to remove those completed tranasports from the list give in the file:

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

      Author's profile photo Eric Poellinger
      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.

      Author's profile photo Ishteyaque Ahmad
      Ishteyaque Ahmad
      Blog 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!!!

      Author's profile photo Former Member
      Former Member

      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.

      Author's profile photo Peter Strauss
      Peter Strauss

      I wonder what the problem was. Using "import all" it should adhere to the order that the requests are added to the buffer. Maybe you ran into the problem described in this blog.

      https://blogs.sap.com/2015/03/19/transport-buffer-with-wrong-sequence-of-transports/

      Author's profile photo Former Member
      Former Member

      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

      Author's profile photo Ishteyaque Ahmad
      Ishteyaque Ahmad
      Blog Post Author

      please try with bash and see if it goes through

      Author's profile photo Former Member
      Former Member

      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

      Author's profile photo Former Member
      Former Member

      Hello,

      Has anyone here tried this script ? Was it successful ?

      Author's profile photo Ishteyaque Ahmad
      Ishteyaque Ahmad
      Blog 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.

      Author's profile photo all basis
      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

      Author's profile photo Guo Peng
      Guo Peng

      This error maybe than the file "/usr/sap/trans/transport_list.txt" not exist.Please check it.

      Author's profile photo Ishteyaque Ahmad
      Ishteyaque Ahmad
      Blog Post Author

      Please try to execute in different shell... for example type bash and press enter and try to run it again.

      Author's profile photo Glenn Simpelo
      Glenn Simpelo

      In case anyone is looking for this, using "u14" will ignore component version in your tp command 🙂

      Author's profile photo Subba Rao Are
      Subba Rao Are

      Hi Ishteyaque,

      Really nice blog.

      We have to import more than 4000 TRs to quality system and your blog hopefully helps us to achieve the same with scripts.

      But however I am not able to execute these scripts in bash or shell or csh. can you please help us out , if we are missing something.

      we get error as ./trns_add2buff.sh: Command not found.

      Regards,

      Subba

      Author's profile photo Sven Burock
      Sven Burock

      Here is a script what it does, with error handling.

      sidimport.sh --> https://github.com/trockenasche/scripts/blob/main/SAP%20Transport%20Import

      Author's profile photo Basis HSL
      Basis HSL

      Dear Ishteyaque Ahmad,

      I have tried to execute the script. but the output of the results is not generated in the log file. but facing the below error. can you guide please.

      ./tr_addtobuffer.sh: line 21: print: command not found

      The code used for the print command is below.

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

      Regards.

      L Naveen.

      Author's profile photo Juan Lee
      Juan Lee

      will this work for multiple systems?

      If i wrote code to run script in abap in DEV,  can this process move files to another system? or will it only move it to DEV systems?