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

help with authority-check

Former Member
0 Likes
1,896

Hello ppl,

On my selection screen for a report, I have the field Sales Org. SELECT-OPTIONS: s_vkorg FOR gs_selscr-vkorg

OBLIGATORY, "Sales Org.

I need to check whether the user has the authorization for the selected sales organisations. So, I am using:

AUTHORITY-CHECK OBJECT 'V_VBAK_VKO'

ID 'VKORG' FIELD s_vkorg

ID 'ACTVT' FIELD '03'.

IF sy-subrc NE 0.

MESSAGE e013. " No authorization

SET CURSOR FIELD 'S_VKORG-LOW'.

ENDIF.

But, will this code handle a range of sales organisations?

Also, how will I be able to display an error message displaying the sales org for which the user has no authorization?

Please help.

Thanks.

5 REPLIES 5
Read only

Former Member
0 Likes
962

Hi David,

Check the Below steps.

1. You have to select all the sales org from TVKO based on the selection screen and assigned to IT_TVKO.

2. loop the internal table IT_TVKO. and check the authorization for sales org.

3. based on your requirement, if the user don't have authorization, delete the sales org from the internal table and continue based on the sales.org in IT_TVKO. Otherwise send the error message and don't continue the process.

Regards,

Boobalan S

Read only

former_member195383
Active Contributor
0 Likes
962

hi...

this code will handle all the plants...

and for message...u can use the following....

MESSAGE e120(m_class) WITH s_vkorg.

in the message class say m_class create a message say message number 120,

as

No authorisation for plant &.

this will help u out

Read only

Former Member
0 Likes
962

AUTHORITY-CHECK OBJECT 'V_VBAK_VKO'

ID 'VKORG' FIELD s_vkorg

ID 'ACTVT' FIELD '03'.

IF sy-subrc NE 0.

MESSAGE e013. " No authorization

SET CURSOR FIELD 'S_VKORG-LOW'.

ENDIF.

But, will this code handle a range of sales organisations?

Also, how will I be able to display an error message displaying the sales org for which the user has no authorization?

You need to call the check inside the loop.

First get the sales organizations based on select options, now loop all sales organizations and check the Authorizations.

and message along with the Sales org , so that user can remove that .

Read only

vinod_vemuru2
Active Contributor
0 Likes
962

Hi David,

By this way u can't do the validation for the range of sales orgs. U have to do like this.


TYPES: BEGIN OF t_tvko,
               vkorg TYPE tvko-vkorg,
END OF t_tvko.
DATA: i_tvko TYPE TABLE OF t_tvko,
wa_tvko TYPE t_tvko.
SELECT vkorg INTO TABLE i_tvko FROM tvko WHERE vkorg IN so_vkorg.

LOOP AT i_tvko INTO wa_tvko.
AUTHORITY-CHECK OBJECT 'V_VBAK_VKO'
ID 'VKORG' FIELD wa_tvko-vkorg
ID 'ACTVT' FIELD '03'.

IF sy-subrc NE 0.
MESSAGE e013 WITH 'U don't have authorization for sales org' , wa_tvko-vkorg. " No authorization
SET CURSOR FIELD 'S_VKORG-LOW'.
ENDIF.
ENDLOOP.

This will do validation for all sales orgs in the range given, even for multiple ranges.

Thanks,

Vinod.

Read only

Former Member
0 Likes
962

selection-screen begin of block b1 with frame .

select-options : so_bukrs for bsid-bukrs obligatory,

so_kunnr for bsid-kunnr,

so_hkont for bsid-hkont,

so_prctr for bsid-prctr ,

so_ktokd for kna1-ktokd.

selection-screen end of block b1.

initialization.

*Clearing the work area.

clear gs_bsid.

  • Refreshing the internal tables.

refresh gt_bsid.

*comm1 = 'Post Dt'.

*comm2 = 'Doc Dt'.

*comm3 = 'Bline Dt'.

*******AUTHORITY-CHECK ***********************************************

at selection-screen .

call function 'ZCAGL_COUNTRYCODE'

exporting

  • IM_WERKS =

  • IM_SPART =

  • IM_PRCTR =

im_bukrs = so_bukrs-low

importing

e_land1 = e_land1.

if e_land1 ne 'IN'.

message i004(yfi02) with 'This Company Code' so_bukrs-low

'doesn''t belong to INDIA'.

leave program.

else.

authority-check object 'ZPRCHK_NEW' :

id 'BUKRS' field so_bukrs-low.

if sy-subrc ne 0.

message e001(yfi02).

leave program.

endif.

endif.

if so_prctr-low is not initial.

call function 'ZCAGL_COUNTRYCODE'

exporting

  • IM_WERKS =

  • IM_SPART =

im_prctr = so_prctr-low

  • IM_BUKRS =

importing

e_land1 = e_land1.

if e_land1 ne 'IN'.

message i004(yfi02) with 'This Profit center'

so_prctr-low 'doesn''t belong to INDIA' .

leave program.

else.

authority-check object 'ZPRCHK_NEW' :

id 'PRCTR' field so_prctr-low.

if sy-subrc ne 0.

message e002(yfi02).

leave program.

endif.

endif.

endif.

this will help u....

Regards

Anbu