‎2011 Jan 11 3:34 PM
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?
‎2011 Jan 11 4:22 PM
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
‎2011 Jan 11 4:28 PM
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...
‎2011 Jan 11 4:52 PM
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