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 line from table control

Former Member
0 Likes
2,810

Hi Friends,

Could some one explain me, as to what the following part does for deleting the lines from the table control. This code is taken from the example program : DEMO_DYNPRO_TABCONT_LOOP_AT.

=========================================================

CONTROLS flights TYPE TABLEVIEW USING SCREEN 100.

DATA: cols LIKE LINE OF flights-cols,

lines TYPE i.

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.

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.

========================================================

In my case, i am not using any table like demo_conn. I am trying to delete the lines at the entry stage itself ie., after entering the data in the screen and before saving, I want to select and delete a particular line.

Kindly explain in detail.

TIA.

Regards,

Mark K

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,006

Hi Mark,

Delete Logic you are asking works as follows:

Here MARK is the field we use to select line on the table control.

it loops at the table control where the user has marked the lines to be deleted and deletes all the lines from the table control internal table.

This is the same internal table which is used to display the data on the table control.

Thanks and Regards,

Kunjal Patel

14 REPLIES 14
Read only

Former Member
0 Likes
2,006

Hi,

DELETE itab.

This will delete the line from Table Control.

Regards,

Padmam.

Read only

Former Member
0 Likes
2,007

Hi Mark,

Delete Logic you are asking works as follows:

Here MARK is the field we use to select line on the table control.

it loops at the table control where the user has marked the lines to be deleted and deletes all the lines from the table control internal table.

This is the same internal table which is used to display the data on the table control.

Thanks and Regards,

Kunjal Patel

Read only

Former Member
0 Likes
2,006

Hi MArk,

When you press the DELETE button it will check the lines.

DEMO_CONN-MARK is the placeholder defined in the table control attribute's

W/SelColumn.

You can check it through SE51 or by double clicking to call screen statement in same program.

Whenver you select a line mark value is 'X'.

So it will delete only those lines.

Reward if useful!

Read only

Former Member
0 Likes
2,006

hi mark...

consider the below given code...

loop at it_cocodes into it_cocodes_wa.

read table it_cocodes_000 with key bukrs = it_cocodes_wa-bukrs.

if sy-subrc = 0.

delete it_cocodes.

endif.

endloop.

here there are 2 tables--

<b>it_cocodes</b> and <b>it_cocodes_000</b>

if the records in both the tables match then i m deleting that record from it_cocodes table by just using this statement-> <b>delete it_cocodes.</b>

Regards,

Roshani

Read only

0 Likes
2,006

Hi Roshani,

it_cocodes : - This is an internal table.

it_cocodes_wa :- This is the work are.

it_cocodes_000 :- What is this?

My doubt is that, how the selected line in the screen, will get deleted in the internal table.

Could u pls explain.

Regards,

Read only

0 Likes
2,006

HI,

item_itab is the internal table which is holding the data being shown in the table control.

WHEN 'DEL_ROW'."function code for del_row in details screen

DATA L_SELLINE LIKE SY-STEPL.

GET CURSOR LINE L_SELLINE.

IF L_SELLINE <> 0.

DELETE ITEM_ITAB INDEX L_SELLINE.

ELSE.

MESSAGE S002(Z_MSG_TAB).

ENDIF.

rgds,

bharat.

Read only

0 Likes
2,006

hi mark,

it_cocodes_000 is also an internbal table.

let me xplain u this way..

it_cocodes contains these records...

a, b, c ,d.

it_cocodes_000 contains these records...

a,b.

now my aim is to delete records from it_cocodes which are present in it_cocodes_000

for this purpose i use the above mentioned code...

loop at it_cocodes into it_cocodes_wa.

read table it_cocodes_000 with key bukrs = it_cocodes_wa-bukrs.

if sy-subrc = 0.

<b>delete it_cocodes.</b>

endif.

endloop.

after this code the table it_cocodes will contain these records...

c,d.

hope it helps u...

Regards,

Roshani.

Read only

0 Likes
2,006

Hi Roshani,

Thanks for your response.

