cancel
Showing results for 
Search instead for 
Did you mean: 

Creating BAPI

Former Member
0 Kudos

Hi,

Can you please give me a detailed description with screen shots of how customized BAPI's are created and how do we trigger from SAP.Examples with the code would be good.

Thanks

Points will be awarded

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Answers (6)

Answers (6)

Former Member
0 Kudos

Check these step by step docs with screen shots.....would be helpfull...

http://www.saptechnical.com/Tutorials/BAPI/BAPIMainPage.htm

former_member193376
Active Contributor
0 Kudos

Hi

BAPI Programming guide: -

http://help.sap.com/saphelp_nw04/helpdata/en/e0/9eb2370f9cbe68e10000009b38f8cf/frameset.htm

BAPI user guide: -

http://help.sap.com/saphelp_46c/helpdata/en/7e/5e115e4a1611d1894c0000e829fbbd/frameset.htm

BAPI STEP BY STEP PROCEDURE: -

http://www.sap-img.com/abap/bapi-step-by-step-guidance.htm

Example:-

http://www.erpgenie.com/abap/bapi/example.htm

PDF download: -

https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/200dd1cc-589e-2910-98a9-bb2c48b7...

list of all bapis

http://www.planetsap.com/LIST_ALL_BAPIs.htm

for BAPI's

http://www.sappoint.com/abap/bapiintro.pdf

http://www.sappoint.com/abap/bapiprg.pdf

http://www.sappoint.com/abap/bapiactx.pdf

http://www.sappoint.com/abap/bapilst.pdf

http://www.sappoint.com/abap/bapiexer.pdf

http://service.sap.com/ale

http://service.sap.com/bapi

http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCMIDAPII/CABFAAPIINTRO.pdf

http://help.sap.com/printdocu/core/Print46c/en/data/pdf/CABFABAPIREF/CABFABAPIPG.pdf

http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCFESDE8/BCFESDE8.pdf

http://www.planetsap.com/Bapi_main_page.htm

http://www.topxml.com/sap/sap_idoc_xml.asp

http://www.sapdevelopment.co.uk/

http://www.sapdevelopment.co.uk/java/jco/bapi_jco.pdf

Example Code

U need to give the step_nr, item_nr, cond_count and cond_type so the correct conditon will be updated. If no condition exists for the given parameters, a new condition will be created.

U can find these parameters for a particular condition type in table KONV.

&----


*& Form saveTransactionJOCR

&----


text

-


--> p1 text

<-- p2 text

-


FORM saveTransactionJOCR .

data: salesdocument like BAPIVBELN-VBELN,

order_header_inx like bapisdh1x,

order_header_in like bapisdh1,

return type standard table of bapiret2 with header line,

conditions_in type standard table of bapicond with header line,

conditions_inx type standard table of bapicondx with header line,

logic_switch like BAPISDLS,

step_nr like conditions_in-cond_st_no,

item_nr like conditions_in-itm_number,

cond_count like conditions_in-cond_count,

cond_type like conditions_in-cond_type.

salesdocument = wa_order_information-VBELN.

LOGIC_SWITCH-COND_HANDL = 'X'.

order_header_inx-updateflag = 'U'.

conditions

clear conditions_in[].

clear conditions_inx[].

clear: step_nr,

item_nr,

cond_count,

cond_type.

step_nr = '710'.

item_nr = '000000'.

cond_count = '01'.

cond_type = 'ZCP2'.

CONDITIONS_IN-ITM_NUMBER = item_nr.

conditions_in-cond_st_no = step_nr.

CONDITIONS_IN-COND_COUNT = cond_count.

CONDITIONS_IN-COND_TYPE = cond_type.

CONDITIONS_IN-COND_VALUE = 666.

CONDITIONS_IN-CURRENCY = 'EUR'.

append conditions_in.

CONDITIONS_INX-ITM_NUMBER = item_nr.

conditions_inx-cond_st_no = step_nr.

CONDITIONS_INX-COND_COUNT = cond_count.

CONDITIONS_INX-COND_TYPE = cond_type.

CONDITIONS_INX-UPDATEFLAG = 'U'.

CONDITIONS_INX-COND_VALUE = 'X'.

CONDITIONS_INX-CURRENCY = 'X'.

append conditions_inx.

CALL FUNCTION 'BAPI_SALESORDER_CHANGE'

EXPORTING

SALESDOCUMENT = salesdocument

ORDER_HEADER_IN = order_header_in

ORDER_HEADER_INX = order_header_inx

LOGIC_SWITCH = logic_switch

TABLES

RETURN = return

CONDITIONS_IN = conditions_in

CONDITIONS_INX = conditions_inx

.

if return-type ne 'E'.

commit work and wait.

endif.

