Skip to Content

Hi experts,

I’m writing this post because SAP provide only 18 message definitions for X12 version 004010, I’m talking about the following XSDs:

if you are one of those who have seen that list and you have cried, this blog is for you!

 

My first questions about this was:

  • What would happen if I created my own X12 message?
  • Would it work?

Then I started to analyze the XSDs and found a pattern, and I created my own XSD and It worked:

We are able to create any message of X12 version 004010!, so the next questions came to my head:

  • Will I need to create the X12 version 004010 messages from scratch ?
  • Where can I find the definitions?

If you look at the XSDs provided by SAP, they have thousands of definition lines, it is not an option create it from scratch, but if you have a SAP PO system with the B2B addon you have all the XSDs in other format.

After analyzing the XSDs provided by SAP PO I found a pattern,so understanding the patterns of the SAP PO XSDs and the patterns of the CPI XSDs I have created the following script to convert the SAP PO XSDs in CPI XSDs:

class test {
	static main(args) {
		def msgNumber = "920"//You have to know it!
		def docNumber = "S_F01/D_67"//You have to find it!
		def msgName = "Claimant"//You have to find it!
		//We read the input files, SAP PO XSD & CPI XSD TEMPLATE
		def PI_XSD_STRING = new File("src/PI_XSD").getText("UTF-8").replaceAll("[\n\r\t]", "")//we need a flat string
		def CPI_RESULT_XSD_STRING = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><xsd:schema xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:hci=\"http://sap.com/hci\" xmlns:ica=\"http://www.sap.com/ica/metameta_schema/metainfo\"><xsd:complexType name=\"M_XXX\"><xsd:sequence><xsd:element name=\"S_ST\"><xsd:complexType><xsd:sequence><xsd:element name=\"D_143\"><xsd:simpleType><xsd:restriction base=\"xsd:token\"><xsd:length value=\"3\"/></xsd:restriction></xsd:simpleType></xsd:element><xsd:element name=\"D_329\"><xsd:simpleType><xsd:restriction base=\"xsd:string\"><xsd:minLength value=\"4\"/><xsd:maxLength value=\"9\"/></xsd:restriction></xsd:simpleType></xsd:element></xsd:sequence></xsd:complexType></xsd:element>CONTENT<xsd:element name=\"S_SE\"><xsd:annotation><xsd:documentation>Transaction Set Trailer. To indicate the end of the transaction set and provide the count of the transmitted segments (including the beginning (ST) and ending (SE) segments) CONTROL SEGMENT</xsd:documentation></xsd:annotation><xsd:complexType><xsd:sequence><xsd:element name=\"D_96\"><xsd:annotation><xsd:documentation>SE01 | Number of Included Segments</xsd:documentation></xsd:annotation><xsd:simpleType><xsd:restriction base=\"xsd:string\"><xsd:minLength value=\"1\"/><xsd:maxLength value=\"10\"/></xsd:restriction></xsd:simpleType></xsd:element><xsd:element name=\"D_329\"><xsd:annotation><xsd:documentation>SE02 | Transaction Set Control Number</xsd:documentation></xsd:annotation><xsd:simpleType><xsd:restriction base=\"xsd:string\"><xsd:minLength value=\"4\"/><xsd:maxLength value=\"9\"/></xsd:restriction></xsd:simpleType></xsd:element></xsd:sequence></xsd:complexType></xsd:element></xsd:sequence></xsd:complexType><xsd:element name=\"M_XXX\" type=\"M_XXX\"><xsd:annotation><xsd:appinfo><hci:resourceinfo><hci:info key=\"typeSystem\" value=\"ASC-X12\"/><hci:info key=\"typeSystemVersion\" value=\"004010\"/><hci:info key=\"category\" value=\"Template\"/><hci:info key=\"rootNode\" value=\"M_XXX\"/><hci:info key=\"responsibleAgencyName\" value=\"Accredited Standards Committee X12\"/><hci:info key=\"responsibleAgencyCode\" value=\"116\"/><hci:info key=\"messageType\" value=\"XXX\"/><hci:info key=\"messageName\" value=\"MESSAGE_NAME\"/><hci:info key=\"documentNumber\" value=\"M_XXX/XPATH_TO_DOCUMENT_NUMBER\"/></hci:resourceinfo></xsd:appinfo></xsd:annotation></xsd:element></xsd:schema>"
		//We change the message number and anothers fields	
		CPI_RESULT_XSD_STRING = CPI_RESULT_XSD_STRING.replaceAll("XXX",msgNumber);
		CPI_RESULT_XSD_STRING = CPI_RESULT_XSD_STRING.replaceAll("XPATH_TO_DOCUMENT_NUMBER",docNumber);
		CPI_RESULT_XSD_STRING = CPI_RESULT_XSD_STRING.replaceAll("MESSAGE_NAME",msgName);
		//We extract the usefull content from SAP PO XSD, This begins after D_329 field and ends before S_SE segment
		def CONTENT_BEGIN_STRING = "<xsd:element name=\"D_329\"><xsd:annotation><xsd:documentation>ST02 | Transaction Set Control Number</xsd:documentation></xsd:annotation><xsd:simpleType><xsd:restriction base=\"xsd:string\"><xsd:minLength value=\"4\"/><xsd:maxLength value=\"9\"/></xsd:restriction></xsd:simpleType></xsd:element>"
		def CONTENT_END_STRING = "<xsd:element name=\"S_SE\">"	
		def CONTENT_BEGIN_INDEX_INT = PI_XSD_STRING.indexOf(CONTENT_BEGIN_STRING)+CONTENT_BEGIN_STRING.length()
		def CONTENT_END_INDEX_INT = PI_XSD_STRING.indexOf(CONTENT_END_STRING);
		def CONTENT_STRING = PI_XSD_STRING.substring(CONTENT_BEGIN_INDEX_INT, CONTENT_END_INDEX_INT)
		//We put the content extracted from SAP PO XSD into CPI XSD
		CPI_RESULT_XSD_STRING = CPI_RESULT_XSD_STRING.replaceAll("CONTENT",CONTENT_STRING)
		//We need to adjust the name of group of segments, in SAP PO those start with "L_", followed of numbers in some cases, 
		//but in CPI those start with "G_" followed of the name of the first segment inside of it
		def GROUP_SEGMENT_ID_STRING = "L_",GROUP_SEGMENT_ID_CPI_STRING = "G_",GROUP_SEGMENT_NAME_STRING = "",FIRST_SEGMENT_AFTER_GROUP_SEGMENT_BEGIN_ID_STRING = "<xsd:element name=\"S",FIRST_SEGMENT_AFTER_GROUP_SEGMENT_END_ID_STRING = "\"",FIRST_SEGMENT_AFTER_GROUP_SEGMENT_BEGIN_INDEX_INT = 0,FIRST_SEGMENT_AFTER_GROUP_SEGMENT_END_INDEX_INT = 0,FIRST_SEGMENT_AFTER_GROUP_SEGMENT_NAME_STRING = "",GROUP_SEGMENT_ID_BEGIN_INDEX_INT = CPI_RESULT_XSD_STRING.indexOf(GROUP_SEGMENT_ID_STRING)
		while( GROUP_SEGMENT_ID_BEGIN_INDEX_INT > 0){
			GROUP_SEGMENT_NAME_STRING = CPI_RESULT_XSD_STRING.substring(GROUP_SEGMENT_ID_BEGIN_INDEX_INT+GROUP_SEGMENT_ID_STRING.length(), GROUP_SEGMENT_ID_BEGIN_INDEX_INT+GROUP_SEGMENT_ID_STRING.length() + CPI_RESULT_XSD_STRING.substring(GROUP_SEGMENT_ID_BEGIN_INDEX_INT+GROUP_SEGMENT_ID_STRING.length()).indexOf(FIRST_SEGMENT_AFTER_GROUP_SEGMENT_END_ID_STRING)+ FIRST_SEGMENT_AFTER_GROUP_SEGMENT_END_ID_STRING.length()-1)
			FIRST_SEGMENT_AFTER_GROUP_SEGMENT_BEGIN_INDEX_INT = GROUP_SEGMENT_ID_BEGIN_INDEX_INT + CPI_RESULT_XSD_STRING.substring(GROUP_SEGMENT_ID_BEGIN_INDEX_INT).indexOf(FIRST_SEGMENT_AFTER_GROUP_SEGMENT_BEGIN_ID_STRING)+ FIRST_SEGMENT_AFTER_GROUP_SEGMENT_BEGIN_ID_STRING.length()
			FIRST_SEGMENT_AFTER_GROUP_SEGMENT_END_INDEX_INT = FIRST_SEGMENT_AFTER_GROUP_SEGMENT_BEGIN_INDEX_INT + CPI_RESULT_XSD_STRING.substring(FIRST_SEGMENT_AFTER_GROUP_SEGMENT_BEGIN_INDEX_INT).indexOf(FIRST_SEGMENT_AFTER_GROUP_SEGMENT_END_ID_STRING) + FIRST_SEGMENT_AFTER_GROUP_SEGMENT_END_ID_STRING.length() - 1
			FIRST_SEGMENT_AFTER_GROUP_SEGMENT_NAME_STRING = CPI_RESULT_XSD_STRING.substring(FIRST_SEGMENT_AFTER_GROUP_SEGMENT_BEGIN_INDEX_INT,FIRST_SEGMENT_AFTER_GROUP_SEGMENT_END_INDEX_INT)
			CPI_RESULT_XSD_STRING = CPI_RESULT_XSD_STRING.replaceFirst(GROUP_SEGMENT_ID_STRING+GROUP_SEGMENT_NAME_STRING, GROUP_SEGMENT_ID_CPI_STRING+FIRST_SEGMENT_AFTER_GROUP_SEGMENT_NAME_STRING )
			GROUP_SEGMENT_ID_BEGIN_INDEX_INT = CPI_RESULT_XSD_STRING.indexOf(GROUP_SEGMENT_ID_STRING)
		}
		//We write the result ;)
		new File("src/ASC-X12_"+msgNumber+"_004010.xsd").write CPI_RESULT_XSD_STRING		
	}
}