Your explaination is clear. But, my doubt is that, how the it_cocodes_000 gets the records a,b. Are these records are selected for deletion in the screen.

Kindly let me know.

TIA.

Regards,

Read only

0 Likes
2,006

hi mark,

No... it_cocodes_000 is populated using a select query...

the code that i mentioned merely reads the two internal table and deletes the records of table 1 from table 2.

what is your requirement?

Read only

0 Likes
2,006

Hi,

My requirement is that, in the screen I have typed 4 lines. Out of these 4 lines, i want to delete line 2. How to do this.

Pls.

Regards,

Read only

0 Likes
2,006

Hi,

Consider U have typed 4 lines in the Table control.It will get stored in internal table.After the 2 nd line is deleted ie.,when u press delete button it should delete the second record from Internal table & re-display the Internal table values in the Table Control.

Regards,

Padmam.

Read only

0 Likes
2,006

> Hi,

> Consider U have typed 4 lines in the Table

> control.It will get stored in internal table.After

> the 2 nd line is deleted ie.,when u press delete

> button it should delete the second record from

> Internal table & re-display the Internal table

> values in the Table Control.

>

> Regards,

> Padmam.

> Hi,

> Consider U have typed 4 lines in the Table

> control.It will get stored in internal table.After

> the 2 nd line is deleted ie.,when u press delete

> button it should delete the second record from

> Internal table & re-display the Internal table

> values in the Table Control.

>

> Regards,

> Padmam.

Hi,

U r right. But, i want to know how to delete the 2nd line from the internal table.

Regards,

Read only

0 Likes
2,006

Hi,

First,U fetch the datas from the tablecontrol & move it to workarea.From workarea delete that record from Internal Table.

DELETE TABLE <itab> FROM <wa>.

Reward all Helpful Answers.

Regards,

Padmam.

Read only

0 Likes
2,006

hi mark...i just wrote this code here...

just 1 thing u need to do here...double click on the "status" and create a field delete.

&----


*& Report ZROSH_TEST

*&

&----


*&

*&

&----


REPORT zrosh_test.

DATA : itab LIKE mara OCCURS 0 WITH HEADER LINE.

TYPE-POOLS : slis.

DATA: gt_fieldcat TYPE slis_t_fieldcat_alv

WITH HEADER LINE,

gd_layout TYPE slis_layout_alv.

SELECT * FROM mara INTO CORRESPONDING FIELDS OF TABLE itab UP TO 10 ROWS.

DATA i_repid LIKE sy-repid.

gt_fieldcat-fieldname = 'MATNR'.

gt_fieldcat-seltext_m = 'Material Number'.

APPEND gt_fieldcat.

gt_fieldcat-fieldname = 'PSTAT'.

gt_fieldcat-seltext_m = 'Maintenance status'.

APPEND gt_fieldcat.

CLEAR gt_fieldcat.

i_repid = sy-repid.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = i_repid

i_callback_pf_status_set = 'SET_PF_STATUS'

i_callback_user_command = 'USER_COMMAND'

i_grid_title = 'test program'

it_fieldcat = gt_fieldcat[]

TABLES

t_outtab = itab

EXCEPTIONS

program_error = 1

OTHERS = 2.

FORM set_pf_status USING rt_extab TYPE slis_t_extab.

SET PF-STATUS 'STATUS' EXCLUDING rt_extab.

ENDFORM. "set_pf_status

*at line selction in ALV grid.

FORM user_command USING r_ucomm TYPE sy-ucomm

rs_selfield TYPE slis_selfield.

CASE r_ucomm.

WHEN '&IC1' OR 'DELETE'.

LOOP AT itab.

READ TABLE itab INDEX rs_selfield-tabindex.

IF sy-subrc = 0.

DELETE itab index rs_selfield-tabindex.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = i_repid

it_fieldcat = gt_fieldcat[]

TABLES

t_outtab = itab

EXCEPTIONS

program_error = 1

OTHERS = 2.

EXIT.

ENDIF.

ENDLOOP.

ENDCASE.

ENDFORM. "user_command

Regards,

Roshani