Application Development 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: 

table control

Former Member
0 Kudos

Hi,

can anyone explain me the use of table control. please give an example also to explain it in a better way.

thanks and regards

vivek

1 ACCEPTED SOLUTION
4 REPLIES 4

Former Member
0 Kudos

Hi,

table control is more comfortable for customizing.scroll bars all possible in this.where as it is not possible in step loops.

check this example.

PROGRAM ZBHTCTRL.

TABLES: LFA1, EKKO.

DATA: OKCODE1 LIKE SY-UCOMM,

OKCODE2 LIKE SY-UCOMM.

CONTROLS TABC TYPE TABLEVIEW USING SCREEN 1001.

DATA: BEGIN OF ITAB OCCURS 0,

MANDT LIKE EKKO-MANDT,

EBELN LIKE EKKO-EBELN,

BSTYP LIKE EKKO-BSTYP,

BSART LIKE EKKO-BSART,

END OF ITAB.

MODULE USER_COMMAND_1000 INPUT.

CASE OKCODE1.

WHEN 'BACK'.

SET SCREEN 0.

WHEN 'NEXT'.

SET SCREEN 1001.

SELECT * FROM EKKO INTO CORRESPONDING FIELDS OF TABLE ITAB WHERE

LIFNR = LFA1-LIFNR.

ENDCASE.

ENDMODULE. " USER_COMMAND_1001 INPUT

MODULE MOVE_DATA OUTPUT.

EKKO-MANDT = ITAB-MANDT.

EKKO-EBELN = ITAB-EBELN.

EKKO-BSTYP = ITAB-BSTYP.

EKKO-BSART = ITAB-BSART.

ENDMODULE. " MOVE_DATA OUTPUT

MODULE USER_COMMAND_1001 INPUT.

CASE OKCODE2.

WHEN 'BACK'.

SET SCREEN 1000.

ENDCASE.

ENDMODULE. " USER_COMMAND_1001 OUTPUT

MODULE STATUS_1001 OUTPUT.

SET PF-STATUS 'MENU'.

SET TITLEBAR 'TIT'.

ENDMODULE. " STATUS_1001 OUTPUT

MODULE STATUS_1000 OUTPUT.

SET PF-STATUS 'DMENU'.

  • SET TITLEBAR 'xxx'.

ENDMODULE. " STATUS_1000 OUTPUT

FORM ON_CTMENU_FORM1 USING CMENU TYPE REF TO CL_CTMENU.

CALL METHOD CMENU->LOAD_GUI_STATUS

EXPORTING

PROGRAM = ' ZBHTCTRL'

STATUS = 'CMENU'

MENU = CMENU.

CALL METHOD CMENU->ADD_FUNCTION

EXPORTING

FCODE = 'RX'

TEXT = 'RECIEVE'.

ENDFORM.

FLOW LOGIC:

PROCESS BEFORE OUTPUT.

MODULE STATUS_1000.

*

PROCESS AFTER INPUT.

MODULE USER_COMMAND_1000.

PROCESS BEFORE OUTPUT.

MODULE STATUS_1001.

LOOP AT ITAB WITH CONTROL TABC CURSOR TABC-TOP_LINE.

MODULE MOVE_DATA.

ENDLOOP.

*

PROCESS AFTER INPUT.

MODULE USER_COMMAND_1001.

LOOP AT ITAB.

ENDLOOP.

for more info check this link.

http://help.sap.com/saphelp_nw2004s/helpdata/en/9f/dbac1d35c111d1829f0000e829fbfe/content.htm

rgds,

bharat.

Message was edited by:

Bharat Kalagara

Former Member

Former Member
0 Kudos

Hi,

Refer to follwoing program:

Table control is used to maintain set of records in tabular form:

report demo_dynpro_table_control_1  message-id sabapdocu.

data: begin of itab occurs 10,
        mark,
        col1 type i,
        col2 type i,
      end of itab.


data ok_code type sy-ucomm.
data ok_save type sy-ucomm.
data tab_lines type i.
data step_lines type i.
data offset type i.

controls table type tableview using screen 100.

call screen 100.

module init output.
  set pf-status 'BASIC'.
endmodule.

module fill_itab output.
  describe table itab lines tab_lines.
  if tab_lines = 0.
    do 40 times.
      itab-col1 = sy-index.
      itab-col2 = sy-index ** 2.
      append itab.
    enddo.
    describe table itab lines tab_lines.
    table-lines = tab_lines.
  endif.
endmodule.

module transp_itab output.
  read table itab index table-current_line.
endmodule.

module lines output.
  step_lines = sy-loopc.
endmodule.

module exit input.
  leave program.
endmodule.

module check_pai input.
  ok_save = ok_code. clear ok_code.
  message s888 with 'TOP_LINE: ' table-top_line
                    ', LINES: '  step_lines.
endmodule.

module check_table input.
  case ok_save.
    when 'MARK'.
      if itab-mark = 'X'.
        message i888 with 'Zeile' table-current_line 'markiert'.
      endif.
    when 'SETM'.
      modify itab index table-current_line.
  endcase.

endmodule.

module check_all input.
  case ok_save.
    when 'ALLM'.
      loop at itab.
        if itab-mark = 'X'.
          message i888 with 'Zeile' sy-tabix 'markiert'.
        endif.
      endloop.
    when 'DELE'.
      loop at itab.
        if itab-mark = 'X'.
          itab-mark = ' '.
          modify itab.
        endif.
      endloop.
  endcase.
endmodule.

module scroll input.
  case ok_save.
    when 'PGDO'.
      offset = table-lines - step_lines.
      if table-top_line lt offset.
        table-top_line = table-top_line + step_lines.
      endif.
    when 'PGUP'.
      offset = step_lines.
      if table-top_line gt offset.
        table-top_line = table-top_line - step_lines.
      else.
        table-top_line = 1.
      endif.
    when 'PGLA'.
      table-top_line = table-lines - step_lines + 1.
    when 'PGTO'.
      table-top_line = 1.
  endcase.
endmodule.