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

deleting itab

Former Member
0 Likes
631

Hi,

I having 10 records in my output screen with check boxes.

I have one EXEC button also.

If i check any one of the records,and if i press EXEC button, i want to delete(remove) that particular record(line).Can any one tell me how to do that?

Points guaranteed.

cheers

kaki

1 ACCEPTED SOLUTION
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
613

Here is a modify version where we are re-writing the list everytime you delete something.



report zrich_0002 no standard page heading.

data: imara type table of mara with header line.

data: check_box(1) type c,
      report_lines type i.


start-of-selection.

* Create the gui status with BACK button in standard place
* and a READ button in the application toolbar

  set pf-status 'CHECK'.

  select * into corresponding fields of table imara
           from mara up to 100 rows.

  loop at imara.
    write:/ check_box as checkbox, imara-matnr, imara-matkl.
    hide imara-matnr.

  endloop.

  report_lines  = sy-linno - 1.

top-of-page.

  write: 'List of materials'.
  uline.

top-of-page during line-selection.

  write:  'Material.....'.
  uline.

at user-command.

  case sy-ucomm.
    when 'READ'.
      check_box = space.
      set pf-status 'CHECK' excluding 'READ'.
      do report_lines times.
        read line sy-index field value check_box.

<b>        if check_box = 'X'.
*        read table imara with key matnr = imara-matnr.
          delete imara where matnr = imara-matnr.
*          write:/  'You have selected material',
*                 imara-matnr, imara-matkl, imara-groes.
        endif.
      enddo.


      set pf-status 'CHECK'.
      clear check_box.
      loop at imara.
        write:/ check_box as checkbox, imara-matnr, imara-matkl.
        hide imara-matnr.
      endloop.
      sy-lsind = sy-lsind - 1.</b>


    when 'BACK'.
      leave to screen 0.
  endcase.

Regards,

Rich Heilman

6 REPLIES 6
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
613

I'm assuming that this is for the current program that you are working on.




at user-command.
case sy-ucomm.
when 'EXEC'.
check_box = space.
set pf-status 'EXEC'.
do report_lines times. 

read line sy-index field value check_box.
if check_box = 'X'.

<b>*read table T_INS with key PRUEFLOS = T_INS-PRUEFLOS.
delete itab where prueflos = t_ins_prueflos.</b>



write:/ 'You have selected material',
T_INS-PRUEFLOS.
endif.
enddo.


REgards,

Rich Heilman

Read only

0 Likes
613

Hi Rich

In your code it is not working. What might be the reason?




report zrich_0002 no standard page heading.

data: imara type table of mara with header line.

data: check_box(1) type c,
      report_lines type i.


start-of-selection.

* Create the gui status with BACK button in standard place
* and a READ button in the application toolbar

  set pf-status 'CHECK'.

  select * into corresponding fields of table imara
           from mara up to 100 rows.

  loop at imara.
    write:/ check_box as checkbox, imara-matnr, imara-matkl.
    hide imara-matnr.

  endloop.

  report_lines  = sy-linno - 1.

top-of-page.

  write: 'List of materials'.
  uline.

top-of-page during line-selection.

  write:  'Material.....'.
  uline.

at user-command.

  case sy-ucomm.
    when 'READ'.
      check_box = space.
      set pf-status 'CHECK' excluding 'READ'.
      do report_lines times.
        read line sy-index field value check_box.

        if check_box = 'X'.
*        read table imara with key matnr = imara-matnr.
          <b>delete imara where matnr = imara-matnr.</b>
          write:/  'You have selected material',
                 imara-matnr, imara-matkl, imara-groes.
        endif.
      enddo.
    WHEN 'BACK'.
      leave to screen 0.
  endcase.

Read only

govind_seenivasan
Participant
0 Likes
613

Hi,

In your code the check_box should be part of the internal table. Look at the corrections in bold

Thanks

report zrich_0002 no standard page heading.

*data: imara type table of mara with header line.

<b>data : begin of imara occurs 0.

check_box(1) type c.

include structure mara.

data : end of imara</b>

*data: check_box(1) type c,

data :report_lines type i.

start-of-selection.

  • Create the gui status with BACK button in standard place

  • and a READ button in the application toolbar

set pf-status 'CHECK'.

select * into corresponding fields of table imara

from mara up to 100 rows.

loop at imara.

write:/ <b>imara-</b>check_box as checkbox, imara-matnr, imara-matkl.

hide imara-matnr.

endloop.

report_lines = sy-linno - 1.

top-of-page.

write: 'List of materials'.

uline.

top-of-page during line-selection.

write: 'Material.....'.

uline.

at user-command.

case sy-ucomm.

when 'READ'.

check_box = space.

set pf-status 'CHECK' excluding 'READ'.

do report_lines times.

read line sy-index field value check_box.

if <b>imara-</b>check_box = 'X'.

  • read table imara with key matnr = imara-matnr.

delete imara where matnr = imara-matnr.

write:/ 'You have selected material',

imara-matnr, imara-matkl, imara-groes.

endif.

enddo.

WHEN 'BACK'.

leave to screen 0.

endcase.

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
613

If you debug it, you notice that it is deleting the entry from the ITAB. You have to re-write the list in order to see it reflected. You are seeing an old version of the list on the screen. If you were to re-write it, you would see that a specific material has been deleted from the itab.

Regards,

Rich Heilman

Read only

0 Likes
613

Hi Rich,

Thank you.I got it.

Points alloted.

Regards

Kaki

Message was edited by: Kaki R

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
614

Here is a modify version where we are re-writing the list everytime you delete something.



report zrich_0002 no standard page heading.

data: imara type table of mara with header line.

data: check_box(1) type c,
      report_lines type i.


start-of-selection.

* Create the gui status with BACK button in standard place
* and a READ button in the application toolbar

  set pf-status 'CHECK'.

  select * into corresponding fields of table imara
           from mara up to 100 rows.

  loop at imara.
    write:/ check_box as checkbox, imara-matnr, imara-matkl.
    hide imara-matnr.

  endloop.

  report_lines  = sy-linno - 1.

top-of-page.

  write: 'List of materials'.
  uline.

top-of-page during line-selection.

  write:  'Material.....'.
  uline.

at user-command.

  case sy-ucomm.
    when 'READ'.
      check_box = space.
      set pf-status 'CHECK' excluding 'READ'.
      do report_lines times.
        read line sy-index field value check_box.

<b>        if check_box = 'X'.
*        read table imara with key matnr = imara-matnr.
          delete imara where matnr = imara-matnr.
*          write:/  'You have selected material',
*                 imara-matnr, imara-matkl, imara-groes.
        endif.
      enddo.


      set pf-status 'CHECK'.
      clear check_box.
      loop at imara.
        write:/ check_box as checkbox, imara-matnr, imara-matkl.
        hide imara-matnr.
      endloop.
      sy-lsind = sy-lsind - 1.</b>


    when 'BACK'.
      leave to screen 0.
  endcase.

Regards,

Rich Heilman