3 Replies Latest reply: Feb 13, 2012 4:34 AM by Schneyinck RSS

    How not to replace the variable

      e.g. I have two script lines:

      ....;

      set fSel_1=(COEP.GJAHR='$(vYr_1)' AND COEP.VERSN='$(vVersion_1)' AND COEP.WRTTP='01');

      set fPlanJahr =Sum (if($(fSel_1),COEP.WKGBTR,0));

      .....;

       

      and I want the string as it is "Sum (if($(fSel_1),COEP.WKGBTR,0))" for fPlanJahr

      but QV replaces $(fSel_1) by the variable content of fSel_1

       

      How can I force QV to handle the right side as a string without replacing?

      Why? Because vYr_1 and vVersion_1 shall be changed by user input and the variables-hierarchy shall be interpreted during interactive reporting.

       

      When using the variable editor it works fine, when creating them by script i miss the solution.

       

      I tried

      set xxx = [Sum (if($(fSel_1),COEP.WKGBTR,0))];

      set xxx = "Sum (if($(fSel_1),COEP.WKGBTR,0));";

       

      best regards Eckhard

        • How not to replace the variable
          Stefan Wühl

          Hi Eckhard,

           

          try something like

           

          set fSel_1=(COEP.GJAHR='$(vYr_1)' AND COEP.VERSN='$(vVersion_1)' AND COEP.WRTTP='01');

           

          let fPlanJahr ='Sum (if('&chr(36)&'(fSel_1),COEP.WKGBTR,0))';

           

          Regards,

          Stefan

            • How not to replace the variable

              Another option is to use a different character to denote the variable and replace the character with the dollar sign. For example:

               

              SET fSel_1=(COEP.GJAHR='@(vYr_1)' AND COEP.VERSN='@(vVersion_1)' AND COEP.WRTTP='01');

               

              LET fSel_1=replace(fSel_1, '@', '$');

               

              I find that this is more readable especially you have many variables were you don't want the dollar-sign expansion to occur.

            • How not to replace the variable

              Hi, bothe helped me.

              In the end I have something like

              // , replaces Komma

              // " replaces '

              // [ replaces (

              // ] replaces )

               

              The resulting code is:

               

               

               

               

              set fMonSel_1=[$[fSel_1] AND COEP.PERIO="$[SelPERIO]"];

              let fMonSel_1=replace(replace(replace('$(fMonSel_1)',']',')'),'[','('),'"',chr(39));

               

               

              Its not fine but the only way i found in a deep hierarchy of formula

              rgds Eckhard