SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

Demo: Table Control



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Dialog Programming
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1636

PostPosted: Mon Nov 05, 2007 12:13 pm    Post subject: Demo: Table Control Reply with quote

Code:
REPORT RSDEMO02.
* demostrates the use of table controls
* unsolved problems: attributes left_col and v_scroll do not work
*                    correctly
TABLES: SPFLI.                         "flight connections, flights
DATA: FCODE2(4), FCODE(4).             "ok-code
CONTROLS: TC_SPFLI TYPE TABLEVIEW USING SCREEN 100,      "flights
          TC_COLS TYPE TABLEVIEW USING SCREEN 100.       "column props
DATA:  COL TYPE CXTAB_COLUMN.          "column of table control
TABLES: DEMO_CPROP, DEMO_TPROP.        "structures for displaying
*                                    global and column specific props
DATA: BEGIN OF IT_SPFLI OCCURS  20,    "flight connections
        MARKED.                        "Check box
        INCLUDE STRUCTURE SPFLI.
DATA: END OF IT_SPFLI.
DATA  LINNO TYPE I.                    "line number at cursor position
DATA  FLD(20).                         "field name at cursor position
DATA  OFF TYPE I.                      "offset of cursor position

START-OF-SELECTION.
* read flight connections
  SELECT *  FROM SPFLI UP TO 100 ROWS.
    MOVE-CORRESPONDING SPFLI TO IT_SPFLI.
    APPEND IT_SPFLI.
  ENDSELECT.
  DESCRIBE TABLE IT_SPFLI LINES TC_SPFLI-LINES.
  TC_COLS-LINES = 6.
* display flights with table control
  CALL SCREEN 100.
*&---------------------------------------------------------------------*
*&      Module  FCODE_100  INPUT
*&---------------------------------------------------------------------*
*       handle user command                                            *
*----------------------------------------------------------------------*
MODULE FCODE_100 INPUT.
  DATA: FLDNAME(100),FLDNAME2(100),FLDNAME3(100).
* copy global property changes made by the user
  TC_SPFLI-FIXED_COLS = DEMO_TPROP-FIXED_COLS.
  TC_SPFLI-LINES = DEMO_TPROP-LINES.
  TC_SPFLI-LINE_SEL_MODE = DEMO_TPROP-LINE_SEL_M.
  TC_SPFLI-COL_SEL_MODE = DEMO_TPROP-COL_SEL_MO.
  TC_SPFLI-LINE_SELECTOR = DEMO_TPROP-LINE_SELEC.
  TC_SPFLI-V_SCROLL = DEMO_TPROP-V_SCROLL.
  TC_SPFLI-H_GRID = DEMO_TPROP-H_GRID.
  TC_SPFLI-V_GRID = DEMO_TPROP-V_GRID.
  FCODE2 = FCODE.
  CLEAR FCODE.
* handle ok code
  CASE FCODE2.
    WHEN 'INFO'.                       "display online docu
      CALL FUNCTION 'RS_TOOL_ACCESS'
           EXPORTING
                OPERATION           = 'DOCS'
                OBJECT_NAME         = 'RSDEMO02'
                OBJECT_TYPE         = 'PROG'
*               ENCLOSING_OBJECT    =
*               position            = '1 1'
*               DEVCLASS            =
*               INCLUDE             =
*               MONITOR_ACTIVATION  = 'X'
*          IMPORTING
*               NEW_NAME            =
*          TABLES
*               OBJLIST             =
           EXCEPTIONS
                NOT_EXECUTED        = 1
                INVALID_OBJECT_TYPE = 2
                OTHERS              = 3.


    WHEN 'SORT'.
      DATA: FLD_LIST LIKE TC_SPFLI-COLS.
