Skip to Content
0
Former Member
Dec 03, 2008 at 11:32 PM

How to add condition in Simple Transformation

1533 Views

Hi Experts,

I am passing internal table data to XML using Simple Transformation, below is my code:

(I need to add a condition in bold code)

<?sap.transform simple?>
<tt:transform xmlns:tt="http://www.sap.com/transformation-templates">

  <tt:root name="RT_BARCODE"/>
  <tt:root name="RT_PAYMENT"/>
  <tt:root name="RT_SCREEN"/>
  <tt:root name="RT_PROMPT"/>
  <tt:root name="RT_AGENCY"/>
  <tt:template>
    <trandef>
      <tt:loop ref=".RT_AGENCY">
        <tt:attribute name="name" value-ref="AGENCYNAME"/>
        <tt:attribute name="logo" value-ref="LOGO"/>
      </tt:loop>
      <barcode>
        <tt:loop ref=".RT_BARCODE">
          <field>
            <tt:attribute name="name" value-ref="FLD_NAME"/>
            <tt:attribute name="from" value-ref="FROM"/>
            <tt:attribute name="to" value-ref="TO"/>
          </field>
        </tt:loop>
      </barcode>
      <paymentmethods>
        <tt:loop ref=".RT_PAYMENT">
          <paymentmethod>
            <tt:attribute name="text" value-ref="PAYMENTMETHOD"/>
            <tt:attribute name="image" value-ref="PAYIMAGE"/>
            <tt:attribute name="surchargetype" value-ref="SURTYPE"/>
            <tt:attribute name="surchargevalue" value-ref="SURVALUE"/>
          </paymentmethod>
        </tt:loop>
      </paymentmethods>
      <screens>
        *<tt:loop name="S" ref=".RT_SCREEN">*
          <screen>
             *<tt:loop name="P" ref=".RT_PROMPT">*
              <prompt>
                <tt:attribute name="name" value-ref="$P.FLD_NAME"/>
                <tt:attribute name="caption" value-ref="$P.CAPTION"/>
                <tt:attribute name="type" value-ref="$P.TYPE"/>
                <tt:attribute name="instruction" value-ref="$P.INSTRUCTION"/>
                <tt:attribute name="formattype" value-ref="$P.FMTYPE"/>
                <tt:attribute name="formatstring" value-ref="$P.FMSTRING"/>
                <tt:attribute name="maxlength" value-ref="$P.MAXLENGTH"/>
              </prompt>
            </tt:loop>
          </screen>
        </tt:loop>
      </screens>
    </trandef>
  </tt:template>

I am able to get the result which is good.

I have .RT_PROMPT table loop within .RT_SCREEN table loop, both the table have a common field SCREENNAME which I need to compare.

I only want to generate <prompt> if RT_PROMPT-SCREENNAME = .RT_SCREEN-SCREENNAME.

Can any one help me please.

Thanks & Regards,

Abhinav

Edited by: Abhinav Tayal on Dec 4, 2008 10:33 AM

Edited by: Abhinav Tayal on Dec 4, 2008 10:35 AM