cancel
Showing results for 
Search instead for 
Did you mean: 

Using a for-each for a CallObject

Former Member
0 Kudos

Hello everyone,

i am having trouble to get the following scenario to work:

1. SQL Call is prepared and called

2. Branch with a condition whether there is a payment related to an invoice

3. For-Each record of the resultset a cancellation will be called by using a B1Objectcall with cancellation method

The for-each is configurated like this:

/vpf:Msg/vpf:Body/vpf:Payload[@Role='C']/jdbc:ResultSet/jdbc:Row

The path is configurated like this:

/vpf:Msg/vpf:Body/vpf:Payload[./@id='atom36']/jdbc:ResultSet[./@rowCount>'0']

My problem is the preparation of the xsl-transformation to access the DocEntry of each record. This is my xml.


<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet xmlns:b1e="urn:com.sap.b1i.sim:b1event" xmlns:b1ie="urn:com.sap.b1i.sim:b1ievent" xmlns:b1im="urn:com.sap.b1i.sim:b1imessage" xmlns:bfa="urn:com.sap.b1i.bizprocessor:bizatoms" xmlns:jdbc="urn:com.sap.b1i.adapter:jdbcadapter" xmlns:rfc="urn:sap-com:document:sap:rfc:functions" xmlns:sim="urn:com.sap.b1i.sim:entity" xmlns:utils2="com.sap.b1i.bpc_tools.Utilities" xmlns:vpf="urn:com.sap.b1i.vplatform:entity" xmlns:xci="urn:com.sap.b1i.xcellerator:intdoc" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" bfa:force="" vpf:force="" jdbc:force="" rfc:force="" b1ie:force="" b1e:force="" xci:force="" sim:force="" utils2:force="" b1im:force="">

  <xsl:output method="xml" encoding="UTF-8" indent="yes"/>

  <xsl:param name="atom"/>

  <xsl:param name="sessionid"/>

  <xsl:variable name="msg" select="/vpf:Msg/vpf:Body/vpf:Payload[./@Role=&apos;S&apos;]"/>

  <xsl:variable name="msg2" select="/vpf:Msg/vpf:Body/vpf:Payload[@Role='C']/jdbc:ResultSet/jdbc:Row"/>

  <xsl:variable name="vpSender" select="/vpf:Msg/vpf:Header/vpf:Sender/@Id"/>

  <xsl:variable name="vpObject" select="/vpf:Msg/vpf:Header/vpf:Sender/@ObjId"/>

  <xsl:variable name="vpReceiver" select="/vpf:Msg/vpf:Header/vpf:ReceiverList/vpf:Receiver[./@handover=&apos;P&apos;]/@Id"/>

  <xsl:variable name="vpSysId" select="/vpf:Msg/vpf:Header/vpf:Variables/vpf:var[./@id=&apos;SysId&apos;]/@value"/>

  <xsl:template match="/">

  <Msg xmlns="urn:com.sap.b1i.vplatform:entity">

  <xsl:copy-of select="/vpf:Msg/@*"/>

  <xsl:copy-of select="/vpf:Msg/vpf:Header"/>

  <Body>

  <xsl:copy-of select="/vpf:Msg/vpf:Body/*"/>

  <Payload Role="X" id="{$atom}">

  <xsl:call-template name="transform"/>

  </Payload>

  </Body>

  </Msg>

  </xsl:template>

  <xsl:template name="transform">

  <Value xmlns="">

  <xsl:value-of select="$msg2/DocEntry"/>

  </Value>

  </xsl:template>

</xsl:stylesheet>

This is the inbound message on the path:


