Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

System ID (SY-SYSID) inside ABAP CDS

dmitry_sharshatkin
Active Participant

Hello colleagues,

Does anyone know a way, how to get a current system ID (SY-SYSID) inside ABAP CDS ?

Thanks, Dima

1 ACCEPTED SOLUTION

walt_b
Participant

Why not do the following? It should do the job (tested on a 7.50 system).

define view ZIM_I_Project
as select from proj as PR
// session variable SY-SYSID not available: read table TADIR instead
left outer join tadir as SY on pgmid = 'HEAD' and object = 'SYST'
{
key PR.pspid as ProjectID,
SY.srcsystem as SystemID
}
6 REPLIES 6

UweFetzer_se38
Active Contributor

I think it's currently not possible. The only session fields are user, client and language (and date).

@AbapCatalog.sqlViewName: 'DEMO_CDS_SESSVAR' 
@AccessControl.authorizationCheck: #NOT_REQUIRED 
define view demo_cds_session_variables 
   as 
   select 
     from demo_expressions 
       { id, 
         $session.user            as system_user, 
         $session.client          as system_client, 
         $session.system_language as system_language,
         $session.system_date     as system_date
        } 
<br>

Edit: added System Date (7.52)

0 Kudos

Hi Uwe,

Thanks for your reply, I knew that.

Potentially I can get the logical system from the table T000 based on the $session.client, but this is not exactly what I want...

So my question is rather, is there any workaround to get SID via $session variables ?

Thanks, Dima

0 Kudos

Hello Fetzer,

i see now $sesion.system_date has become obsolete

is there any other option in CDS to get system date

0 Kudos

Where do you have got the infomation from, that system_date became obsolete? This fields new to 7.51 (link) and I don't think SAP will revert this already again.

kaus19d
Active Contributor
0 Kudos

Hi Dmitrii Sharshatkin,

Well one way could be, with the help of "AbapCatalog.dbHints[ ].dbSystem" you can try to get it by running database queries

https://help.sap.com/doc/abapdocu_752_index_htm/7.52/en-US/abencds_f1_view_entity_annotations.htm

Please also check the below,

https://answers.sap.com/questions/3783883/system-information-tables.html

Thanks,

Kaushik

walt_b
Participant

Why not do the following? It should do the job (tested on a 7.50 system).

define view ZIM_I_Project
as select from proj as PR
// session variable SY-SYSID not available: read table TADIR instead
left outer join tadir as SY on pgmid = 'HEAD' and object = 'SYST'
{
key PR.pspid as ProjectID,
SY.srcsystem as SystemID
}