0

I want to transfer this SQL script code to CE functions:

select
    A.MANDT, 
    A.ORGEH, 
    A.ORGLV, 
    A.S_PLANS, 
    A.S_PERNR,
    b.ENAME as ENAME,
    (case 
        when a.ORGLV = 'ROOT' then 'ROOT - ALL Chief'
        when a.S_PERNR is null then ''
        when b.ENAME is null then a.S_PERNR
        else a.S_PERNR||' - '||b.ENAME end) as CA_LV_CHIEF
from : "Table1" as a left outer join "Table2" as b         
    on b.PERNR = a.S_PERNR  
    AND A."MANDT" = B."MANDT"
group by A.MANDT, A.ORGEH, A.S_PERNR, A.S_PLANS, A.ORGLV, b.ENAME

My question is about the calculated attribute CA_LV_CHIEF. You can see there are multiple when...then statements in the original SQL. I want to use CE_CALC() function to convert it to CE function, but I don't know how to nest CASE statement in it.

If possible, how can I do it; or if not possible, is there any other way to convert it to a CE function? Thanks

Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
Rlearn
  • 45
  • 1
  • 5

1 Answers1

1

The correct answer to this question is: don't do it! Using CE functions has been clearly disencouraged by SAP. With your SQL statement you have an easy to understand, straight forward to maintain and good optimizable statement. Don't make it worse in every of those aspects by rewriting it as a CE function call.

Lars Br.
  • 9,949
  • 2
  • 15
  • 29
  • Hi Lars I know use SQL is easy, but this is my work requirement, so I need to use CE, do you know how to write in CE? – Rlearn Apr 11 '16 at 22:25