cancel
Showing results for 
Search instead for 
Did you mean: 

$session.user in CDS for Analysis for Office

alina_chira2
Associate
Associate
0 Kudos
191

Hi,

I need to add current user as a parameter to a CDS View which is used in Analysis for Office.

I have tried both ways:

- as a parameter:

   @Environment.systemField : #USER

    p_uname                      : syst_uname,

This is just not working, parameter is not showing in the Variables list.

- as a filter:

  @Consumption.filter: {selectionType: #SINGLE, multipleSelections: false, mandatory: true}

  $session.user as SessionUser

This generates an error when CDS View is opened in Analysis for Office:

'cds variable!cds_f_user is not formally, correctly defined' .

SAP ABAP release is 758.

What am I missing?

 

Thank you,

Alina

SAP Analysis for Microsoft Office 

alina_chira2
Associate
Associate
0 Kudos

I have solved this by taking into consideration that parameter needs to be used in the query in order to be visible. Below is the code which makes system user parameter hidden from the prompts, but visible in the Analysis Design->Variables list: 

@Consumption.hidden: true

@EndUserText.label: 'sap user'

@Environment.systemField: #USER

P_SessionUser                : syuname,

   ….

@Consumption.filter: {selectionType: #SINGLE, multipleSelections: false, mandatory: false, hidden: true }

@Consumption.derivation: { lookupEntity: 'I_SYSTEMUSER', resultElement: 'UserID',

binding: [{ targetElement: 'UserID', type : #PARAMETER, value: 'P_SessionUser' }] }

UserID                           as SessionUser,

 

Alina

Accepted Solutions (0)

Answers (0)