‎2007 Oct 31 12:16 PM
Can we provide authority check to selection screen.
if yes then how
‎2007 Oct 31 12:21 PM
‎2007 Oct 31 12:21 PM
Hi
refer this program....
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.
Regards
Vasu
‎2007 Oct 31 12:21 PM
‎2007 Oct 31 12:22 PM
Hi,
Yes you can here i am attaching a form which i am calling at the time of at selecton screen event for screen field p_bukrs.
FORM check_comp_auth .
AUTHORITY-CHECK OBJECT 'F_BKPF_BUK'
ID 'BUKRS' FIELD p_bukrs
ID 'ACTVT' FIELD '03'.
IF sy-subrc NE 0.
MESSAGE e060(00) WITH p_bukrs.
ENDIF.
ENDFORM. " Check_Comp_auth
Reward if helpful
Regards
Gagan
‎2007 Oct 31 12:23 PM
/**Table Declarations
TABLES : mara,
iseg.
&----
Type Declarations *
&----
TYPE-POOLS : slis.
*
TYPES: BEGIN OF t_iseg,
iblnr LIKE iseg-iblnr, "Physical inventory document
gjahr LIKE iseg-gjahr, "Fiscal year
matnr LIKE iseg-matnr, "Material number
werks LIKE iseg-werks, "Plant
lgort LIKE iseg-lgort, "Storage location
zldat LIKE iseg-zldat, "Date of last count
erfmg LIKE iseg-erfmg, "Quantity in unit of entry
abcin LIKE iseg-abcin, "Physical inventory indicator
wrtzl LIKE iseg-wrtzl, "Value of phy. inv count
END OF t_iseg,
*
BEGIN OF t_mara,
matnr LIKE mara-matnr, "Material number
matkl LIKE mara-matkl, "Material group
END OF t_mara,
*
BEGIN OF t_output,
matnr LIKE iseg-matnr, "Material number-1
abcin LIKE iseg-abcin, "Physical inv. indicator-2
lgort LIKE iseg-lgort, "Storage location-3
iblnr LIKE iseg-iblnr, "Physical inv. document-4
zldat LIKE iseg-zldat, "Date of last count-5
gjahr LIKE iseg-gjahr, "Fiscal year-6
erfmg LIKE iseg-erfmg, "Quantity in unit of entry-7
wrtzl LIKE iseg-wrtzl, "Value of phy. inv count-8
END OF t_output.
*
&----
Table Declarations *
&----
DATA : i_mara TYPE STANDARD TABLE OF t_mara WITH HEADER LINE,
i_output TYPE STANDARD TABLE OF t_output,
i_iseg TYPE STANDARD TABLE OF t_iseg.
*
DATA : it_fcat TYPE slis_t_fieldcat_alv,
it_sort TYPE slis_t_sortinfo_alv,
it_header TYPE slis_t_listheader.
*
&----
Work Area Declarations *
&----
DATA : wa_output LIKE LINE OF i_output,
wa_iseg LIKE LINE OF i_iseg.
*
DATA : wa_fcat TYPE slis_fieldcat_alv,
wa_sort TYPE slis_sortinfo_alv,
wa_header TYPE slis_listheader.
*
&----
Constants Declarations *
&----
&----
Input parameters *
&----
Design Selection Screen
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-019.
*
PARAMETERS : p_werks LIKE iseg-werks OBLIGATORY, "Plant
p_gjahr LIKE iseg-gjahr OBLIGATORY. "Fiscal Year
*
SELECT-OPTIONS :
s_matkl FOR mara-matkl, "Material Group
s_matnr FOR mara-matnr, "Materila Number
s_lgort FOR iseg-lgort, "Storage Loc
s_abcin FOR iseg-abcin. "ABC Indicator
*
SELECTION-SCREEN END OF BLOCK b1.
*
&----
INITIALIZATION
&----
INITIALIZATION.
*&----
AT SELECTION-SCREEN
&----
<b>AT SELECTION-SCREEN.
Validate Input At Selection Screen
PERFORM screen_validation.
Authority Check
PERFORM authority_check.</b>
&----
START-OF-SELECTION.
&----
START-OF-SELECTION.
Get Records from ISEG and MARA
PERFORM get_records.
&----
END-OF-SELECTION.
&----
END-OF-SELECTION.
IF i_iseg[] IS INITIAL.
MESSAGE s090(zm) WITH 'No Records Found for the Selection'(001).
*
ELSEIF ( NOT s_matkl[] IS INITIAL ) AND ( i_mara[] IS INITIAL ).
MESSAGE s090(zm) WITH
'Material Group(s) does not contain any Records'(020).
ELSE.
Prepare O/P Table
PERFORM fill_output.
Perform Build Field catalog
PERFORM fill_field_catalog.
ALV O/P Display
PERFORM alv_output.
ENDIF.
&----
*& Form screen_validation
&----
At Selection Screen Validation for Inputs.
----
FORM screen_validation.
*
*Validation for Plant
IF NOT p_werks IS INITIAL.
SELECT COUNT(*) FROM t001w WHERE werks EQ p_werks.
IF sy-subrc NE 0.
MESSAGE e090(zm) WITH
'Plant not found'(002).
ENDIF.
ENDIF.
*
*Validation for Materila Group
IF NOT s_matkl[] IS INITIAL.
SELECT COUNT(*) FROM t023 WHERE matkl IN s_matkl.
IF sy-subrc NE 0.
MESSAGE e090(zm) WITH
'Material Group(s) not found'(003).
ENDIF.
ENDIF.
*
*Validation for Material Number
IF NOT s_matnr[] IS INITIAL.
SELECT COUNT(*) FROM mara WHERE matnr IN s_matnr.
IF sy-subrc NE 0.
MESSAGE e090(zm) WITH
'Material Number(s) not found'(004).
ENDIF.
ENDIF.
*
*Validation for Storage Location
IF NOT s_lgort[] IS INITIAL.
SELECT COUNT(*) FROM t001l WHERE lgort IN s_lgort.
IF sy-subrc NE 0.
MESSAGE e090(zm) WITH
'Storage Location(s) not found'(005).
ENDIF.
ENDIF.
*
*Validation for Release Indicator
IF NOT s_abcin[] IS INITIAL.
SELECT COUNT(*) FROM t159c WHERE werks EQ p_werks
AND abcin IN s_abcin.
IF sy-subrc NE 0.
MESSAGE e090(zm) WITH
'Release Indicator(s) not matched'(006).
ENDIF.
ENDIF.
*
ENDFORM. " screen_validation
&----
*& <b> Form authority_check
&----
Authority Check
----
FORM authority_check.
Authority Check At Plant Level
*
IF sy-subrc <> 0.
MESSAGE e090(zm) WITH 'No Authorization(s) Exisits'(017).
ENDIF.
*
ENDFORM. " authority_check</b>
&----
*& Form get_records
&----
Get all the Required Records
----
FORM get_records.
*
SELECT
iblnr "Physical inventory document
gjahr "Fiscal year
matnr "Material number
werks "Plant
lgort "Storage location
zldat "Date of last count
erfmg "Quantity in unit of entry
abcin "Physical inventory indicator
wrtzl "Value of phy. inv count
INTO TABLE i_iseg FROM iseg
WHERE gjahr EQ p_gjahr
AND werks EQ p_werks
AND matnr IN s_matnr
AND lgort IN s_lgort
AND abcin IN s_abcin.
*
IF sy-subrc = 0.
*
SORT i_iseg BY matnr.
Process When 'Materila Group' is Entered at Sel.Screen
IF NOT s_matkl[] IS INITIAL.
*
SELECT
matnr "Material number
matkl "Material group
INTO TABLE i_mara FROM mara
FOR ALL ENTRIES IN i_iseg
WHERE matnr EQ i_iseg-matnr
AND matkl IN s_matkl.
IF sy-subrc = 0.
SORT i_mara BY matnr.
ENDIF.
ENDIF.
*
ENDIF.
*
ENDFORM. " get_records
&----
*& Form fill_output
&----
Prepare the Out Put Table.
----
FORM fill_output.
*
LOOP AT i_iseg INTO wa_iseg.
*
Select Records with respect to Materila Group
IF NOT s_matkl[] IS INITIAL.
READ TABLE i_mara WITH KEY matnr = wa_iseg-matnr
BINARY SEARCH.
IF sy-subrc <> 0.
CONTINUE.
ENDIF.
ENDIF.
*
wa_output-matnr = wa_iseg-matnr.
wa_output-abcin = wa_iseg-abcin.
wa_output-lgort = wa_iseg-lgort.
wa_output-iblnr = wa_iseg-iblnr.
wa_output-zldat = wa_iseg-zldat.
wa_output-erfmg = wa_iseg-erfmg.
wa_output-wrtzl = wa_iseg-wrtzl.
*
APPEND wa_output TO i_output.
*
CLEAR : wa_iseg,
wa_output.
*
ENDLOOP.
*
ENDFORM. " fill_output
*&----
*& Form fill_field_catalog
*&----
Build Field Catalog
*----
*
FORM fill_field_catalog.
*
CLEAR wa_fcat.
wa_fcat-fieldname = 'MATNR'.
wa_fcat-outputlen = 25. "colume width
wa_fcat-seltext_m = 'Part No'(010).
wa_fcat-col_pos = 1.
wa_fcat-key = 'X'.
APPEND wa_fcat TO it_fcat.
*
CLEAR wa_fcat.
wa_fcat-fieldname = 'ABCIN'.
wa_fcat-outputlen = 14. "colume width
wa_fcat-seltext_m = 'ABC Indicator.'(011).
wa_fcat-col_pos = 2.
wa_fcat-key = 'X'.
APPEND wa_fcat TO it_fcat.
*
CLEAR wa_fcat.
wa_fcat-fieldname = 'LGORT'.
wa_fcat-outputlen = 9. "colume width
wa_fcat-seltext_m = 'Location'(012).
wa_fcat-col_pos = 3.
APPEND wa_fcat TO it_fcat.
*
CLEAR wa_fcat.
wa_fcat-fieldname = 'IBLNR'.
wa_fcat-outputlen = 10. "colume width
wa_fcat-seltext_m = 'PI Doc'(013).
wa_fcat-col_pos = 4.
APPEND wa_fcat TO it_fcat.
*
CLEAR wa_fcat.
wa_fcat-fieldname = 'ZLDAT'.
wa_fcat-outputlen = 11. "colume width
wa_fcat-seltext_m = 'Count Date'(014).
wa_fcat-col_pos = 5.
APPEND wa_fcat TO it_fcat.
*
CLEAR wa_fcat.
wa_fcat-fieldname = 'ERFMG'.
wa_fcat-outputlen = 13. "colume width
wa_fcat-seltext_m = 'Count Qty'(015).
wa_fcat-col_pos = 6.
APPEND wa_fcat TO it_fcat.
*
CLEAR wa_fcat.
wa_fcat-fieldname = 'WRTZL'.
wa_fcat-currency = 'USD'.
wa_fcat-outputlen = 15. "colume width
wa_fcat-seltext_m = 'Amount'(016).
wa_fcat-col_pos = 7.
APPEND wa_fcat TO it_fcat.
*
*Build Sort Info Table
wa_sort-spos = 1.
wa_sort-fieldname = 'MATNR'.
wa_sort-up = 'X'.
APPEND wa_sort TO it_sort.
CLEAR wa_sort.
*
wa_sort-spos = 2.
wa_sort-fieldname = 'ABCIN'.
wa_sort-up = 'X'.
APPEND wa_sort TO it_sort.
CLEAR wa_sort.
*
wa_sort-spos = 4.
wa_sort-fieldname = 'IBLNR'.
wa_sort-up = 'X'.
APPEND wa_sort TO it_sort.
CLEAR wa_sort.
*ENDFORM. " fill_field_catalog
*&----
*& Form alv_output
*&----
ALV O/P Display
*----
*
FORM alv_output.
*
DATA : v_prog LIKE sy-repid.
*
v_prog = sy-repid.
*
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = v_prog
it_fieldcat = it_fcat[]
it_sort = it_sort[]
i_callback_top_of_page = 'TOP_OF_PAGE'
TABLES
t_outtab = i_output[].
*
ENDFORM. " alv_output
&----
*& Form toppage
&----
Write Header Commentry
----
FORM top_of_page.
*
DATA : v_matgrp(50) TYPE c.
*
Prepare Commentry Table
wa_header-typ = 'H'.
wa_header-info = 'Cycle Count History'(021).
APPEND wa_header TO it_header.
CLEAR wa_header.
*
wa_header-typ = 'S'.
wa_header-key = 'Plant'(022).
wa_header-info = p_werks.
APPEND wa_header TO it_header.
CLEAR wa_header.
*
wa_header-typ = 'S'.
wa_header-key = 'Fiscal Year'(023).
wa_header-info = p_gjahr.
APPEND wa_header TO it_header.
CLEAR wa_header.
*
Prepare 'Form' 'To' Header for Material Group
CONCATENATE s_matkl-low 'TO' s_matkl-high
INTO v_matgrp SEPARATED BY space.
*
wa_header-typ = 'S'.
wa_header-key = 'Material Group'(024).
wa_header-info = v_matgrp.
APPEND wa_header TO it_header.
CLEAR wa_header.
*
PERFORM write_commentary.
*
ENDFORM. " toppage
&----
*& Form write_commentary
&----
Write Commentary Header
----
FORM write_commentary.
Call Function Write Commentry
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = it_header.
*
REFRESH it_header.
*
ENDFORM. " write_commentary */
‎2007 Oct 31 12:34 PM
‎2007 Oct 31 1:49 PM
Hi,
By transaction PFCG or consult with basis people..
Regards
Gagan