none
SAP Adapter: question flat file schema generation IDoc RRS feed

  • Question

  • Hello everybody,

    I wish to update the status of a successfully received INVOICE IDoc via the SYSTAT01 IDoc.

    I assume I will have to perform the following steps:

    a) Generate a flat file schema for the SYSTAT01 IDoc
    b) From this schema generate a serializable class
    c) Generate  an XML document conforming to schema a) and adding appropriate information (IDoc number, status etc) from within a construct message shape using the expression editor.
    I would do this by using class b) and serializing it.
    d) Take a send pipeline and use it with a) to transform the XML representation of the IDoc to a flat file representation I can send of the wire to SAP.

    Is the the correct way of doing this? Are there easier ways?

    Regarding a) I thought I could use the consume adapter service to generate a flat flle schema for SYSTAT01. However the
    adapter generates two files for the actual IDoc where I would expect one. Or am I missing something here?

    What I want to avoid is manually creating a flat file schema for SYSTAT01.

    Any help would be appreciated.

    Regards,

    Marco


     




    Sunday, May 10, 2009 11:31 AM

Answers

  • Hi Marco,

    Of the generated schema files, there will be a schema with "Send" root element. This is the type that you have to send to the adapter. This schema has two child nodes, idocData and guid.
    What you can do is create a new message(of the send type) in the orchestration, and use xpath queries to fill in the values, assuggested by Rohit.

    Eg:
    In a construct message shape:
    Message_1 = new System.Xml.XmlDocument();
    xpath(Message_1,"XPATH_QUERY") = "VALUE";

    Monday, May 11, 2009 3:51 PM
  • Hi Jeevitha,

    thanks for the Info. No the Idoc never arrives. I will do the trace today.

    Regards,

    Marco
    • Marked as answer by MMARZ Wednesday, May 20, 2009 10:25 PM
    Wednesday, May 20, 2009 6:35 AM

