08-10-2011 7:33 AM
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.
08-10-2011 8:15 AM
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.
08-10-2011 7:40 AM
Hi,
did you call BAPI_TRANSACTION_COMMIT after the change?
Best regards,
Oliver
08-10-2011 7:43 AM
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.
08-10-2011 7:57 AM
Hi,
an enhancement during order update? So maybe your change is overwritten after then?
Can't you modify any variables available?
Best regards,
Oliver
08-10-2011 8:50 AM
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
08-10-2011 8:15 AM
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.
08-10-2011 8:53 AM
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.
08-10-2011 9:49 AM
> 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
08-10-2011 10:28 AM
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.
08-10-2011 10:38 AM
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
08-10-2011 11:20 AM
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.
08-10-2011 11:36 AM
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