‎2006 Oct 16 8:00 AM
Hi,
Pls provide me with some code sample for inserting rows in a table control (module pool)...
Regards
Gunjan
‎2006 Oct 16 8:03 AM
Hello,
describe table g_t_tab[] lines tab_cont-lines.
init the internal table
if lines( g_t_tab[] ) = 0.
clear g_t_tab.
do 5 times.
append g_t_tab.
enddo.
endif.
Best regards,
Krishnakumar
‎2006 Oct 16 8:07 AM
HI
Y dont u create a TABLE CONTROL using wizard and copy the coding-
TRY THIS-
WHEN 'INSR'. "insert row
PERFORM FCODE_INSERT_ROW USING P_TC_NAME
P_TABLE_NAME.
FORM fcode_insert_row
USING P_TC_NAME TYPE DYNFNAM
P_TABLE_NAME .
&SPWIZARD: BEGIN OF LOCAL DATA----
DATA L_LINES_NAME LIKE FELD-NAME.
DATA L_SELLINE LIKE SY-STEPL.
DATA L_LASTLINE TYPE I.
DATA L_LINE TYPE I.
DATA L_TABLE_NAME LIKE FELD-NAME.
FIELD-SYMBOLS <TC> TYPE CXTAB_CONTROL.
FIELD-SYMBOLS <TABLE> TYPE STANDARD TABLE.
FIELD-SYMBOLS <LINES> TYPE I.
&SPWIZARD: END OF LOCAL DATA----
ASSIGN (P_TC_NAME) TO <TC>.
*&SPWIZARD: get the table, which belongs to the tc *
CONCATENATE P_TABLE_NAME '[]' INTO L_TABLE_NAME. "table body
ASSIGN (L_TABLE_NAME) TO <TABLE>. "not headerline
*&SPWIZARD: get looplines of TableControl *
CONCATENATE 'G_' P_TC_NAME '_LINES' INTO L_LINES_NAME.
ASSIGN (L_LINES_NAME) TO <LINES>.
*&SPWIZARD: get current line *
GET CURSOR LINE L_SELLINE.
IF SY-SUBRC <> 0. " append line to table
L_SELLINE = <TC>-LINES + 1.
*&SPWIZARD: set top line *
IF L_SELLINE > <LINES>.
<TC>-TOP_LINE = L_SELLINE - <LINES> + 1 .
ELSE.
<TC>-TOP_LINE = 1.
ENDIF.
ELSE. " insert line into table
L_SELLINE = <TC>-TOP_LINE + L_SELLINE - 1.
L_LASTLINE = <TC>-TOP_LINE + <LINES> - 1.
ENDIF.
*&SPWIZARD: set new cursor line *
L_LINE = L_SELLINE - <TC>-TOP_LINE + 1.
*&SPWIZARD: insert initial line *
INSERT INITIAL LINE INTO <TABLE> INDEX L_SELLINE.
<TC>-LINES = <TC>-LINES + 1.
*&SPWIZARD: set cursor *
SET CURSOR LINE L_LINE.
ENDFORM. " FCODE_INSERT_ROW
HOpe this helps u
Regds,
Seema.
‎2006 Oct 16 8:09 AM
Hi,
Check this link.It will help you.In this,I am explaining about the database manipulations using table control.
Message was edited by: Jayanthi Jayaraman
‎2006 Oct 16 8:17 AM
Hello,
I hope you might have included the following statement in your code,
CONTROLS: tab_ctrl TYPE TABLEVIEW USING SCREEN '8000'.
Now you can just use the control name 'tab_cntrl' to add rows to the table control.
First get the internal table rows ( Table controls rows) in to some variable called 'lv_cnt'.
Now,
tab_ctrl-lines = lv_cnt + 5.
This statement will add new rows (5) to your table control.
Regs,
Venkat
‎2006 Oct 16 9:19 AM
hi,
use this standard program and go through the code .
demo_dynpro_tabcont_loop
regards,
Vijay
‎2006 Oct 16 9:34 AM
Iserting data is trying to move data from table control to internal table.
Check the below code it may help u.
&----
*& Module move_data_to_table OUTPUT
&----
This is to move the data from the internal table to the table control
----
MODULE move_data_to_table OUTPUT.
This is to move the data from the internal table to the table control
zmpets_mode-modecode,zmpets_range-rangeid,zmpets_servfacto-factor are column name if *table control
*
READ TABLE int_factor INDEX tab_control-current_line.
IF sy-subrc = 0.
zmpets_mode-modecode = int_factor-modecode.
zmpets_range-rangeid = int_factor-rangeid.
zmpets_servfacto-factor = int_factor-factor.
ENDIF.
ENDMODULE. " move_data_to_table OUTPUT
**********************
&----
*& Module move_data_from_table INPUT
&----
Date is moved from the table control to the Internal Table
----
MODULE move_data_from_table INPUT.
To move the data from the table control to internal table 'INT_FACTOR.
int_factor-modecode = zmpets_mode-modecode.
int_factor-rangeid = zmpets_range-rangeid.
int_factor-factor = zmpets_servfacto-factor.
MODIFY int_factor INDEX tab_control-current_line.
IF sy-subrc NE 0.
APPEND int_factor.
CLEAR int_factor.
ENDIF.
ENDIF.
ENDMODULE. " move_data_from_table INPUT
Regards