cancel
Showing results for 
Search instead for 
Did you mean: 

SAP B1 Integration framework : add sales order (http restful) scenario not returning document number

SatyaDeo
Participant
0 Kudos

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

SatyaDeo
Participant
0 Kudos

I'm only able to get the DocEntry as response.What is the issue here?.I need to fetch the DocNum as well.Please help me.

Accepted Solutions (1)

Accepted Solutions (1)

kvbalakumar
Active Contributor
0 Kudos

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

SatyaDeo
Participant
0 Kudos

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>
kvbalakumar
Active Contributor
0 Kudos

Hi,

In addition, could you please provide the output of "B1 Object" atom (preferably while debug mode)?

SatyaDeo
Participant
0 Kudos

this is the b1 object

SatyaDeo
Participant
0 Kudos

whenever i debug this , this error window is showing always.

kvbalakumar
Active Contributor

Hi,

Alternatively, if the scenario is active, you can debug the already processed messages via Monitoring -> Message Log -> Debug

SatyaDeo
Participant
0 Kudos

I'm only able to get the DocEntry as response.What is the issue here?.I need to fetch the DocNum as well.Please help me.

SatyaDeo
Participant
0 Kudos

If I set the query inside sql call atom directly it gives the response.The issue is ,sql atom could not fetch the query element from the xsl atom.Please help me on this with any samples

kvbalakumar
Active Contributor

Hi,

I encourage you to check these blogs

B1if Part 1

B1if Part 2

SatyaDeo
Participant
0 Kudos

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

kvbalakumar
Active Contributor
0 Kudos

Could you please provide the output of B1 Call atom?

SatyaDeo
Participant
0 Kudos

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>
SatyaDeo
Participant
0 Kudos
<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>
kvbalakumar
Active Contributor
0 Kudos

Hi Rajesh,

Based on your Final atom output, I can guess that the configuration is not correct for SQL atom.

SatyaDeo
Participant
0 Kudos

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

kvbalakumar
Active Contributor
0 Kudos

At SQL atom definition, it is clearly highlighted in red that the SQL statement is wrong.

It is sufficient to mention the #atom4 , refer the image below

SatyaDeo
Participant
0 Kudos

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.

kvbalakumar
Active Contributor

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).

SatyaDeo
Participant
0 Kudos

thank you for the help..at last it works. : )

kvbalakumar
Active Contributor

Glad that it works.

Feel free to mark the correct answer and close this question.

Answers (1)

Answers (1)

kvbalakumar
Active Contributor
0 Kudos

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

SatyaDeo
Participant
0 Kudos
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