<Msg xmlns="urn:com.sap.b1i.vplatform:entity" MessageId="14123112452456040534C0A800138613" BeginTimeStamp="20141231124524" logmsg="0000" SubMessageId="" status="success" owntst="false" test="true">

  <Header>

  <IPO Id="INB_IQ_INTQ_ASYN_QS" tid="14123109281856033321C0A80013BACE" />

  <IPO Id="PRC_QS" tid="14123109281856033506C0A8001381B0" />

  <msglog step="Default message log" always="false" b1ifactive="true" />

  <Resumption>

  <starter ipo="/vP.0010000000.in_IQ/com.sap.b1i.vplatform.runtime/INB_IQ_INTQ_ASYN_QS/INB_IQ_INTQ_ASYN_QS.ipo/proc" />

  <restart id="processing" q="Q.PRC_QS.0010000000" s="S.sap.DRFISQueuertFIS" u="14123112231756033345C0A800139613.4" />

  </Resumption>

  <ProcStream>S.sap.DRFISQueuertFIS</ProcStream>

  <Sender Id="0010000000" ObjId="sap.DetailReportFIS" />

  <Successor Id="" Mode="" />

  <Identification Ident="Queue/Stream" IdPar="n.a." />

  <nsList>

  <ns id="b1mb" ns="http://tempuri.org/" />

  </nsList>

  <ReceiverList>

  <Receiver Id="0010000000" filter="" />

  </ReceiverList>

  <Retrieval type="Handover" />

  <Outbound type="Void" channel="VOID" />

  <vBIU Id="sap.DRFISQueue" ver="1.0.0" SId="sap.Files" filter="" phase="" />

  <Variables>

  <var id="userid" value="no_authentication" />

  <var id="username" value="no_authentication" />

  <var id="SysId" value="0010000117" />

  </Variables>

  <Properties />

  <SysTypeProperties type="B1if" offline="" snd="0010000000" rcv="receiverdummy" ssystype="B1i.20" rsystype="" />

  <LocalProperties type="B1if" biu="sap.DRFISQueue" snd="0010000000" rcv="receiverdummy" sid="sap.Files" offline="" />

  <VarProperties>

  <property call="callb1obj.bfd" atom="atom3" id="SysId" value="#0010000117" />

  <property call="callsql.bfd" atom="atom36" id="SysId" value="#0010000117" />

  </VarProperties>

  </Header>

  <Body>

  <Payload Role="T" Type="Queue" add="sap.DetailReportFIS" />

  <Payload Role="S">

  <Document xmlns="">

  <row>

  <BuchungsID>47662</BuchungsID>

  <Datum>15.12.2014</Datum>

  <VertragspartnerID>61</VertragspartnerID>

  <Firmenname>Software Integrator</Firmenname>

  <KreditorenID>K123456</KreditorenID>

  <Kreditor>Intrum Justitia AG</Kreditor>

  <ForderungsID>9015</ForderungsID>

  <Rechnungsnummer>121</Rechnungsnummer>

  <Buchungstyp>DEBTCLAIM_REVOKE</Buchungstyp>

  <Buchungstext>Forderungsruecknahme</Buchungstext>

  <Waehrung>CHF</Waehrung>

  <Nettobetrag>-7560.00</Nettobetrag>

  <MwStSatz>0</MwStSatz>

  <MwStBetrag>0</MwStBetrag>

  <Bruttobetrag>-7560.00</Bruttobetrag>

  <Verrechnungsposition>n</Verrechnungsposition>

  </row>

  </Document>

  </Payload>

  <Payload Role="X" id="atom35">

  <row xmlns="">

  <Value>SELECT T0.DocNum FROM ORCT T0 WHERE T0.Canceled ='N' AND T0.DocNum IN (SELECT T1.DocNum FROM ORCT T0 INNER JOIN RCT2 T1 ON T0.DocEntry = T1.DocEntry INNER JOIN OINV T2 ON T1.DocEntry = T2.DocNum WHERE T2.DocNum = '121')</Value>

  <Value2>Update OINV set U_sapSTORNF = '1' WHERE DocEntry = '121'</Value2>

  </row>

  </Payload>

  <Payload Role="C" id="atom36" system="0010000117" mode="single" method="Automatic detection by key word(Automatic detection by key word)" plr="4" dbtype="SQL" blockExecution="false" compatibilityMode="true" delimiter=";" sql="SELECT T0.DocNum FROM ORCT T0 WHERE T0.Canceled ='N' AND T0.DocNum IN (SELECT T1.DocNum FROM ORCT T0 INNER JOIN RCT2 T1 ON T0.DocEntry = T1.DocEntry INNER JOIN OINV T2 ON T1.DocEntry = T2.DocNum WHERE T2.DocNum = '121')" disable-output-escaping="false">

  <ResultSet xmlns="urn:com.sap.b1i.adapter:jdbcadapter" rowCount="1">

  <Row>

  <DocNum>163</DocNum>

  </Row>

  </ResultSet>

  </Payload>

  <Payload Role="C" id="atom48" status="ok" input="atom35" queue="Q.INB_IQ_INTQ_ASYN_QS.0010000000" stream="sap.DRFISQueue3" />

  <Payload Role="X" id="atom33">

  <row xmlns="">

  <Value>163</Value>

  </row>

  </Payload>

  </Body>

</Msg>

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos
Former Member
0 Kudos

Hello everyone,

THis is how my stuff looks now:

i have tried the above named solutions but i think, that as soon as i am checking the inbound parameter of the for-each it says something like that:

- <ResultSet xmlns="urn:com.sap.b1i.adapter:jdbcadapter" rowCount="1">

- <Row>

<DocNum>163</DocNum>

</Row>

</ResultSet>

While in the path i have got a such inbound parameter:

the code just shows the sql call and the X Role of atom33 where i am using the personal tag

- <Payload Role="C" id="atom36" system="0010000117" mode="single" method="Automatic detection by key word(Automatic detection by key word)" plr="4" dbtype="SQL" blockExecution="false" compatibilityMode="true" delimiter=";" sql="SELECT T0.DocNum FROM ORCT T0 WHERE T0.Canceled ='N' AND T0.DocNum IN (SELECT T1.DocNum FROM ORCT T0 INNER JOIN RCT2 T1 ON T0.DocEntry = T1.DocEntry INNER JOIN OINV T2 ON T1.DocEntry = T2.DocNum WHERE T2.DocNum = '121')" disable-output-escaping="false">

