Tuesday, December 2, 2008

Don't forget to surface BAPI_TRANSACTION_*!

When working with SAP and the BizTalk Adapter Pack, you've got a lot of opportunities to make mistakes -- especially when working in RFC mode, the mode that's recommended by Microsoft (and, to a certain extent, me, as it makes life easier having all your BAPIs on one object and being able to combine multiple BAPIs into one transaction). One newbie mistake is forgetting to surface BAPI_TRANSACTION_COMMIT and BAPI_TRANSACTION_ROLLBACK. Don't forget these guys! Many, if not most, BAPI functions in modern versions of SAP don't auto-commit, and you'll be left wondering why SAP said your changes were saved and documents were created but nothing shows up in your installation if you don't remember to surface and call these BAPIs as necessary. "As necessary" means checking the Messages in the returned BAPIRET2 table and looking for messages with no TYPE or a TYPE of "S" (for Success, naturally), then calling the rollback BAPI if you find some messages that don't fall into that category. Otherwise, you should call the commit BAPI.*

Oh, you're probably wondering what BAPIs and RFC mode are. Those will have to wait for another day.

* Note that SAP can generate some warnings and still succeed in performing the task. This is common when working with Sales Orders if two Customer PO Numbers (BAPISDHD1.PURCH_NO_C) are the same. Also, SAP can fail to perform a task without generating any error message; this is common when working with documents associated with the Business Object, such as SAPTexts or Order Schedules. If one of those fails to create (because of incorrect parameters or insufficient information), you won't receive any message about it at all. Otherwise, you'll receive a Success message. I'll have more on SAP's "error information" -- and those are massive sarcasm quotes -- at a later date.

No comments: