Tip

Making row selection in a table control dynamic

When a table control is used in a screen, the users selection of row(s) in the table control doesn't invoke any 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:

    Requires Free Membership to View

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

		
		

This was first published in March 2002

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.