All replies

  • Hi Marco,

    I am assuming that you are using WCF based sap adapters from your previous posts.

    For sending an Idoc from BizTalk to the sap system, you dont need to create any schemas manually.
    As mentioned in your post, you can use the consume adapter service wizard to generate the schemas.
    The adapter generates schemas for Send, SendResponse(if that is what you meant by 'adapter generates two files for the actual IDoc where I would expect one') ,
    where Send schema has the actual IdocData and Guid, which will be used if the idoc has to be sent transactionally(tRFC)
    and SendResponse, is the response that we get from the adapter after sending the idoc thru a two way port.

    http://msdn.microsoft.com/en-us/library/cc185479.aspx - This msdn page has step by step info about how to send idocs to the sap system from biztalk server.

    Hope this helps.

    Thanks,
    Jeevitha

    Monday, May 11, 2009 9:06 AM
  • Hi Jeevitha,

    thank you again for answering my request.

    I have read this article. In fact I used the other article ("Receiving an IDOC") as the basis for my application.
    In this "Send IDoc" example, there is code to send a response to SAP after receiving an IDOC. I would like to use this response port to send back a status IDOC to SAP, acknowleding that the IDOC was received.

    The problem with the article you mention is that, the flat file IDOC is already there and is then imply sent to SAP. 

    I on the other hand don't have this IDOC, the SYSTAT01 Idoc, yet. I have to create it, then send it. Also I need to push some information into it. But maybe I haven't understood the article correctly.

    Again, thanks for your efforts.

    Marco

     

     

     




    Monday, May 11, 2009 1:14 PM
  • Marzoram,

    If I get you correctly,

    You said that you  want to avoid  manually creating a flat file schema for SYSTAT01, and  as the the

    adapter generates two files for the actual  IDOC, you don't know which one to use. Can you please elaborate on this?


    If you just want to set  a few  header information like IDoc number, status  etc. using Xpath querries is always a  good idea,
    as compared to deserilaizing, editing and serializing using a genrated serializable class.


    You don't need to worry about converting the  Xml to flat file representaion, the WCF-SAP adapter can do it for you.

    Just reffer to the XML IDOC section  of the link http://msdn.microsoft.com/en-us/library/cc185479.aspx (Set the Action to Send operation).
    Monday, May 11, 2009 1:49 PM
  • Hello Rohit,

    the table reads "Input XML IDoc". That is exactly my problem. Where to I get the XML document from to use the XPath queries on? That is my problem. I need the  XML representation of the IDoc, so I can then set the information and pass it through the adapter to SAP. So I need the XML document. Can I generate it out of the schema files the adaper generates?
    But I get several schema files (in this case 5) and i don't know which one to use. I don't know where to start here.

    Regards,

    Marco

    Monday, May 11, 2009 3:11 PM
  • Hi Marco,

    Of the generated schema files, there will be a schema with "Send" root element. This is the type that you have to send to the adapter. This schema has two child nodes, idocData and guid.
    What you can do is create a new message(of the send type) in the orchestration, and use xpath queries to fill in the values, assuggested by Rohit.

    Eg:
    In a construct message shape:
    Message_1 = new System.Xml.XmlDocument();
    xpath(Message_1,"XPATH_QUERY") = "VALUE";

    Monday, May 11, 2009 3:51 PM
  • Hi,

    thank you very much for the information.

    I wll check this out.

    Regards,

    Marco
    Monday, May 11, 2009 4:04 PM
  • Hi Jeevitha,

    I have another question regarding this, as I am experiencing some problems.

    If I do as you suggested:

    In a construct message shape:
    Message_1 = new System.Xml.XmlDocument();
    xpath(Message_1,"XPATH_QUERY") = "VALUE";

    Will I not simply have an empty xml document Message_1, that will not conform to the schema that I need to send an Idoc? But I need to create an instance confirming to the schema. As I mentioned above, this a completely new message that needs to be constructed, which simply acknowledges that I received the first IDoc. It is not a message I have received.

    Thanks,

    Marco











    Sunday, May 17, 2009 1:38 PM
  • You should declare the message(Message_1) to the schema type, that you are intended to send to the sap port.

    The schema type will be inherited from the XmlDocument class, and hence the assignment statement specified works.

    Thanks,
    Jeevitha

    Sunday, May 17, 2009 4:30 PM
  • Hi Jeevitha,

    I did as you said and I was able to generate the message. According to HAT it went out, but SAP never received it.
    I changed the send port from SAP WCF to a simple File port to see what was being generated and it was a correct XML representation
    of the SYSTAT01 Idoc I am trying to send. I then created a pipleline to assemble XML into a flatfile and output it to the file location again.
    It looked OK. But when I send it over the wire to SAP I get a  "data at the root level is invalid, line 1 position 11" error.
    Why root? I am sending a flatfile over the wire. Any ideas.

    Thanks,

    Marco
    Monday, May 18, 2009 4:13 PM
  • Did you find any errors/warnings in adapter's event log when SAP haven't receive the Idoc?
    Can you try to enable RfcSdkTrace and verify that there were no errors in the Rfc calls. To enable rfcsdk tracing, please refer http://msdn.microsoft.com/en-us/library/cc185518.aspx.
    The trace file will be created in the system32 folder. Specifically, you can look for the rfc IDOC_INBOUND_ASYNCHRONOUS, which is used by the adapter to send Idoc to sap.

    Are you using SendIdoc operation for sending the idoc as a flatfile? If so, then you have to either map the contents of the flatfile to the idocData node of SendIdoc or you can use the Message template feature (in WCF-Custom adapter)  to add the SendIdoc and idocData tags.

    Monday, May 18, 2009 7:16 PM
  • Hi Jeevitha,

    thanks for this info. I will check the traces.

    I have one question regarding your last statement, which I don't quite understand:

    I have generated a new Idoc message conforming to the "Send Schema" (not SendIdoc)  I generated with the consume adapter service. I did not receive it.

    So I suppose the "Input to BizTalk" is "XML IDoc" or is it "Flat-file IDOC in XML message" ? The output I want to SAP is the flatfile Idoc.

    Thanks.

    Regards,

    Marco
    Tuesday, May 19, 2009 7:42 AM
  • Sorry, if i was not clear before.. You mentioned that you got a "data at the root level invalid" error, while sending the flat file idoc, right? Which operation did you use to send that flatfile? Can you please explain a liitle more on what you have tried as part of this.

    Thanks,
    Jeevitha

    Tuesday, May 19, 2009 12:59 PM
  • Hi jeevitha,

    what I did was

    1) I used the consume adapter service to create 4 schema files to "Send" the IDoc SYSTAT01.
    2) I used the schema file SAPBinding2.xsd (which contains the Send statement and the IDoc data under a separate node) to created a message to this schema type.
    3) I populated this message with a few pieces of information. This message only acknowledges that I received an INVOIC Idoc successfully before. The receiving works without any problems after you helped me.
    4) I sent this message through the adapter to SAP. using this soap action: http://Microsoft.LobServices.Sap/2007/03/Idoc/3/SYSTAT01//700/Send
    4) As a pipline I used XMLTransmit, I also used the Passthru pipeline in a second test. Of course I want an IDoc flat file to arrive at the SAP system, not it's XML representation.

    What happened was that BizTalk sent the message without any problems or errors (HAT confirmed this).

    What I did then was

    5) I saved the IDoc I was sending to disk to see what what happening (same pipelines as in 4). I saw that I was saving an XML file. So I thought, I was making the mistake of not assembling the flatfile properly, that I was sending XML over the line to SAP and SAP was not understanding what I was sending so
    6) I created a send pipeline with a flatfile assembler set to the Send schema file Sapbinding2.xsd
    7) I used this pipeline for the SAP adapter instead of the XMLTransmit and Passthrough I had used before, hoping that I was now sending the Idoc in its flatfile representation and not as XML.
    8) That is when I got the error "data at the root level is invalid, line 1 position 11".

    I think I am not generating the flatfile representation of the Idoc correctly out of the XML representation. What I mean is,
    I think an XML idoc leaves my send port and SAP can't understand what it's about and ignores it.

    The orchestration is currently very simple. I use a one way receive port to receive the INVOIC01 IDoc. I then create the response IDoc conforming to the SYSTAT01 schemas I generated using a construct message shape and then send it out through a one way send port. I also save the received Idoc INVOIC01 to disk for troubleshooting purposes. Receiving and saving to disk works without any problems.
     
    Thank you for your help.

    Marco

    Tuesday, May 19, 2009 11:42 PM
  • Looks good.

    Just one clarification.
    When an Idoc is sent to a sap system, the adapter doesn't send a flat file in the wire. It makes a call to an RFC where the contents of the idoc is passed as parameter.
    So, you dont need to bother whether you are sending a XML idoc or a flat file idoc or a flat file idoc in xml message, as long as your input conform to the schema generated using adapter. At the end of the day, all of these are translated to a RFC call.

    Are you able to receive the SYSTAT01 idoc in the sap system? Did you get a chance to look into the trace?

    Thanks,
    Jeevitha

    Wednesday, May 20, 2009 4:14 AM
  • Hi Jeevitha,

    thanks for the Info. No the Idoc never arrives. I will do the trace today.

    Regards,

    Marco
    • Marked as answer by MMARZ Wednesday, May 20, 2009 10:25 PM
    Wednesday, May 20, 2009 6:35 AM
  • Hi Jeevitha,

    it's working. Thank you very much!

    The error was caused by the fact that I was setting some fields in the Idoc incorrectly. Why this resulted in the Idoc

    not being received by SAP I don't know. But I had a colleague from our SAP team check my settings. After the corrections

    the Idoc was received and displayed.

    Thank you again for your help and patience.

    Regards,

    Marco

    Wednesday, May 20, 2009 10:25 PM