In the previous script I converted the message 920 of X12 Version 004010 from the XSD  of message 920 X12 Version 004010 downloaded from SAP PO, I think that explains itself, so I will not go into details( I’m not a Groovy guy so sorry if my code is not the best).

So I uploaded my “ASC-X12_920_004010.xsd” generated by the script to CPI and I made a simple test of a simple EDI2XML IFLOW:

 

Request:

EDI X12 Version 004010 message 920 with only the mandatory fields

ISA*01*0000000000*01*0000000000*ZZ*ABCDEFGHIJKLMNO*ZZ*123456789012345*101127*1719*U*00400*000003438*0*P*1~
GS*OW*7705551212*3111350000*20000128*0557*3317*T*004010~
ST*920*2~
F01*3*4*5*6*7~
F02~
SE*4*9~
GE*1*200031010~
IEA*1*100031010~

Response:

<?xml version="1.0" encoding="UTF-8"?><ns0:Interchange xmlns:ns0="urn:sap.com:typesystem:b2b:116:asc-x12:004010">
    <S_ISA>
        <D_I01>01</D_I01>
        <D_I02>0000000000</D_I02>
        <D_I03>01</D_I03>
        <D_I04>0000000000</D_I04>
        <D_I05_1>ZZ</D_I05_1>
        <D_I06>ABCDEFGHIJKLMNO</D_I06>
        <D_I05_2>ZZ</D_I05_2>
        <D_I07>123456789012345</D_I07>
        <D_I08>101127</D_I08>
        <D_I09>1719</D_I09>
        <D_I10>U</D_I10>
        <D_I11>00400</D_I11>
        <D_I12>000003438</D_I12>
        <D_I13>0</D_I13>
        <D_I14>P</D_I14>
        <D_I15>1</D_I15>
    </S_ISA>
    <FunctionalGroup>
        <S_GS>
            <D_479>OW</D_479>
            <D_142>7705551212</D_142>
            <D_124>3111350000</D_124>
            <D_373>20000128</D_373>
            <D_337>0557</D_337>
            <D_28>3317</D_28>
            <D_455>T</D_455>
            <D_480>004010</D_480>
        </S_GS>
        <M_920>
            <S_ST>
                <D_143>920</D_143>
                <D_329>2</D_329>
            </S_ST>
            <S_F01>
                <D_373>3</D_373>
                <D_127>4</D_127>
                <D_610>5</D_610>
                <D_140>6</D_140>
                <D_544>7</D_544>
            </S_F01>
            <G_F02/>
            <S_SE>
                <D_96>4</D_96>
                <D_329>9</D_329>
            </S_SE>
        </M_920>
        <S_GE>
            <D_97>1</D_97>
            <D_28>200031010</D_28>
        </S_GE>
    </FunctionalGroup>
    <S_IEA>
        <D_I16>1</D_I16>
        <D_I12>100031010</D_I12>
    </S_IEA>
