SAP details: Events News - Training - World wide sites  - Sap Labs SAP Magazine  - SAP Screen saver - Stock Price
Online Programming Table Control

SAP Table Control Example  (contributed by Manoj Kelkar)

This example shows how to build a table control using ABAP. 

SCREEN 100

PROCESS BEFORE OUTPUT.
	MODULE STATUS_0100.
	LOOP WITH CONTROL TCTRL_USERDATA.
		MODULE DISPLAY_USERDATA.
	ENDLOOP.
	MODULE AFTER_LOOPING.
*
PROCESS AFTER INPUT.
	MODULE USER_COMMAND_0100.
	LOOP WITH CONTROL TCTRL_USERDATA.
		MODULE EXTRACT_USERDATA.
	ENDLOOP.
	MODULE USER_COMMAND_0100_AFTER_LOOP.

ZTBLDTOP


*&---------------------------------------------------------------------*
*& Include ZTBLDEMO                         Report ZTBLDEMO            *
*&                                                                     *
*&---------------------------------------------------------------------*

REPORT   ZTBLDEMO   MESSAGE-ID AT                   .

DATA: BEGIN OF RECORD,
          NAME(30),
          PHONE(20),
          EMAIL(50),
      END OF RECORD.

DATA: ITAB_PHONELIST LIKE RECORD OCCURS 0 WITH HEADER LINE.

CONTROLS: TCTRL_PHONELIST TYPE TABLEVIEW USING SCREEN 100.

DATA: SAVE_CODE(4),
      OK_CODE(4),
      FILENAME LIKE RLGRAP-FILENAME,
      CONFIRMATION,
      SELECTION.

ZTBLDEMO


*&---------------------------------------------------------------------*
*& Report  ZUSRDATA                                                    *
*&                                                                     *
*&---------------------------------------------------------------------*
*&                                                                     *
*&                                                                     *
*&---------------------------------------------------------------------*

INCLUDE ZTBLDTOP.                      " global Data

* INCLUDE ZUSRDO01.                    " PBO-Modules                   *
* INCLUDE ZUSRDI01.                    " PAI-Modules                   *
* INCLUDE ZUSRDF01.                    " FORM-Routines                 *

*&---------------------------------------------------------------------*
*&      Module  STATUS_0100  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE STATUS_0100 OUTPUT.
  SET PF-STATUS 'FOR100'.
  SET TITLEBAR '100'.
ENDMODULE.                 " STATUS_0100  OUTPUT

*&---------------------------------------------------------------------*
*&      Module  DISPLAY_USERDATA  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE DISPLAY_USERDATA OUTPUT.
    READ TABLE ITAB_PHONELIST INDEX TCTRL_PHONELIST-CURRENT_LINE.
    IF SY-SUBRC EQ 0.
        RECORD-NAME = ITAB_PHONELIST-NAME.
        RECORD-PHONE = ITAB_PHONELIST-PHONE.
        RECORD-EMAIL = ITAB_PHONELIST-EMAIL.
    ELSE.
        EXIT FROM STEP-LOOP.
    ENDIF.
ENDMODULE.                 " DISPLAY_USERDATA  OUTPUT
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_0100  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_0100 INPUT.
    SAVE_CODE = OK_CODE.
    CLEAR OK_CODE.
    CASE SAVE_CODE.
        WHEN 'BACK'.
            CALL FUNCTION 'COPO_POPUP_TO_GOON'
                EXPORTING
                     TEXTLINE1 = 'Any modifications will be lost!'
                     TEXTLINE2 = 'Are you sure?'
                     TITEL     = 'Exit The Program'
                IMPORTING
                     answer    = confirmation.
            if confirmation = 'G'.
                LEAVE PROGRAM.
            ENDIF.
        WHEN 'DELE'.
            CALL FUNCTION 'COPO_POPUP_TO_GOON'
                EXPORTING
                     TEXTLINE1 = 'Selected rows will be deleted!'
                     TEXTLINE2 = 'Are you sure?'
                     TITEL     = 'Delete rows'
                IMPORTING
                     answer    = confirmation.
            IF CONFIRMATION = 'G'.
                REFRESH ITAB_PHONELIST.
                CLEAR ITAB_PHONELIST.
            ENDIF.
        WHEN 'SAVE'.
            REFRESH ITAB_PHONELIST.
            CLEAR ITAB_PHONELIST.
        WHEN 'APND'.
            REFRESH ITAB_PHONELIST.
            CLEAR ITAB_PHONELIST.
        WHEN 'READ'.
            IF NOT FILENAME IS INITIAL.
                CALL FUNCTION 'COPO_POPUP_TO_GOON'
                    EXPORTING
                         TEXTLINE1 = 'Any modifications will be lost!'
                         TEXTLINE2 = 'Are you sure?'
                         TITEL     = 'Read Another File'
                    IMPORTING
                         answer    = confirmation.
            ENDIF.
            if confirmation = 'G' or
               FILENAME IS INITIAL.
                CALL FUNCTION 'UPLOAD'
                    EXPORTING
                         FILENAME            =
                        'c:\temp\fonelist.txt'
                    IMPORTING
                         ACT_FILENAME        = FILENAME
                     TABLES
                          DATA_TAB            = ITAB_PHONELIST.
            ENDIF.
    ENDCASE.
ENDMODULE.                 " USER_COMMAND_0100  INPUT

*&---------------------------------------------------------------------*
*&      Module  EXTRACT_USERDATA  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE EXTRACT_USERDATA INPUT.
    CASE SAVE_CODE.
        WHEN 'DELE'.
            IF SELECTION IS INITIAL AND
               confirmation = 'G'.
                PERFORM TRANSFER.
            ENDIF.
        WHEN 'SAVE'.
            PERFORM TRANSFER.
        WHEN 'APND'.
            PERFORM TRANSFER.
    ENDCASE.
ENDMODULE.                 " EXTRACT_USERDATA  INPUT
*&---------------------------------------------------------------------*
*&      Form  TRANSFER
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM TRANSFER.
    CLEAR ITAB_PHONELIST.
    ITAB_PHONELIST-NAME = RECORD-NAME.
    ITAB_PHONELIST-PHONE = RECORD-PHONE.
    ITAB_PHONELIST-EMAIL = RECORD-EMAIL.
    APPEND ITAB_PHONELIST.
ENDFORM.                    " TRANSFER
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_0100_AFTER_LOOP  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_0100_AFTER_LOOP INPUT.
    CASE SAVE_CODE.
        WHEN 'SAVE'.
            CALL FUNCTION 'DOWNLOAD'
                EXPORTING
                     FILENAME            = FILENAME
                TABLES
                     DATA_TAB            = ITAB_PHONELIST.
        WHEN 'APND'.
             CLEAR ITAB_PHONELIST.  " a blank row being created.
             APPEND ITAB_PHONELIST. " a blank row being added.
    ENDCASE.
ENDMODULE.                 " USER_COMMAND_0100_AFTER_LOOP  INPUT

Field List


GUI Status


Objects


Table Attributes


Table Columns













 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Planetsap.com
 
Home     Post an article    Suggestion   Contact
 
Disclaimer    Copyright; 1998-2002 Softron Systems, Inc. All rights reserved.
 
Home Discussion Forum Services Advertise Contact About Us Sign Up