cancel
Showing results for 
Search instead for 
Did you mean: 

Changing field usage in Feeder class for Lists

benjamin_allsopp
Active Participant
0 Kudos

Hi,

We have a requirement to hide fields, and set as read only, and mandatory dynamically at run time on standard UIBBs.

To achieve this I am editing the GET_DATA method of the Feeder class and changing ct_field_usage. And then setting  ev_field_usage_changed = abap_true.

This seems to work well for the FEEDER_FORM classes but is not working on the FEEDER_LIST classes. For instance the Dimensions UIBB fields are not becoming read only.

I have debugged the code and seen that ct_field_usage for my fields is in fact being changed (to read only) but the UI is keeping these fields as editable.

What am I doing wrong?

Thanks in advance

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Benjamin,

Try with below code...

FIELD-SYMBOLS: <fs_field> TYPE fpmgb_s_fieldusage.

" To set visibility

READ TABLE ct_field_usage ASSIGNING <fs_field> WITH KEY name = 'FIELD_NAME1'.

        IF sy-subrc EQ 0.

           <fs_field>-visibility = 01.

          ELSE.

            <fs_field>-visibility = 02.

        ENDIF.

         ev_field_usage_changed = abap_true.

" To set read only property

READ TABLE ct_field_usage ASSIGNING <fs_field> WITH KEY name = 'FIELD_NAME2'.

        IF sy-subrc EQ 0.

           <fs_field>-read_only = 'X'.

          ELSE.

           <fs_field>-read_only = ''.

        ENDIF.

         ev_field_usage_changed = abap_true.

Best Regards,

Naga

benjamin_allsopp
Active Participant
0 Kudos

Thanks Naga...

Your code doesn't work...it generates a short dump for trying to use an unassigned field symbol. I modified it as such to get it to work...

FIELD-SYMBOLS: <fs_field> TYPE fpmgb_s_fieldusage.

* To set read only property

READ TABLE ct_field_usage ASSIGNING <fs_field> WITH KEY name = 'FIELD_NAME2'.

  

    IF sy-subrc EQ 0.

           <fs_field>-read_only = 'X'.

        ENDIF.

   

    ev_field_usage_changed = abap_true.

It still didn't have the desired effect. The problem is, I was already doing this code, except using work areas instead of field symbols. And then modifying ct_field_usage by the changed structure.

Using structures successfully changes ct_field_usage. And so does your field symbol method. But the fields still are not read only. The same bit of code is successfully changing the visibility so I'm beginning to wander if some SAP standard code is resetting the read only flag after the get_data method.

I've tried to work out which methods are executed after get_data but none seem to reset the flag.

Do we know what methods are fired after get_data which could change read only status of a field?

Former Member
0 Kudos

Hi Benjamin,

Could please share your code?? Is there any problem with display type in the list uibb?

Regards,

Naga

0 Kudos

Benjamin,

I also faced the same problem setting the  read_only field in the list UIBB and it didn't work . In our requirement we have to disable the manual entry of Articles and we used following code ( As i mentioned earlier ) to achieve this in GET_DATA method.

FIELD-SYMBOLS: <FS_FIELD> TYPE FPMGB_S_FIELDUSAGE.

UNASSIGN <FS_FIELD>.

       READ TABLE CT_FIELD_USAGE ASSIGNING <FS_FIELD>

       WITH KEY  NAME = 'MABNR'.

       IF <FS_FIELD> IS ASSIGNED.

         CV_FIELD_USAGE_CHANGED = 'X'.

         CV_ACTION_USAGE_CHANGED = 'X'.

         <FS_FIELD>-ENABLED   = ' '.

        

       ENDIF.




ulrich_miller
Active Participant
0 Kudos

Hi there,

just a small question: You say you like to change the property read_only and that it does not work. Well in your code snippet I can see this:

<FS_FIELD>-ENABLED   = ' '


but why not doing like this


<FS_FIELD>-READ_ONLY   =  ABAP_TRUE.


???

0 Kudos

Hi,

