P_GMAVCSetLocCurr

DDL: P_GMAVCSETLOCCURR SQL: PGMAVCSETLCURR Type: view BASIC

P_GMAVCSetLocCurr is a Basic CDS View in SAP S/4HANA. It reads from 11 data sources and exposes 5 fields.

Data Sources (11)

SourceAliasJoin Type
P_GMAVCLDGRACTMinMax g1 left_outer
P_GMAVCLDGRACTMinMax g1 union_all
fpb_persparm p1 union_all
fpb_persparm p2 left_outer
fpb_persparm p2 left_outer
t001 t0 inner
tcurc t1 from
tcurc t1 union_all
tcurc t2 left_outer
tcurc t3 left_outer
tcurc t3 left_outer

Parameters (1)

NameTypeDefault
P_CompanyCodeCurrency vdm_v_company_code_currency

Annotations (10)

NameValueLevelField
AbapCatalog.sqlViewName PGMAVCSETLCURR view
ClientHandling.type #CLIENT_DEPENDENT view
ClientHandling.algorithm #SESSION_VARIABLE view
ObjectModel.usageType.dataClass #ORGANIZATIONAL view
ObjectModel.usageType.serviceQuality #A view
ObjectModel.usageType.sizeCategory #S view
AbapCatalog.compiler.compareFilter true view
AccessControl.authorizationCheck #CHECK view
VDM.viewType #BASIC view
VDM.private true view

Fields (5)

KeyFieldSource TableSource FieldDescription
UserID
userasvdm_useridasUserID
userasvdm_useridasUserID
userasvdm_useridasUserID
CompanyCodeCurrency
@AbapCatalog.sqlViewName: 'PGMAVCSETLCURR'
//@ClientDependent: true

@ClientHandling.type: #CLIENT_DEPENDENT
@ClientHandling.algorithm: #SESSION_VARIABLE
@ObjectModel.usageType.dataClass: #ORGANIZATIONAL
@ObjectModel.usageType.serviceQuality: #A
@ObjectModel.usageType.sizeCategory: #S
@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck: #CHECK
@VDM.viewType: #BASIC
@VDM.private: true
//@EndUserText.label: 'Set local currency for AVC applications'

define view P_GMAVCSetLocCurr with parameters
  P_CompanyCodeCurrency: vdm_v_company_code_currency

// First take the input currency, if it is valid:

as select from tcurc as t1
  {
   cast($session.user as vdm_userid)             as UserID,
   cast(t1.waers as vdm_v_company_code_currency) as CompanyCodeCurrency
  }                   
where t1.waers = :P_CompanyCodeCurrency


// if the input currency is not valid, take the currency from the personalization:

union all select from fpb_persparm as p1 
left outer join tcurc as t2 on t2.waers = :P_CompanyCodeCurrency 
  {
   cast($session.user as vdm_userid)           as UserID,
   cast(p1.low as vdm_v_company_code_currency) as CompanyCodeCurrency
  }                   
where t2.waers           is null
  and p1.perskeytp       = 'U'
  and p1.perskey         = $session.user
  and p1.applid          = 'GM-MY_GRANTS'
  and p1.fieldname       = 'CC_CURRENCY'
  and p1.pers_subcontext = ''
  and p1.noauth          = ' '
  and p1.sel_sign        = 'I'
  and p1.fieldtype       = 'V'
  and p1.sel_option      = 'EQ'
  and p1.low             <> ''


// if the input currency is invalid and nothing is found in the personalization, 

// take the currency from the first company code with active AVC:

union all select from P_GMAVCLDGRACTMinMax as g1
inner join t001 as t0 on t0.bukrs = g1.min_comp_code
left outer join tcurc as t3 on t3.waers = :P_CompanyCodeCurrency         
left outer join fpb_persparm as p2 on p2.perskeytp       = 'U'
                                  and p2.perskey         = $session.user
                                  and p2.applid          = 'GM-MY_GRANTS'
                                  and p2.fieldname       = 'CC_CURRENCY'
                                  and p2.pers_subcontext = ''
                                  and p2.noauth          = ' '
                                  and p2.sel_sign        = 'I'
                                  and p2.fieldtype       = 'V'
                                  and p2.sel_option      = 'EQ'
  {
   cast($session.user as vdm_userid)             as UserID,
   cast(t0.waers as vdm_v_company_code_currency) as CompanyCodeCurrency
  }                   
where   t3.waers is null
  and ( p2.low   is null or p2.low = '' )

  
// as very last fallback, take EUR to avoid leaving the currency blank:

union all select from tcurc as t1
left outer join P_GMAVCLDGRACTMinMax as g1 on g1.min_comp_code is not null
left outer join tcurc as t3 on t3.waers = :P_CompanyCodeCurrency         
left outer join fpb_persparm as p2 on p2.perskeytp       = 'U'
                                  and p2.perskey         = $session.user
                                  and p2.applid          = 'GM-MY_GRANTS'
                                  and p2.fieldname       = 'CC_CURRENCY'
                                  and p2.pers_subcontext = ''
                                  and p2.noauth          = ' '
                                  and p2.sel_sign        = 'I'
                                  and p2.fieldtype       = 'V'
                                  and p2.sel_option      = 'EQ'
  {
   cast($session.user as vdm_userid)             as UserID,
   cast(t1.waers as vdm_v_company_code_currency) as CompanyCodeCurrency
  }                   
where   t1.waers         = 'EUR'
  and   g1.min_comp_code is null
  and   t3.waers         is null
  and ( p2.low           is null or p2.low = '' )
/*+[internal] {
"BASEINFO":
{
"FROM":
[
"P_GMAVCLDGRACTMINMAX",
"FPB_PERSPARM",
"T001",
"TCURC"
],
"ASSOCIATED":
[],
"BASE":
[],
"ANNO_REF":
[],
"VERSION":0,
"ANNOREF_EVALUATION_ERROR":""
}
}*/