Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

table control

Former Member
0 Likes
464

hi everyone..

can anyone tell me how can i add records of a standard table in a table control and display the records.

thanks an advance..

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
422

Hi Fathima,

This code i have taken from t.code abapdocu...

just go through this you will understand a lot

<b>Main program</b>



REPORT demo_dynpro_tabcont_loop_at.

CONTROLS flights TYPE TABLEVIEW USING SCREEN 100.
DATA: cols LIKE LINE OF flights-cols,
      lines TYPE i.

DATA: ok_code TYPE sy-ucomm,
      save_ok TYPE sy-ucomm.

DATA: itab TYPE TABLE OF demo_conn.
TABLES demo_conn.

SELECT * FROM spfli INTO CORRESPONDING FIELDS OF TABLE itab.

LOOP AT flights-cols INTO cols WHERE index GT 2.
  cols-screen-input = '0'.
  MODIFY flights-cols FROM cols INDEX sy-tabix.
ENDLOOP.

CALL SCREEN 100.

MODULE status_0100 OUTPUT.
  SET PF-STATUS 'SCREEN_100'.
  DESCRIBE TABLE itab LINES lines.
  flights-lines = lines.
ENDMODULE.

MODULE cancel INPUT.
  LEAVE PROGRAM.
ENDMODULE.

MODULE read_table_control INPUT.
  MODIFY itab FROM demo_conn INDEX flights-current_line.
ENDMODULE.

MODULE user_command_0100 INPUT.
  save_ok = ok_code.
  CLEAR ok_code.
  CASE save_ok.
    WHEN 'TOGGLE'.
      LOOP AT flights-cols INTO cols WHERE index GT 2.
        IF  cols-screen-input = '0'.
          cols-screen-input = '1'.
        ELSEIF  cols-screen-input = '1'.
          cols-screen-input = '0'.
        ENDIF.
        MODIFY flights-cols FROM cols INDEX sy-tabix.
      ENDLOOP.
    WHEN 'SORT_UP'.
      READ TABLE flights-cols INTO cols WITH KEY selected = 'X'.
      IF sy-subrc = 0.
        SORT itab STABLE BY (cols-screen-name+10) ASCENDING.
        cols-selected = ' '.
        MODIFY flights-cols FROM cols INDEX sy-tabix.
      ENDIF.
    WHEN 'SORT_DOWN'.
      READ TABLE flights-cols INTO cols WITH KEY selected = 'X'.
      IF sy-subrc = 0.
        SORT itab STABLE BY (cols-screen-name+10) DESCENDING.
        cols-selected = ' '.
        MODIFY flights-cols FROM cols INDEX sy-tabix.
      ENDIF.
    WHEN 'DELETE'.
      READ TABLE flights-cols INTO cols WITH KEY screen-input = '1'.
      IF sy-subrc = 0.
        LOOP AT itab INTO demo_conn WHERE mark = 'X'.
          DELETE itab.
        ENDLOOP.
      ENDIF.
  ENDCASE.
ENDMODULE.

<b>Flow logic:</b>

PROCESS BEFORE OUTPUT.
  MODULE STATUS_0100.
    LOOP AT ITAB INTO DEMO_CONN WITH CONTROL FLIGHTS.
  ENDLOOP.

PROCESS AFTER INPUT.
  MODULE CANCEL AT EXIT-COMMAND.
  LOOP AT ITAB.
    module read_table_control.
  ENDLOOP.
  module user_command_0100.

i think you can design the layout by yourself,you can check out the same program in your system.

REgards,

pankaj singh

4 REPLIES 4
Read only

Former Member
0 Likes
422

Hello Fathima,

check

see the examples related to Table Control in SE38

demo_dynpro_tabcont_loop

demo_dynpro_tabcont_loop_at

or look in transaction DWDM

RSDEMO_TABLE_CONTROL

Check this sample programs

http://www.planetsap.com/online_pgm_main_page.htm

http://sap.niraj.tripod.com/id29.html

