Application Development and Automation 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: 
Read only

ABAP Session ID

Former Member
4,382

Is there a way to get the abap session id progmatically. Or anything which uniquely identifies a session?

1 ACCEPTED SOLUTION
Read only

RichHeilman
Developer Advocate
Developer Advocate
2,473

Maybe this will work.

report zrich_0002 .
 
data: opcode_get_session_id type x value 68.
data: session_id(32) type c.
data: id_len type i.
 
 
call 'ThUsrInfo' id 'OPCODE' field opcode_get_session_id
          id 'SESSION_ID' field session_id
          id 'ID_LEN' field id_len.
 
write:/ session_id.

Regards,

Rich Heilman

11 REPLIES 11
Read only

former_member194669
Active Contributor
0 Likes
2,473

Check fm TH_GET_SESSION_ID

a®

Read only

RichHeilman
Developer Advocate
Developer Advocate
2,474

Maybe this will work.

report zrich_0002 .
 
data: opcode_get_session_id type x value 68.
data: session_id(32) type c.
data: id_len type i.
 
 
call 'ThUsrInfo' id 'OPCODE' field opcode_get_session_id
          id 'SESSION_ID' field session_id
          id 'ID_LEN' field id_len.
 
write:/ session_id.

Regards,

Rich Heilman

Read only

0 Likes
2,473

thank you so much..I need to try out this....

but can you please explain a little bit more how session id works.

Read only

0 Likes
2,473

ok i got it buddies.

So its a system call (its a call to a C source code files of SAP Kernel) to retrieve data.

correct me if i am wrong...

thanks.

Read only

0 Likes
2,473

Try searching the forum for the term "GUID_CREATE" (the FM).

It might meet your requirement.

Cheers,

Julius

ps: I deleted one of your posts. It was a copy& paste from SAPhelp...

Read only

0 Likes
2,473

deleted one of my posts!!!!! why...which one.....?? saphelp!!??

Read only

0 Likes
2,473

>

> ok i got it buddies.

> So its a system call (its a call to a C source code files of SAP Kernel) to retrieve data.

> correct me if i am wrong...

>

> thanks.

Those functions are not (publicly) documented to my knowledge and are subject to change without warning. See the F1 docs....

A better option is to use an FM (preferably a released one) to create an own GUI-ID for your purposes, or a standard API which does the whole job in one shot (see tcode BAPI).

Cheers,

Julius

Read only

0 Likes
2,473

as per my understanding...

suppose i open a new session at the workbench...that session has got an unique ID..which can be retrived using the FM th_get_session_id...

is my understanding correct??

Read only

0 Likes
2,473

>

> deleted one of my posts!!!!! why...which one.....?? saphelp!!??

Sorry, I might have been mistaken and posted that to the wrong thread.

Copy&Paste from SAPhelp without showing the source is a bit of a problem, so we reject such posts (to encourage the search) and I must have mistaken one of yours for another.

Sorry about that,

Julius

Read only

0 Likes
2,473

ok no probs..but..this...

as per my understanding...

suppose i open a new session at the workbench...that session has got an unique ID..which can be retrived using the FM th_get_session_id...

is my understanding correct??

Read only

0 Likes
2,473

Perhaps if you explain for which scenario / requirement you need the session ID, then there might be a better way of doing it that c-calling the user info function.

> is my understanding correct??

I see that your question is marked answered, so obviously you got it to work already.

But none-the-less, it would be interesting to know why you need the session ID?

Cheers,

Julius