3 Replies Latest reply: Jul 8, 2013 8:35 AM by Tresesco B RSS

    Where to put Switch Case statement: Load or SQL SELECT?

    Robert Fishel

      Hello to all.  I am trying to write a load statement with a switch case in it.  For some reason, this is not working.  I was wondering if you can put a switch case in a load statement, and if so, why mine is not working.

       

       

       

      SYSyPSPULL:
      LOAD PSPLN As TASK, 
           PSCASN, 
           PSSEA, 
           PSLTYP, 
           PSAREA, 
           PSZONE, 
           PSAISL, 
           PSBAY, 
           PSLEVL, 
           PSPOSN, 
           PSSYR, 
           PSSTYL, 
           PSSSFX,
           LEFT(PSSYR & PSSTYL & PSSSFX,3) AS SAPMERCHDIVISIONCODE, 
           PSSYR & PSSTYL & PSSSFX AS SKU,
           PSSZDS, 
           PSSQTY, 
           PSQPUL, 
           PSRLOC, 
           PSSTAT, 
           PSDCR, 
           PSCRT;
           
           SWITCH RESERVELOCATION
           CASE 001 
               LOAD TRIM(PSAREA) & TRIM(PSZONE) & Left(TRIM(PSAISL),1) & Right(TRIM(PSAISL),1) & TRIM(PSBAY);
           CASE 003
               LOAD TRIM(PSAISL) & TRIM(PSLEVL) & TRIM(PSPOSN);
           DEFAULT
              LOAD TRIM(PSAISL) & TRIM(PSLEVL) & TRIM(PSPOSN);
           END SWITCH;
      
      SELECT * FROM PKMANH221D.PSPULL00
      WHERE PSCRT ='1' AND PSDCR >= $(zconvDate);
      
        • Re: Where to put Switch Case statement: Load or SQL SELECT?
          Robert Fishel

          Thank you for the quick response.  Unfortunately this does not answer my question.  I am trying to understand if the switch statement will work in a Load statement or if it has to be used only in the SQL Select kind of statement.  Thanks.

            • Re: Where to put Switch Case statement: Load or SQL SELECT?
              jagan mohan rao appala

              Hi,

               

              Try like this

               

              SYSyPSPULL:
              LOAD PSPLN As TASK,
                   PSCASN,
                   PSSEA,
                   PSLTYP,
                   PSAREA,
                   PSZONE,
                   PSAISL,
                   PSBAY,
                   PSLEVL,
                   PSPOSN,
                   PSSYR,
                   PSSTYL,
                   PSSSFX,
                   LEFT(PSSYR & PSSTYL & PSSSFX,3) AS SAPMERCHDIVISIONCODE,
                   PSSYR & PSSTYL & PSSSFX AS SKU,
                   PSSZDS,
                   PSSQTY,
                   PSQPUL,
                   PSRLOC,
                   PSSTAT,
                   PSDCR,
                   PSCRT,
                  
                   If( RESERVELOCATION = '001', TRIM(PSAREA) & TRIM(PSZONE) & Left(TRIM(PSAISL),1) & Right(TRIM(PSAISL),1) & TRIM(PSBAY)
                   If(RESERVELOCATION = '003', TRIM(PSAISL) & TRIM(PSLEVL) & TRIM(PSPOSN),
                   TRIM(PSAISL) & TRIM(PSLEVL) & TRIM(PSPOSN))) AS DimensionName;   
              SELECT * FROM PKMANH221D.PSPULL00
              WHERE PSCRT ='1' AND PSDCR >= $(zconvDate);

               

              Hope this helps you.

               

              Regads,

              Jagan.

            • Re: Where to put Switch Case statement: Load or SQL SELECT?
              Tresesco B

              SWITCH  CASE works in LOAD script. What is the error you are getting? You can try something like:

               

              CASE '001'   ........... if they are not numeric.