- <ResultSet xmlns="urn:com.sap.b1i.adapter:jdbcadapter" rowCount="1">

- <Row>

<DocNum>163</DocNum>

</Row>

</ResultSet>

</Payload>

<Payload Role="C" id="atom48" status="ok" input="atom35" queue="Q.INB_IQ_INTQ_ASYN_QS.0010000000" stream="sap.DRFISQueue3" />

- <Payload Role="X" id="atom33">

<DocId xmlns="">163</DocId>

</Payload>


</Body>

This is my call object configuration

This message is the Key Value:

/vpf:Msg/vpf:Body/vpf:Payload[./@Role='X' and ./@id='atom33']/DocId

This is my atom33:


<xsl:for-each select="/vpf:Msg/vpf:Body/vpf:Payload[./@Role=&apos;C&apos; and ./@id=&apos;atom36&apos;]/jdbc:ResultSet/jdbc:Row">
<DocId xmlns="">
<xsl:value-of select="jdbc:DocNum"/>
</DocId>
</xsl:for-each>

When checking the message of the join inbound it shows the following:

So it seems that at some point i am completely losing some inbound message (such as the atom33).

- <Msg xmlns="urn:com.sap.b1i.vplatform:entity">

- <Body>

- <Payload Role="X" id="atom56">

<DocId2 xmlns="" />

</Payload>

- <Payload Role="C" id="atom55" system="0010000117">

<B1CallResult status="failure" b1login="Technical User" method="Synchronous Cancel" objectid="24" payload="atom56" keyname="DocEntry" keyvalue="" />

</Payload>

</Body>

</Msg>

This is the atom56 config, which is just a tryout. Or do I use a wrong payload in my call object?

Help is greatly appreciated.

Regards Simon

bastian_schaefer
Active Contributor
0 Kudos

Hi Simon,

the graphical for-each element cuts out everything which includes /vpf:Msg/vpf:Body....

Please activate debugging and check the inbound message of your atom56.

Adjust your xpaths according to the result message structure after for-each.

Best regards

Bastian

P.S.: another option (for insert or update but not for cancellation) is to split one inbound message into several B1 outbound messages is to use with the root tag <b1im_multimsg> and the tag <b1im_msg> for each single message in final atom0.

Please check online Help for "SAP Business One Outbound".

Former Member
0 Kudos

Hello Bastian,

i have found out, that the PATH atom cuts everything besides the result of the SQL call where the rowCount is bigger than 0.



<Payload Role="C" id="atom36" system="0010000117" mode="single" method="Automatic detection by key word(Automatic detection by key word)" plr="4" dbtype="SQL" blockExecution="false" compatibilityMode="true" delimiter=";" sql="SELECT T0.DocNum FROM ORCT T0 WHERE T0.Canceled ='N' AND T0.DocNum IN (SELECT T1.DocNum FROM ORCT T0 INNER JOIN RCT2 T1 ON T0.DocEntry = T1.DocEntry INNER JOIN OINV T2 ON T1.DocEntry = T2.DocNum WHERE T2.DocNum = '121')" disable-output-escaping="false">

- <ResultSet xmlns="urn:com.sap.b1i.adapter:jdbcadapter" rowCount="2">

- <Row>

<DocNum>163</DocNum>

</Row>

- <Row>

<DocNum>164</DocNum>

</Row>

</ResultSet>

</Payload>

The path configuration:

/vpf:Msg/vpf:Body/vpf:Payload[./@id=&apos;atom36&apos;]/jdbc:ResultSet[./@rowCount>&apos;0&apos;]

which checks if there are payments related to a certain invoice (rowcount > 0). Causes the inbound message in this for-each:

- <ResultSet xmlns="urn:com.sap.b1i.adapter:jdbcadapter" rowCount="2">

- <Row>

<DocNum>163</DocNum>

</Row>

- <Row>

<DocNum>164</DocNum>

</Row>

</ResultSet>

Now cutting this with: (as Ronny Frohberg suggested)

/vpf:ResultSet/vpf:Row

again results in a message not well formed in atom56. If i am not cutting at all, the message seems to be well formed.

EDIT: Problem solved myself. jdbc instead of vpf did the trick.

Former Member
0 Kudos

Hi Simon

This message means that for-each was not able to return anything.

My suggestion: try to use your own tag(s) to wrap-up elements that need to be iterated over. In your example I'd first try to extract DocNum into my own tag in predecessing transformation atom and then iterate over my own tag:

predecessor:

<xsl:for-each select="//jdbc:ResultSet/jdbc:Row">

<myTag><xsl:value-of select="jdbc:DocNum" /></xsl:value-of></myTag>

</xsl:for-each>

Then in definition of for-each atom I'd try to use: /vpf:Msg/vpf:Body/vpf:Payload[./@Role=&apos;X&apos;]/myTag

Kind regards,

Radek

Former Member
0 Kudos

Hello Simon,

try this in your For-Each:

/vpf:ResultSet/vpf:Row

Ronny