Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Authority Object

Former Member
0 Likes
1,056

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.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
825

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:

http://sap.ittoolbox.com/groups/technical-functional/sap-dev/how-to-loop-through-itab-and-get-field-...

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_

4 REPLIES 4
Read only

Former Member
0 Likes
825

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

Read only

Former Member
0 Likes
825

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

Read only

GauthamV
Active Contributor
0 Likes
825

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.

Read only

Former Member
0 Likes
826

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:

http://sap.ittoolbox.com/groups/technical-functional/sap-dev/how-to-loop-through-itab-and-get-field-...

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_