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

Insertion in Table Control

Former Member
0 Likes
1,222

Hi Team,

Is it possible to insert a row in Table control.

Whatever the row is selected in table control, that row should

be in editable mode and user will insert data into it and then

he will save data.

please let me know regarding this.

Thanks and Regards,

S.Anilkumar

7 REPLIES 7
Read only

Former Member
0 Likes
1,076

Hi,

it's possible to insert a row in a table control and making changes. in which case do you want to insert a row can you elaborate?

Regards,

Sathish Reddy.

Read only

Former Member
0 Likes
1,076

Hi,

Is it possible to insert a row in Table control.: Yes.

Whatever the row is selected in table control, that row should

be in editable mode and user will insert data into it and then

he will save data: plz look into below example :

CONTROLS flights TYPE TABLEVIEW USING SCREEN 100.

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

DATA: itab TYPE TABLE OF demo_conn,
fill TYPE i.
TABLES demo_conn.

DATA: lines TYPE i,
limit TYPE i.

SELECT * FROM spfli INTO TABLE itab.

CALL SCREEN 100.

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

MODULE fill_table_control OUTPUT.
READ TABLE itab INTO demo_conn INDEX flights-current_line.
ENDMODULE.

MODULE cancel INPUT.
LEAVE PROGRAM.
ENDMODULE.

MODULE read_table_control INPUT.
lines = sy-loopc.
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 'SAVE'.
INSERT <DataBASEtable> FROM TABLE itab ACCEPTING DUPLICATE KEYS. 

(or)

Modify <DataBASEtable> from table itab. 
ENDCASE.
ENDMODULE.

Note:- here u can insert data into table control, then u can copying the data in table control into itab, then modify or insert database table from this itab.

And also u can insert or modify database table for selected entries in table control by adding a field(FLAG) of type character and length 1 and according to if this fields value(FLAG) = 'X' then insert into database table .... also.....

thanx.

Read only

Former Member
0 Likes
1,076

Is it possible to insert a row in Table control.

Whatever the row is selected in table control, that row should

be in editable mode and user will insert data into it and then

he will save data.

please let me know regarding this.

Thanks and Regards,

S.Anilkumar

Hi,

It is possible to add row in a table control. During PAI, whenever you are looping with the table control, you can append a row to it.And then during PBO, you write DESCRIBE IT LINES TC-LINES to populate table control with the newest lines.The row is automatically in editable mode.

For Editable,

Whenever user selects a row, in PBO looping with control, you get the current index of the table which is selected using GET CURSOR statement. And on that line, you do LOOP AT SCREEN and ENDSCREEN with screen-input = 1.

Read only

Former Member
0 Likes
1,076

Hi Satharupa,

You can use the following module to include a blank line in your Table when the use presses the ADD button.

MODULE add_line INPUT.

CASE ok_code2.

WHEN 'ADD'.

*Appending an empty line to add a line in table control.

APPEND INITIAL LINE TO itab.

CLEAR ok_code2.

ENDCASE.

ENDMODULE. " add_line INPUT

After this you can update the line.

check this.

Read only

Former Member
0 Likes
1,076

Hi Team,

For example 10 records are displayed in

table control.

when user select 5th record and press insert button, then

new empty editable row should be inserted for all fields in table control,sothat user can insert the data into all fields for this row and press save button .In this case, 5th record is going to move to 6th row in table control since we are adding empty row in 5 th row.

I dont need logic for modifying the table control.

I want exactly this requirement.

Thanks and Regards

S.ANILKUMAR

Read only

0 Likes
1,076

Hi,

try like this...

case ok_code.
when 'INSERT'.
if v_index is not initial.
        describe table itab lines v_index.
        v_index = v_index + 1.
        tc-current_line = tc-current_line + 1.
        v_index = tc-current_line.
        insert initial line into itab index v_index.
      else.
        get cursor line  v_line.
        move : v_line to v_index.
        v_index = v_index + 1.
        insert initial line into itab index v_index.
      endif.
      tc-lines = v_lines + 1.
ENDCASE.

Regards,

Sathish Reddy.

Read only

0 Likes
1,076

Hi,

try like this...

case ok_code.
when 'INSERT'.
if v_index is not initial.
        describe table itab lines v_index.
        v_index = v_index + 1.
        tc-current_line = tc-current_line + 1.
        v_index = tc-current_line.
        insert initial line into itab index v_index.
      else.
        get cursor line  v_line.
        move : v_line to v_index.
        v_index = v_index + 1.
        insert initial line into itab index v_index.
      endif.
      tc-lines = v_lines + 1.
ENDCASE.

Regards,

Sathish Reddy.