Closed Tset-Noitamotua closed 7 years ago
Not all transactions use BAPIs, some more, some less. A good starting point is BAPI
transaction (/nbapi
) showing the overview of Business Objects and related BAPIs:
That's really a good starting point. As a total SAP noob I already found out how to use some of the information with PyRFC.
Business Object and BAPIs:
The details of a BAPI method reveal it's technical name which have to be used with PyRFC:
Using transaction SE37
one get further information which are needed to know how to call the desired BAPI correctly:
EDIT: A double click on technical name of BAPI (in screenshot above) has the same effect as using transaction SE37
but will drop you directly into SourceCode Tab of BAPI.
Here we see that BAPI_USER_EXISTENCE_CHECK
takes one not optional (thus mandatory) argument USERNAME
which we have to provide a value when doing a call:
When we do a call we get some response like below:
>>> mysap.call('BAPI_USER_EXISTENCE_CHECK', USERNAME='horst')
{'RETURN': {'SYSTEM': 'DESTENATION_123', 'MESSAGE_V2': '', 'ROW': 0, 'MESSAGE_V4': '', 'TYPE': 'I', 'MESSAG
E_V1': 'HORST', 'MESSAGE': 'Benutzer HORST existiert.', 'LOG_MSG_NO': '000000', 'LOG_NO': '', 'FIELD'
: '', 'PARAMETER': '', 'NUMBER': '088', 'MESSAGE_V3': '', 'ID': '01'}}
In case of BAPI_USER_EXISTENCE_CHECK
things were relatively easy.
But what about BAPIs like BAPI_SALESORDER_CREATEFROMDAT2
? The only mandatory argument it takes is ORDER_HEADER_IN
which is not represented by a single value like "horst" in case of BAPI_USER_EXISTENCE_CHECK. I gues it's some more complex data structure. But how to find out how this data structure looks like? And how would the syntax of a correct PyRFC call to such BAPI look like?
Examples are given in the documentation. How data structure looks like you may see in SE37 or, programatically, via the RFC_METADATA_GET RFC call, which you can also test locally, in SE37.
Is it possible to call a transaction like in SAP GUI e.g. VA01?
Or is a transaction like e.g. VA01 just processed by some BAPI behind the scenes of SAP GUI? If so - how to find out which BAPI(s) a transaction refers to?