05-11-2007 7:10 AM
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
05-11-2007 7:24 AM
hi,
table control scrolling:
table control with wizard :
http://help.sap.com/saphelp_nw04/helpdata/en/6d/150d67da1011d3963800a0c94260a5/content.htm
http://help.sap.com/saphelp_nw04/helpdata/en/9f/dbac1d35c111d1829f0000e829fbfe/frameset.htm
http://help.sap.com/saphelp_nw2004s/helpdata/en/9f/dbac1d35c111d1829f0000e829fbfe/frameset.htm
05-11-2007 7:12 AM
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
05-11-2007 7:14 AM
05-11-2007 7:20 AM
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.
05-11-2007 7:24 AM
hi,
table control scrolling:
table control with wizard :
http://help.sap.com/saphelp_nw04/helpdata/en/6d/150d67da1011d3963800a0c94260a5/content.htm
http://help.sap.com/saphelp_nw04/helpdata/en/9f/dbac1d35c111d1829f0000e829fbfe/frameset.htm
http://help.sap.com/saphelp_nw2004s/helpdata/en/9f/dbac1d35c111d1829f0000e829fbfe/frameset.htm