ENDFORM. " saveTransactionJOCR

Thanks

Saiyog

former_member193376
Active Contributor
0 Kudos

Hi

BAPI Programming guide: -

http://help.sap.com/saphelp_nw04/helpdata/en/e0/9eb2370f9cbe68e10000009b38f8cf/frameset.htm

BAPI user guide: -

http://help.sap.com/saphelp_46c/helpdata/en/7e/5e115e4a1611d1894c0000e829fbbd/frameset.htm

BAPI STEP BY STEP PROCEDURE: -

http://www.sap-img.com/abap/bapi-step-by-step-guidance.htm

Example:-

http://www.erpgenie.com/abap/bapi/example.htm

PDF download: -

https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/200dd1cc-589e-2910-98a9-bb2c48b7...

list of all bapis

http://www.planetsap.com/LIST_ALL_BAPIs.htm

for BAPI's

http://www.sappoint.com/abap/bapiintro.pdf

http://www.sappoint.com/abap/bapiprg.pdf

http://www.sappoint.com/abap/bapiactx.pdf

http://www.sappoint.com/abap/bapilst.pdf

http://www.sappoint.com/abap/bapiexer.pdf

http://service.sap.com/ale

http://service.sap.com/bapi

http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCMIDAPII/CABFAAPIINTRO.pdf

http://help.sap.com/printdocu/core/Print46c/en/data/pdf/CABFABAPIREF/CABFABAPIPG.pdf

http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCFESDE8/BCFESDE8.pdf

http://www.planetsap.com/Bapi_main_page.htm

http://www.topxml.com/sap/sap_idoc_xml.asp

http://www.sapdevelopment.co.uk/

http://www.sapdevelopment.co.uk/java/jco/bapi_jco.pdf

Example Code

U need to give the step_nr, item_nr, cond_count and cond_type so the correct conditon will be updated. If no condition exists for the given parameters, a new condition will be created.

U can find these parameters for a particular condition type in table KONV.

&----


*& Form saveTransactionJOCR

&----


text

-


--> p1 text

<-- p2 text

-


FORM saveTransactionJOCR .

data: salesdocument like BAPIVBELN-VBELN,

order_header_inx like bapisdh1x,

order_header_in like bapisdh1,

return type standard table of bapiret2 with header line,

conditions_in type standard table of bapicond with header line,

conditions_inx type standard table of bapicondx with header line,

logic_switch like BAPISDLS,

step_nr like conditions_in-cond_st_no,

item_nr like conditions_in-itm_number,

cond_count like conditions_in-cond_count,

cond_type like conditions_in-cond_type.

salesdocument = wa_order_information-VBELN.

LOGIC_SWITCH-COND_HANDL = 'X'.

order_header_inx-updateflag = 'U'.

conditions

clear conditions_in[].

clear conditions_inx[].

clear: step_nr,

item_nr,

cond_count,

cond_type.

step_nr = '710'.

item_nr = '000000'.

cond_count = '01'.

cond_type = 'ZCP2'.

CONDITIONS_IN-ITM_NUMBER = item_nr.

conditions_in-cond_st_no = step_nr.

CONDITIONS_IN-COND_COUNT = cond_count.

CONDITIONS_IN-COND_TYPE = cond_type.

CONDITIONS_IN-COND_VALUE = 666.

CONDITIONS_IN-CURRENCY = 'EUR'.

append conditions_in.

CONDITIONS_INX-ITM_NUMBER = item_nr.

conditions_inx-cond_st_no = step_nr.

CONDITIONS_INX-COND_COUNT = cond_count.

CONDITIONS_INX-COND_TYPE = cond_type.

CONDITIONS_INX-UPDATEFLAG = 'U'.

CONDITIONS_INX-COND_VALUE = 'X'.

CONDITIONS_INX-CURRENCY = 'X'.

append conditions_inx.

CALL FUNCTION 'BAPI_SALESORDER_CHANGE'

EXPORTING

SALESDOCUMENT = salesdocument

ORDER_HEADER_IN = order_header_in

ORDER_HEADER_INX = order_header_inx

LOGIC_SWITCH = logic_switch

TABLES

RETURN = return

CONDITIONS_IN = conditions_in

CONDITIONS_INX = conditions_inx

.

if return-type ne 'E'.

commit work and wait.

endif.

ENDFORM. " saveTransactionJOCR

Thanks

Saiyog

vijay_b4
Active Contributor
0 Kudos

Hi,

Check this link for Creating BAPI:

http://help.sap.com/saphelp_nw04/helpdata/en/8b/40aeefc95c11d1ad0c080009b0fb56/frameset.htm

Reward points if this helps

Regards

Vani.

former_member556603
Active Contributor
0 Kudos

Hi,

Follow these steps..