* search for selected columns.
      REFRESH FLD_LIST.
      LOOP AT TC_SPFLI-COLS INTO COL.
        IF COL-SELECTED = 'X'.
          APPEND COL TO FLD_LIST.
        ENDIF.
      ENDLOOP.
      SORT FLD_LIST BY INDEX.
      CLEAR:FLDNAME, FLDNAME2, FLDNAME3.
      READ TABLE FLD_LIST INDEX 1 INTO COL.
      FLDNAME = COL-SCREEN-NAME+9.
      READ TABLE FLD_LIST INDEX 2 INTO COL.
      FLDNAME2 = COL-SCREEN-NAME+9.
      READ TABLE FLD_LIST INDEX 3 INTO COL.
      FLDNAME3 = COL-SCREEN-NAME+9.
      SORT IT_SPFLI BY (FLDNAME) (FLDNAME2) (FLDNAME3).
    WHEN 'BACK'.
      SET SCREEN 0.
      LEAVE SCREEN.
    WHEN 'DELL'.
* remove marked lines
      LOOP AT IT_SPFLI WHERE MARKED = 'X'.
        DELETE IT_SPFLI.
      ENDLOOP.
      IF SY-SUBRC <0>= 1.
          LINNO = LINNO + TC_SPFLI-TOP_LINE - 1.
          CLEAR IT_SPFLI.
          INSERT IT_SPFLI INDEX LINNO.
          TC_SPFLI-LINES = TC_SPFLI-LINES + 1.
        ELSE.
          CLEAR IT_SPFLI.
          APPEND IT_SPFLI.
          TC_SPFLI-LINES = TC_SPFLI-LINES + 1.
        ENDIF.
      ENDIF.
  ENDCASE.
ENDMODULE.                             " FCODE_100  INPUT
*&---------------------------------------------------------------------*
*&      Module  INIT_100  OUTPUT
*&---------------------------------------------------------------------*
*                                        *
*----------------------------------------------------------------------*
MODULE INIT_100 OUTPUT.
  SET PF-STATUS 'S100'.
* make global props visible
  MOVE:
  TC_SPFLI-FIXED_COLS TO DEMO_TPROP-FIXED_COLS,
  TC_SPFLI-LINES TO DEMO_TPROP-LINES,
  TC_SPFLI-TOP_LINE TO DEMO_TPROP-TOP_LINE,
  TC_SPFLI-CURRENT_LINE TO DEMO_TPROP-CURRENT_LI,
  TC_SPFLI-LEFT_COL TO DEMO_TPROP-LEFT_COL,
  TC_SPFLI-LINE_SEL_MODE TO DEMO_TPROP-LINE_SEL_M,
  TC_SPFLI-COL_SEL_MODE TO DEMO_TPROP-COL_SEL_MO,
  TC_SPFLI-LINE_SELECTOR TO DEMO_TPROP-LINE_SELEC,
  TC_SPFLI-V_SCROLL TO DEMO_TPROP-V_SCROLL,
  TC_SPFLI-H_GRID TO DEMO_TPROP-H_GRID,
  TC_SPFLI-V_GRID TO DEMO_TPROP-V_GRID.
ENDMODULE.                             " INIT_100  OUTPUT
*&---------------------------------------------------------------------*
*&      Module  MODIFY_IT_SPFLI  INPUT
*&---------------------------------------------------------------------*
*       transport changes to internal table                        *
*----------------------------------------------------------------------*
MODULE MODIFY_IT_SPFLI INPUT.
  MODIFY IT_SPFLI INDEX TC_SPFLI-CURRENT_LINE.
