cancel
Showing results for 
Search instead for 
Did you mean: 

In SAP, how to provide a table name,execute and export the data through command line

Former Member
0 Kudos

Able to launch SAP and provide tcodes, but unable to provide table name ,execute and export the table data through batch scripting(i.e through command line). Please suggest. Thanks in advance.

Below is the script i have witten:

@echo off

cd \

set /p Username= Enter username:

set /p Password= Enter password:

set /p Tcode= Enter Tcode:

set /p Database=Enter Database:

REM: cd Program Files\SAP\FrontEnd\SapGui

start sapshcut.exe -system=%Database% -client=320 -command=%Tcode% -user=%Username% -pw=%Password%

pause

Accepted Solutions (1)

Accepted Solutions (1)

stefan_schnell
Active Contributor
0 Kudos

Hello Ashok,

welcome in the SAP Community.

In my opinion your requirement should not be possible with a batch file like yours with SAPshcut.exe only. Please take a look at SAP Note 103019 - SAPShortcut: Program parameters.

start sapshcut.exe -system=%Database% -client=320 -type=Transaction -command=%Tcode% -user=%Username% -pw=%Password%

And in %Tcode% you can use at your command line this

SE16 DATABROWSE-TABLENAME=TADIR;

to open the table immediately - but not more.

Please take a look at SAP GUI Scripting. With SAP GUI Scripting you can logon to your system and download the content of a table easily - you can find an example here how to download any table you like via SAP GUI Scripting. Also you can combine SAP GUI Scripting with batch file processing.

Best regards
Stefan

Former Member
0 Kudos

Hi Stefan,

Thank you for the answer.

One question i have is, where to run the SAP GUI script, to automate exporting the tables data from SAP?

and also please give an example how to combine SAP GUI script with the batch script?

I don't have any knowledge on the SAP GUI scripting. Can you please provide a website to learn SAP GUI scripting.

Please confirm and thank you very much again for the reply.

Thanks,

Ashok

stefan_schnell
Active Contributor
0 Kudos

Hello Ashok,

thanks for your comment.

The SAP GUI Scripting runs on your frontend server where your SAP GUI for Windows is installed, because the SAP GUI Scripting API is part of it.

It is very easy to integrate SAP GUI Scripting inside a batch, try the following tiny example. At first a simple VBScript file, save it as Test.vbs:

MsgBox "Hello Ashok" 

Here now the batch file to start it:

wscript Test.vbs

That is all, now the batch file executes the VBScript and it looks like this:

A good entry point for SAP GUI Scripting is the SAP Community Wiki:

https://wiki.scn.sap.com/wiki/display/ATopics/SAP+GUI+Scripting

Look at the presentation.

Cheers
Stefan

Answers (0)