2 Replies Latest reply on Oct 28, 2020 8:25 PM by Shashikant Gagare

    How to remove single last byte zero from String in Informatica

    Shashikant Gagare Active Member

      Hi All,

       

      I want to remove last byte zero from given string in Informatica. Could you please assist ?

       

      Example -

       

      '1636600' needs to be converted as '163660'

      '637410' needs to be converted as '63741'

      '1903000' needs to be converted as '190300'

       

      Really appreciate the quick help !

       

      Thank you so much !!

        • 1. Re: How to remove single last byte zero from String in Informatica
          Nico Heinze Guru

          Use the LENGTH() function to get the length of the string and assign this number to a variable port v_length of type Integer.

          Then use SUBSTR( original_string, 1, v_length - 1) to get everything except the last character from your input string.

           

          If you have to explicitly check that this last character is a '0' digit (and in all other cases you need the complete string), then you can use this expression term:

            IIF( SubStr( original_string, v_length, 1) = '0', SubStr( original_string, 1, v_length - 1), original_string)

           

          This can be shortened to the following term:

              SubStr( original_string, 1, v_length - IIF( SubStr( original_string, v_length, 1) = '0', 1, 0))

           

          What does this expression mean?

          The length of the string copy is either the length less one (if the last character is a '0') or the full length of the input string (if the last character is not a '0').

           

          Regards,

          Nico

          • 2. Re: How to remove single last byte zero from String in Informatica
            Shashikant Gagare Active Member

            Above logic is working for me.Thanks alot Nico. It was really quick one !!