3 Replies Latest reply on Nov 30, 2017 2:34 PM by Francisco Amores

    Import Script with Amount calculation

    3355552

      Hi all,

       

       

       

       

      I have an Import script where I would like to calculate the amount(change sign) before I Import that look like below:

       

       

      def Amount_Changesign(strField, strRecord):

       

       

          if UD1[57:60] == "ABC":

              vAmt = strRecord[116:129].strip()*-1     #this does not return anything

          else:

              vAmt = strRecord[116:129].strip()          #this returns value

       

       

          return vAmt

       

       

       

       

      The calculation *-1 did not seem to work, do I need to convert the record first? I tried to put float(strRecord[116:129].strip()) * -1 but it does not seem to return anything either.

       

      My upload file is in txt format. I am using FDMEE the latest patch 210.

       

       

       

       

      What do I need to convert my vAmt to??

       

      Tx in adv!

        • 1. Re: Import Script with Amount calculation
          Francisco Amores

          Hi,

           

          I think you should replace UD1 by strRecord right?

          also use float

           

          something like this...

          def Amount_Changesign(strField, strRecord):

             

              # parse recor

              srcUd1 = strRecord[57:60]

              srcAmt = float(strRecord[116:129].strip())

              if srcUd1 == "ABC":

                  vAmt = srcAmt*-1      #this does not return anything

              else:

                  vAmt = srcAmt         #this returns value

           

              return vAmt

          • 2. Re: Import Script with Amount calculation
            3355552

            Hi Francisco,

             

            Got your idea, but apparently the one that makes the FDMEE confuse was the fact that amount extracted from SAP looks like this 210,000.00- (so the minus sign is located at the back).

             

             

            So what I did was I use the position of the "-" sign at the back, and only read the amount. S

             

             

            If it reads the "-" sign:        # the minus sign is in strRecord[128:129]

               it will take the value of the amount and multiply it with -1, but when it does not have minus sign at the back, it will literally just take the amount.       #amount is strRecord[116:128] got to be changed into float and replace the "," with ""

            else:

            take only the amount

             

             

             

            This is resolved Francisco,  thanks for the lookout !

            • 3. Re: Import Script with Amount calculation
              Francisco Amores

              Cool, please mark the thread as answered then.

               

              Regards