Beware of double conversions in the B2B Converter Modules
Hi folks
Just a short real life story I want to share with you all, in case you too have experienced some strange behavior with conversion of messages in the SAP PI/PO B2B Add-on.
Problem
A few weeks ago, we started to see some strange behavior with our EDI messages sent to a transport forwarding company. In some cases the messages we sent to them was delivered in xml structure and not EDIFACT, which we expected.
After some thorough investigation we found out that the messages with wrong structure all have failed in SAP PO at some point.
Reason
This strange behavior was finally explained when we found out that the EdifactConversionModule step in our SFTP adapter module was actually being run through twice, when an error occurred.
As you can see in the screenshot below we have 4 steps:
..but why is it run through twice?
Well, this was caused, as the failed message was persisted after step 3 (we had set the “Store on error” for Mapping step in “Advanced Settings” of the ICO)
So then we had a persisted failed message that was already converted from XML to EDIFACT.
Now what does the adapter do when we resend the message? It sends it through all 4 steps once again. And if you know about the “EdifactConversionModule”, then you know that is converts between xml and edifact and vice versa. So the second time it runs through the steps, the message is now converted back again from edifact to xml 😕
Solution
We raised a ticket with SAP and suggested them to change the behavior to do one of these 2 things in case this issue happens:
- Restart the processing sequence with the original xml message (not the persisted edifact converted in step 3)
- Restart from step 4 as step 1-3 was completed and persisted.
Furthermore we suggested them to ad a module parameter, allowing us to control how the module is converting (e.g. always convert xml-> edifact and not the other way)
SAP said they would get back with a patch for controlling the behavior, but till then, the solution would be to remove the “Store on error” for Mapping step in “Advanced Settings” of the ICO.
Post notes
I am currently not aware if this behavior is the same with some of the other converter modules available (EANCOM, ODETTE, TRADACOM, etc). But please leave a comment if you experience this.
I Hope this will help some of you out 😉
Cheers,
Chris
Hi Chris
I'm wondering what's the reason behind using staging. Even without staging, the message is persisted in case there are any errors, which then allows you to reprocess/resend the message.
Note that unnecessary staging can impact the performance of your system due to additional overhead and execution time.
Also, you might want to check out SAP Note 1760915 Answer A11.4 for Q11 - it suggests using MODE_STORE_AND_RETURN in case of errors in module processing.
Regards
Eng Swee
Hi Eng Swee
Thanks for commenting.
Initially we set the "Store on error" as we wanted to be able to see how the message looked in case the error occurred on the mapping step. If this was default behavior even though we didn't set it, then it doesn't explain why the message is now only converted once when we restart it after errors.
I havent seen that note before, but it looks very interesting and I will look more into the MODE_STORE_AND_RETURN usage.
Thanks
Cheers,
Chris
Hi Chris
If you just want to look at how the message looked after the mapping step, you can use logging instead of staging.
Regards
Eng Swee