‎2009 Jan 08 9:41 AM
Hi,
I have created a classical report/basic list where user can select check boxes and adjacent rows should be deleted. But after the action, I wish to refresh the report and remove the selected lines from displaying.
Please let me know how to achieve this.
Thanks in advance.
Nitin
‎2009 Jan 08 10:23 AM
Hi,
Put a flag like check box. and use read line statement in the do loop like this.
loop at itab.
Do.
read line into itab1 index sy-index.
if sy-subrc <> 0.
exit.
endif.
if itab-flag = 'X'.
*delete line fromitab.
endif.
enddo.
endloop.
loop at itab.
*display the table itab.
endloop.
Regards
Lakshmi Kamala.
Code Formatted by: Alvaro Tejada Galindo on Jan 8, 2009 3:36 PM
‎2009 Jan 08 10:04 AM
Hi Nitin,
This can be achieved like as given below
say your displaying a table itab in the output, and on the user action you are deleting a line from that table, then
PERFORM print_output. "Form that prints your output.
"when the user command is delete the line then
"Logic to delete the line
PERFORM print_output. "Again print the new listRegards,
Manoj Kumar P
Edited by: Manoj Kumar on Jan 8, 2009 11:04 AM
‎2009 Jan 08 10:10 AM
HI Manoj,
I already checked that but it creates secondary list and using Back button you can come to basic list which will reflect as it was. I wish the basic list to overlay.
Regards,
Nitin
‎2009 Jan 08 10:16 AM
there is some command to kill subscreen. Please check for the same
‎2009 Jan 08 10:23 AM
Hi,
Put a flag like check box. and use read line statement in the do loop like this.
loop at itab.
Do.
read line into itab1 index sy-index.
if sy-subrc <> 0.
exit.
endif.
if itab-flag = 'X'.
*delete line fromitab.
endif.
enddo.
endloop.
loop at itab.
*display the table itab.
endloop.
Regards
Lakshmi Kamala.
Code Formatted by: Alvaro Tejada Galindo on Jan 8, 2009 3:36 PM
‎2009 Jan 08 10:34 AM
Hi Lakshmi ,
I have already done everything and it is working fine. But when I loop on itab for second time, it creates secondary list and basic list remains as it is.
Regards,
Nitin
‎2009 Jan 08 8:43 PM
Before writing the Internal table second time reset the List Indicator by:
AT USER-COMMAND.
...
SY-LSIND = 0.
PERFORM WRITE_ITAB.
Regards,
Naimesh Patel
‎2009 Jan 09 6:47 AM
Hi Nitin,
Check the following program.
Here on pressing the delete push button(FCODE: DELETE) it will delete all
rows which has adjacent checkboxes checked.
REPORT ztest_list_processing NO STANDARD PAGE HEADING .
TYPES: BEGIN OF ty_tab,
delete,
f1(3) TYPE c,
f2(3) TYPE c,
f3(3) TYPE c,
END OF ty_tab.
DATA: it_tab TYPE TABLE OF ty_tab,
wa_tab TYPE ty_tab.
DATA: w_delete TYPE c,
w_lines TYPE i,
w_ind TYPE i.
wa_tab-f1 = '111'.
wa_tab-f2 = 'ABC'.
wa_tab-f3 = '123'.
APPEND wa_tab TO it_tab.
wa_tab-f1 = '222'.
wa_tab-f2 = 'DEF'.
wa_tab-f3 = '456'.
APPEND wa_tab TO it_tab.
wa_tab-f1 = '333'.
wa_tab-f2 = 'GHI'.
wa_tab-f3 = '789'.
APPEND wa_tab TO it_tab.
wa_tab-f1 = '444'.
wa_tab-f2 = 'JKL'.
wa_tab-f3 = '987'.
APPEND wa_tab TO it_tab.
wa_tab-f1 = '555'.
wa_tab-f2 = 'MNO'.
wa_tab-f3 = '654'.
APPEND wa_tab TO it_tab.
*
SET PF-STATUS '100'. "Contains Delete button
PERFORM print_output.
"Logic which you can implement
AT USER-COMMAND.
CASE sy-ucomm.
WHEN 'DELETE'.
DESCRIBE TABLE it_tab LINES w_lines.
DO w_lines TIMES. "To read all rows
CLEAR: wa_tab.
READ LINE w_ind FIELD VALUE wa_tab-delete
wa_tab-f1. "Getting the values
IF wa_tab-delete EQ 'X'. "Delete when check box is 'X'
DELETE it_tab WHERE f1 = wa_tab-f1.
ENDIF.
ADD 1 TO w_ind."Index for next line
ENDDO.
IF it_tab IS INITIAL.
WRITE: / 'There are no data in the table'.
ELSE.
PERFORM print_output. "Reprint the updated data(like refreshing)
ENDIF.
"Modified the existing Back button in standard Toolbar so that on
"pressin the back button it will come to program and not to
"previous displayed list
WHEN '&BACK'.
LEAVE SCREEN.
ENDCASE.
*&---------------------------------------------------------------------*
*& Form print_output
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM print_output.
LOOP AT it_tab INTO wa_tab.
WRITE:/ wa_tab-delete AS CHECKBOX INPUT ON, "Display as checkbox
wa_tab-f1,
wa_tab-f2,
wa_tab-f3.
IF sy-tabix EQ 1.
w_ind = sy-linno. "Get the line position of first row
ENDIF.
ENDLOOP.Hope this helps you.
Regards,
Manoj Kumar P
‎2009 Jan 09 7:23 AM
Hi Manoj,
Thankx for the reply.
I wanted the next thing from the result we get after executing the code U mentioned and I got it simply initializing SY-LSIND.
Regards,
Nitin