‎2009 Jun 23 12:36 PM
Hi,
I had added a Authorization Object on basis of Plant in my report and it is giving the problem that instead of displaying the Plant it is displaying as IEQPlant 1. i had taken plant as a selection screen instead of parameter.
Please tell provide me guidelines how to display the Plant name only instead of IEQPlant Name.
AUTHORITY-CHECK OBJECT 'ZPLANT1'
ID 'WERKS' FIELD P_WERKS.
IF SY-SUBRC <> 0.
MESSAGE E045(ZMSG) WITH P_WERKS.
ENDIF.
‎2009 Jun 23 12:39 PM
Hi,
If its the message you are talking about then instead of P_WERKS use P_WERKS-LOW.
KR Jaideep,
‎2009 Jun 23 12:43 PM
hi,
yes,i had checked in the debuug mode it is storing the data Plant Name in LOW and there is a field called OPTION and SIGN i.e. I and EQ . It is coming as IEQDACF.
Please provide me guidelines how to solve this problem as i want to hav only DACF.
‎2009 Jun 23 12:45 PM
AUTHORITY-CHECK OBJECT 'ZPLANT1'
ID 'WERKS' FIELD P_WERKS.
IF SY-SUBRC <> 0.
MESSAGE E045(ZMSG) WITH P_WERKS-LOW. "<<<<<<<<.
ENDIF.
‎2009 Jun 23 12:48 PM
Use this logic instead of directly passing the values.
SELECT-OPTIONS: S_WERKS FOR PA0001-WERKS , "Personnel Area
S_BTRTL FOR PA0001-BTRTL , "Personnel Subarea
S_PERSG FOR PA0001-PERSG , "Employee Group
S_PERSK FOR PA0001-PERSK . "Employee Subgroup
DATA: h_werks LIKE t500p OCCURS 0 WITH HEADER LINE ,
h_funkt LIKE t591a OCCURS 0 WITH HEADER LINE .
AT SELECTION-SCREEN.
REFRESH :h_werks[] , h_funkt .
CLEAR :h_werks , h_funkt .
SELECT * FROM t500p INTO TABLE h_werks WHERE persa IN s_werks .
SELECT * FROM t591a INTO TABLE h_funkt WHERE infty = '0034' AND subty IN s_funkt.
LOOP AT h_werks .
LOOP AT h_funkt .
AUTHORITY-CHECK OBJECT 'Z_HR_AUTH'
ID 'PERSA' FIELD h_werks-persa
ID 'FUNKT' FIELD h_funkt-subty.
IF sy-subrc NE 0.
MESSAGE e001(zhrrep) WITH h_werks-persa h_funkt-subty .
ENDIF.
ENDLOOP.
ENDLOOP.
‎2009 Jun 23 12:56 PM
HI,
I had tried as you had said and it is working fine but if a user specify the range of plant near 5 or 6 ,does it going to create a problem or not?
‎2009 Jun 23 1:00 PM
‎2009 Jun 23 1:02 PM
Hi,
I had tried as you had said and it is working fine but if a user specify the range of plant near 5 or 6 ,it is displaying the low value only not the high ..
AUTHORITY-CHECK OBJECT 'ZPLANT1'
ID 'WERKS' FIELD P_WERKS
IF SY-SUBRC eq 0.
MESSAGE E005(zmsg) WITH P_WERKS-LOW.
ENDIF.
if i remove the low from p_werks it is again defining it as a IBTMMCODACF.
Please provide me guidelines as i am able to display it as MMCODACF.
‎2009 Jun 23 1:06 PM
DATA : BEGIN OF itab OCCURS 0,
werks TYPE werks_d,
END OF itab.
SELECT werks INTO TABLE itab FROM <table>
WHERE werks IN p_werks.
LOOP AT itab.
AUTHORITY-CHECK OBJECT 'ZPLANT1'
ID 'WERKS' FIELD itab-werks.
IF sy-subrc EQ 0.
MESSAGE e005(zmsg) WITH itab-werks.
ENDIF.
ENDLOOP.
‎2009 Jun 23 1:15 PM
Hi,
I had tried as you had said but it is not working.Please provide me guidelines to solve this problem.
‎2009 Jun 23 1:19 PM
‎2009 Jun 23 1:21 PM
hi,
i am displaying the code which i am using in the report.
SELECTION-SCREEN BEGIN OF BLOCK PAR1 WITH FRAME TITLE TEXT-001.
*PARAMETERS: P_WERKS LIKE ZPR_DET-WERKS.
SELECT-OPTIONS: P_WERKS FOR ZPR_DET-WERKS,
BUDAT FOR ZPR_DET-BUDAT,
VERAN FOR CRHD-VERAN,
KTSCH FOR ZPR_DET-KTSCH.
SELECTION-SCREEN END OF BLOCK PAR1.
AUTHORITY-CHECK OBJECT 'ZPLANT1'
ID 'WERKS' FIELD P_WERKS.
IF SY-SUBRC <> 0.
MESSAGE E045(ZMSG) WITH P_WERKS."-LOW P_WERKS-HIGH.
ENDIF.
‎2009 Jun 23 1:25 PM
Seems you dint check later post... please do changes according to that and come back to us in case any problem..
Thanks
‎2009 Jun 23 1:25 PM
Hi,
Ankur Parab, Jaideep Sharma, Gautham Vangaveti, GTREN and Perez C (second attempt) have all given you the solution.
If you follow their code the program will work.
Regards,
Nick
‎2009 Jun 23 1:29 PM
hi,
The following code:-
I am passing the value to the i.e. range 1 to 6. i checked in the debug mode it is giving the problem that
it storing the lot of values .
DATA : BEGIN OF itab1 OCCURS 0,
werks TYPE werks_d,
END OF itab1.
SELECT werks INTO TABLE itab1 FROM ZPR_DET
WHERE werks IN p_werks.
LOOP AT itab1.
AUTHORITY-CHECK OBJECT 'ZPLANT1'
ID 'WERKS' FIELD itab1-werks.
IF sy-subrc EQ 0.
MESSAGE e005(zmsg) WITH itab1-werks.
ENDIF.
ENDLOOP.
Edited by: ricx .s on Jun 23, 2009 2:30 PM
‎2009 Jun 23 1:33 PM
Follow this:
Data: begin of i_werks occurs 0,
werks like t001w-werks,
End of i_werks.
SELECTION-SCREEN BEGIN OF BLOCK PAR1 WITH FRAME TITLE TEXT-001.
*PARAMETERS: P_WERKS LIKE ZPR_DET-WERKS.
SELECT-OPTIONS: P_WERKS FOR ZPR_DET-WERKS,
BUDAT FOR ZPR_DET-BUDAT,
VERAN FOR CRHD-VERAN,
KTSCH FOR ZPR_DET-KTSCH.
SELECTION-SCREEN END OF BLOCK PAR1.
Select werks into i_werks from t001w where werks IN P_WERKS.
Loop at i_werks.
AUTHORITY-CHECK OBJECT 'ZPLANT1'
ID 'WERKS' FIELD I_WERKS-WERKS.
IF SY-SUBRC NE 0.
MESSAGE E045(ZMSG) WITH I_WERKS-WERKS.
ENDIF.
Endloop.
‎2009 Jun 23 1:36 PM
Hi,
I am not sure you have to select from ZPR_DET.
The table T001W is the master table for the plant.
It may happen that the plant entered on selection screen is in T001W and not in ZPR_DET.
In that case even if the person is authorised for the plant; you will have error.
Regards,
Ankur Parab
‎2009 Jun 23 1:36 PM
Final attempt....Small correction
LOOP AT itab1.
AUTHORITY-CHECK OBJECT 'ZPLANT1'
ID 'WERKS' FIELD itab1-werks.
IF sy-subrc EQ 0. "<<<<< Should be NE, not EQ
MESSAGE e005(zmsg) WITH itab1-werks.
ENDIF.
ENDLOOP.
‎2009 Jun 23 1:48 PM
Hi,
I am really thankfull to all of you for letting my problem solved.
I am closing this thread,problem solved.
‎2009 Jun 23 12:40 PM
Hi,
Incase of select options you will have to first fetch all the plants from T001W which the user has put in the select option into an internal table.
This is because user can enter multiple plants.
For a select option you cannot jut compare the low and high values because select-options can have complex selections.
Then LOOP on this internal table and for each value check the authority object and then give the error message accordingly for the incorret plant.
Thats the way how you should do it.
Regards,
Ankur Parab
Edited by: Ankur Parab on Jun 23, 2009 5:10 PM
‎2009 Jun 23 12:42 PM
Hi,
Please see the sample code below that I used to have the same functionality in one of my programs.
*---Authorization for Company code entered by the users.
*---This code will restrict users to see data for company
*---codes which they are not authorized to.
*---Select all the company codes based upon selection entered by the
*---user
DATA: li_bukrs TYPE TABLE OF bukrs,
lwa_bukrs TYPE bukrs,
lv_flag TYPE c.
SELECT bukrs
FROM t001
INTO TABLE li_bukrs
WHERE bukrs IN bukrs.
IF sy-subrc EQ 0.
*---Clear Screen variable for Company code
CLEAR bukrs.
REFRESH bukrs.
*---Filter and prepare Select options for Company code table to be
*---passed to query. Table will only have values of company codes he is
*---authorized to for display.
LOOP AT li_bukrs INTO lwa_bukrs.
AUTHORITY-CHECK OBJECT 'F_BKPF_BUK'
ID 'BUKRS' FIELD lwa_bukrs
ID 'ACTVT' FIELD '03'.
IF sy-subrc = 0.
bukrs-sign = 'I'.
bukrs-option = 'EQ'.
bukrs-low = lwa_bukrs.
bukrs-high = space.
APPEND bukrs.
ELSE.
lv_flag = 'X'.
ENDIF.
ENDLOOP.
*---Give warning message to the user in case he is not authorized to see
*---data for all the company codes that he has entered.
IF lv_flag = 'X'.
MESSAGE ID 'ZF_MSS_FNG' TYPE 'W' NUMBER '015'.
ENDIF.
ENDIF.KR Jaideep,
‎2009 Jun 23 12:50 PM
TRY Like this..........
AUTHORITY-CHECK OBJECT 'ZPLANT1'
ID 'WERKS' FIELD P_WERKS
IF SY-SUBRC eq 0.
MESSAGE E005(zmsg) WITH P_WERKS-LOW.
ENDIF.
Hope it helps you......
‎2009 Jun 23 1:03 PM
TRY SOMETHING LIKE FOLLOWING
data lv_werks
Select WERKS FROM T001W INTO LV_WERKS
WHERE WERKS IN P_WERKS.
AUTHORITY-CHECK OBJECT 'ZPLANT1'
ID 'WERKS' FIELD LV_WERKS.
IF SY-SUBRC <> 0.
MESSAGE E045(ZMSG) WITH LV_WERKS.
ENDIF.
ENDSELECT.