8 Replies Latest reply: Aug 21, 2013 5:58 AM by Avinash_Varma RSS

    Nested If Condition

    bavani

      Hi all,

       

      I'm trying to create a fairly simple multiple if condition in rtf and I can't seem to get the desired result - tried various syntax nothing worked unsure if I've got my syntax wrong. The logic is as follows:

       

      if NET_AMOUNT = 0 and MATERIAL_CODE = 'IXD IMPLEMEN' then 'IXD'

      if NET_AMOUNT = 0 and MATERIAL_CODE != 'IXD IMPLEMEN' then 'Other'

      if NET_AMOUNT != 0 then NET_AMOUNT

       

      XML looks like this:

       

      -<G_1>

      <MASTER_KEY>455570120fc043aca4fa6037e4</MASTER_KEY>

      <ITEM_NUMBER>1</ITEM_NUMBER>

      <QUANTITY>3 Unit</QUANTITY>

      <UNIT_PRICE>0</UNIT_PRICE>

      <NET_AMOUNT>0</NET_AMOUNT>

      <MATERIAL CODE>IXD IMPLEMEN</NET_AMOUNT>

      </G_1>

      -<G_1>

      <MASTER_KEY>455570120fc043aca4fa6037e4</MASTER_KEY>

      <ITEM_NUMBER>2</ITEM_NUMBER>

      <QUANTITY>4 Unit</QUANTITY>

      <UNIT_PRICE>0</UNIT_PRICE>

      <NET_AMOUNT>0</NET_AMOUNT>

      <MATERIAL CODE>PM</MATERIAL CODE>

      </G_1>

      -<G_1>

      <MASTER_KEY>455570120fc043aca4fa6037e4</MASTER_KEY>

      <ITEM_NUMBER>3</ITEM_NUMBER>

      <QUANTITY>1 Unit</QUANTITY>

      <UNIT_PRICE>3600-</UNIT_PRICE>

      <NET_AMOUNT>3600</NET_AMOUNT>

      <MATERIAL CODE>MPM</MATERIAL CODE>

      </G_1>


      Appreciate your input. Thank you.

        • 1. Re: Nested If Condition
          BIPuser

          <?if:NET_AMOUNT= 0 and MATERIAL CODE ='IXD IMPLEMEN'?>IXD<?end if?>

          <?if:NET_AMOUNT= 0 and MATERIAL CODE !='IXD IMPLEMEN'?>Other<?end if?>

          <?if:NET_AMOUNT!= 0?><?NET_AMOUNT?><?end if?>

           

          Thanks,

          Bipuser

          • 2. Re: Nested If Condition
            bavani

            Thanks I've tried that which seems to be like an easy solution but it doesn't work. The only rule that is catered to is when net_amount != 0. For columns that meet the other two conditions, the column remains null.

            • 3. Re: Nested If Condition
              bavani

              Anyone able to help me with this? Thanks

              • 4. Re: Nested If Condition
                Avinash_Varma

                did u tried using xdofx , xdoxslt

                 

                <?xdofx:if NET_AMOUNT= 0 and MATERIAL CODE ='IXD IMPLEMEN' then 'IXD' else if NET_AMOUNT= 0 and MATERIAL CODE !='IXD IMPLEMEN'  then 'Other' else if NET_AMOUNT!= 0 then NET_AMOUNT end if?>

                 

                or

                 

                <?xdoxslt:ifelse(NET_AMOUNT= 0 and MATERIAL CODE ='IXD IMPLEMEN','IXD',xdoxslt:ifelse(NET_AMOUNT= 0 and MATERIAL CODE! ='IXD IMPLEMEN', 'Other', xdoxslt:ifelse(NET_AMOUNT!= 0,NET_AMOUNT,)))?>

                 

                if it didn't work could you send me template and xml i will try.

                 

                email:datlaavinash@gmail.com

                • 5. Re: Nested If Condition
                  bavani

                  Doesn't seem to work still, I thought it's like that too, no clue what am I missing here. Or should the data type for the field set to text in rtf instead of number? i'll try that now but sent the files to you before I thought of this. Thanks.

                  • 6. Re: Nested If Condition
                    Avinash_Varma

                    i think you didn't notice it . xml tag name for MATERIAL CODE is  different in xml u posted in otn and the real xml u are using.

                     

                    OTN xml tag name is MATERIAL CODE

                     

                    REAL xml tag name is MATERIAL_TITLE

                     

                    once also check the value u kept fpr MATERIAL_TITLE ='IXD IMPLEMEN'  but real value is 'IXD Implementation' 

                     

                     

                    so we gave the code using MATERIAL CODE and condition =''IXD IMPLEMEN' based on xml and conditions u posted on otn , thats why it is not working for you.

                     

                    final nest if logic used in the template forwarded to you.

                     

                    <?xdofx:if NET_AMOUNT= 0 and MATERIAL_TITLE ='IXD Implementation'  then 'IXD' else if NET_AMOUNT= 0 and MATERIAL_TITLE !='IXD Implementation'  then 'Other' else if NET_AMOUNT!= 0 then NET_AMOUNT  end if?>

                    • 7. Re: Nested If Condition
                      bavani

                      Hi Avinash,

                       

                      Sorry for wasting your time, and mine, for using the xml WITHOUT the material code which I had in earlier. Silly me have extracted material code back in and its working fine as per your syntax. thanks alot!

                      • 8. Re: Nested If Condition
                        Avinash_Varma

                        it happens ..