Page 1 of 1

QualityStage Ruleset problem - variable

Posted: Sun May 07, 2006 5:27 pm
by Luciana
I need to store the result of a multiplication in a variable.
COPY " 3 " tmp1
COPY " 4 " tmp2
[tmp1 * tmp2] = result

Is it possible to do this in QualityStage? I verified in the documentation of the Pattern-Action Language that is possible to execute a multiplication, but I didn't find anything on this.

Can any one help me to resolve

Posted: Sun May 07, 2006 11:19 pm
by roy
Hi,
I think the docs have the language syntax.
Alas I have no access to QS at the moment and it has been a while since I last used it...

IHTH,

Re: QualityStage Ruleset problem - variable

Posted: Thu May 25, 2006 9:02 am
by Alexander
Hi,

I don't use arithmetic expression in a ruleset along time ago.

Last time I do it, i used a TBL file with the arithmethic table:
1x1 1
...
4x5 20
...
9x9 81

then put var1xvar2 in one variable and convert it using TBL file.

Posted: Thu May 25, 2006 10:32 am
by Luciana
Hi Alexander,

Thank you. Your solution is interesting, but I also need to execute sum and division.
I have a routine in basic (in DataStage) and it would like this validation in QualityStage.

Code: Select all

Function valCPF(cpf)

   Dim VetNum(11)

   numCpf = fmt(cpf,"11'0'R")
   For count = 1 to 11
      VetNum(count) = numCpf[count, 1]
   Next count

   Total1 = VetNum(1) * 10 + VetNum(2) * 9 + VetNum(3) * 8 + VetNum(4) * 7 + VetNum(5) * 6
   Total1 = Total1 + VetNum(6) * 5 + VetNum(7) * 4 + VetNum(8) * 3 + VetNum(9) * 2

   resto1 = mod(Total1,11)
   if resto1 < 2 then
      Dig1 = 0
   End
   Else
      Dig1 = 11 - resto1
   End

   if Dig1 <> VetNum(10) then
      Ans = "CPF invalid"
   End
   Else
 
      Total2 = VetNum(1) * 11 + VetNum(2) * 10 + VetNum(3) * 9 + VetNum(4) * 8 + VetNum(5) * 7
      Total2 = Total2 + VetNum(6) * 6 + VetNum(7) * 5 + VetNum(8) * 4 + VetNum(9) * 3 + Dig1 * 2

      resto2 = mod(Total2,11)
      if resto2 < 2 then
         Dig2 = 0
      End
      Else
         Dig2 = 11 - resto2
      End

      if Dig2 <> VetNum(11) then
         Ans = "CPF invalid"
      End
      Else
         Ans = "CPF valid"
      End
   End
Return(Ans)

Posted: Fri May 26, 2006 7:51 am
by Alexander
Hi,

I recgonize that function, it's to validate a checkdigit of somekind.

In QS there isn't any easy way to do it, you could use a Ruleset but will give you a lot of headache, using 2 TBL files with two arithmetic + and *.

I advise you to implement it in another language wich you could invoke from PGM operation, like perl or shellscript.

Alex

Posted: Fri May 26, 2006 3:53 pm
by ray.wurlod
I agree - that would be almost impossible in PAL. Alexander's advice to use PGM is sound.