Vous êtes sur la page 1sur 8

Finding Function Modules

Its a typical ABAPer scenario: you need to create or update SAP data and
youre fairly certain there should be a standard function module around that
data. So how do you go about finding that function module?

Most major objects have a BAPI wrapped around them. In


these cases you can call the function module behind the BAPI methods from
your ABAP program. To find the BAPI and related function modules use the
transaction code BAPI. Browse through either the hierarchical or alphabetical
list until you find the object of interest. Expand the object and you will see all
the operations available for that object. Select one of the operations and a
new window will appear with the details of that operation including (surprise!)
the function module associated with that operation.
Sometimes you get lucky and the function module has an intuitive name. In
this case, a quick search from SE37 will turn up some good possibilities. For
example, searching for *USER* finds hundreds of function modules for every
type of user-related operation you can think of.
Unfortunately, some objects do not have an associated BAPI, nor an easy-tofind function module name. Heres a method that has worked for me in these
situations:
Go to the screen whose functionality you are trying to recreate. In this
example I was looking for a function module to create a PRT. The TCode to
manually create a PRT is CF01.

Select Status from the System menu and look at the last 4 characters of the
program name in this case, CFST.

Now go to SE37 and click the function module search help. Put the 4
characters into the function group name and search.

You can also try searching for function modules (not function groups) using the
pattern *CFST* or *CF_ST* (using the characters specific to your scenario).
In this case, I was able to find a less-than-intuitively-named function module to
create PRTs.

Function Module Test Sequence


Function Module Test Sequence - By using this option we can test a number of function modules all together where first's
output is the Input for the next.
Many times we have to use BAPIs in our ABAP code or in XI/PI for some interfacing with SAP. In some BAPIs we need to
commit work. Until I was not aware of this option I used to write a piece of code and test it. But now we can test it as
follows:
Example: I am using the two BAPIs to test in sequence.
1.

BAPI_PO_CREATE1 (To Create a standard Purchase Order)

2.

BAPI_TRANSACTION_COMMIT (To Commit Work)

BAPI_PO_CREATE1 is used to create Purchase order but even after getting a success message as output we are not able
to see the Purchase Order created because the work done by this BAPI is not committed in database. That's why we have
to use BAPI_TRANSACTION_COMMIT.
Go to transaction SE37. Go to menu Function Module->Test->Test Sequences as shown:

Give the name of BAPIs BAPI_PO_CREATE1 and BAPI_TRANSACTION_COMMIT and Execute.

The BAPI_PO_CREATE test is opened. Give the Header and Item Data (Header and Item data may vary according to
configuration of your system)

Enter the Values for POHEADER

Click on the icon next to refresh or (Shift + F7) to have a better view to enter the DATA.

Enter the Values for POHEADERX


In POHEADERX you have to put 'X' for the values you entered in POHEADER

Enter the Values for POITEM

Enter the Values for POITEMX

In POITEMX you have to put 'X' for the values you entered in POITEM.
Execute the function module and check the RETURN table. If you get the success message then only the next BAPI

BAPI_TRANSACTION_COMMIT is useful.
So, once you get the success message go back. It will take you to the next function module.

Give the value 'X' for input wait and execute. Work is committed now you can check the Purchase Order created.
Go to Transaction Me23/Me23n to check Purchase order created.

Vous aimerez peut-être aussi