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

Get controllingarea

Former Member
0 Likes
1,436

Hi experts

I have to get the controllingarea using ABAP. I know that the controllingarea is set for a user in SU01, but you can change it temporary in OKKS. Where is the temporary conrollingarea saved in SAP after it's changed using OKKS? The controllingarea in SU01 won't change when it's changed using OKKS...

I've managed to get the controllingarea in ABAP using this code:

GET PARAMETER ID 'CAC' FIELD lv_controllingarea.

When i run it in a test program this code returns the value of the controllingarea in OKKS.

But when i run it in my webdynpro application it returns the value of controllingarea saved for the user in SU01....

Does anyone know why this is happening? Or does anyone know a better way to get the controllingarea in abap?

3 REPLIES 3
Read only

Former Member
0 Likes
1,039

Use FM BAPI_CONTROLLINGAREA_FIND

Here a simple code:

DATA: CONTROLLINGAREAID LIKE BAPI0004_2-CO_AREA , 
COMPANYCODEID LIKE BAPI0002_2-CO_AREA , 
RETURN LIKE BAPIRETURN . 

COMPANYCODEID = '0001'. 

CALL FUNCTION 'BAPI_CONTROLLINGAREA_FIND' 
EXPORTING 
COMPANYCODEID = COMPANYCODEID 
IMPORTING 
CONTROLLINGAREAID = CONTROLLINGAREAID 
RETURN = RETURN 
EXCEPTIONS 
OTHERS = 1 .

Edited by: spantaleoni on Jan 11, 2011 5:22 PM

Read only

0 Likes
1,039

Thanks for your reply, but i can't call this bapi because you have to give the companycodeID

At the beginning of my program i have to get the controllingarea of the system (OKKS).

Next thing i have to do is to search all companies for that controllingarea.

So i can't supply the bapi with a companycode at the first moment...

Read only

0 Likes
1,039

Did you try looking at the transaction OKKS via SE93? You will find that function K_KOKRS_SET is called, so you can maybe analyse that function module and find out how SAP standard does it.

I doubt though that you will be able to determine a unique controlling area this way (unless there is only one configured), because OKKS is used to set this value by user interaction and only for the user context, not to return it to a calling process.

Thomas