Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

SQL Scripting

Hi,

how i can use more than one CASE Statement in one calculation view? Every time i get syntay errors

BEGIN

    

   

     var_out = SELECT

               "_BIC_ZC2VERTST",

               "_BIC_ZC2MASTAT",

               "_BIC_ZC2MITARB",

               "_BIC_ZK2KOPF",

               "_BIC_ZC2ORGTGS",

                      

              

             (case

                 

                 when ("_BIC_ZC2MASTAT" = '01'  AND ("_BIC_ZC2VERTST" = '01' OR "_BIC_ZC2VERTST" = '02'))

                     then "_BIC_ZK2KOPF"

                         ELSE NULL END) as "ZK2GBKOPF"

                         

                          /*First CASE Statement works alone*/

                              

              (case

                 

                 when ("_BIC_ZC2MASTAT" = '01'  AND ("_BIC_ZC2VERTST" = '01' OR "_BIC_ZC2VERTST" = '02'))

                     then "_BIC_ZK2KOPF"

                         ELSE NULL END) as "ZK2GBKOPF"       

               

                             

                

                 

               

from  "sap.bw::ZDRPE_GESVIEW";

END

Thank you so much!

Tags:
replied

The problem is not the calculation view or procedure, but that your statement violates SQL syntax.

Not sure what you want to achieve by copying the same case clause into the selection list a second time, but

a) there would need to be a comma between both case clauses

and

b) you can assign only one expression to a projection column - you'd need to rename the output column of the second case.

- Lars

0 View this answer in context

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question