2014 Mar 27 5:46 PM
Hi All,
I have a requirement where I need to update the authorization check for the FB02 T code...
task is :
Insert authority check prior to calling Transactions or program
Program is ( a part where i need to update the code):
set parameter if 'BLN' field accrual_belnr
set parameter if 'BUK' field accrual_bukrs
set parameter if 'GJR' field accrual_gjahr
call transaction 'FB02' and skip first screen. (Here I need to update the Auth check)
I have written a Authorization check code like:
AUTHORITY-CHECK OBJECT 'S_FB02'
ID 'belnr' FIELD accrual_belnr
ID 'gjahr' FIELD accrual_gjahr
ID 'bukrs' FIELD accrual_bukrs.
IF sy-subrc = 0.
MESSAGE 'No authorization' TYPE 'E'.
ELSE.
MESSAGE 'Congrats! You are authorized' TYPE 'S'.
ENDIF.
Is my code is correct or do i need to make any changes?? Wht is the existing tcode call?
kindly help with this.
Regards,
Kiran
2014 Mar 28 6:41 AM
Thanks for reply.
But as I got the update like, All I have to do was to add auth check not remove any code .
So
set parameter if 'BLN' field accrual_belnr
set parameter if 'BUK' field accrual_bukrs
set parameter if 'GJR' field accrual_gjahr
call transaction 'FB02' and skip first screen. (Here I need to update the Auth check)
how to do that??
-Kiran
2014 Mar 27 8:38 PM
Hi Kiran,
Are you saying that you want to check if the user has authorization to execute FB02, prior to calling it?
The standard SAP FB02 transaction will do many authorization checks.
I would suggest you scrap the authorization check and just let your code call FB02 using call transaction and get the messages back from the call transaction. If one of the messages is an authorization error, you will find out then. If there is no authorization error, you can inform the user of any other errors or of the successful execution.
I don't see much point in congratulating users for having access to a T-code... I'll assume you put that there just for the example ... and that if the user has access, your code will call FB02. In that case, the behaviour will be exactly as I described above.
I hope this is helpful.
2014 Mar 28 12:52 AM
Yep, I second your recommendation, just leave standard code do the job.
Lootens Jurgen wrote:
I don't see much point in congratulating users for having access to a T-code...
If he keeps this I would suggest some change in case of no authorization:
MESSAGE 'No authorization. Burn in hell!!!!' TYPE 'E'. c
2014 Mar 28 2:49 AM
Guys,
I just need to use the SAP standard S_TCODE for above to it..
How to do that???/
Urgently required to resolve this..
Regards,
Kiran
2014 Mar 28 3:22 AM
Hi Kiran,
No, what Lootens said is, when you use call transaction, the transaction being called will perform the authorization checks.
But in this case you will need to use call transaction using bdctab, so you can catch the error messages. On a second thought, I think your code (doing the authority-check in the caller program) is a better option.
Cheers,
Custodio
2014 Mar 28 6:41 AM
Thanks for reply.
But as I got the update like, All I have to do was to add auth check not remove any code .
So
set parameter if 'BLN' field accrual_belnr
set parameter if 'BUK' field accrual_bukrs
set parameter if 'GJR' field accrual_gjahr
call transaction 'FB02' and skip first screen. (Here I need to update the Auth check)
how to do that??
-Kiran
2014 Mar 28 6:46 AM
Kiran
Standard FMB02 tcode will perform these checks but if you still want to check authorization then you can do as mentioned below but it does not make any sense.
set parameter if 'BLN' field accrual_belnr
set parameter if 'BUK' field accrual_bukrs
set parameter if 'GJR' field accrual_gjahr
AUTHORITY-CHECK OBJECT 'S_TCODE'
ID ''TCODE' FIELD 'FB02'
IF sy-subrc = 0.
MESSAGE 'No authorization' TYPE 'E'.
ELSE.
MESSAGE 'Congrats! You are authorized' TYPE 'S'.
ENDIF.
call transaction 'FB02' and skip first screen. (Here I need to update the Auth check)
Nabheet
2014 Mar 28 7:19 AM
Nabheet,
The above mentioned code of your will work properly??
ID ''TCODE' FIELD 'FB02' (In this bold area, I should suppose to give the field names isn`t it??
you have mentioned the Transaction code itself?!!!
Kiran
2014 Mar 28 7:21 AM
Kiran we can give a variable or a constant. Since you want to check auhtorization for tcode FB02 i hard coded it. It depends on what authorization object you use. Just double click on authorization object you will see what all fields it uses.
2014 Mar 28 10:11 AM
Hi Nabheet..
Thanks.. I did some changes in the code which you have mentioned...
but for this below codes, how to add the authorization object?
IF NOT p_alv-belnr IS INITIAL.
SET PARAMETER ID 'BUK' FIELD p_alv-bukrs.
SET PARAMETER ID 'BLP' FIELD p_alv-belnr.
SET PARAMETER ID 'BLN' FIELD p_alv-belnr.
SET PARAMETER ID 'RBN' FIELD p_alv-belnr.
SET PARAMETER ID 'GJR' FIELD p_alv-gjahr.
SELECT SINGLE * FROM bkpf WHERE bukrs = p_alv-bukrs
AND belnr = p_alv-belnr
AND gjahr = p_alv-gjahr.
IF sy-subrc EQ 0.
CASE bkpf-bstat.
* Parked document
WHEN 'V' OR 'W' OR 'Z'.
CALL TRANSACTION 'FBV3' AND SKIP FIRST SCREEN. ( AO for this)
"#EC CI_CALLTA
* Posted document
WHEN OTHERS.
CALL TRANSACTION 'FB03' AND SKIP FIRST SCREEN. (AO for this)
"#EC CI_CALLTA
ENDCASE.
ELSE.
2014 Mar 28 11:12 AM
2014 Mar 28 11:25 AM
I am not very confident that CALL TRANSACTION command will check for all S_TCODE authorizations. I read somewhere that LEAVE TO TRANSACTION does check for such authorizations but CALL TRANSACTION will not
Use the FM,
ABAP4_CALL_TRANSACTION.
*" IMPORTING
*" VALUE(TCODE) LIKE SY-TCODE
*" VALUE(SKIP_SCREEN) LIKE SY-FTYPE DEFAULT SPACE
*" VALUE(MODE_VAL) LIKE SY-FTYPE DEFAULT 'A'
*" VALUE(UPDATE_VAL) LIKE SY-FTYPE DEFAULT 'A'
*" EXPORTING
*" VALUE(SUBRC) LIKE SY-SUBRC
*" TABLES
*" USING_TAB STRUCTURE BDCDATA OPTIONAL
*" SPAGPA_TAB STRUCTURE RFC_SPAGPA OPTIONAL
*" MESS_TAB STRUCTURE BDCMSGCOLL OPTIONAL
*" EXCEPTIONS
*" CALL_TRANSACTION_DENIED
*" TCODE_INVALID
Pass the T-Code and 'X' to SKIP_SCREEN to make sure that all the authority checks are performed even when you call it programatically.
Regards,
Yuvaraj S
2014 Mar 28 11:33 AM
Hi yuvaraj,
Instead of calling FM, we can use the Objects for Auth Request right??
I am preferring to use the Objects...
So, and for below mentioned code, I need to do the Auth Req Obj..
IF NOT p_alv-belnr IS INITIAL.
SET PARAMETER ID 'BUK' FIELD p_alv-bukrs.
SET PARAMETER ID 'BLP' FIELD p_alv-belnr.
SET PARAMETER ID 'BLN' FIELD p_alv-belnr.
SET PARAMETER ID 'RBN' FIELD p_alv-belnr.
SET PARAMETER ID 'GJR' FIELD p_alv-gjahr.
SELECT SINGLE * FROM bkpf WHERE bukrs = p_alv-bukrs
AND belnr = p_alv-belnr
AND gjahr = p_alv-gjahr.
IF sy-subrc EQ 0.
CASE bkpf-bstat.
* Parked document
WHEN 'V' OR 'W' OR 'Z'.
CALL TRANSACTION 'FBV3' AND SKIP FIRST SCREEN. ( AO for this)
"#EC CI_CALLTA
* Posted document
WHEN OTHERS.
CALL TRANSACTION 'FB03' AND SKIP FIRST SCREEN. (AO for this)
"#EC CI_CALLTA
ENDCASE.
ELSE.