ENDMODULE.                             " MODIFY_IT_SPFLI  INPUT
*&---------------------------------------------------------------------*
*&      Module  READ_COLS  OUTPUT
*&---------------------------------------------------------------------*
*       Read according column property and make it visible         *
*----------------------------------------------------------------------*
MODULE READ_COLS OUTPUT.
  READ TABLE TC_SPFLI-COLS INDEX TC_COLS-CURRENT_LINE INTO COL.
  IF SY-SUBRC <> 0.
    EXIT FROM STEP-LOOP.
  ENDIF.
  MOVE:
   COL-SCREEN-NAME TO DEMO_CPROP-NAME,
   COL-SCREEN-GROUP1 TO DEMO_CPROP-GROUP1,
   COL-SCREEN-GROUP2 TO DEMO_CPROP-GROUP2,
   COL-SCREEN-GROUP3 TO DEMO_CPROP-GROUP3,
   COL-SCREEN-GROUP4 TO DEMO_CPROP-GROUP4,
   COL-SCREEN-REQUIRED TO DEMO_CPROP-REQUIRED,
   COL-SCREEN-INPUT TO DEMO_CPROP-INPUT,
   COL-SCREEN-OUTPUT TO DEMO_CPROP-OUTPUT,
   COL-SCREEN-INTENSIFIED TO DEMO_CPROP-INTENS,
   COL-SCREEN-INVISIBLE TO DEMO_CPROP-INVISIBLEV,
   COL-SCREEN-LENGTH TO      DEMO_CPROP-LENGTH,
   COL-SCREEN-ACTIVE TO      DEMO_CPROP-ACTIVE,
   COL-INDEX TO      DEMO_CPROP-INDEX,
   COL-SELECTED TO     DEMO_CPROP-SELECTED,
   COL-VISLENGTH TO DEMO_CPROP-VISLENGTH,
   COL-INVISIBLE TO DEMO_CPROP-INVISIBLEC.

ENDMODULE.                             " READ_COLS  OUTPUT
*&---------------------------------------------------------------------*
*&      Module  MODIFY_COLS  INPUT
*&---------------------------------------------------------------------*
*       text                                                           *
*----------------------------------------------------------------------*
MODULE MODIFY_COLS INPUT.
  CLEAR COL.
  READ TABLE TC_SPFLI-COLS INDEX TC_COLS-CURRENT_LINE INTO COL.
  COL-SCREEN-GROUP1      = DEMO_CPROP-GROUP1.
  COL-SCREEN-GROUP2      = DEMO_CPROP-GROUP2.
  COL-SCREEN-GROUP3      = DEMO_CPROP-GROUP3.
  COL-SCREEN-GROUP4      = DEMO_CPROP-GROUP4.
  COL-SCREEN-REQUIRED    = DEMO_CPROP-REQUIRED.
  COL-SCREEN-INPUT       = DEMO_CPROP-INPUT.
  COL-SCREEN-OUTPUT      = DEMO_CPROP-OUTPUT.
  COL-SCREEN-INTENSIFIED = DEMO_CPROP-INTENS.
  COL-SCREEN-INVISIBLE   = DEMO_CPROP-INVISIBLEV.
  COL-SCREEN-LENGTH      = DEMO_CPROP-LENGTH.
  COL-SCREEN-ACTIVE      = DEMO_CPROP-ACTIVE.
  COL-INVISIBLE          = DEMO_CPROP-INVISIBLEC.
* update column specific property changes made by the user
  MODIFY TC_SPFLI-COLS INDEX TC_COLS-CURRENT_LINE FROM COL.
ENDMODULE.                             " MODIFY_COLS  INPUT

*Text elements
*----------------------------------------------------------
* 001 Demo program for table control (FlowLogic via LOOP or LOOP AT <itab>)