Go to the T: code SE37

First You Create Function Group

On That u specify

Function Group Name..............

Short Text..............................

save...

Go to SE 37

Specify the Function Module Name: Eg: Z_Bapi_Materialmaster

Short Text.......

Save...

Next Go to Attributes..

Select Radio button : Remote enabled model

Go to Parameters..

Click Import...

Give Parameter Type Associate type S.t

next Click Export...

Give Parameter Type Associate type S.t

Next Click Tables Button..

Specify tables..

Next click source code button..

Write Source code here..

Eg : Select statements Etc..

Finally we should be select the Radio button Enable remorely

https://www.sdn.sap.com/irj/sdn/wiki?path=/pages/viewpage.action?pageId=39728

https://www.sdn.sap.com/irj/sdn/wiki?path=/display/abap/bapi%2bstep%2bby%2bstep

Hope this information is useful to you..

Satya

GabrielSagaya
Active Contributor
0 Kudos

These are the different steps in BAPI.

1 Create BAPI Structure

2 Create BAPI Function Module or API Method.

3 Create BAPI object

4 Release BAPI Function Module.

5 Release BAPI object.

Step1. Creating BAPI Structure:

Go to <SE11>.

Select Data Type & Enter a name.

Click on Create.

Note: Always BAPI should be in a development class with request number (Not Local Object).

Select Structure & hit ENTER.

Enter the fields from your database. Make sure that the first field is the Primary Key Field.

Then SAVE & ACTIVATE.

Step 2. Creating BAPI module:

Enter TR.CODE <SE37>.

Before entering any thing, from the present screen that you are in, select the menu

Goto -> Function Groups -> Create Group.

Enter a name (Note: This name Must start with ZBAPI)

Let this screen be as it is and open another window and there, enter TR.CODE <SE80).

Click on the Third ICON that says Inactive Objects.

Select the group that you just created and click on Activate.

Notice that the group you created will disappear from the list of inactive objects.

Go back to ><SE37> screen and enter a name and hit <ENTER>. Then enter the group name that you just created and activated.

NOTE: When you release a function module the respective group will be attached to that particular application. It cannot be used for any other application. NEVER include an already existing group that is attached to another module.

Now click on the first Tab that says ATTRIBUTES and select the radio button that says remote-enabled module since we will be accessing this from any external system.

Then click on the second tab that says IMPORT.

Enter a PARAMETER NAME, TYPE and the structure you created in the first step. Also select the check box ‘Pa’. All remotely enabled functional modules MUST be Pa enabled, where Pa means ‘Passed by Value’ and if you don’t select ‘Pa’, then that means it will be passed by reference..

Then click on tab that says EXPORT.

Enter the following as is in the first three fields

RETURN TYPE BAPIRETURN (These 3 field values are always same)

Here also select ‘Pa’ meaning Pass by value.

Note: BAPIRETURN contains structure with message fields.

Then SAVE and ACTIVATE.

Step 3. Creating BAPI object: - Enter Tr.Code <SWO1> (Note. It is letter ‘O’ and not Zero).

Enter a name and then click on create. Enter details.

NOTE: Make sure that that Object Type and Program name are SAME.

Enter Application ‘M’, if you are using standard table Mara. If you are using your own database then select ‘Z’ at the bottom.

Then hit <ENTER>.

Now we have to add ‘Methods’. High light METHODS and then select the following from the menu:

Goto Utilities -> API Methods -> Add Methods.

Enter function Module name and hit <ENTER>.

Select the second FORWARD ARROW button (>)to go to next step.

Check if every thing looks ok and again click on FORWARD ARROW button (>).

Then select ‘YES’ and click on <SAVE>.

Now on a different screen goto TR.CODE <SE37>. Enter Function Module name and select from the top menu Function Module -> Release -> Release.

Goback to TR.CODE <SWO1>.

Here select the menu combination shown below in the same order.

Edit -> Change Release Status -> Object Type Component -> To Implemented.

Edit -> Change Release Status -> Object Type Component -> To Released.

Edit -> Change Release Status -> Object Type -> To Implemented.

Edit -> Change Release Status -> Object Type -> To Released.

Then click on <SAVE>.

Then click on Generate Button (4th button from left hand side looks like spinning wheel).

Then Click on the button that says ‘PROGRAM’ to see the source code.

To check if this is present in work flow goto TR.CODE <BAPI>.

Here it shows business object repository.

First click on the middle button and then select “ALL” and hit ENTER.

Goto tab ALPHABETICAL and look for the object that you created. This shows that the BAPI object has been created successfully

BAPI step by step example

http://www.erpgenie.com/abap/bapi/example.htm

BAPI Step by step Guidance

http://www.sap-img.com/abap/bapi-step-by-step-guidance.htm