In  our requirement , we wanted to disable the entry Material number  ( ERP_SLS_LO_OIF  Lean Order ) dynamically ( Based on the order types ) . We did try with READ_ONLY property , but the based on SD System level configuration over writing the READ_ONLY property , so we disabled the column by setting the ENABLED property to ABAP_FALSE .

Thx,

Dingari

ulrich_miller
Active Participant
0 Kudos

I see, my recommendation would be to just set both read_only and enabled.

benjamin_allsopp
Active Participant
0 Kudos

Do you know which standard config was overwriting your values?

benjamin_allsopp
Active Participant
0 Kudos

Below is the exact code I am using at the moment - this is a copy of code I am using in the FEEDER_FORM class which works as desired.


zmdgm_ui_config is a custom table containing lists of fields against CR types and Step numbers as well as the fields from ct_field_usage (for example read_only and visibility) and is a way to dynamically set the field usage


* Get Read-only Access to USMD Model Data & Retrieve Change Request Info

     call method cl_usmd_model_ext=>get_instance

     exporting

       i_usmd_model = 'MM'

     importing

       eo_instance  = lr_model.

     lo_app_context = cl_usmd_app_context=>get_context( ).

     if not lo_app_context is initial.

       lo_app_context->get_attributes(

       importing

         ev_crequest_type = lv_crequest_type

         ev_crequest_step = lv_crequest_step ).

     endif.

* Loop Through Field Usage Parameter for Each Field

     sort ct_field_usage by name ascending.

     lt_field_usage = ct_field_usage.

     loop at lt_field_usage into ls_field_usage.


* Change the field usage based on UI config table

       select single *

       from zmdgm_ui_config

       into ls_zmdgm_ui_config

       where crtype eq lv_crequest_type

       and step       eq lv_crequest_step

       and name     eq ls_field_usage-name.


       if sy-subrc = 0.

         ls_field_usage-visibility = ls_zmdgm_ui_config-visibility.

         ls_field_usage-read_only = ls_zmdgm_ui_config-read_only.

         ls_field_usage-mandatory = ls_zmdgm_ui_config-mandatory.

         ls_field_usage-enabled   = ls_zmdgm_ui_config-enabled.


* Retrieve index of Parameter and change the appropriate row according to UI Config Table

         read table ct_field_usage

         with key name = ls_zmdgm_ui_config-name transporting no fields

         binary search.

         modify ct_field_usage index sy-tabix from ls_field_usage.

       endif.

     endloop.

* Set Parameter to Changed

         ev_field_usage_changed    = abap_true.

ulrich_miller
Active Participant
0 Kudos

I am sorry, what do you mean by "standard config"?

benjamin_allsopp
Active Participant
0 Kudos

Sorry, that wasn't very well phrased.

I was referring to whatever was overwriting the read only flag in Dingari's message.


Haricharan Dingari wrote:

...but the based on SD System level configuration over writing the READ_ONLY property...

Essentially I'm trying to pinpoint where and why our read only flag might be being overwritten; I've started to debug the process after the get_data method is called but there's a lot going on before the screen is output so any knowledge about where this data might be changed would be helpful.

Hi,

There is a Check in the DISPATCH_PBO Method for the READ_ONLY Property ( CL_FPM_LIST_UIBB_ASSIST ). Even though you set the READ_ONLY Property in the GET_DATA method , property is over written here if there is a READ_ONL_REF filed exists for the given Column.

What we can do is

1. GET_DEFINITION Method , Clear out the READ_ONLY_REF  field for the Given Column

READ TABLE CT_FIELD_DESCRIPTION WITH KEY NAME = 'KWMENG'

       ASSIGNING <FS_FIELD>.

       IF <FS_FIELD> IS ASSIGNED.

         <FS_FIELD>-READ_ONLY_REF = ' '.

   "      <FS_FIELD>-HEADER_LABEL = 'GPP'.

       ENDIF.

2. Then in GET_DATA Method set the property READ_ONLY

UNASSIGN <FS_FIELD>.

      READ TABLE CT_FIELD_USAGE ASSIGNING <FS_FIELD>

      WITH KEY  NAME = 'KWMENG'.

      IF <FS_FIELD> IS ASSIGNED.

        CV_FIELD_USAGE_CHANGED = 'X'.

        CV_ACTION_USAGE_CHANGED = 'X'.

        <FS_FIELD>-READ_ONLY = 'X'.

      ENDIF.

