We will be going through a very common requirement,
How to make a Input Field as Read Only and then auto populate with default value ?
Just a few steps and then done..!!
1. Find the feeder class of the application.
2. Create a new Z global class by inheriting the standard feeder class.
3. In the newly created Z class, go to method GET_DATA,
here first invoke the super class GET_DATA method,
then
LOOP AT ct_field_usage INTO l_field_usage WHERE name eq <fld name>. l_tabix = sy-tabix. l_field_usage-read_only = abap_true. MODIFY ct_field_usage FROM l_field_usage INDEX l_tabix TRANSPORTING read_only."This makes our field Noneditable ev_field_usage_changed = abap_true. ASSIGN COMPONENT <fld name> OF STRUCTURE cs_data TO <l_data>. IF <l_data> IS ASSIGNED. <l_data> = default value. ev_data_changed = abap_true. CLEAR l_change_log. l_change_log-name = < fld name>. GET REFERENCE OF <l_data> INTO l_change_log-new_value. CLEAR lt_change_log. INSERT l_change_log INTO TABLE lt_change_log. GET REFERENCE OF cs_data INTO lcs_data. CALL METHOD if_fpm_guibb_form~flush EXPORTING it_change_log = lt_change_log is_data = lcs_data. ENDIF. ENDLOOP.
4. In the FPM config, now replace the standard feeder class with the new Z feeder class created now.
We are done now, we can test our application..!!
Further Reading :
It's a real good article for Feeder Class related basics,
Generic UI Building Block - Service Provider Infrastructure (SPI) - SCN Wiki
Suggestion :
Please come up with comments / suggestion / feedback for this article,
which can help in further value addition of this blog.
Thanking You All..!!