cancel
Showing results for 
Search instead for 
Did you mean: 

BAPI parameters

Former Member
0 Kudos

Hi all,

It is told that we have to create a structure in order to pass input values to a BAPI, whether it is via import paramter or tables parameter.

When i tried to declare a import parameter with TYPE declaration also BAPI was generated and worked fine.

<b>Why is it necessary to create a structure to import/export values?</b>

Please throw light on the concept behind declaring the structures

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi All,

I have a doubt regarding the logic behind declaring a separate BAPI structure for import paramters and use it.

Let me explain you clearly,

Whenever we pass an import parameter(like vendor number/sales order number) to an normal function module we declare it using either like/type referring to an existing dictionary structure field. but when the number of import parameters increase we may think of creating a single structure with all and use it for simplicity.

But when it is the case with a BAPI, it is suggested that we create a structure even when we have single import parameter.

for example.

supposing that we create a normal function module to get the details of a given Vendor, then we declare the import parameter as below

VENDORNO LIKE LFA1-LIFNR

But if we observe the BAPI_VENDOR_DISPLAY, We find that declaration for the same as

<b>VENDORNO like BAPIVENDOR_ID-VENDOR_NO,

where BAPIVENDOR_ID is a separate BAPI sturcture created and assocaited only with Business object "Vendor".</b>

I tried it by declaring as for a normal FM, even then it work fine.

Now my question is,

If SAP Suggests that we have a separate structure for all import parameters starting with name BAPI and use only those fields to reference with,

what is the logic/reason behind asking so.

I had created a BAPI with paramters referring to standard database fields like

VENDORNO like LFA1-LIFNR and it is still working

I had also written interface programs using VB/ .NET to access the data from my own BAPI and standard BAPI's and both were working alike.

so anyone <b>please give me the reason/logic behind declaring a separate BAPI stuture for all the import parameters</b> to be used in a method.

Former Member
0 Kudos

Hi,

BAPI is an interface to SAP application and can be triggered from external application as well. When an external application wants pass values to parameters it has to read structures of the parameters of BAPI before the BAPI object being generated which is possible only if we declare the parameters with TYPE declarations.

Hope u got the clarity if you need any more clarification please let me know I shall give you more detailed explanation.

Regards

Savitha.

Message was edited by: savitha m

Former Member
0 Kudos

Hi,

Seems that I m not clear in asking my Question.

Let me put it this way:

In the Standard BAPI, <b>BAPI_VENDOR_DISPLAY</b> <b>which takes Vendor Number</b> as an import paramter has been delacred as <b>VENDORNO LIKE BAPIVENDOR_ID-VENDOR_NO</b> where BAPIVENDOR is a structure created explicitely for this BAPI.

Not only for this every standard BAPI paramters will have the same rule being followed.

Now my question is

<b>Why is it a structure is created to pass/get parameters to/from a BAPI?</b>

Thanks

Lakshmi

Former Member
0 Kudos

Hi Lakshmi,

If you do not create a structure, we cannot read the structure unless BAPI object being created, which is not possible when you are trying to access BAPI from other applications like JAVA and VB...So it is mandatory to define structures.

Regards

Savitha

former_member181962
Active Contributor
0 Kudos

HI,

There is no other option to declare the import/export/tables parameter other than creating a structure.

Suppose you want to create a bapi which accepts a structure with fields name(char 20) and roll number(numc 10 ).

If they are single fields then you can create with referance to char20 and num10 data types,but they must be declared as a structure.How can you declare in a bapi?

If it is a program you can delare whatever we like using data: begin of ..endof statements.

BUt how do we do that in the bapi interface parameter declaration??

We must refer a structure that is not previously there.

That means we have to create it in order to tell the system that the bapi import parameter is of so and so structure.

Hope it clarifies.

REgards,

Ravi

former_member188685
Active Contributor
0 Kudos

Hi,

if you don't want to create you can make use of existing one's. and if they are not helpful then you should create new ones.

Regards

vijay

former_member181962
Active Contributor
0 Kudos

HI Lakshmi,

Whoever told you that you have to create a struture for import /export/tables parameters might have meant that if you are <b>creating</b> a bapi/fm, then you need to create a structure.

When you <b>USE</b> a bapi, you need not create a structure but can declare a internal table/internal structure withing the program which refers to the bapi parameters' structure.

If your question is about creation of bapis, then we can explain like this.

To tell the system that the bapi accepts the parameters in a specific format we should tell the system that the parameter X is of type so and so.

This type must be defined at a global level so that it is visible to the bapi.

And moreover the tpes that are available may not be exactly what we want.

So It is always advisable to create a structure in se11 .

The concept of reusablility can be stated as another reason.

Regards,

Ravi

Former Member
0 Kudos

can we convert function module into bapi? if yes how?

Former Member
0 Kudos

Hi Suma,

Yes.

You can convert a FM to BAPI, provided:

1. It is Remotely enabled (Attributes: Remote-enabled)

2. You cannot have exceptions being returned by FM

3. any Errors/Success messages are to be returned using BAPI Return Structure (BAPIRET1/2..)

4. It is advisable to create separate structures for import and export parameters whose names start with BAPI

(although this is not compulsory but advisable)

5. Then write your code for FM

Once you are ready with FM which is remotely enabled, now

1. Goto SWO1 (business object creation) give business object name and desc, program name (a prog will be generated by SAP under this name)and application. click on next.

2. Save it under a package.(it is must else u cannot transport it)

3. Goto UTILITIES-API METHODS - ADD METHOD

4. Give the FM (remotely enabled) which u have created, click on next

5. Select the method, goto EDIT - Change release status- object type component - to be implemented

6. Select the object type, goto EDIT - Change release status- object type component - to be implemented

7. Goto SE37, give FM name select RELEASE under Functionmodule menu.

8. Again comeback to SWO1, Select the object type, goto EDIT - Change release status- object type component - to be release

9. Select the method, goto EDIT - Change release status- object type component - to be released

10. Select the object type,click on GENERATE button to generate the business object.

NOW Goto BAPI Explorer using TCODE: BAPI, goto tab alphabetical and checkout for the business object created by with given name.

Hope this will help you.

still got any doubts please refer to online documentation on HELP.SAP.COM

with regards,

Lakshmi