Making row selection in a table control dynamic
When table control is used in a screen, the selection of row(s) in table control doesn't invoke a PAI event automatically.
When a table control is used in a screen, the users selection of row(s) in the table control doesn't invoke any...
Continue Reading This Article
Enjoy this article as well as all of our content, including E-Guides, news, tips and more.
PAI event automatically.
But in some cases, users row selection on table control should be responded immediately without waiting until next PAI event is invoked. For eg. Customer asked me to change the menu dynamically when user select or deselect a row (only single selection is allowed in this scenario.)
Solution:
Added a push button (with function code 'ROWS') as the first column in the table control.
Deselected the "lineselection" option of the tablecontrol.
Used a variable "prev_selected" to reflect the on/off state of the button.
when ok-code = 'ROWS', identified the selected row using "GET CURSOR FIELD...." (PAI)
When the button state changed from "off" to "on" highlighted the selected row using the "SCREEN-INTENSIFIED" attribute inside the loop at screen(PBO)
Portion of the ABAP code (PAI and PBO) is shown below. TBL_ZAWBST is the table control variable.
PROCESS BEFORE OUTPUT. MODULE STATUS_0100. LOOP AT INT_TRIGGERS WITH CONTROL TBL_ZAWBST CURSOR TBL_ZAWBST-CURRENT_LINE. MODULE DISPLAY_TRIGGERS. ENDLOOP. PROCESS AFTER INPUT. LOOP AT INT_TRIGGERS. MODULE SET_LINE_COUNT. ENDLOOP. MODULE USER_COMMAND_0100. PAI MODULE USER_COMMAND_0100 input. WHEN 'ROWS' . GET CURSOR FIELD CSL_FIELD LINE CSL_LINE. * IDX = CSL_LINE + TBL_ZAWBST-TOP_LINE - 1. IF IDX > 0. READ TABLE INT_TRIGGERS INDEX IDX. PREV_SELECTED = ''. IF INT_TRIGGERS-CHK_TBL_ZAWBST = 'X'. PREV_SELECTED = 'X'. ENDIF. LINE_COUNT = 0. LOOP AT INT_TRIGGERS. CLEAR WA_INT_TRIGGERS. WA_INT_TRIGGERS = INT_TRIGGERS. LINE_COUNT = LINE_COUNT + 1. WA_INT_TRIGGERS-CHK_TBL_ZAWBST = ''. MODIFY INT_TRIGGERS FROM WA_INT_TRIGGERS INDEX LINE_COUNT. ENDLOOP. READ TABLE INT_TRIGGERS INDEX IDX. IF PREV_SELECTED = ''. INT_TRIGGERS-CHK_TBL_ZAWBST = 'X'. ROW_SELECTED = 'x'. ELSE. ROW_SELECTED = ''. ENDIF. MODIFY INT_TRIGGERS INDEX IDX. ENDIF. PBO *&---------------------------------------------------------------------* *& Module DISPLAY_TRIGGERS OUTPUT *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* MODULE DISPLAY_TRIGGERS OUTPUT. IF LIN < 1. EXIT FROM STEP-LOOP. ENDIF. CHK_TBL_ZAWBST =''. IF INT_TRIGGERS-CHK_TBL_ZAWBST NE ''. CHK_TBL_ZAWBST ='X'. LOOP AT SCREEN. IF SCREEN-NAME = 'ZAWBST-WBSTYP' OR SCREEN-NAME = 'ZAWBST-WBSTNR' OR SCREEN-NAME = 'ZAWBST-WFCLO' OR SCREEN-NAME = 'ZAWBST-WFCHI' OR SCREEN-NAME = 'ZAWBST-WFNDL' OR SCREEN-NAME = 'ZAWBST-WFNDH' OR * screen-name = 'ZAWBST-TRIGR' OR SCREEN-NAME = 'ZAWBST-TROPR' OR SCREEN-NAME = 'ZAWBST-TRVAL' OR SCREEN-NAME = 'ZAWBST-WBSOA' OR SCREEN-NAME = 'ZAWBST-WBSOC' OR SCREEN-NAME = 'ZAWBST-WBSOD'. SCREEN-INTENSIFIED = '1'. ENDIF. MODIFY SCREEN. ENDLOOP. ENDIF. ZAWBST-WBSTYP = INT_TRIGGERS-WBSTYP. ZAWBST-WBSTNR = INT_TRIGGERS-WBSTNR. ZAWBST-WFCLO = INT_TRIGGERS-WFCLO. ZAWBST-WFCHI = INT_TRIGGERS-WFCHI. ZAWBST-WFNDL = INT_TRIGGERS-WFNDL. ZAWBST-WFNDH = INT_TRIGGERS-WFNDH. * zawbst-trigr = int_triggers-trigr. ZAWBST-TROPR = INT_TRIGGERS-TROPR. ZAWBST-TRVAL = INT_TRIGGERS-TRVAL. ZAWBST-WBSOA = INT_TRIGGERS-WBSOA. ZAWBST-WBSOC = INT_TRIGGERS-WBSOC. ZAWBST-WBSOD = INT_TRIGGERS-WBSOD. ENDMODULE. " DISPLAY_TRIGGERS OUTPUT