Please try this code and let me know .

Thanks,

Dingari

ulrich_miller
Active Participant
0 Kudos

Hi Dingari,
yes I think you are correct. In List ATS UIBB there are two ways to control the read only property.

One is via read_only_ref in method get_definition, parameter et_field_description. And the other way is via parameter ct_field_usage read only in method get_data.

Now, it is like this: If both are used then the first has priority. I. e. if read_only_ref has a value then field usage read only property is ignored.

Kind regards,
Ulrich

benjamin_allsopp
Active Participant
0 Kudos

Dingari,

Worked perfectly. Thank you very much for your assistance in this!

Answers (2)

Answers (2)

benjamin_allsopp
Active Participant
0 Kudos

Hi Guys,

I'm still searching for the answer to this and still not getting the desired results.

I've tried editing the GET_DEFINITION method with the following enhancement code:

FIELD-SYMBOLS <ls_field_descr> TYPE fpmgb_s_listfield_descr.

LOOP AT et_field_description ASSIGNING <ls_field_descr>.

  if <ls_field_descr>-name = 'ZZTEST'.

  <ls_field_descr>-read_only = abap_true.

  <ls_field_descr>-read_only_ref = <ls_field_descr>-name.

  ENDIF.

  endloop.

The test field is becoming read only in the table using this code; making the whole visible list read only now BUT this only works for entries already made...the user can still add lines at the bottom of the list.

any further ideas on how to get this working?

any new ideas on how to make everything in this workflow step read only?

any work around ideas?

former_member469314
Participant
0 Kudos

Have you activated the "add_lines" option in the UIBB configuration? You could try to deactivate this option and add empty lines at the end of the table in method GET_DATA when the user should be able to add lines.

benjamin_allsopp
Active Participant
0 Kudos

Thanks Rebekka,

This would mean we'd have to combine several bits of coding into what should be a simple job:

  1. Dynamically (for different CR types and steps) disable the Action buttons on the list UIBBs in the get_data method
  2. Dynamically (for different CR types and steps) force the fields into read only using the get_definitions method and setting read only ref field
  3. Remove the empty lines at the bottom of the table for each of the list UIBBS

as well as

   4.  Dynamically (for different CR types and steps)  hiding fields where applicable using the get_data method because inexplicably hiding the fields works here, whereas setting read only does not

0 Kudos

Try

READ TABLE CT_FIELD_USAGE ASSIGNING <FS_FIELD>

       WITH KEY  NAME = 'XXX'.


IF  <FS_FIELD> IS ASSIGNED.

         CV_FIELD_USAGE_CHANGED = 'X'.

         CV_ACTION_USAGE_CHANGED = 'X'.

         <FS_FIELD>-ENABLED   = ' '.

        

       ENDIF.

benjamin_allsopp
Active Participant
0 Kudos

Thank you for you reply...

I have added this code in and the field usage is changing in ct_field_usage (as seen in debugging) and ev_field_usage_changed & ev_action_usage_changed flagged...but the fields selected are still not displaying the appropriate behavior.

Anything displayed on FORM feeder classes is working as expected. It's just any fields in a LIST feeder class which isn't working.

Is there something that can be done to lock the whole table down?

former_member469314
Participant
0 Kudos

Are you using a LIST_UIBB or a LIST_UIBB_ATS?

benjamin_allsopp
Active Participant
0 Kudos

That's a good question...all my lists are LIST_UIBB_ATS.


What does that mean for changing field behaviour? Do I have to use a different method?

former_member469314
Participant
0 Kudos

As far as I know the usage of the methods for LIST and LIST_ATS is the same, but I just tried it myself and it worked with a LIST_UIBB_ATS, but not for the LIST_UIBB. I used the same feeder class for both UIBBs, but with the normal LIST it didn't work.

If you would have been using the normal LIST_UIBB it might have helped to switch to the LIST_UIBB_ATS, but as you are already using the LIST_ATS I'm not sure what might be the problem.