****************************************************************
* This file was generated by Direct Download Enterprise. *
* Please do not change it manually. *
****************************************************************
%_DYNPRO
RSDEMO02
0100
620
40
%_HEADER
RSDEMO02 0100 0100 32123192 34 0 0 35130 0G D 20001113153222
%_DESCRIPTION
Table control
%_FIELDS
%_AUTOTEXT001 CHAR 75 00 00 00 30 00 2 6 0 0 0 0 0 0 Table control tc spfli
TC_SPFLI 76 F5 C8 00 00 00 3 6 E 101 1 0 8 T 0 0
SPFLI-CARRID 2 CHAR 16 30 00 04 30 A0 1 1 T 101 1 0 3 CAR 3 0 Airline
SPFLI-CONNID 2 NUMC 15 30 00 00 30 A0 1 2 T 101 1 0 4 CON 4 0 Flight Number
SPFLI-CITYFROM 2 CHAR 11 30 00 04 30 80 1 3 T 101 1 0 20 20 0 Depart.city
SPFLI-AIRPFROM 2 CHAR 14 30 00 00 30 80 1 4 T 101 1 0 3 3 0 Dep. airport
SPFLI-CITYTO 2 CHAR 15 30 00 04 30 80 1 5 T 101 1 0 20 20 0 Arrival city
SPFLI-AIRPTO 2 CHAR 15 30 00 00 30 80 1 6 T 101 1 0 3 3 0 Dest. airport
SPFLI-FLTIME 2 TIMS 15 30 00 00 30 80 1 7 T 101 1 0 8 6 0 Flight time
SPFLI-DEPTIME 2 TIMS 15 30 00 00 30 80 1 8 T 101 1 0 8 6 0 Departure
SPFLI-ARRTIME 2 TIMS 15 30 00 00 30 80 1 9 T 101 1 0 8 6 0 Arrival Time
SPFLI-DISTANCE 2 10 30 00 00 30 80 1 10 T 101 1 0 10 8 0 SPFLI-DISTID Distance
SPFLI-DISTID 2 UNIT 8 30 00 10 30 80 1 11 T 101 1 0 3 3 0 Distance
SPFLI-FLTYPE 2 CHAR 7 30 00 01 30 80 1 12 T 101 1 0 1 1 0 Charter
IT_SPFLI-MARKED C CHAR 1 80 00 80 00 20 1 0 T 101 1 0 1 C 0 0 111 _
IT_SPFLI-CARRID C CHAR 3 80 00 80 40 20 1 1 T 101 1 0 3 CAR 0 0 ___
IT_SPFLI-CONNID N NUMC 4 80 00 80 40 20 1 2 T 101 1 0 4 CON 0 0 ____
IT_SPFLI-CITYFROM C CHAR 20 80 00 80 40 00 1 3 T 101 1 0 20 0 0 ____________________
IT_SPFLI-AIRPFROM C CHAR 3 80 00 80 40 00 1 4 T 101 1 0 3 0 0 ___
IT_SPFLI-CITYTO C CHAR 20 80 00 80 40 00 1 5 T 101 1 0 20 0 0 ____________________
IT_SPFLI-AIRPTO C CHAR 3 80 00 80 40 00 1 6 T 101 1 0 3 0 0 ___
IT_SPFLI-FLTIME T TIMS 8 80 00 80 40 00 1 7 T 101 1 0 8 0 0 ________
IT_SPFLI-DEPTIME T TIMS 8 80 00 80 40 00 1 8 T 101 1 0 8 0 0 ________
IT_SPFLI-ARRTIME T TIMS 8 80 00 80 40 00 1 9 T 101 1 0 8 0 0 ________
IT_SPFLI-DISTANCE P QUAN 10 80 00 80 40 00 1 10 T 101 1 0 10 8 0 SPFLI-DISTID __________
IT_SPFLI-DISTID C UNIT 3 80 00 80 40 00 1 11 T 101 1 0 3 0 0 ___
IT_SPFLI-FLTYPE C CHAR 1 80 00 80 40 00 1 12 T 101 1 0 1 0 0 _
%_AUTOTEXT002 CHAR 59 00 00 00 30 00 12 5 0 0 0 9 R 0 0 108 Global attributes for table control tc spfli
DEMO_TPROP-FIXED_COLS 4 10 30 00 10 30 00 13 8 0 0 0 0 10 0 Fixed_cols
DEMO_TPROP-FIXED_COLS X INT4 10 A0 00 90 40 00 13 22 0 0 0 0 10 0 _________V
DEMO_TPROP-LINE_SELEC 0 13 30 00 00 30 00 13 45 0 0 0 0 C 1 0 104 Line selector
DEMO_TPROP-LINE_SELEC C CHAR 1 A0 00 80 00 00 13 60 0 0 0 0 C 1 0 104 _
DEMO_TPROP-LINES 4 10 30 00 10 30 00 14 8 0 0 0 0 10 0 Lines
DEMO_TPROP-LINES X INT4 10 A0 00 90 40 00 14 22 0 0 0 0 10 0 _________V
DEMO_TPROP-V_SCROLL 0 8 30 00 00 30 00 14 45 0 0 0 0 C 1 0 109 V scroll
DEMO_TPROP-V_SCROLL C CHAR 1 A0 00 80 00 00 14 60 0 0 0 0 C 1 0 109 _
DEMO_TPROP-TOP_LINE 4 10 30 00 10 30 00 15 8 0 0 0 0 10 0 Top_line
DEMO_TPROP-TOP_LINE X INT4 10 A0 00 90 70 00 15 22 0 0 0 0 10 0 _________V
DEMO_TPROP-H_GRID 0 6 30 00 00 30 00 15 45 0 0 0 0 C 1 0 103 H grid
DEMO_TPROP-H_GRID C CHAR 1 A0 00 80 00 00 15 60 0 0 0 0 C 1 0 103 _
DEMO_TPROP-CURRENT_LI 4 INT4 12 30 00 10 30 00 16 8 0 0 0 0 10 0 Current_line
DEMO_TPROP-CURRENT_LI X INT4 10 A0 00 90 70 00 16 22 0 0 0 0 10 0 _________V
DEMO_TPROP-V_GRID 0 6 30 00 00 30 00 16 45 0 0 0 0 C 1 0 105 V grid
DEMO_TPROP-V_GRID C CHAR 1 A0 00 80 00 00 16 60 0 0 0 0 C 1 0 105 _
DEMO_TPROP-LEFT_COL 4 10 30 00 10 30 00 17 8 0 0 0 0 10 0 Left_col
DEMO_TPROP-LEFT_COL X INT4 10 A0 00 90 70 00 17 22 0 0 0 0 10 0 _________V
DEMO_TPROP-LINE_SEL_M 4 13 30 00 01 30 00 18 8 0 0 0 0 10 0 Line_sel_mode
DEMO_TPROP-LINE_SEL_M X INT4 10 A0 00 81 40 08 18 22 0 0 0 0 10 0 __________
DEMO_TPROP-COL_SEL_MO 4 12 30 00 01 30 00 19 8 0 0 0 0 10 0 Col_sel_mode
DEMO_TPROP-COL_SEL_MO X INT4 10 A0 00 81 40 08 19 22 0 0 0 0 10 0 __________
%_AUTOTEXT003 CHAR 119 00 00 00 30 00 22 6 0 0 0 0 0 0 Column-specific attributes for table control tc spfli
TC_COLS 105 E0 C0 00 00 00 23 6 E 102 1 0 10 T 0 0
DEMO_CPROP-NAME 4 30 30 00 00 30 A0 1 1 T 102 1 0 20 30 0 Name
DEMO_CPROP-GROUP1 4 6 30 00 00 30 80 1 2 T 102 1 0 5 3 0 Group1
DEMO_CPROP-GROUP2 4 6 30 00 00 30 80 1 3 T 102 1 0 5 3 0 Group2
DEMO_CPROP-GROUP3 4 6 30 00 00 30 80 1 4 T 102 1 0 5 3 0 Group3
DEMO_CPROP-GROUP4 4 6 30 00 00 30 80 1 5 T 102 1 0 5 3 0 Group4
DEMO_CPROP-REQUIRED 4 8 30 00 01 30 80 1 6 T 102 1 0 6 1 0 Required
DEMO_CPROP-INPUT 4 5 30 00 01 30 80 1 7 T 102 1 0 5 1 0 Input
DEMO_CPROP-OUTPUT 4 6 30 00 01 30 80 1 8 T 102 1 0 5 1 0 Output
DEMO_CPROP-INTENS 4 11 30 00 01 30 80 1 9 T 102 1 0 6 1 0 Intensified
DEMO_CPROP-INVISIBLEV 4 9 30 00 01 30 80 1 10 T 102 1 0 6 1 0 Invisible
DEMO_CPROP-LENGTH 4 6 30 00 00 30 80 1 11 T 102 1 0 5 3 0 Length
DEMO_CPROP-ACTIVE 4 6 30 00 01 30 80 1 12 T 102 1 0 5 1 0 Active
DEMO_CPROP-INDEX 4 10 30 00 10 30 80 1 13 T 102 1 0 5 10 0 Index
SELECTED CHAR 8 00 00 00 30 80 1 14 T 102 1 0 5 0 0 Selected
DEMO_CPROP-VISLENGTH 4 9 30 00 00 30 80 1 15 T 102 1 0 5 3 0 Vislength
INVISIBLEC CHAR 9 00 00 00 30 80 1 16 T 102 1 0 5 0 0 Invisible
DEMO_CPROP-NAME C CHAR 30 A1 00 80 70 20 1 1 T 102 1 0 20 30 0 ______________________________
DEMO_CPROP-GROUP1 C CHAR 3 A1 00 80 40 00 1 2 T 102 1 0 5 3 0 ___
DEMO_CPROP-GROUP2 C CHAR 3 A1 00 80 40 00 1 3 T 102 1 0 5 3 0 ___
DEMO_CPROP-GROUP3 C CHAR 3 A1 00 80 40 00 1 4 T 102 1 0 5 3 0 ___
DEMO_CPROP-GROUP4 C CHAR 3 A1 00 80 40 00 1 5 T 102 1 0 5 3 0 ___
DEMO_CPROP-REQUIRED C CHAR 1 A1 00 81 40 08 1 6 T 102 1 0 6 1 0 _
DEMO_CPROP-INPUT C CHAR 1 A1 00 81 40 08 1 7 T 102 1 0 5 1 0 _
DEMO_CPROP-OUTPUT C CHAR 1 A1 00 81 40 08 1 8 T 102 1 0 5 1 0 _
DEMO_CPROP-INTENS C CHAR 1 A1 00 81 40 08 1 9 T 102 1 0 6 1 0 _
DEMO_CPROP-INVISIBLEV C CHAR 1 A1 00 81 40 08 1 10 T 102 1 0 6 1 0 _
DEMO_CPROP-LENGTH X INT1 3 A1 00 80 40 00 1 11 T 102 1 0 5 3 0 ___
DEMO_CPROP-ACTIVE C CHAR 1 A1 00 81 40 08 1 12 T 102 1 0 5 1 0 _
DEMO_CPROP-INDEX X INT4 10 A1 00 90 70 00 1 13 T 102 1 0 5 10 0 _________V
DEMO_CPROP-SELECTED C CHAR 1 A0 00 80 30 00 1 14 T 102 1 0 5 C 1 0 106 _
DEMO_CPROP-VISLENGTH X INT1 3 A1 00 80 70 00 1 15 T 102 1 0 5 3 0 ___
DEMO_CPROP-INVISIBLEC C CHAR 1 A0 00 80 00 00 1 16 T 102 1 0 5 C 1 0 107 _
FCODE CHAR 4 80 10 00 40 00 255 255 O 0 0 0 0 0 0 ____
%_FLOWLOGIC
PROCESS BEFORE OUTPUT.
MODULE INIT_100.
LOOP AT IT_SPFLI WITH CONTROL TC_SPFLI CURSOR TC_SPFLI-CURRENT_LINE.
ENDLOOP.
LOOP WITH CONTROL TC_COLS.
MODULE READ_COLS.
ENDLOOP.
*
PROCESS AFTER INPUT.
LOOP AT IT_SPFLI.
MODULE MODIFY_IT_SPFLI.
ENDLOOP.
LOOP WITH CONTROL TC_COLS.
MODULE MODIFY_COLS.
ENDLOOP.
MODULE FCODE_100.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Dialog Programming All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.