on 03-11-2019 5:40 AM
I'm working on sap b1 integration framework.My objective is to create a http restful api for posting sales order and it should return the created document number as response.I have created the scenario and it is returning the docEntry as response.but instead of this I would like to return the document number as response
Hi,
You should transform the Final atom with the required output.
You can use the Call Atom's result at the Final atom.
For example, try the below transform snippet for Final atom.
<xsl:template name="transform">
<io xmlns="urn:com.sap.b1i.bizprocessor:bizatoms" pltype="json">
<object>
<xsl:variable name="DImessage" select="/vpf:Msg/vpf:Body/vpf:Payload[./@id='CallB1']/Envelope/Header"/>
<string name="Result"><xsl:value-of select="$DImessage/ActionResult"/></string>
<string name="ActionMessage"><xsl:value-of select="$DImessage/ActionMessage"/></string>
</object>
</io>
</xsl:template>
In order to get the other details related to the created object like DocNum, you should use the response at the "Call SQL" atom and use the output of "Call SQL" atom at the Final atom.
Regards,
Bala
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Please do check my scenario here and kindly let me know my mistakes.
</vpf:Msg></xsl:template><xsl:template name="transform">
<!--place_here_your_B1_ServiceLayerEntity_Schema -->
<!--starting in the root with an object-->
<xsl:variable name="resMsg" select="/vpf:Msg/vpf:Body/vpf:Payload[./@id='atom1']/@DImsg"></xsl:variable>
<xsl:variable name="docEntry" select="$resMsg/@DImsg"></xsl:variable>
<CustomQuery>
SELECT T0.DocNum FROM ORDR T0 WHERE T0.DocEntry='162'
</CustomQuery>
<br>
inside sql object i have added
#/vpf:Msg/vpf:Body/vpf:Payload[./@id='atom4']/CustomQuery <br>
the final atom is given below.
</vpf:Msg></xsl:template><xsl:template name="transform">
<Docentry>
<xsl:value-of select="/vpf:Msg/vpf:Body/vpf:Payload[./@id='atom1']/@DImsg"></xsl:value-of>
</Docentry>
<xsl:for-each select="/vpf:Msg/vpf:Body/vpf:Payload[./@id='atom3']/jdbc:ResultSet/jdbc:Row">
<Result>
<xsl:value-of select="jdbc:DocNum"></xsl:value-of>
</Result>
</xsl:for-each>
</xsl:template>
Hi,
Alternatively, if the scenario is active, you can debug the already processed messages via Monitoring -> Message Log -> Debug
thanks for the samples..One more doubt.Please help. given below is my query.
#SELECT DocNum FROM ORDR WHERE DocEntry='$docEntry'
value of docEntry is /vpf:Msg/vpf:Body/vpf:Payload[./@id='atom1']/@DImsg .
I am getting error like 'Conversion failed when converting the varchar value '$docEntry' to data type int'.
How do I convert this to int ?? ..Please help
this is the debug output of final atom.Please have a look .
<?xml version="1.0"?>
-<Msg test="true" owntst="true" status="success" SubMessageId="" logmsg="0000" BeginTimeStamp="20190313104037" MessageId="19031310403723526265C0A823235F40" xmlns="urn:com.sap.b1i.vplatform:entity">-<Header><IPO Id="vPlatform_Test"/><Sender Id="" ObjId="sampleOrder/create"/><Receiver Id=""/>-<ReceiverList><Receiver Id="" handover="P"/></ReceiverList><Identification IdPar="n.a." Ident="RESTful"/><nsList/><vBIU Id="GNX.AddSalesOrderSample" phase="" filter="" SId="GNX.createSO" ver="1.0.0"/>-<Variables><var value="" id="userid"/><var value="" id="username"/><var value="" id="docEntry"/></Variables><Properties/><SysTypeProperties rsystype="" ssystype="" rcv="receiverdummy" snd="senderdummy" offline="" type="B1if"/><LocalProperties rcv="receiverdummy" snd="senderdummy" offline="" type="B1if" sid="GNX.createSO" biu="GNX.AddSalesOrderSample"/><VarProperties/></Header>-<Body><Payload Type="Call" Role="T"/><Payload Role="S">*** no test message specified ***</Payload>-<vpf:Payload id="atom2" Role="X" ts="2019/03/13 10:40:37" xmlns:vpf="urn:com.sap.b1i.vplatform:entity">-<Documents xmlns="">-<row><DocObjectCode>17</DocObjectCode><CardCode> MAHD16270 </CardCode><DocDueDate> 20190207 </DocDueDate><BPL_IDAssignedToInvoice> 1 </BPL_IDAssignedToInvoice><SalesPersonCode> 6 </SalesPersonCode></row></Documents>-<Document_Lines xmlns="">-<row><ItemCode> EF-NN960PAE </ItemCode><Quantity> 2 </Quantity><UnitPrice> 2583.90 </UnitPrice><DiscountPercent> 2.5 </DiscountPercent><WarehouseCode> SBM001 </WarehouseCode></row></Document_Lines></vpf:Payload><Payload status="success" id="atom1" Role="C" DImsg="197" DIresult="success" keyvalue="" keyname="DocEntry" payload="atom2" objectid="17" method="Synchronous Insert" b1login="Technical User" system="001sap0005"/>-<vpf:Payload id="atom4" Role="X" ts="2019/03/13 10:40:37" xmlns:vpf="urn:com.sap.b1i.vplatform:entity">\ <xpath xmlns="">SELECT T0.DocNum FROM ORDR T0 WHERE T0.DocEntry = 197</xpath></vpf:Payload>-<Payload id="atom3" Role="C" method="Automatic detection by key word(Automatic detection by key word)" system="001sap0005" disable-output-escaping="false" sql="/vpf:Msg/vpf:Body/vpf:Payload[./@id='atom4']/xpath" commitMode="2PC" delimiter=";" compatibilityMode="true" blockExecution="false" dbtype="SQL" plr="4" mode="single">-<SqlExceptions xmlns="urn:com.sap.b1i.adapter:jdbcadapter">-<SqlException><ErrorCode>102</ErrorCode><Message>Incorrect syntax near '/'.</Message><SqlState>S0001</SqlState></SqlException></SqlExceptions></Payload></Body></Msg>
<br>
<Payload id="atom3" Role="C" method="Automatic detection by key word(Automatic detection by key word)" system="001sap0005" disable-output-escaping="false" sql="/vpf:Msg/vpf:Body/vpf:Payload[./@id='atom4']/xpath" commitMode="2PC" delimiter=";" compatibilityMode="true" blockExecution="false" dbtype="SQL" plr="4" mode="single">-<SqlExceptions xmlns="urn:com.sap.b1i.adapter:jdbcadapter">-<SqlException><ErrorCode>102</ErrorCode><Message>Incorrect syntax near '/'.</Message><SqlState>S0001</SqlState></SqlException></SqlExceptions></Payload>
Kindly please do check this as well.I'm a newbie to integration framework.Please do check the below code and screen .
given below is the atom4 where sql statement is written.
<xsl:variable name="DIMessage" select="/vpf:Msg/vpf:Body/vpf:Payload[./@id='atom1']"></xsl:variable>
<xpath>SELECT T0.DocNum FROM ORDR T0 WHERE T0.DocEntry =
<xsl:value-of select="$DIMessage/@DImsg"></xsl:value-of>
</xpath>
and given below is the sql call object configuration
Hi Bala,
So kind of you to replying my doubts and issues.I did like as you specified.But if i'm placing a static value like 66 instead of DocEntry value it works fine..Otherwise B1DI (SLD) connection getting stopped and I need to restart the system again.Please see the screenshots below.
If I'm giving tempVal variable instead of DIMessage inside xpath.it works fine and returns the data. Otherwise B1DI (SLD) connection getting stopped and I need to restart the system again
<xsl:template name="transform">
<xsl:variable name="DIMessage" select="/vpf:Msg/vpf:Body/vpf:Payload[./@id='atom1']/@DImsg"></xsl:variable>
<xsl:variable name="tempVal" select="66"></xsl:variable>
<xpath>SELECT DocNum FROM ORDR WHERE DocEntry =
<xsl:value-of select="$DIMessage"></xsl:value-of>
</xpath>
</xsl:template>
It would be so helpful if could give me your contact details.
Hi Rajesh,
Try by selecting "SAP Business One DI Single Transaction" at Step Design!
You are welcome to contact me on my Twitter or LinkedIn (from my profile page).
Glad that it works.
Feel free to mark the correct answer and close this question.
Hi,
Following snippet works for me
<xsl:variable name="DIMessage" select="/vpf:Msg/vpf:Body/vpf:Payload[./@id='atom1']"></xsl:variable>
Select DocNum from ORDR WHERE DocEntry = <xsl:value-of select="$DIMessage/@DImsg"></xsl:value-of>
Regards,
Bala
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Payload id="atom3" Role="C" method="Automatic detection by key word(Automatic detection by key word)" system="001sap0005" disable-output-escaping="false" sql="/vpf:Msg/vpf:Body/vpf:Payload[./@id='atom4']/xpath" commitMode="2PC" delimiter=";" compatibilityMode="true" blockExecution="false" dbtype="SQL" plr="4" mode="single">-<SqlExceptions xmlns="urn:com.sap.b1i.adapter:jdbcadapter">-<SqlException><ErrorCode>102</ErrorCode><Message>Incorrect syntax near '/'.</Message><SqlState>S0001</SqlState></SqlException></SqlExceptions></Payload>
this error is getting in debug final atom
User | Count |
---|---|
89 | |
7 | |
6 | |
3 | |
3 | |
3 | |
3 | |
3 | |
3 | |
2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.