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 delete the Chosen line from the Table Control

Former Member
0 Kudos

Hi Friends,

i am new to Module Pool Programming , i developed a Table Control in input mode and i am getting data also into that table control. my requirement is that i want to delete the current chosen line from that table control. please help me out.

7 REPLIES 7

rahulkavuri
Active Contributor
0 Kudos

Use TC-line for pointing out to the current record

[code]DATA: BEGIN OF it_knbk OCCURS 0,

banks LIKE knbk-banks,

bankl LIKE knbk-bankl,

bankn LIKE knbk-bankn,

bkont LIKE knbk-bkont,

koinh LIKE knbk-koinh,

chk TYPE c,

END OF it_knbk.

<b>

CONTROLS: tc1 TYPE TABLEVIEW USING SCREEN 0200.</b>

MODULE user_command_0200 INPUT.

v_ucomm = sy-ucomm.

CASE v_ucomm.

WHEN 'DELE'.

<b>DELETE it_knbk where chk eq 'X'.

DESCRIBE TABLE it_knbk LINES tc1-lines.[/</b>code]

<b>Please award points if found helpful</b>

former_member181962
Active Contributor
0 Kudos

Once you chose the record to be deleted,

then you can read the internal table based on the selection and delete

delete table itab where check = 'X'. "Where check is the field that indicates where a record has been chosen or not.

Regards,

Ravi

Former Member
0 Kudos

hii

Sample program for Table Control

<b>http://www.sapdevelopment.co.uk/dialog/tabcontrol/tc_basic.htm

http://www.sapdevelopment.co.uk/dialog/tabcontrol/tc_highlight.htm</b>;

For Inserting a Row

<b></b>

PROCESS AFTER INPUT.

LOOP AT i_rec .

module modify_itab_0200.

ENDLOOP.

MODULE modify_itab_0200 INPUT.

CHECK wa_rec-sel EQ 'X'.

DELETE i_rec.

ENDMODULE.

chk this demo program <b>RSDEMO02</b>.

chk these link

<b>

Reward points if helpful

Regards

Naresh

Former Member
0 Kudos

Hi Ram,

Please Check This code .

WHEN 'DELETE'.
      READ TABLE flights-cols INTO cols WITH KEY screen-input = '1'.
      IF sy-subrc = 0.
        LOOP AT itab INTO demo_conn WHERE mark = 'X'.
          DELETE itab.
        ENDLOOP.
      ENDIF.
  ENDCASE.

Check this program : <b>demo_dynpro_tabcont_loop_at</b>

<i>Hope This Info Helps YOU.</i>

Regards,

Raghav

Former Member
0 Kudos

hi ram,

in pai of the screen where u have ur table control

MODULE user_command_0200 INPUT.

v_ucomm = sy-ucomm.

CASE v_ucomm.

WHEN 'DELE'.

DELETE it_knbk where chk eq 'X'.

DESCRIBE TABLE it_knbk LINES tc1-lines.

endmodule.

define another module modify in the same pai.

MODULE modify INPUT.

IF v_check = 'X'.

it_knbk-chk = 'X'.

MODIFY it_knbk index tc1-current_line.

ELSE.

CLEAR it_knbk-chk .

ENDIF.

ENDMODULE. " modify INPUT

hope this helps,

priya.

Former Member
0 Kudos

Hi ram,

In the pai, write the code.

v_ucomm = sy-ucomm.

case sy-ucomm.

WHEN 'DEle'.

LOOP AT itab WHERE sel = 'X'.

DELETE itab.

endloop.

endcase.

award if it helps.

regards,

keerthi.

Former Member
0 Kudos

HI

GOOD

GO THROUGH THIS REPORT

REPORT demo_dynpro_tabcont_loop_at.

CONTROLS flights TYPE TABLEVIEW USING SCREEN 100.

DATA: cols LIKE LINE OF flights-cols,

lines TYPE i.

DATA: ok_code TYPE sy-ucomm,

save_ok TYPE sy-ucomm.

DATA: itab TYPE TABLE OF demo_conn.

TABLES demo_conn.

SELECT * FROM spfli INTO CORRESPONDING FIELDS OF TABLE itab.

LOOP AT flights-cols INTO cols WHERE index GT 2.

cols-screen-input = '0'.

MODIFY flights-cols FROM cols INDEX sy-tabix.

ENDLOOP.

CALL SCREEN 100.

MODULE status_0100 OUTPUT.

SET PF-STATUS 'SCREEN_100'.

DESCRIBE TABLE itab LINES lines.

flights-lines = lines.

ENDMODULE.

MODULE cancel INPUT.

LEAVE PROGRAM.

ENDMODULE.

MODULE read_table_control INPUT.

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 'TOGGLE'.

LOOP AT flights-cols INTO cols WHERE index GT 2.

IF cols-screen-input = '0'.

cols-screen-input = '1'.

ELSEIF cols-screen-input = '1'.

cols-screen-input = '0'.

ENDIF.

MODIFY flights-cols FROM cols INDEX sy-tabix.

ENDLOOP.

WHEN 'SORT_UP'.

READ TABLE flights-cols INTO cols WITH KEY selected = 'X'.

IF sy-subrc = 0.

SORT itab STABLE BY (cols-screen-name+10) ASCENDING.

cols-selected = ' '.

MODIFY flights-cols FROM cols INDEX sy-tabix.

ENDIF.

WHEN 'SORT_DOWN'.

READ TABLE flights-cols INTO cols WITH KEY selected = 'X'.

IF sy-subrc = 0.

SORT itab STABLE BY (cols-screen-name+10) DESCENDING.

cols-selected = ' '.

MODIFY flights-cols FROM cols INDEX sy-tabix.

ENDIF.

WHEN 'DELETE'.

READ TABLE flights-cols INTO cols

WITH KEY screen-input = '1'.

IF sy-subrc = 0.

LOOP AT itab INTO demo_conn WHERE mark = 'X'.

DELETE itab.

ENDLOOP.

ENDIF.

ENDCASE.

ENDMODULE.

CHANGE THE CODE AS PER THIS LIGIC.

THANKS

MRUTYUN