on 2022 Mar 02 7:28 AM
Hello.
I'm trying to generate a document from a Draft on B1iF. I'm working on the 2.0 version. I read the documentation and found how to do this on the 1.0 version but, as I said, I'm on the 2.0 version.
My scenario is as follow:
- Expose a webservice that receives a JSON with the DocEntry of the Draft. In my case is a Purchase Invoice Draft.
- Look for this draft on the ODRF table (just to be sure that the draft exists)
- Generate the final Purchase Invoice document FROM the Draft (This is the step that I need)
- Return the final DocNum of the Purchase Invoice in the response of the webservice call.
Many Thanks for any help 🙂
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
First you need to retrieve the structure of that draft. Next, you need an atom to prepare all info, structure as follows is for DI API call based data (please check and change any IDs as per your recieved structure from this draft):
<xsl:variable name="query" select="/vpf:Msg/vpf:Body/vpf:Payload[@Role='S']/BOM/BO/AddressExtension/row"></xsl:variable>
<Envelope2 throwException="true" autoCommit="true">
<DiCall>
<Header>
<Action>add</Action>
</Header>
<Body>
<BOM>
<BO>
<AdmInfo>
<Object>13</Object>
<Version>2</Version>
</AdmInfo>
<xsl:variable name="DocEntry">
<xsl:value-of select="/vpf:Msg/vpf:Body/vpf:Payload[@Role='S']/BOM/BO/Documents/row/DocEntry"></xsl:value-of>
</xsl:variable>
<AddressExtension>
<row>
<xsl:copy-of select="$query/*"></xsl:copy-of>
</row>
</AddressExtension>
<Document_Lines>
<xsl:for-each select="/vpf:Msg/vpf:Body/vpf:Payload[@Role='S']/BOM/BO/Document_Lines/row">
<row>
<ItemCode>
<xsl:value-of select="ItemCode"></xsl:value-of>
</ItemCode>
<Quantity>
<xsl:value-of select="Quantity"></xsl:value-of>
</Quantity>
<UnitPrice>
<xsl:value-of select="Price"></xsl:value-of>
</UnitPrice>
<Currency>
<xsl:value-of select="Currency"></xsl:value-of>
</Currency>
<WarehouseCode>
<xsl:value-of select="WarehouseCode"></xsl:value-of>
</WarehouseCode>
<BaseType>
<xsl:value-of select="ObjType"></xsl:value-of>
</BaseType>
<BaseEntry>
<xsl:value-of select="DocEntry"></xsl:value-of>
</BaseEntry>
<BaseLine>
<xsl:value-of select="LineNum"></xsl:value-of>
</BaseLine>
</row>
</xsl:for-each>
</Document_Lines>
</BO>
</BOM>
</Body>
</DiCall>
</Envelope2><br>
Last step is saving the new document by using B1DI Adapter. XPath would be (assuming previous atom is "DOCprepare"):
/vpf:Msg/vpf:Body/vpf:Payload[./@id='DOCprepare']/Envelope2<br>
Please note that this might need some minor tweaking, as I took this for one of my scenarios.
BR,
Matija
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
96 | |
8 | |
6 | |
6 | |
5 | |
5 | |
5 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.