2006 Oct 18 12:13 PM
I have to delete all those records from one of my ztable where length of material no. (matnr) is less than 18 characters.
can anyone give me the idea of query that I'll have to write.
Regards,
Alok.
2006 Oct 18 12:15 PM
Hi Alok,
First get all the records in an internal table ITAB whose matnr length is LT 18.
then write the below logic.
delete ztable from ITAB.
if sy-subrc eq 0.
commit work.
endif.
regards
Nagaraj
Message was edited by: nagaraj kumar nishtala
2006 Oct 18 12:17 PM
Dear nagaraj,
Here I have to address the length of the field 'matnr'.
Alok.
2006 Oct 18 12:17 PM
Hi
itab type ztable
Select * from ztable into itab.
loop at itab into wa_itab.
count = strlen(wa_itab-field).
if count ge 18.
DELETE itab from wa_itab.
endif.
endloop.
DELETE ztable from table itab.
2006 Oct 18 12:17 PM
2006 Oct 18 12:19 PM
Try like this...
fetch the values of z table into an internal table..
loop at the internal table..
every time get the length of matnr field.
if matnr field length is < 18.
delete ztable where matnr = ur internal table matnr value.
Madhavi
2006 Oct 18 12:32 PM
Hi Alok,
u can try following also.
DATA: v1(19) TYPE c,
n(19) TYPE n.
START-OF-SELECTION.
v1 = '000023456'.
PACK v1 TO n.
WRITE:/ n.
IF n < '100000000000000000'.
WRITE:/ 'lesser'.
ELSE.
WRITE:/ 'greater'.
ENDIF.
v1 = '111111111111111111'.
PACK v1 TO n.
WRITE:/ n.
IF n < '100000000000000000'.
WRITE:/ n.
WRITE:/ 'lesser'.
ELSE.
WRITE:/ 'greater'.
ENDIF.
-Anu
2006 Oct 18 12:50 PM
Hi,
follow below logic
data lv_matnr(17) type c.
do 17 times.
clear lv_index,lv_matnr.
lv_index = sy-index.
do lv_index times.
concatenate lv_matnr '_' into lv_matnr.
endo.
delete from ztable where matnr like lv_matnr.
enddo.
Regards
amole
2006 Oct 18 3:34 PM
Hi,
Retrieve all the data into an internal table.
Loop at itab into lw_itab.
*Calculate the length of material
l_length = strlen(lw_itab-matnr).
if l_length < 18.
delete ztable where matnr = lw_matnr.
if sy-subrc = 0.
commit.
endif.
endif.
endloop.
Reward if it is helpful.
Cheers.
2006 Oct 18 3:37 PM
Hi,
Correction in detete statement in my previous reply.
delete ztable where matnr = lw_itab-matnr.
Cheers