‎2008 Jun 11 8:26 AM
Hi
i want to delete the records from ZTABLE. Following coding is not working. pls help me.
Select * from z1ychlog into table it_z1log
where VBELN in s_vbeln
AND vstel = p_vstel
AND WERKS = P_werks.
loop at it_z1log.
if it_z1log-APPROVELNO is not initial.
*do nothing
else.
delete z1ychlog.
endif.
endloop.Edited by: Kumar k on Jun 11, 2008 9:28 AM
‎2008 Jun 11 8:31 AM
Hi,
Use like this.
tables z1ychlog.
loop at it_z1log.
if it_z1log-APPROVELNO is not initial.
*do nothing
else.
clear z1ychlog.
move it_z1log to z1ychlog.
delete z1ychlog.
endif.
endloop.
\[removed by moderator\]
Edited by: Ravi Kumar on Jun 11, 2008 9:42 AM
Edited by: Jan Stallkamp on Jun 11, 2008 10:35 AM
‎2008 Jun 11 8:32 AM
Hi ,
You will need to use the syntax as below.
DELETE { {FROM target [WHERE sql_cond]}
| {target FROM source} }.
Ex:
SELECT carrid connid fldate
FROM sflight
INTO CORRESPONDING FIELDS OF TABLE sflight_key_tab
WHERE carrid = p_carrid AND
fldate = sy-datum AND
seatsocc = 0.
DELETE sflight FROM TABLE sflight_key_tab.
Also it would be better if you call an explicit COMMIT WORK for the database operation to take place.
\[removed by moderator\]
Regards.
Edited by: Jan Stallkamp on Jun 11, 2008 10:35 AM
‎2008 Jun 11 8:32 AM
DELETE z1ychlog
WHERE VBELN in s_vbeln
AND vstel = p_vstel
AND WERKS = P_werks
AND APPROVELNO EQ SPACE.
IF SY-SUBRC EQ 0.
COMMIT WORK.
ENDIF.
‎2008 Jun 11 8:33 AM
‎2008 Jun 11 8:34 AM
Hi,
you are deleting wrong table.
Select * from z1ychlog into table it_z1log
where VBELN in s_vbeln
AND vstel = p_vstel
AND WERKS = P_werks.
loop at it_z1log.
if it_z1log-APPROVELNO is not initial.
*do nothing
else.
*delete z1ychlog. "You are dng
delete it_z1log. " do this
endif.
endloop.
\[removed by moderator\]
regards,
Dhan.
Edited by: Jan Stallkamp on Jun 11, 2008 10:36 AM
‎2008 Jun 11 8:40 AM
Hi kumar,
Select * from z1ychlog into table it_z1log
where VBELN in s_vbeln
AND vstel = p_vstel
AND WERKS = P_werks.
loop at it_z1log.
if it_z1log-APPROVELNO is not initial.
delete it_z1log where APPROVELNO = space
or
delete it_z1log where APPROVELNO = 0
try this , may this will work
Regards
Thushara
‎2008 Jun 11 8:49 AM
Hi
I want to delete the records from Ztable. Not internal table
‎2008 Jun 11 9:01 AM
Hi
u should try to use statement
Delete target from source
where target is name of your table
and source is the itab.
Statement will delete the the
records from dbtab matching the selection criteria
in itab
OR
use tables statement
Tables:Ztable
Select * from Ztable where....
Delete Ztable
Here data is getting populated into itab with same name as Ztable and respective records are deleted
Surbhi
‎2008 Jun 11 9:27 AM
Hi
i changed my coding. but still delete statement is not working. Anyone pls help me?
Select * from z1ychlog into table it_z1log
where VBELN in s_vbeln
AND vstel = p_vstel
AND WERKS = P_werks
AND APPROVELNO = space.
if sy-subrc = 0.
delete z1ychlog from it_z1log.
else.
endif.
‎2008 Jun 11 9:31 AM
hii
use DELETE table-name WHERE condition.
it will delete your records as per your condition.
\[removed by moderator\]
twinkal
Edited by: Jan Stallkamp on Jun 11, 2008 10:36 AM