‎2011 Jul 01 2:37 AM
Hi Guru's,
I am facing a bit of problem to understand authority objects.
For example. : I have authority object - ZXYZ
Which has 3 id's - A, B, C.
Based on the authority - I have to set certain editable columns in a custom report as not editable.
If autho object zxyz and id A is sy-subrc = 0 then column one will be non editable, but col 2 and 3 will be editable.
How can we achieve the same?
Br,
Swordfish.
‎2011 Jul 01 5:53 AM
hello,
if you are using ALV grid the code should look something like this (i will write only parts of code for better understanding):
1) create field catalog based on custom structure
call function 'LVC_FIELDCATALOG_MERGE'
exporting
i_structure_name = 'ZPPREQ_ALV_ST'
changing
ct_fieldcat = gt_fieldcat[]
exceptions
inconsistent_interface = 1
program_error = 2
others = 3.
ls_fiedcat-edit = 'X'.
modify gt_fieldcat from ls_fiedcat transporting edit where fieldname = 'BUKRS' or fieldname = 'GJAHR'.
ZPPREQ_ALV_ST - is a custom structure which you have to create via se80 tcode and it should have field CELL_TAB type LVC_T_STYL. it is table responsible for fields edit state.
2) define ALV grids layout:
cs_layout-zebra = 'X' .
cs_layout-smalltitle = 'X'.
cs_layout-cwidth_opt = 'X'.
cs_layout-stylefname = 'CELL_TAB'.
cs_layout-edit = 'X'.you have to identify that this table is responsible for cells style (editable/ non editable)
3) Select data and call ALV grids object for first display and make additional logic if it is required.
4) change fields state:
loop at it_outab reference into lp_outtab.
authority-check object 'F_BKPF_BUK'
id 'BUKRS' field lp_outtab->bukrs
id 'ACTVT' field '02'.
if sy-subrc ne 0.you can get fields name dynamically:
or you could use some other logic up to you.
case fieldname.
when 'BUKRS'
ls_cell_tab-fieldname = 'BUKRS'.
ls_cell_tab-style = cl_gui_alv_grid=>mc_style_disabled.
append ls_cell_tab to lp_outtab-cell_tab.
WHEN 'GJAHR
....
when others
endcase.
endif.
endloop.br,
dez_
‎2011 Jul 01 5:38 AM
Hi,
You can achieve this as follows:
IF sy-tcode EQ 'tcode-name'.
AUTHORITY-CHECK OBJECT 'zxyz'
ID 'zxyz_tcode' FIELD 'tcode_name'
ID 'zxyz_field' FIELD 'col_name'
ID 'ACTVT' FIELD '02'.
ENDIF.01 - create or generate
02 - change
03 - display
'zxyz_tcode' - are the Authorization fields that needs to be configured in the Authorization Object.
Regards,
Sowmya
‎2011 Jul 01 5:41 AM
Please refer the below link:
[http://sap.mis.cmich.edu/sap-abap/abap06/sld023.htm|http://sap.mis.cmich.edu/sap-abap/abap06/sld023.htm]
The above example is same as your requirement.
Regards,
Sowmya
‎2011 Jul 01 5:43 AM
Try this logic by passing different values to g_field and gc_field.
IF g_field IS NOT INITIAL.
AUTHORITY-CHECK OBJECT 'ZOBJECT'
FOR USER g_user
ID 'ZFIELD' FIELD g_field.
IF sy-subrc NE 0.
LOOP AT SCREEN.
IF screen-name = gc_field.
screen-input = gc_false.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
ENDIF.
ENDIF.
‎2011 Jul 01 5:53 AM
hello,
if you are using ALV grid the code should look something like this (i will write only parts of code for better understanding):
1) create field catalog based on custom structure
call function 'LVC_FIELDCATALOG_MERGE'
exporting
i_structure_name = 'ZPPREQ_ALV_ST'
changing
ct_fieldcat = gt_fieldcat[]
exceptions
inconsistent_interface = 1
program_error = 2
others = 3.
ls_fiedcat-edit = 'X'.
modify gt_fieldcat from ls_fiedcat transporting edit where fieldname = 'BUKRS' or fieldname = 'GJAHR'.
ZPPREQ_ALV_ST - is a custom structure which you have to create via se80 tcode and it should have field CELL_TAB type LVC_T_STYL. it is table responsible for fields edit state.
2) define ALV grids layout:
cs_layout-zebra = 'X' .
cs_layout-smalltitle = 'X'.
cs_layout-cwidth_opt = 'X'.
cs_layout-stylefname = 'CELL_TAB'.
cs_layout-edit = 'X'.you have to identify that this table is responsible for cells style (editable/ non editable)
3) Select data and call ALV grids object for first display and make additional logic if it is required.
4) change fields state:
loop at it_outab reference into lp_outtab.
authority-check object 'F_BKPF_BUK'
id 'BUKRS' field lp_outtab->bukrs
id 'ACTVT' field '02'.
if sy-subrc ne 0.you can get fields name dynamically:
or you could use some other logic up to you.
case fieldname.
when 'BUKRS'
ls_cell_tab-fieldname = 'BUKRS'.
ls_cell_tab-style = cl_gui_alv_grid=>mc_style_disabled.
append ls_cell_tab to lp_outtab-cell_tab.
WHEN 'GJAHR
....
when others
endcase.
endif.
endloop.br,
dez_