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: 

Need to delete the record based on the checkbox xselected

Former Member
0 Kudos

I am displaying the data from tables vbrk and vbrp.along with that data i am displaying the checkbox also.

here my requirement is when ever the user checks the checkboxes and click on delete button the checkbox selected items should deleted and need to display the remaining.

please any send me the example how to process it.

thanks and regards

vamsi

vamsin@intelligroup.com.

7 REPLIES 7

Former Member
0 Kudos

hi,

where r u dsplaying the fields? in alv grid or list?oops or normal?

In the okcode of the delete button check the internal table which u have displayed.

if checkbox field in the internal table contains 'X'(checked) then delete those records from the internal tables and display the internal table with the modified records.

rgds,

Prajith

p291102
Active Contributor
0 Kudos

Hi,

Herewith i am sending the sample coding for checkbox alv report. Kindly go through it. U can get some idea for your requirement.

REPORT YMS_CHECKBOXALV.

TYPE-POOLS: slis.

DATA: t_fieldcatalog TYPE slis_t_fieldcat_alv.

DATA: s_fieldcatalog TYPE slis_fieldcat_alv.

DATA: s_layout TYPE slis_layout_alv.

DATA: BEGIN OF itab OCCURS 0,

icon TYPE icon-id,

vbeln TYPE vbeln,

kunnr TYPE kunnr,

erdat TYPE erdat,

box TYPE c,

END OF itab.

DATA: v_repid TYPE syrepid.

START-OF-SELECTION.

  • Get the data.

SELECT vbeln kunnr erdat UP TO 100 ROWS

FROM vbak

INTO CORRESPONDING FIELDS OF TABLE itab.

IF sy-subrc <> 0.

MESSAGE s208(00) WITH 'No data found'.

LEAVE LIST-PROCESSING.

ENDIF.

  • Modify the record with red light.

itab-icon = '@0A@'.

MODIFY itab TRANSPORTING icon WHERE NOT vbeln IS initial.

v_repid = sy-repid.

  • Get the field catalog.

CLEAR: s_fieldcatalog.

s_fieldcatalog-col_pos = '1'.

s_fieldcatalog-fieldname = 'ICON'.

s_fieldcatalog-tabname = 'ITAB'.

s_fieldcatalog-seltext_l = 'Status'.

s_fieldcatalog-icon = 'X'.

APPEND s_fieldcatalog TO t_fieldcatalog.

CLEAR: s_fieldcatalog.

s_fieldcatalog-col_pos = '2'.

s_fieldcatalog-fieldname = 'VBELN'.

s_fieldcatalog-tabname = 'ITAB'.

s_fieldcatalog-rollname = 'VBELN'.

APPEND s_fieldcatalog TO t_fieldcatalog.

CLEAR: s_fieldcatalog.

s_fieldcatalog-col_pos = '3'.

s_fieldcatalog-fieldname = 'KUNNR'.

s_fieldcatalog-tabname = 'ITAB'.

s_fieldcatalog-rollname = 'KUNNR'.

APPEND s_fieldcatalog TO t_fieldcatalog.

CLEAR: s_fieldcatalog.

s_fieldcatalog-col_pos = '4'.

s_fieldcatalog-fieldname = 'ERDAT'.

s_fieldcatalog-tabname = 'ITAB'.

s_fieldcatalog-rollname = 'ERDAT'.

APPEND s_fieldcatalog TO t_fieldcatalog.

  • Set the layout.

s_layout-box_fieldname = 'BOX'.

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

EXPORTING

i_callback_program = v_repid

is_layout = s_layout

i_callback_pf_status_set = 'SET_PF_STATUS'

i_callback_user_command = 'USER_COMMAND'

it_fieldcat = t_fieldcatalog[]

TABLES

t_outtab = itab.

----


  • FORM SET_PF_STATUS *

----


  • ........ *

----


  • --> EXTAB *

----


FORM set_pf_status USING extab TYPE slis_t_extab.

SET PF-STATUS 'TEST2'.

ENDFORM.

----


  • FORM user_command *

----


  • ........ *

----


  • --> UCOMM *

  • --> SELFIELD *

----


FORM user_command USING ucomm LIKE sy-ucomm

selfield TYPE slis_selfield.

  • Check the ucomm.

IF ucomm = 'DETAIL'.

LOOP AT itab WHERE box = 'X'.

itab-icon = '@08@'.

MODIFY itab TRANSPORTING icon.

ENDLOOP.

ENDIF.

selfield-refresh = 'X'.

ENDFORM.

Thanks,

Shankar

Former Member
0 Kudos

Hi Vamsi,

Mailed a sample code to you.

Use that and do accordingly.

reward if useful

Regards,

Anji

former_member533584
Contributor
0 Kudos

hai,

REPORT YH649_TEST_01 .

DATA FS_SPFLI LIKE SPFLI.

DATA T_SPFLI LIKE STANDARD TABLE OF SPFLI.

DATA CHECK TYPE C.

DATA W_LINE TYPE I.

DATA W_INDEX TYPE I.

SELECT * FROM SPFLI INTO TABLE T_SPFLI.

LOOP AT T_SPFLI INTO FS_SPFLI.

WRITE 😕 CHECK AS CHECKBOX,

FS_SPFLI-CARRID,

FS_SPFLI-CONNID.

ENDLOOP.

DESCRIBE TABLE T_SPFLI LINES W_LINE.

SET PF-STATUS 'DELETE'.

AT USER-COMMAND.

CASE SY-UCOMM.

WHEN 'DELETE'.

<b> DO W_LINE TIMES.

W_INDEX = SY-INDEX + 2.

READ LINE W_INDEX FIELD VALUE CHECK INTO CHECK.

IF CHECK EQ 'X'.

DELETE T_SPFLI INDEX SY-INDEX.

ENDIF.

CHECK = ' '.

ENDDO.</b>

ENDCASE.

LOOP AT T_SPFLI INTO FS_SPFLI.

WRITE 😕 CHECK AS CHECKBOX,

FS_SPFLI-CARRID,

FS_SPFLI-CONNID.

ENDLOOP.

Regards ,

ananth.

0 Kudos

<b>Already i tried with this flow but it acting randomly.

its not giving the exact output</b>

0 Kudos

i think the sy-index value is not the correct value for deleting so you are getting wrong result...

if your itab contains any unique value then do like this suppose you have matnr as unique value in your table.

at user-command.

describe table itab lines line.

case sy-ucomm.

when 'DEL'.

do line times.

read line sy-index field value itab-chkbox into check itab-matnr into matnr.

if check = x.

read table itab with key matnr = matnr.

delete itab index sy-tabix.

endif.

enddo.

endcase.

and or before changing the code which i have posted earlier i want to know whether you have used HIDE command or not in your report? if not just add that..

where you are writing the data

loop at itab.

write : / itab-f1, itab-f2...

hide itab.<after writting the data>

endloop.

regards

shiba dutta

Former Member
0 Kudos

data : line type i,

check.

at user-command.

describe table itab lines line.

case sy-ucomm.

when 'DEL'.

do line times.

read line sy-index field value itab-chkbox into check.

if check = x.

delete itab index sy-index.

endif.

enddo.

endcase.

regards

shiba dutta