Showing posts with label SAP. Show all posts
Showing posts with label SAP. Show all posts

Sunday, January 26, 2014

IDOC to SAP and the hierarchy is all wrong?


In SAP, have you ever come across this scenario, sending an IDOC to SAP and the hierarchy is all wrong?

I am working on the ORDERS message to SAP.

Have a look below, my E1EDP01 Segment needs to have children beneath it, E1EDP02 is a child of E1EDP01, however it does not have this… 




This is what I need to see in SAP, however they are coming all below each other…. Why ??? 

 
 
I looked at the SAP schema in BizTalk, in particular:

DATAHEADERCOLUMN_SEGNUM   - The segment number of this element.
DATAHEADERCOLUMN_HLEVEL – The Hierarchy level of the element
DATAHEADERCOLUMN_PSGNUM – The parent Segment number


Now, you can try mapping to these, however all the documents say that on the inbound iDOC these are not important…

Well the truth is, on the outbound iDOC they are fully populated, and it’s quite nice to see when SAP sends it to you.

On the inbound, these are not required, the KEY is to look at the schema of the IDOC, it’s quite crucial.

Look at my NODE, first of all in the version of the iDOC, its called E2EDP01008, in SAP based on the data structure type, its E1EDP01. 


Look at the MAX occurs, it is just once and it MUST be there, however I have quite a few repeated here….

Look at its parent, it occurs 999999 times; which is enough, underneath the parent are all of the children nodes that were also repeating.


ONE Instance of the parent is for ONE item, and all the children related to that ONE item. It’s the parent that should be looping all of the items, however quite often some of the children do repeat, within EACH item.

For these you need to use table looping, or structure you source message to handle this correctly.

You need to focus  on making the mandatory fields match up and getting the data from various places to ensure this occurs.

These are the steps I followed, and had to work out, and I managed to get it to work, it needs to be followed exactly, once done the potential is endless. 

Thursday, May 16, 2013

SAP DATA TYPES



When sending a document to SAP, or making a RFC or BAPI call you may get this error:

Microsoft.ServiceModel.Channels.Common.XmlReaderGenerationException: An error occurred when trying to convert the byte array [30-00-30-00-30-00-30-00-30-00-30-00-30-00-30-00] of RFCTYPE RFCTYPE_DATE with length 8 and decimals 0 to XML format. Parameter/field name: REF_DATE   Error message: Year, Month, and Day parameters describe an un-representable DateTime. ---> System.ArgumentOutOfRangeException: Year, Month, and Day parameters describe an un-representable DateTime.

Usually its the date field, most likely one you do not even use, and do not care about,  sadly SAP date format is different from yours, and a null date is a big no no. 

It comes down to how you generated your SAP schemas in the first place. 

 Add Generated Items/Add Adapter Meta Data/WCF-SAP 

Under the Configure Button are three tabs, set up your connection on the first two, and then there is binding properties.


Look at the metadata section, change the Enable Safe Typing to true, this will generate your schema with safe types, its a fancy way of saying that all of the types generated will be of type string, rather than of type datetime, long, int, etc...  SAP does not seem to care, it will do the conversion correctly now.

The node names do not change, just the types, so you can simply replace your current schema, keeping the same name, with the definition generated now. 

Then your problem, will go away, and SAP will once again be happy. 

AT RUN TIME: Ensure your send or receive port also has the same setting or it will not work.