cancel
Showing results for 
Search instead for 
Did you mean: 

Invoking SAP transaction through program

Former Member
0 Kudos

Hi,

I have a question regarding how to invoke specific SAP transaction (e.g. SM21, SM51) through program ? Are there any APIs available to do so ?

Intention is to automate the invocation of required SAP transactions.

Thanks in advance!

Thanks,

Ashish

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

I think you call using " CALL TRANSACTION " through a functional module and call remotely.

Thx,

Balki

athavanraja
Active Contributor
0 Kudos

Welcome to SDN.

from where do you want to do this?

by invoke what do you mean? just showing the transaction initial screen or processing the transaction?

Regards

Raja

Former Member
0 Kudos

let me take an example to explain this.

I want to get list of SAP app servers running in the landscape. SM51 does it thru SAPGUI. Now I want to write a program (in ABAP/script/C/Java language depending on availability of SAP API) which would give me this info programmatically.

So for eg invoking an API like char ** getAppServerList() could return me list of App servers running as a return value.

Intention is to call SAP transaction thru program (ABAP/C/Java/script)

Thanks,

Ashish

chrisp_vigelius
Explorer
0 Kudos

Hi Ashish,

a transaction is always (ok, at least in most cases) a program which has its own visualization, so you cannot read out info from a transaction directly. It is only possible to start a transaction visually in SAPGUI.

If you want to read out the information which is displayed in SM51 through a program, use the function modules "TH_WPINFO" to get a list of work processes for one server and "TH_SERVER_LIST" to get a list of servers. AFAIK there is no BAPI for this (but you can use transaction BAPI to check for yourself). The function modules I've mentioned can be called either from ABAP (if you want to write a report or transaction) or from external programs through RFC (you'll need either JCo or .NET connector; alternatively you could use RFCSDK directly from C, but that is much more difficult).

Please keep in mind that these function modules are not released officially, which means that SAP can change their signature in the future without giving notice (even if that may be somewhat unlikely in this special case).

Former Member
0 Kudos

Thanks for all the replies !

Where can I get the mapping-information on ABAP functional module for a specific SAP transaction ? For eg as Chris has mentioned TH_SERVER_LIST/TH_WPINFO modules for SM51.

I am looking for SM28, SM21, DB02 transactions.

Thanks,

Ashish

chrisp_vigelius
Explorer
0 Kudos

Hi Ashish,

unfortunately there is no generic mapping between transactions and API, and there is also no guarantee that such an API even exists in all cases.

There are two ways to get that information anyway, but both require some understanding of the WAS system and the ABAP language.

Both methods start with opening the transaction in the development workbench (SE80) (use "Workbench"->"Edit object"->"more"->"transaction").

Method 1: find out function modules in the same package

This requires only little knowledge of the ABAP language. After opening the transaction, navigate to the package the transaction is in, then press CTRLSHIFTF5, to make the object list appear in the tree on the left. In the tree, open the "Function Groups" folder and see whether there are any function modules which do what you want. Execute the function modules in question to find out what they are really doing. Problem here is, there are some rather large packages containing a lot of function modules, so searching them manually will take some time. There's also the chance that you won't find the right module because it is in another package. But more often than not, one can succeed with this method.

Method 2: analyse the code

This requires some more ABAP knowledge.

The transaction screen also lets you navigate to the source code of the transaction (often a simple report, but may also be a function module). By looking at the source, one can analyse what modules are called (some understanding of how reports are built is very useful here).

Using the second approach, one can find out that

- SM28 does not call any function module (see below)

- SM21 calls a lot of function modules

- What DB02 does, depends on the database type

So unfortunately it turns out that in the transactions you need, there is no easy-to-use API.

For SM28, you could write a function module by yourself which does the appropriate syscall to SAPICC. Should not be too hard, since you can almost c&p from the report and add the information to a table instead of WRITE. Then you can call that module via RFC.

For SM21, some deeper analysis of the reports inner workings would be necessary - sorry, but I don't have that much time right now. It may also be easier to use operating-system level functions to access that information (e.g. MMC on Windows).

For DB02, you should check out the reports which are called from the case statement, depending on your database system.

Former Member
0 Kudos

Hi Ashish,

You cannot call transactions from your program but you can call BAPI related to this transaction if any available.

Regards,

Bhavik

Former Member
0 Kudos

Where can I get information on required BAPI for required SAP transaction ? What is this SDK called ?

Thanks,

Ashish