‎2019 Jan 16 1:55 PM
Scenario:
IF Purch. doc. Category (EKPO-bstyp) = ‘F’ then Display Purchasing Document (EBLEN)for each unique Material + Vendor (EKKO Table) Combination
IF Purch. doc. Category (EKPO-bstyp) != ‘F’ (or it doesn’t exists) then Display Purchasing Document (EBLEN)where Purch. doc. Category (bstyp) = ‘K’
What We have tried :
1.casewhen ekpo.bstyp ='F'then ekpo.ebeln
when(ekpo.bstyp <>'F'and ekpo.bstyp ='K')then ekpo.ebeln endas PO,

‎2019 Jan 16 6:51 PM
Your logic seems to be ok only the condition ekpo.bstyp <>'F' is redundant. Are you facing any issues with these statements?
‎2019 Jan 17 6:51 AM
Why don't you use the direct check in case statement instead of using not equal to F in second condition.When your condition satisfies then if will fill data.If both the conditions doesn't satisfies then use others statements to set default values.
case ekpo.ebeln.
when ekpo.bstyp ='F'then ekpo.ebeln
when ekpo.bstyp ='K' then ekpo.ebeln endas PO,
when others
endcase.
‎2019 Jan 17 7:50 AM
Refer demo CDS view - DEMO_CDS_SEARCHED_CASE
cast( case when ekpo.bstyp= 'F' // Purchase Order
then ekpo.ebeln
when ekpo.ebeln = 'K' // Contract
then ekpo.ebeln
when others
end as ebeln ) as DocumentNumber
Regards,
Shyam
‎2019 Jan 17 3:42 PM
Hello Shyam,
Thank you so much for the response. Our requirement if Flag=’F’ condition is met for any material + Vendor combination then we need to ignore all the EBELN records where Flag = ‘K’.
As of now with the use of your suggested CAST(CASE STATEMENT), we are able to mask the records where Flag=K with ‘#’, but question is can we remove this record line (#) as well from the result set.
Attached is the Screenshot for the same (CAST_CASE_STATEMENT).

‎2019 Jan 23 8:06 AM
In case you want to remove then your where clause condition has to do the same. Please share your complete CDS code