Application Development 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: 

Bapi Task issue

former_member423024
Participant
0 Kudos

Hi Gurus,

I'm using BAPI BAPI_PO_CHANGE for chnaging PO Prices with in a Pricing Routine related to Sales Order processing...

But the Po is not getting changed until it is been declared as shown below (in background Mode).

CALL FUNCTION 'BAPI_PO_CHANGE' IN BACKGROUND TASK

EXPORTING

purchaseorder = lw_po-ebeln

poheader = lw_poheader

poheaderx = lw_poheaderx

Could any please suggest if there is any alternative to fix the above issue,I just want to call the BAPI as it is like below and it should work.

CALL FUNCTION 'BAPI_PO_CHANGE'

EXPORTING

purchaseorder = lw_po-ebeln

poheader = lw_poheader

poheaderx = lw_poheaderx

Thanks

Natasha SS.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

Try to updated/change PO data directly using Modify keyword. check the code.

loop at it_header into wa_header.

modify DATABASE_TABLE from wa_header.

commit work.

loop at it_item into wa_item where PURCHASEORDER = wa_header-PURCHASEORDER.

modify DATABASE_TABLE from wa_item.

commit work.

clear wa_item.

endloop.

clear wa_header.

endloop.

Ram.

11 REPLIES 11

Former Member
0 Kudos

Hi,

did you call BAPI_TRANSACTION_COMMIT after the change?

Best regards,

Oliver

0 Kudos

Nope.As it is some sort of Enhancement program that will trigger during sales Order Change..I didn't use the FM for commiting the Database.

Thanks

Natasha SS.

0 Kudos

Hi,

an enhancement during order update? So maybe your change is overwritten after then?

Can't you modify any variables available?

Best regards,

Oliver

0 Kudos

Hello Natasha,

As per the BAPI documentation the changes to the PO will be written to the DB only if you call 'BAPI_TRANSACTION_COMMIT'. Infact this is a good BAPI programming practice

As it is some sort of Enhancement program that will trigger during sales Order Change..I didn't use the FM for commiting the Database

Of course you should not interrupt the ongoing LUW with a COMMIT WORK.

Since you're using IN BACKGROUND TASK addition, the RFC call is registered in the system tables & is executed once the LUW is completed by a COMMIT WORK. So in your case PO gets updated when the Sales Order Change LUW is completed!

BR,

Suhas

Former Member
0 Kudos

Hi,

Try to updated/change PO data directly using Modify keyword. check the code.

loop at it_header into wa_header.

modify DATABASE_TABLE from wa_header.

commit work.

loop at it_item into wa_item where PURCHASEORDER = wa_header-PURCHASEORDER.

modify DATABASE_TABLE from wa_item.

commit work.

clear wa_item.

endloop.

clear wa_header.

endloop.

Ram.

0 Kudos

Dear All,

My issue is actually the BAPI is working only when it is been called IN BACKGROUND TASK...I need to make it work with out calling in Background Mode..

Thanks

Natasha SS.

0 Kudos

> My issue is actually the BAPI is working only when it is been called IN BACKGROUND TASK

My previous post should answer why it is working with IN BACKGROUND TASK addition!

I need to make it work with out calling in Background Mode.

Why? What is the business requirement you want to achieve?

BR,

Suhas

0 Kudos

Dear Suhas,

Great.Your are correct that it would work with an Update Function Module or in Background Mode.

But now the Problem is incase if we use "IN BACKGROUND MODE" it will be tough to capture the Messages..(TABLES

return = lt_return

)

CALL FUNCTION 'BAPI_PO_CHANGE' IN BACKGROUND TASK

EXPORTING

purchaseorder = lw_po-ebeln

poheader = lw_poheader

poheaderx = lw_poheaderx

TABLES

return = lt_return

In this case, Can you suggest how to handle it..

Thanks

Natasha SS.

0 Kudos

Hi,

you could create a new FM that get's called in background and that calls and captures BAPI_PO_CHANGE.

Question beside: which kind of enhancement do you use in po update?

Best regards,

Oliver

0 Kudos

Hi,

we can create an update FM in Background Task and call BAPI, But in that case BAPI_PO_CHANGE can not throw the messages.

now the problem is to capture the error messages even if teh BAPI is called in background Mode.

Thanks

Natasha SS.

0 Kudos

Hello,

So the idea is to start a parallel LUW & commit the changes in that disjoint LUW. A use-case for asynch RFC(aRFC)!

You can create a custom RFM to wrap the BAPI_PO_CHANGE & BAPI_TRANSACTION_COMMIT and start the custom RFM as an aRFC.

But bear in mind that an aRFC triggers a database commit in the calling program.

BR,

Suhas