"
Supported by

CASE inside a SELECT (available soon)

Get ready because you’ll soon be running into a lot of surprises. ABAP is learning new tricks. Look at this one:


CONSTANTS:
  lc_menina TYPE STRING VALUE ‘GIRL',
  lc_menino TYPE STRING VALUE ‘BOY’,
  lc_senhor TYPE STRING VALUE ’GENTLEMAN’,
  lc_senhora TYPE STRING VALUE ‘LADY’.

SELECT nome,  
 CASE
   WHEN sexo_id = ‘M' AND idade < 18 THEN @lc_menino
   WHEN sexo_id = ‘F’ AND idade < 18 THEN @lc_menina
   WHEN sexo_id = ‘M' AND idade >=18 THEN @lc_senhor
   WHEN sexo_id = ‘F’ AND idade >=18 THEN @lc_senhora
 END AS titulo
FROM zpessoa
WHERE pessoa_id = @pessoa_id
INTO CORRESPONDING FIELDS OF @lt_pessoas.

You just have to wait for version 7.40.

Thank you Sérgio Fraga for the tip.

Thank you Anil Wadghule for the photo.

Greetings from Abapinho.

Deixe um comentário


About Abapinho
Abapinho runs on WordPress
Articles (RSS) e Comments (RSS).