Change of Cell in Webinterface works only after Refresh
I'm stuck here at a clients site and hope somebody of you guys can help me out.
I have a Webinterface which shows a layout with some characteristics and a 2 keyfigure columns. Depending on a condition the keyfigure of one column (col 22) should be input ready or protected from input. Found out, that this can be done by changing LR_LAY->MT_HTML_CELL-VALUE_TYPE.
This actually works fine. My problem now is that this only works after a refresh. Tried to move the code to the method Initialization, but the cant be used there like that.
Any hint would be appreciated!
Here is the coding:
method DISPATCH. constants: C_LAYOUT_CLASS type STRING value 'LAYOUT', C_LAYOUT_METHOD type STRING value 'API_GET_DATA'. data: LR_COMPONENT type ref to IF_UPWB_C_COMPONENT, LR_CONVERT type ref to IF_UPWB_C_COMPONENT, LR_LAY type ref to IF_UPWB_C_LAYOUT2, LR_FUNC type ref to IF_UPWB_C_BUT_FUNCTION, LV_CLASS type STRING, LV_ID type STRING, LV_SUBRC like SY-SUBRC, LT_MSG_LOG type table of BAPIRET2. field-symbols: <LY_CELL> type UPWB_YS_HTML_CELL. LR_COMPONENT ?= IS_HANDLER-COMPONENT. LV_ID = LR_COMPONENT->GET_ID( ). LV_CLASS = LR_COMPONENT->GET_CLASS( ). * Gewünschte Methode? if LV_CLASS = C_LAYOUT_CLASS and IS_HANDLER-METHOD = C_LAYOUT_METHOD. LR_LAY ?= LR_COMPONENT. if LR_LAY is bound and LR_LAY->MT_HTML_CELL is not initial. loop at LR_LAY->MT_HTML_CELL assigning <LY_CELL> where COL = '22' and VALUE_TYPE = 'I'. <LY_CELL>-VALUE_TYPE = SPACE. modify LR_LAY->MT_HTML_CELL from <LY_CELL>. endloop. endif. endif. endif. if R_SUBRC is initial. call method SUPER->DISPATCH exporting IS_HANDLER = IS_HANDLER receiving R_SUBRC = R_SUBRC. endif. endmethod. "dispatch
We can achieve this through a simple macro which runs when layout opens.
IF condition TRUE
cells(row,column).disable = true.
This will disable the cell from user entry. Keep this code in SAPAFTERDATAPUT and give tick for SAPAFTERDATAPUT in the excel settings of your layout so that it runs automatically when layout opens.