Setting the background design dynamically
I recently had an requirement to highlight changes to input fields dynamically. To my surprise I didn’t find any examples on SCN so I went ahead and implemented a simple solution myself. I don’t know exactly the reason why background design can’t be bound to a context element and changed dynamically but you can work around the restriction with the attached solution. NetWeaver Application Server ABAP 7.31 SPS04 was used for the implementation.
Create a method called SET_BGDES with the import parameters IO_VIEW (ref to IF_WD_VIEW), IV_ATTR_NAME (STRING) and IV_BGDES (WDUI_CELL_BG_DESIGN). Call the method from WDDOMODIFYVIEW for any pair of labels and input elements you want to change the background design for, specifying the background design type. See cl_wd_matrix_data=>e_cell_background_design for possible values of background design.
wd_this->set_bgdes( io_view = io_view
iv_attr_name = ‘<XYZ>’
iv_bgdes = cl_wd_matrix_data=>e_cell_background_design-transparent )
Labels on the layout should be named LBL_<XYZ> and the respective input fields INP_<XYZ>. All elements should be contained in layouts of type MatrixData or MatrixHeadData. See the attachment for the coding of the method SET_BGDES.