</ns0:Interchange>

 

And the questions that does not let me sleep at night are:

  1. Why SAP has only released 18 messages for X12 Version 004010?
  2. Why have they changed the structure of it?.

The CPI consultants need the XSDs for yesterday 😉

 

Max.

To report this post you need to login first.

4 Comments

You must be Logged on to comment or reply to a post.

  1. Former Member

    Hello Max,

    many thanks for the interesting blog and the very good questions.

    We published the 18 most frequently used XSD for X12 and UN/EDIFACT together with our set of B2B capabilities at CPI in July, last year. The main purpose of this small set of XSDs was that the partners and customers can start using and testing these B2B capabilities at CPI.

    The manual provisioning of these XSD is just an interim solution, because our road-map entails the provisioning of all required B2B standard and de-facto libraries just on integration content advisor (ICA) for SAP Cloud Platfrom Integration. The new version was released on Jan 22nd, 2018 (see: https://blogs.sap.com/2018/01/19/announcement-new-integration-content-advisor-for-sap-cloud-platform-integration/).

    ICA will provide all versions, all message types, and especially all documentation per B2B standard library and you can directly use it in ICA for the specification/customization of your own structures and the specification of mappings to the corresponding customized structures.

    Please contact me, if you need more information about the ICA. I will publish further blogs, soon.

    Kind regards,

    Gunther

    (1) 
    1. Maximiliano Colman Post author

      Hi Gunther,

      Thanks for you reply, I had access to the “basic” ICA tool and I found the following problems:

      1. You have to paid for ICA
      2. You have to pad for X12
      3. The library UN/CEFACT is empty
      4. You only can use the structures in your library(predefined by SAP), means that you can not use custom structures or external WSDLs,XSDs,OData,BAPIs, etc…. to build MIGs
      5. You can not export the definitions of your library, you must build a MAG to get the XSDs, so you’re forcing us to use the tool to get them
      6. The idocs version in the library are for 1709 and we are almost in 1802, will not this cause problems?

       

      I think the tool is very usefull for scenarios where you have EDI(X12,UN/EDIFACT,UN/CEFACT) and IDOCs, but there are other types of communication nowadays in addition of IDOCs.

       

      I’ll wait for the further blogs, if I’m wrong in something, please let me know it.

       

      Kind Regards.

      Max.

      (0) 
  2. Former Member

    Hello Max,

    regarding your problems:

    1.) This is correct, ICA is a part of the enterprise edition license

    2.) This is correct, you have to pay for it all time, because the X12 content is in general not for free. This is a part of usage policy of ASC X12 use (see: http://store.x12.org/store/ip-use). You have to purchase for every X12 content/versions (http://store.x12.org/store/)

    3.) ICA should provide UN/EDIFACT, too. It has to be purchased, too. Because a partner provides the whole content.

    4.) OK – This is a completely new approach and paradigm. We are adding further features in the next takts. The definition of customer specific structures is on our roadmap.

    4.a) We will provide further libraries such as cXML, APIs, etc. soon.

    5.) The intention is that we provide all versions and the whole library of IDoc. The 1709 release is our starting point.

    Kind regards,

    Gunther

     

    (1) 
    1. Maximiliano Colman Post author

      Hi Gunther,

      From my point of view, the XSDs should be independent of ICA tool, SAP is creating an unnecessary dependence.

      I understand that the product is new, but due to the limitation that ICA has, SAP is limiting and obstructing the CPI developments that the ICA tool does not cover.

      The clearest example is to integrate a non IDOC service( ODATA,BAPI,SOAP,etc) with an X12 message not provided in the 004010 package, we are being forced to pay for ICA, pay for X12 library to only get the XSDs and not use ICA tool, since it does not cover this scenario, It does not make any sense to me,in the worst case scenarios, SAP could sell the XSDs separately.

       

      It’s just the opinion of a CPI consultant 🙂

       

      Kind Regards.

      Max.

      (0) 

Leave a Reply