Hello,

Sign up to join our community!

Welcome Back,

Please sign in to your account!

Forgot Password,

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

You must login to ask a question.

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

SAP EWM Help Latest Questions

  • 0
  • 0
basantbharti

How to use Case Statement in CDS View

Here in this example, We are going to create CDS view with Case statement, here new field “DocText” will be added and value will be calculated based on below.

    case vbtyp
        when 'A' then 'Inquiry'
        when 'B' then 'Quotation'
        when 'C' then  
            case netwr
                 when 0 then 'Not Paid Order'
                else 'Paid Order'
            end    
        else 'Unknown'
    end as DocText, 

 

@AbapCatalog.viewEnhancementCategory: [#NONE]
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'CDS - Session Variables'
@Metadata.ignorePropagatedAnnotations: true
@ObjectModel.usageType:{
    serviceQuality: #X,
    sizeCategory: #S,
    dataClass: #MIXED
}
define view entity ZCDS_CASE 
as select from vbak
{
    key vbeln as SaleDoc,
    vbtyp as DocCatCode,
    vkorg as SalesOrg,
    vtweg as DistChannel,
    spart as Div,
    kunnr as CustNo,
    
    case vbtyp
        when 'A' then 'Inquiry'
        when 'B' then 'Quotation'
        when 'C' then  
            case netwr
                 when 0 then 'Not Paid Order'
                else 'Paid Order'
            end    
        else 'Unknown'
    end as DocText,     
}

 

Related Questions

Leave an answer

Leave an answer