Skip to Content
author's profile photo Former Member
Former Member

Multi selection

Hi all,

how can I use the multi selection in table controls? So what command I use to get all lines I have selected?

Thanks for your help,

Fabian

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Mar 24, 2006 at 04:06 PM

    u can add one button and write code for that,

    in PAI

    case sy-ucomm.
    
      when 'ALL'.
        loop at itab.
           itab-sel = 'x'.
           modify itab transporting sel.
           clear itab.
        endloop.
    endcase.

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Your table control must be populating data in some internal table (where you have added new character column which is updated with X for selected record).

      So in PAI loop at table control pass on all data to internal table. There you need to make sure this selection value also gets updated in internal table.

  • Posted on Mar 24, 2006 at 05:14 PM

    Hi Fabian,

    You can take a look at SAP demo program <b>RSDEMO02</b> on how to setup the selection column (Mark).

    Also find the following sample code for table control logic handling based on user selection action.

    MODULE USER_COMMAND_0100 INPUT.
      DATA: FLDNAME(100), HELP(100).
    
      SAVE_OK = OK_CODE.
      CLEAR OK_CODE.
      CASE SAVE_OK.
        WHEN 'TOGGLE'.
          IF DISPLAY = 'X'.
            PERFORM ENQUEUE USING 'E'.
            IF RC = 0.
              DISPLAY = SPACE.
              LOOP AT TC-COLS INTO COL.
                COL-SCREEN-INPUT = '1'.
                MODIFY TC-COLS FROM COL INDEX SY-TABIX.
              ENDLOOP.
            ENDIF.
          ELSE.
            PERFORM ENQUEUE USING 'D'.
            IF RC = 0.
              DISPLAY = 'X'.
              LOOP AT TC-COLS INTO COL.
                COL-SCREEN-INPUT = '0'.
                MODIFY TC-COLS FROM COL INDEX SY-TABIX.
              ENDLOOP.
            ENDIF.
          ENDIF.
    
        WHEN 'SORTUP'.
          READ TABLE TC-COLS INTO COL WITH KEY SELECTED = 'X'.
          IF SY-SUBRC = 0.
            SPLIT COL-SCREEN-NAME AT '-' INTO HELP FLDNAME.
            SORT I_BINLOC ASCENDING BY (FLDNAME).
          ENDIF.
    
        WHEN 'SORTDOWN'.
          READ TABLE TC-COLS INTO COL WITH KEY SELECTED = 'X'.
          IF SY-SUBRC = 0.
            SPLIT COL-SCREEN-NAME AT '-' INTO HELP FLDNAME.
            SORT I_BINLOC DESCENDING BY (FLDNAME).
          ENDIF.
    
        WHEN 'INSERT'.
          READ TABLE TC-COLS INTO COL WITH KEY SCREEN-INPUT = '1'.
          IF SY-SUBRC = 0.
            LOOP AT I_BINLOC INTO ZMBINLOC WHERE ZMARK = 'X'.
              CLEAR ZMBINLOC.
              INSERT ZMBINLOC INTO I_BINLOC INDEX SY-TABIX.
            ENDLOOP.
            DESCRIBE TABLE I_BINLOC LINES TC-LINES.
          ENDIF.
    
        WHEN 'DELETE'.
          READ TABLE TC-COLS INTO COL WITH KEY SCREEN-INPUT = '1'.
          IF SY-SUBRC = 0.
            LOOP AT I_BINLOC INTO ZMBINLOC WHERE ZMARK = 'X'.
              I_DELETE = ZMBINLOC.
              I_DELETE-ZMARK = SPACE.
              APPEND I_DELETE.
              DELETE I_BINLOC.
            ENDLOOP.
            DESCRIBE TABLE I_BINLOC LINES TC-LINES.
          ENDIF.
    
        <b>* Select all entries in table control 
    WHEN 'SELALL'.
          READ TABLE TC-COLS INTO COL WITH KEY SCREEN-INPUT = '1'.
          IF SY-SUBRC = 0.
            LOOP AT I_BINLOC INTO ZMBINLOC.
              ZMBINLOC-ZMARK = 'X'.
              MODIFY I_BINLOC FROM ZMBINLOC.
            ENDLOOP.
            DESCRIBE TABLE I_BINLOC LINES TC-LINES.
          ENDIF.</b>
    
        WHEN 'DESALL'.
          READ TABLE TC-COLS INTO COL WITH KEY SCREEN-INPUT = '1'.
          IF SY-SUBRC = 0.
            LOOP AT I_BINLOC INTO ZMBINLOC.
              ZMBINLOC-ZMARK = ' '.
              MODIFY I_BINLOC FROM ZMBINLOC.
            ENDLOOP.
            DESCRIBE TABLE I_BINLOC LINES TC-LINES.
          ENDIF.
    
        WHEN 'COPY'.
          READ TABLE TC-COLS INTO COL WITH KEY SCREEN-INPUT = '1'.
          IF SY-SUBRC = 0.
            CALL SCREEN 200 STARTING AT 03 01 ENDING AT 32 4.
            IF COPY_OK = 'ENTER'.
              LOOP AT I_BINLOC INTO ZMBINLOC WHERE ZMARK = 'X'.
                ZMBINLOC-WERKS = COPY_WERKS.
                ZMBINLOC-LGORT = COPY_LGORT.
                ZMBINLOC-ZMARK = ' '.
                INSERT ZMBINLOC INTO I_BINLOC INDEX SY-TABIX.
              ENDLOOP.
              SORT I_BINLOC ASCENDING BY WERKS LGORT ZBINLOC.
              DELETE ADJACENT DUPLICATES FROM I_BINLOC.
              DESCRIBE TABLE I_BINLOC LINES TC-LINES.
            ENDIF.
          ENDIF.
    
        WHEN 'SAVE'.
          SORT I_BINLOC ASCENDING BY WERKS LGORT ZBINLOC.
          DELETE ADJACENT DUPLICATES FROM I_BINLOC.
          IF NOT I_DELETE[] IS INITIAL.
            DELETE ZMBINLOC FROM TABLE I_DELETE.
          ENDIF.
    
          MODIFY ZMBINLOC FROM TABLE I_BINLOC.
          IF SY-SUBRC = 0.
            MESSAGE S899(BD) WITH TEXT-002.
          ENDIF.
    
        WHEN 'EXIT'.
          PERFORM ENQUEUE USING 'D'.
          LEAVE PROGRAM.
    
        WHEN OTHERS.
      ENDCASE.
    
    ENDMODULE.                 " USER_COMMAND_0100  INPUT

    Hope this will help.

    Regards,

    Ferry Lianto

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.