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

Deletion of records from a Ztable

Former Member
0 Kudos
478

I have a table ZVDELIVERY.

It contains data under columns such as Plant, Material No.,BoxNo., BoxSize etc.

Plant and Material No. are primary keys.

The material code MATNR is a 18 digit number e.g. 21FA2P2021A3551ADZ etc. I have to delete all that material from this table whose MATNR has first four digits as 21FA, 21FB and 21FC.

Can someone please write the required code for me. I have no exposure to ABAP programming hence this request please.

Regards,

Vinay.

6 REPLIES 6
Read only

Former Member
0 Kudos
445

data itab like ZVDELIVERY occurs 0 with header line.

start-of-selection.

select * from ZVDELIVERY in to table itab.

loop at itab.

if itab-matnr CA '21FA' or

itab-matnr CA '21FB' or

itab-matnr CA '21FC'.

delete ZVDELIVERY from itab.

endif.

endloop.

hope this helps!!

Thanks ,

Harkamal

Read only

sudhindra_chandrashekar
Product and Topic Expert
Product and Topic Expert
0 Kudos
445

DATA: T_DELIV TYPE ZVDELIVERY OCCURS 0 WITH HEADER LINE.

SELECT * FROM ZVDELIVERY INTO T_DELIV.

LOOP AT T_DELIV.

IF T_DELIV-MATNR(4) = '21FA' OR T_DELIV-MATNR(4) = '21FB' OR T_DELIV-MATNR(4) = '21FC'.

DELETE T_DELIV.

ENDLOOP.

MODIFY ZVDELIVERY FROM TABLE T_DELIV.

Read only

0 Kudos
445

delete from zvdelivery where matnr like '21FA%' or matnr like '21FB%' or matnr like '21FC'.

regards,

Hans

Read only

Former Member
0 Kudos
445

hi alok,

try this...

IF ( itab-matnr+0(4) = 'Z1FA' ) OR

( itab-matnr+0(4) = 'Z1FB' ) OR

( itab-matnr+0(4) = 'Z1FC' ).

delete ZVDELIVERY from table itab.

endif.

hope this helps,

priya.

Read only

Former Member
0 Kudos
445
HI Alok 

  You can do it in single statment using.

  delete from ZVDELIVERY where matnr like '21FA%' or
                               mantr like '21FB%' or
                               matnr liek '21FC%'.

   Hope this works for you.

Kind Regards
Eswar
Read only

Former Member
0 Kudos
445

Hello Alok,

Try like this.

<b> delete from ZVDELIVERY where matnr like '21FA%' or

mantr like '21FB%' or

matnr liek '21FC%'.

commit work and wait.</b>

If useful reward.

Vasanth