Tuesday, December 28, 2010
Internal Table to be shown on table control should have one field(CHECK in the below example) for check box on table control.

Report ztest_program.
*--------------------------------------------------------------------------*
"Table control related declaration
*--------------------------------------------------------------------------*
CONTROLS tchkbox TYPE TABLEVIEW USING SCREEN 1001 .
DATA: 
    BEGIN OF it_nfal OCCURS 0,
        check TYPE c,
        einri TYPE nfal-einri,
        falnr TYPE nfal-falnr,
        falar TYPE nfal-falar,
        patnr TYPE nfal-patnr,
        bekat TYPE nfal-bekat,
    END OF it_nfal.
DATA:ok_code TYPE sy-ucomm.

START-OF-SELECTION.

call screen 1001.
*&---------------------------------------------------------------------*
*&      Module  STATUS_1001  OUTPUT
*&---------------------------------------------------------------------*
  MODULE status_1001 OUTPUT.
  SET PF-STATUS 'ZTEST_PROGRAM'.
*  SET TITLEBAR 'xxx'.

ENDMODULE.                 " STATUS_1001  OUTPUT
*&---------------------------------------------------------------------*
*&      Module  GET_DATA_FROM_NFAL  OUTPUT
*&---------------------------------------------------------------------*
MODULE get_data_from_nfal OUTPUT.

IF it_nfal[] IS INITIAL.
  SELECT *
  FROM nfal
  INTO CORRESPONDING FIELDS OF TABLE it_nfal
  WHERE einri EQ 'KKH'.
ENDIF.
ENDMODULE.                 " GET_DATA_FROM_NFAL  OUTPUT


*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_1001  INPUT
*&---------------------------------------------------------------------*
MODULE user_command_1001 INPUT.
CLEAR ok_code.
ok_code = sy-ucomm.

CASE ok_code.
WHEN 'BACK' OR 'EXIT' OR 'CANCEL'.
  LEAVE TO SCREEN 0.
WHEN 'DELETE'.
  LOOP AT it_nfal WHERE check = 'X'.
    DELETE it_nfal.
  ENDLOOP.
WHEN 'SELECTALL'.
  LOOP AT it_nfal.
    it_nfal-check = 'X'.
    MODIFY it_nfal INDEX sy-tabix TRANSPORTING check.
  ENDLOOP.
WHEN 'DSELECTALL'.
  LOOP AT it_nfal.
    it_nfal-check = space.
    MODIFY it_nfal INDEX sy-tabix TRANSPORTING check.
  ENDLOOP.
ENDCASE.
ENDMODULE.                 " USER_COMMAND_1001  INPUT
*&---------------------------------------------------------------------*
*&      Module  READ_TABLE_CONTROL  INPUT
*&---------------------------------------------------------------------*
MODULE read_table_control INPUT.
MODIFY it_nfal INDEX tchkbox-current_line.
ENDMODULE.                 " READ_TABLE_CONTROL  INPUT

Flow logic of screen 1001.

*PBO
process before output.
  module status_1001.
  MODULE get_data_from_nfal.
  LOOP AT it_nfal WITH CONTROL tchkbox.
  ENDLOOP.

*PAI
process after input.
  LOOP AT it_nfal.
    MODULE read_table_control.
  ENDLOOP.
  module user_command_1001.

3 comments:

  1. This Tutorial is extremely helpful on Table Control with check boxes and i am really impressed and benefited from this.

    Thank a lot for whom so ever has sent this .

    Prashanth

    ReplyDelete
  2. Hi, what if there is a secondary list to be displayed based on the values checkboxed in the basic list, then how do we go about it?

    ReplyDelete

Your useful comments, suggestions are appreciated.Your comments are moderated.

Followers

Contact Form

Name

Email *

Message *

Web Dynpro ABAP Book

An SAP Consultant

Follow US


Want to Contribute ?

If you are interested in writing about the new stuff you learn everyday while working, please write to the.sap.consultants@gmail.com.

Click on Contribution for more details.