http://www.sapdevelopment.co.uk/dialog/tabcontrol/tc_basic.htm

reward if usefull..

Regards,

Srini

Read only

Former Member
0 Likes
422

Hello,

Select the records from the table into an internal table. Then add the following code in the PBO of your screen.

loop at <int_table> into <work_area> with control <table_control>.

endloop.

Make sure that the field names in the table control are same as the Work area field names.

Regards,

Manoj

Read only

Former Member
0 Likes
423

Hi Fathima,

This code i have taken from t.code abapdocu...

just go through this you will understand a lot

<b>Main program</b>



REPORT demo_dynpro_tabcont_loop_at.

CONTROLS flights TYPE TABLEVIEW USING SCREEN 100.
DATA: cols LIKE LINE OF flights-cols,
      lines TYPE i.

DATA: ok_code TYPE sy-ucomm,
      save_ok TYPE sy-ucomm.

DATA: itab TYPE TABLE OF demo_conn.
TABLES demo_conn.

SELECT * FROM spfli INTO CORRESPONDING FIELDS OF TABLE itab.

LOOP AT flights-cols INTO cols WHERE index GT 2.
  cols-screen-input = '0'.
  MODIFY flights-cols FROM cols INDEX sy-tabix.
ENDLOOP.

CALL SCREEN 100.

MODULE status_0100 OUTPUT.
  SET PF-STATUS 'SCREEN_100'.
  DESCRIBE TABLE itab LINES lines.
  flights-lines = lines.
ENDMODULE.

MODULE cancel INPUT.
  LEAVE PROGRAM.
ENDMODULE.

MODULE read_table_control INPUT.
  MODIFY itab FROM demo_conn INDEX flights-current_line.
ENDMODULE.

MODULE user_command_0100 INPUT.
  save_ok = ok_code.
  CLEAR ok_code.
  CASE save_ok.
    WHEN 'TOGGLE'.
      LOOP AT flights-cols INTO cols WHERE index GT 2.
        IF  cols-screen-input = '0'.
          cols-screen-input = '1'.
        ELSEIF  cols-screen-input = '1'.
          cols-screen-input = '0'.
        ENDIF.
        MODIFY flights-cols FROM cols INDEX sy-tabix.
      ENDLOOP.
    WHEN 'SORT_UP'.
      READ TABLE flights-cols INTO cols WITH KEY selected = 'X'.
      IF sy-subrc = 0.
        SORT itab STABLE BY (cols-screen-name+10) ASCENDING.
        cols-selected = ' '.
        MODIFY flights-cols FROM cols INDEX sy-tabix.
      ENDIF.
    WHEN 'SORT_DOWN'.
      READ TABLE flights-cols INTO cols WITH KEY selected = 'X'.
      IF sy-subrc = 0.
        SORT itab STABLE BY (cols-screen-name+10) DESCENDING.
        cols-selected = ' '.
        MODIFY flights-cols FROM cols INDEX sy-tabix.
      ENDIF.
    WHEN 'DELETE'.
      READ TABLE flights-cols INTO cols WITH KEY screen-input = '1'.
      IF sy-subrc = 0.
        LOOP AT itab INTO demo_conn WHERE mark = 'X'.
          DELETE itab.
        ENDLOOP.
      ENDIF.
  ENDCASE.
ENDMODULE.

<b>Flow logic:</b>

PROCESS BEFORE OUTPUT.
  MODULE STATUS_0100.
    LOOP AT ITAB INTO DEMO_CONN WITH CONTROL FLIGHTS.
  ENDLOOP.

PROCESS AFTER INPUT.
  MODULE CANCEL AT EXIT-COMMAND.
  LOOP AT ITAB.
    module read_table_control.
  ENDLOOP.
  module user_command_0100.

i think you can design the layout by yourself,you can check out the same program in your system.

REgards,

pankaj singh

Read only

Former Member
0 Likes
422

Hi Fathima,

While creating table control there will be an option you can enter either database table name or internal table name.Then enter your table name.

You can find all records intable control.

Pls. reward points for all helpful answers