2006 Oct 14 6:50 AM
Hi All..
My requirement is to incorporate the Authority-Check for Sales Organization field ( VBAK-VKORG) inthe selection screen. In the meanwhlie, i should restrict further processing of Report, if unauthorized Sales Organzations.
Please help me in explaining the meaning of above requirement and can any one give me the code sample for this..????
Its urgent issue and kindly request you to help me out...
2006 Oct 14 8:15 AM
Hi..
When restricting the report execution by sales organization, i need to follow the logic below.
- If none of the sales organizations input in the selection screen is authorized, give a message No authorization for any Sales Org input.
- If some of the sales organizations are authorized but others not, retrieve the data of the authorized sales organizations and display them in the report.
Please give me code sample, as i am unable to make it happen...
Hi All..
My requirement is to incorporate the Authority-Check for Sales Organization field ( VBAK-VKORG) inthe selection screen. In the meanwhlie, i should restrict further processing of Report, if unauthorized Sales Organzations.
Please help me in explaining the meaning of above requirement and can any one give me the code sample for this..????
Its urgent issue and kindly request you to help me out...
2006 Oct 14 7:01 AM
Please check if the below code helps you:
One way is as below.
DATA: BEGIN OF lt_tvko OCCURS 0,
vkorg TYPE vkorg,
bukrs TYPE bukrs,
END OF lt_tvko.
SELECT vkorg bukrs FROM tvko INTO TABLE lt_tvko
WHERE vkorg IN lr_vkorg.
IF sy-subrc NE 0.
MESSAGE e085(wv).
ENDIF.
* Check all retrieved co.codes
SORT lt_tvko BY bukrs.
DELETE ADJACENT DUPLICATES FROM lt_tvko COMPARING bukrs.
LOOP AT lt_tvko.
* Error Message: No authorization for sales organization &1
PERFORM f_bukrs_auth_chk_p USING lt_tvko-bukrs 'ICC_FI_CN' 'E' '010'
lt_tvko-vkorg '' '' ''.
ENDLOOP.
FORM f_bukrs_auth_chk_p USING value(lc_bukrs) TYPE bukrs
value(lc_msgid) LIKE sy-msgid
value(lc_msgty) LIKE sy-msgty
value(ln_msgno) LIKE sy-msgno
value(lc_msgv1)
value(lc_msgv2)
value(lc_msgv3)
value(lc_msgv4).
AUTHORITY-CHECK OBJECT 'F_BKPF_BUK'
ID 'BUKRS' FIELD lc_bukrs
ID 'ACTVT' FIELD '03'.
IF sy-subrc NE 0.
MESSAGE ID lc_msgid TYPE lc_msgty NUMBER ln_msgno
WITH lc_msgv1 lc_msgv2 lc_msgv3 lc_msgv4.
ENDIF.
ENDFORM. "f_bukrs_auth_chk_p
Select the sales organization mapping to Company code and then restrict.
Kind Regards
Eswar
2006 Oct 14 8:15 AM
Hi..
When restricting the report execution by sales organization, i need to follow the logic below.
- If none of the sales organizations input in the selection screen is authorized, give a message No authorization for any Sales Org input.
- If some of the sales organizations are authorized but others not, retrieve the data of the authorized sales organizations and display them in the report.
Please give me code sample, as i am unable to make it happen...
2006 Oct 14 8:22 AM
Hi Pavan ,
in addition to E.Rao u have to put simple logic :
1.If he has no authorization then delete that Sales Org from the Internal table which u are ref.
2.And finally If Sales ord table is Empty then raise error.
<b>check the sample logic in case of plant for sales ord please ref.Eswar Code .</b>
select werks
into table i_auth_werks
from t001w
where werks in s_werks.
loop at i_auth_werks.
authority-check object 'Z_PLNT_AUT'
id 'ACTVT' field '03'
id 'WERKS' field i_auth_werks-werks.
if sy-subrc ne 0 .
delete i_auth_werks.
endif.
endloop.2. describe table i_auth_werks lines n.
if nle 0.
message e398(00) with
'User' sy-uname 'not authorised for Plant : ' i_auth_werks-werks.
endif.
<b>Please modify ur code as per sample code</b>
regards
Prabhu
2006 Oct 14 8:27 AM
Hi Pavan
Have made some changes to the code. Please check the same.
DATA: BEGIN OF lt_tvko OCCURS 0,
vkorg TYPE vkorg,
bukrs TYPE bukrs,
END OF lt_tvko.
SELECT vkorg bukrs FROM tvko INTO TABLE lt_tvko
WHERE vkorg IN lr_vkorg.
IF sy-subrc NE 0.
MESSAGE e085(wv).
ENDIF.
* Check all retrieved co.codes
SORT lt_tvko BY bukrs.
DELETE ADJACENT DUPLICATES FROM lt_tvko COMPARING bukrs.
LOOP AT lt_tvko.
* Error Message: No authorization for sales organization &1
PERFORM f_bukrs_auth_chk_p USING lt_tvko-bukrs 'ICC_FI_CN' 'E' '010'
lt_tvko-vkorg '' '' ''
CHANGING sy-subrc.
if sy-subrc ne 0.
delete lt_tvko.
endif.
ENDLOOP.
ranges: r_vkorg for tvko-vkorg.
if lt_tvko[] is initial.
Message eooo(00) with No authorization for any Sales Org input.
else.
r_vkorg-sign = 'I'.
r_vkorg-option = 'EQ'.
loop at lt_tvko.
r_vkorg-low = lt_tvko-vkorg.
append r_vkorg.
endlloop.
endif.
FORM f_bukrs_auth_chk_p USING value(lc_bukrs) TYPE bukrs
value(lc_msgid) LIKE sy-msgid
value(lc_msgty) LIKE sy-msgty
value(ln_msgno) LIKE sy-msgno
value(lc_msgv1)
value(lc_msgv2)
value(lc_msgv3)
value(lc_msgv4)
CHANGING p_subrc.
AUTHORITY-CHECK OBJECT 'F_BKPF_BUK'
ID 'BUKRS' FIELD lc_bukrs
ID 'ACTVT' FIELD '03'.
p_subrc = sy-subrc.
ENDFORM. "f_bukrs_auth_chk_pNow range
r_vkorg
will have the list of authorized sales organizations. You can use it as the select-option for further processing.Am not on SAP, have just coded from notepad. Please bear incase of any syntax errors.
Kind Regards
Eswar
2006 Oct 14 8:29 AM
Hi
TABLES TVKO.
SELECT-OPTIONS: SO_VKORG FOR TVKO-VKORG.
DATA IT_TVKO LIKE STANDARD TABLE OF TVKO WITH HEADER LINE.
AT SELECTION-SCREEN.
SELECT * FROM TVKO INTO TABLE IT_TVKO WHERE VKORG IN SO_VKORG.
LOOP AT IT_TVKO.
AUTHORITY-CHECK OBJECT 'V_VBAK_VKO'
ID 'VKORG' FIELD IT_TVKO-VKORG
ID 'VTWEG' DUMMY
ID 'SPART' DUMMY
ID 'ACTVT' FIELD '03'.
IF SY-SUBRC <> 0.
DELETE IT_TVKO.
ENDIF.
ENDLOOP.
DESCRIBE TABLE IT_TVKO LINES SY-TABIX.
IF SY-TABIX < 1.
MESSAGE E208(00) WITH 'No authorization for any Sales Org input'.
ENDIF.
Max
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |