cancel
Showing results for 
Search instead for 
Did you mean: 

CT_FIELD_USAGE-Visibility has no effect

roger_beach
Participant
0 Kudos

Working in CL_HRESS_PER_OVERVIEW->IF_FPM_GUIBB_LIST~GET_DATA

I have created an implicit enhancement at the end of the method to manipulate visibility of fields that have no value.  Essentially if the field is blank then I do not want to show it on the overview screen.

I can follow what I've done in the debugger and see that the visibility for those fields in the ct_field_usage does indeed change from 02 to 01.  However, the fields still come on the screen.

Following is my enhancement:


FIELD-SYMBOLS : <ct_field_usage_wa>  LIKE LINE OF ct_field_usage.

IF ms_object_key = 'HRPAD IT0021'.

   LOOP AT <lt_data> ASSIGNING <lt_ct_data>.

     ASSIGN COMPONENT 'DISPLAY_COLUMN' OF STRUCTURE <lt_ct_data> TO <lt_display_column>.

     <lt_display_column> = ''.

   ENDLOOP.

   ct_data = <lt_data>.

ELSEIF ms_object_key = 'HRPAD IT9007'.

   LOOP AT <lt_data> ASSIGNING <lt_ct_data>.

     ASSIGN COMPONENT 'OVRD_CONTR_LVL' OF STRUCTURE <lt_ct_data> TO <lt_display_column>.

     IF <lt_display_column> IS ASSIGNED AND <lt_display_column> = ''.

       READ TABLE ct_field_usage ASSIGNING <ct_field_usage_wa> WITH KEY name = 'OVRD_CONTR_LVL'.

       IF sy-subrc = 0.

         <ct_field_usage_wa>-visibility = cl_wd_uielement=>e_visible-none.

         ev_field_usage_changed = abap_true.

       ENDIF.

       UNASSIGN <lt_display_column>.

     ENDIF.

     ASSIGN COMPONENT 'VEST_CONTR_LVL' OF STRUCTURE <lt_ct_data> TO <lt_display_column>.

     IF <lt_display_column> IS ASSIGNED AND <lt_display_column> = ''.

       READ TABLE ct_field_usage ASSIGNING <ct_field_usage_wa> WITH KEY name = 'VEST_CONTR_LVL'.

       IF sy-subrc = 0.

         <ct_field_usage_wa>-visibility = cl_wd_uielement=>e_visible-none.

         ev_field_usage_changed = abap_true.

       ENDIF.

     ENDIF.

   ENDLOOP.

ENDIF.

Is this an incorrect place to attempt to control visibility?

Accepted Solutions (1)

Accepted Solutions (1)

siddharthrajora
Product and Topic Expert
Product and Topic Expert
0 Kudos

There is a method GET_DATA where the visibility of the fields can be set via parameter CT_FIELD_USAGE (component VISIBILITY). However this is not per record; this affects all records. If you want to set the visibility per record, the visibility information has to be part of the data table CT_DATA. I.e. it has to be a special field within CT_DATA that holds visibility information about an infotype field. Both fields need to be linked. At runtime you have to fill this special field with the corresponding visibility information. The linkage of the special field to the infotype field has to be done in method GET_DEFINITION via parameter ET_FIELD_DESCRIPTION component VISIBILITY_REF.

sahirn
Active Contributor
0 Kudos

You would have to proceed as Siddharth indicated...

If you would like to set these attributes for single cells, proceed as follows:

1. Create a new column for the table (add a field to the field catalog in the

GET_DEFINITION method).

2. Define the column as a technical column that is not visible at runtime, by setting the

field technical_field to „X‟. This column contains the properties of the cells.

3. In the GET_DEFINITION method, adjust the field description accordingly. For example,

you have a column A and you want to set the property Read_only for single cells in

that column. For this reason you created a technical column B. In the field description,

set read_only_ref to B.

There after set the value of column B per record as per your logic in get_data.

Refer to post

Hope this helps.

With regards,

Sahir

roger_beach
Participant
0 Kudos

Thanks Siddharth!!

It worked perfectly.

Answers (0)