Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Regarding BAPI

0 Likes
1,881

Hi Experts,

i was confused with BAPI and researched so many at last i find some thing gathering all, am posting what i have gathered regarding BAPI in this post .

please correct me if am go wrong.

BAPI is RFC enabled function module to be get connected with other system either it is third party or another SAP system.

BAPI must uses update function moulde to update the database tables during commit work statement or roll back statement.

update function module are triggered when program sees the commit work statement.

based on the ubove mentioned is right, i have one doubt here.

these update function module wont allow parameters, how can the BAPI send the values to update function module to update the particular value to DB. suppose we are doing BAPI to update material description how can update FM recognize that these are the material number to update the values and these are the material description??

can any one let me know if my understanding is wrong or if it is correct let me know how the update FM knows that these are the values needs to be updated.

Thanks in advance.

Dinesh kumar

8 REPLIES 8
Read only

former_member219762
Contributor
0 Likes
1,238

Hi,

Update function module allow input parameters but not export or exceptions.So we can give parameters from BAPI to update function module.Another possibility is if bapi and update function module is in same function group then both access the global variable of function group.

Bapi is not only to update data,so it may not use update function module.

Regards,

Sreenivas.

Read only

0 Likes
1,238

Hi Rao,

Suppose let we take BAPI "BAPI_SALESDOCU_CREATEFROMDATA1" to create sales order. this will update to data base while BAPI_TRANSACTION_COMMIT. let us take this scenario.

is this use any update FM to update the database? or else any other using to update DB?

if yes, how can we come to know what is the update FM for this BAPI?

Read only

0 Likes
1,238

Hi,

Search for string IN UPDATE TASK there we can find update function module.

Regards,

Sreenivas.

Read only

Former Member
0 Likes
1,238

Hi Dinesh,

As suggested by sreenivas rao yarru,

Use of the Update Task

 

Operations that change the database must be carried out through the updating process. Otherwise, there’s a risk that both unchecked and unwanted database COMMITs are executed during the RFC call.

U can follow the below the below link to know more about BAPI.

http://help.sap.com/saphelp_46c/helpdata/EN/a5/3ec8654ac011d1894e0000e829fbbd/frameset.htm

Thanks

Vijay

Read only

former_member227140
Active Participant
0 Likes
1,238

Hi,

Few BAPIS require BAPI_TRANSACTION_COMMIT to be called in sequence with your original BAPI. for this you can follow following sequence

Go to SE37 , type your BAPI name ,in menu click on Function Module >>> Test >>> Test sequence

and Give the Main BAPI name on first line and BAPI_TRANSACTION_COMMIT on second line and then TEST the BAPI to create or update data.

2) while in some scenario its not required to commit BAP to save data /update data to databse tables.

you can simply execute BAPI enter required import / tables parameters and execute it will save the data to DB tables.

but you need do some research to check if a separate commit is required or not.

Read only

Former Member
0 Likes
1,238

Hi dinesh,

An update function module bundles all the database updates and registers itself in a LUW (logical unit of work) in a repository. As soon as it sees a transaction commit or commit work statement it does all the bundled database updates together. The updates may be stored in an internal table or other data types while in the repository.

Actually the update function modules dont need any parameters to be passed. It has all the updates that you do..for eg in your case if you do a change of material description via a transaction it stores the change in an internal table or something and make the changes to the database only after it sees the commit work statement.

For more details refer these links:

http://help.sap.com/saphelp_nw04/helpdata/en/e5/de86e135cd11d3acb00000e83539c3/content.htm

http://help.sap.com/saphelp_nw04/helpdata/en/e5/de86d835cd11d3acb00000e83539c3/content.htm

Read only

0 Likes
1,238

Hi All,

As per the above suggestions, i clear that BAPI always does not need COMMIT WORK to commit to DB.

1. so in that case simply insert or modify or update statement is enough to write our data to DB?

2.  if we are using COMMIT WORK then there is definitely be update function module which takes care of our update to DB?

going more practical.

example for scenario 1:

FM: zbapi_mm_create which is RFC enabled.

insert table mara is performed directly without commit statement.

eample for scenario 2:

FM: zbapi_mm_create which is RFC enabled.

if material is already there then through error in return else BAPI_TRANSACTION_COMMIT

inside zbapi_mm_create, we will have update FM zbapi_mm_create_update in update task.

zbapi_mm_create_update with import parameter matnr.

insert to table mara values matnr.

i have explained the above steps to create a bapi. is it correct? is it the process carried in all bapi?

i think now you clearly understood my question. and one more , why it is placed in BOR? what is the use?

Thanks in advance.

Dinesh

Read only

0 Likes
1,238

so in that case simply insert or modify or update statement is enough to write our data to DB?

<<< No need to write any statement you have to just execute the BAPI with required Import / Tables parameter , it will update /create data into database. BAPI always updates DB tables unlike BDC where in updation takes place through sequence of screens.

if we are using COMMIT WORK then there is definitely be update function module which takes care of our update to DB?

COMMIT WORK BAPI itself updates records to DB . why you need to worry what statements are written when it solves the purpose. if you really want to know just debug COMMIT WORK and know what it does.

FM: zbapi_mm_create which is RFC enabled.

insert table mara is performed directly without commit statement.

if its your own RFC enabled FM then you just need to call BAPI_MATERIAL_SAVEDATA

to create material . also this BAPI does not need COMMIT BAPI to be called in sequence to save material.

why it is placed in BOR

<< placing it in BOR makes you access this BAPI through third party applications .