8 Replies Latest reply: Sep 4, 2013 10:29 AM by Cotiso Hanganu RSS

    Deactivate/ Activate pieces of script?

    Friedrich Hofmann


      Hi,

       

      I have just solved my latest difficulty and triggered the loading of a constructed record to a historization_qvd in case the LOAD from the database brought no records.

      => That  brings me up to my next question:

       

      Instead of going, like

      LOAD

      IF(v_test='X', DATE(TODAY())) as Y,

      IF(v_test='X' count(y)) as Z

      RESIDENT ...

       

      (stating the condition in every line of the LOAD statement)

      can't I simply nest the entire LOAD inside the IF-condition? Or do as I did in another program, make the statement a multi-line comment in case the IF-condition returns TRUE? That way, I would save quite some typework.

       

      Thanks a lot!

      Best regards,

       

      DataNibbler

        • Re: Deactivate/ Activate pieces of script?
          Juan Pedro Hidalgo

          I use in several applications what you want to achive here is a sample:

           

          for vLoad = year(today())-5 to year(Today())+1 //dichiaro il ciclo e la variabile con il primo anno d'analizzare in questo modo non devo u e il l'anno attuale. 
          if isnull(filetime('$(rootFolder_f)Biological_Prod_$(vLoad).qvd')) THEN //CONTROLLO SE ESISTE UNA ULTIMA DATA DI MODIFICA E QUINDI SE ESISTE IL FILE 
          DATI_MARKETING: //Se il file non esiste carico dai dati concatenati generati nel manual data nella pagina precedente
          LOAD YEAR, 
               PRODUCT, 
               CUSTOMER, 
               MONTH, 
               PRICE,
               FOC_DISC,
               BDG_QTA, 
               BDG_VAL, 
               FCST_QTA, 
               FCST_VAL,
               IF( PRICE>0,( (100-(FOC_DISC)) * PRICE/100)* FCST_QTA,FCST_VAL) AS FORECAST,
               BDG_RV_QTA, 
               BDG_RV_VAL, 
               CUSTOMER_ID, 
            TRX_DATE,
               INVOICED_QTA, 
               INVOICED_CHF, 
               INVOICED_VAL, 
               BACKLOG_QTA, 
               BACKLOG_VAL, 
               RLG_QTA, 
               RLG_VAL,
            IF( PRICE >0, PRICE*(100-( FOC_DISC))/100 *  RLG_QTA, RLG_VAL) as ROLLING  
          FROM
          '$(rootFolder)Concatenated_Data.qvd'
          (qvd)
          where YEAR = $(vLoad);
          
          
          else //Se esiste carico direttamente dal file qvd generato dal freezing degli anni 
          
          
          LOAD YEAR, 
               PRODUCT, 
               CUSTOMER, 
               MONTH, 
               PRICE,
               FOC_DISC,
               BDG_QTA, 
               BDG_VAL, 
               FCST_QTA, 
               FCST_VAL,
               IF( PRICE>0,( (100-(FOC_DISC)) * PRICE/100)* FCST_QTA,FCST_VAL) AS FORECAST,
               BDG_RV_QTA, 
               BDG_RV_VAL, 
               CUSTOMER_ID, 
            TRX_DATE,
               INVOICED_QTA, 
               INVOICED_CHF, 
               INVOICED_VAL, 
               BACKLOG_QTA, 
               BACKLOG_VAL, 
               RLG_QTA, 
               RLG_VAL,
            IF( PRICE >0, PRICE*(100-( FOC_DISC))/100 *  RLG_QTA, RLG_VAL) as ROLLING  
          FROM
          '$(rootFolder_f)Biological_Prod_$(vLoad).qvd'
          (qvd);
          end if //esco dal ciclo if 
          next vLoad; //Incremento la variabile vLoad fino all'anno odierno dopodiche procede nella seguente pagina
          
          

           

          In this specific case i check the existance of a file with freezed data and load it for that year.