on 08-26-2014 5:04 PM
Hi Folks,
I have a specific requirement, I am trying to automate transports by using the command tp import all using a batch script.
Things are running fine but I am unable to capture the return code into a variable.
Once if I get the return code I can validate the success and failure of TR.
Please suggest a solution.
Thanks in advance.
Thanks,
Pavan
Hi
This is not easy as TP command does not set any RC.
The only way I found was to process the TP log file in order to be able to grab the RC that is only ouput to console.
But this should be done in a dirty "GOTO" loop to wait until the import is over.
Regards
Tp import [...] > "%log%" 2>&1
:TEST_RC_IMP
set rc=9999
for /f "tokens=2 delims=:" %%y in ('more %log% ^| findstr /C:"tp finished with return code"') do (set /A rc=%%y && echo OT=%%o RC=%%y )
rem wait for the tp command to end
if /I !rc! EQU 9999 goto :TEST_RC_IMP
if /I !rc! GEQ 8 (
echo Error on importing order %%o , RC=!rc! >> "%global_log%"
) ELSE (echo %%o : !rc! >> "%global_log%")
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I just grab the RC code by performing a search for a string (tp finished with return code) in the log more %log% | findstr /C:"tp finished with return code"
I used it in a "for" command to be able to extract the value of the RC that is after the ':' in the line I found. The for /f "tokens=2 delims=:" extracts the second field (tokens=2) using ':' as a separator and put it in the %y variable and then to the RC variable.
To be able to see the content the RC variable outside of the "for" loop (with !RC!) you should enable delayed expansion by the beginning of your script with the here under command
setlocal ENABLEDELAYEDEXPANSION
Thank you all,
For your valuable inputs
Thanks,
Pavan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Pavan,
1) You can divert the output of script to a log file
for eg. ./import_tr >> trout.log
2) You may check the return code from transaction code STMS
Regards,
Deepak Kori
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Pavan,
If you can write a correct algorithm to get this function then you can covert that into a batch script for this purpose. For eg. You have have to use a filter to get the return code from log files you can search a pattern and save the output in a new file. For this you can use findstr command of windows. So, it's all about replacing you algo with correct script.
Regards
Hi Pavan,
Shell script and batch script are different, where shell is rich n intensive and batch is limited. You can't always map them completely. If you know programming, write a program for doing this some supported language of your OS , OR Yves has presented a read-made script, just fine tune it and apply in your landscape.
Regards,
Divyanshu
User | Count |
---|---|
92 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.