Skip to Content
avatar image
Former Member

Using a for-each for a CallObject

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • avatar image
    Former Member
    Jan 01, 2015 at 09:18 PM

    Hello Simon,

    try this in your For-Each:

    /vpf:ResultSet/vpf:Row

    Ronny

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jan 02, 2015 at 04:49 PM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jan 07, 2015 at 11:37 AM
    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Bastian Schaefer

      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.