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: 

How To Select a line in table control and code on that selection

Former Member
0 Kudos

Hi All,

I am using Table Control in one of my proframs.I want to select some rows in that table and do some changes after that.Can somebody guide me on how to do that eg the syntax etc.

1 ACCEPTED SOLUTION

former_member667836
Active Participant
0 Kudos

Hi saket,

You can use the code samples.

1.Give the selection variable of table control first.

DATA : BEGIN OF it_list OCCURS 0.

DATA sel TYPE c.<----


Check This

DATA description(200) TYPE c.

DATA segnum TYPE edid4-segnum.

DATA :END OF it_list.

<b>Go to the table control attribute and check the w/selcolumn check box and give

wa_list-sel in that field(as per this example)</b>

Modify the internal table in PAI of the screen.

LOOP AT it_e1vdewunh .

MODULE move_data.

ENDLOOP.

MODULE move_data.

MODIFY it_e1vdewunh FROM wa_e1vdewunh INDEX tc_msg-current_line.

IF sy-subrc <> 0.

APPEND wa_e1vdewunh TO it_e1vdewunh .

ENDIF.

ENDMODULE.

suppose you want to delete the selected line you can do the following code.

MODULE user_command_9006 INPUT.

save_okcode = ok_code.

CLEAR ok_code.

CASE save_okcode.

WHEN 'DEL'.

PERFORM del_tc_msg.

WHEN 'INS'.

PERFORM add_tc_msg.

ENDCASE.

ENDMODULE. " USER_COMMAND_9006 INPUT

FORM del_tc_msg .

LOOP AT it_e1vdewunh INTO wa_e1vdewunh WHERE sel = 'X'.

IF sy-subrc = 0.

DELETE it_e1vdewunh_s[] INDEX sy-tabix.

ENDIF.

ENDLOOP.

ENDFORM.

3 REPLIES 3

former_member667836
Active Participant
0 Kudos

Hi saket,

You can use the code samples.

1.Give the selection variable of table control first.

DATA : BEGIN OF it_list OCCURS 0.

DATA sel TYPE c.<----


Check This

DATA description(200) TYPE c.

DATA segnum TYPE edid4-segnum.

DATA :END OF it_list.

<b>Go to the table control attribute and check the w/selcolumn check box and give

wa_list-sel in that field(as per this example)</b>

Modify the internal table in PAI of the screen.

LOOP AT it_e1vdewunh .

MODULE move_data.

ENDLOOP.

MODULE move_data.

MODIFY it_e1vdewunh FROM wa_e1vdewunh INDEX tc_msg-current_line.

IF sy-subrc <> 0.

APPEND wa_e1vdewunh TO it_e1vdewunh .

ENDIF.

ENDMODULE.

suppose you want to delete the selected line you can do the following code.

MODULE user_command_9006 INPUT.

save_okcode = ok_code.

CLEAR ok_code.

CASE save_okcode.

WHEN 'DEL'.

PERFORM del_tc_msg.

WHEN 'INS'.

PERFORM add_tc_msg.

ENDCASE.

ENDMODULE. " USER_COMMAND_9006 INPUT

FORM del_tc_msg .

LOOP AT it_e1vdewunh INTO wa_e1vdewunh WHERE sel = 'X'.

IF sy-subrc = 0.

DELETE it_e1vdewunh_s[] INDEX sy-tabix.

ENDIF.

ENDLOOP.

ENDFORM.

Former Member
0 Kudos

HI,

check the code below,it may be of any help:

if yes reward.

IN PAI:

module scheduleitems input.

case ok_code2.

when 'header'.

  • Activate TAB_ITEM tabstrip

tabstripg8-activetab = 'header'.

when 'LINE'.

  • Activate TAB_ITEM tabstrip

tabstripg8-activetab = 'LINE'.

when 'SCHEDULE'.

  • Activate TAB_ITEM tabstrip

tabstripg8-activetab = 'SCHEDULE'.

loop at itabline.

clear itabschedule.

if itabline-mark1 = 'X'.

itabschedule-ebelp = itabline-ebelp.

append itabschedule.

itabline-mark1 = ' '.

modify itabline.

endif.

endloop.

loop at itabline_del.

delete itabschedule where ebelp = itabline_del-ebelp.

endloop.

refresh itabline_del.

endcase.

endmodule. " SCHEDULEITEMS INPUT

&----


*& Module MODIFY INPUT

&----


  • text

----


module modify input.

modify itabschedule index zg8tablecont2-current_line.

endmodule. " MODIFY INPUT

&----


*& Module USER_COMMAND_0203 INPUT

&----


  • text

----


module user_command_0203 input.

flag = '0'.

case ok_code2.

when 'ADDS'.

  • To insert or append an initial line into table control

loop at itabschedule.

if itabschedule-mark2 = 'X'.

insert initial line into itabschedule.

flag = '1'.

endif.

endloop.

if flag <> '1'.

append initial line to itabschedule.

endif.

when 'DELETES'.

  • To delete the seleceted line from table control

loop at itabschedule.

if itabschedule-mark2 = 'X'.

move-corresponding itabschedule to itabschedule_del.

append itabschedule_del.

delete itabschedule.

endif.

endloop.

when 'SELECTS'.

  • To select all the rows of table control

loop at itabschedule.

itabschedule-mark2 = 'X'.

modify itabschedule.

endloop.

when 'DESELECTS'.

  • To deselect the rows of table control

loop at itabschedule.

itabschedule-mark2 = ' '.

modify itabschedule.

endloop.

endcase.

thanx.

Former Member
0 Kudos

Thanks for all inputs