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

delete selected row in table control

Former Member
0 Likes
1,180

Hi,

I am deleting record in tabcontrol using this statement.

delete itab index ztabcontrol-current_line.

initially 3 records in tabcontrol.

if i select 2 nd and 3 rd row and press delete button,second row is getting deleted,and third row is moved to 2 nd row.

next time for third row values ztabcontrol-current_line is 3 and there is only two records in tabcontrol.

if anybody came across this Situation and got solution ,please help me out.

Regards,

Sathya.

5 REPLIES 5
Read only

Former Member
0 Likes
654

Hi,

I came across the same situation

After deleting the record in tablecontrol you also decrease the index value by 1.

By this it will achieve your requirement.

Read only

Former Member
0 Likes
654

Satya,

just look at the sample code below:

MODULE user_command_9000 INPUT.
CASE ok_code.
WHEN 'BACK' OR 'UP' OR 'CANCEL'.
LEAVE PROGRAM.
WHEN 'DIS'.
WRITE 'DEV'.
CALL SCREEN 9001 STARTING AT 10 10 ENDING AT 20 20.

WHEN 'DEL'.
GET CURSOR LINE lin_no.
f1 = 1.
WHEN ''.
f = 1.
ENDCASE.
ENDMODULE. " USER_COMMAND_9000 INPUT



here my delete button name in DEL...

now u would have some module in PBO in which u fetching data from data base....

write this in that module...


MODULE get_data OUTPUT.

IF f1 1.
SELECT kunnr name1
INTO CORRESPONDING FIELDS OF TABLE mytab
FROM kna1.
ENDIF.

IF f1 = 1.
IF lin_no IS NOT INITIAL.
DELETE mytab INDEX lin_no.
FREE lin_no.
FREE f1.
ENDIF.
ENDIF.

ENDMODULE. " get_data OUTPUT

Amit.

Read only

Former Member
0 Likes
654

hi,

If you hace created a marker field ( let say with name 'MARK') in your table control , then you can use this statement,

delete itab where itab-mark = 'X'.

Read only

Former Member
0 Likes
654

Hi,

Use

DELETE <itab> FROM 2 to 3.

2 and 3 are the upper index and lower index...

like wise you can delete 1 to 100 rows at one go from your internal table.

Hope this would solve your issue.

Regards

Narin

Read only

Former Member
0 Likes
654

Hi,

If you are tracing the selected row in the table control .the delete can be achieve by using the following code.

WHEN 'FDEL'.

LOOP AT it_mara .

DELETE it_mara WHERE sel = 'X'.

ENDLOOP.

ENDCASE.

Rewards points if usefull.

Thanks and Regards

Jatender