‎2009 Feb 09 1:28 PM
HI,
iam facing a proble with the delete statement.
iam getting sy-subrc value = 4.
code
LOOP AT t_tab INTO w_tab.
IF w_tab-check = 'X' AND
w_tab-flag = 'X'.
DELETE t_tab . " deleting the value in the internal table
move-corresponding w_tab to ztest_tab.
delete ztest_tab.
ENDIF.
ENDLOOP.
ztest_tab is the database table name.
can any one help me.
regards
priyanka
‎2009 Feb 09 1:50 PM
Hi Priyanka,
Do like this
LOOP AT t_tab INTO w_tab.
IF w_tab-check = 'X' AND
w_tab-flag = 'X'.
"DELETE t_tab . deleting the value in the internal table Dont use this
move-corresponding w_tab to ztest_tab. " no need for this
delete ztest_tab FORM w_tab.
ENDIF.
ENDLOOP.
DELETE t_tab WHERE check = 'X' and flag = 'X'. "if u need to delete such records
‎2009 Feb 09 1:31 PM
HI,
If u want to delete the same row from database table use
DELETE <dbtable> from <workarea>
‎2009 Feb 09 1:31 PM
iam getting sy-subrc value = 4.
Where ur checking sy-subrc value .
In which statement ur geting that value...
‎2009 Feb 09 1:33 PM
Have you declared "ztest_tab" using the tables declaration? If not try doing that.
TABLES:
ZTEST_TAB.
‎2009 Feb 09 1:33 PM
Hi ,
try use the
delete from <table > where condition.
Regards,
Bharani
‎2009 Feb 09 1:35 PM
Hi
You need to use delete t_tab from w_tab ( or use refresh or FREE statement to delete internal table )
Thanks
Viquar Iqbal
‎2009 Feb 09 1:36 PM
hi,
Can you be more specific about the deletion you are trying to do ?
Moreover
move-corresponding w_tab to ztest_tab.
This statement has no effect on the database.
Thanks
Sharath
‎2009 Feb 09 1:40 PM
i have declared the tables satatement
ie :
tables :
ztest_tab.
after the delete statement is executed the operation is being failed.
ie : iam getting the sy-subrc value = 0.
Regards
Priyanka.
‎2009 Feb 09 1:49 PM
‎2009 Feb 09 1:51 PM
hi,
Declare another internal table of structure similar to the earlier one.
Append the records to this 2nd table which satisfy the IF condition you have mentioned inside the loop.
loop at itab1 into w_itab1.
if------
ie. append ztest_tab to itab2.
endif.-----
endloop.
Use Delete DBTAB from table itab2.
This way you can achieve your required functionality, its working as per requirement
Regards
Sharath
‎2009 Feb 09 1:54 PM
hi,
PS. Never perform any database operations such as select, delete..etc inside loops (DO, loop...etc).
This kind of coding creates a severe performance overhead on your system.
Better assemble records of your choice for deletion into a internal table and delete using the table as a reference
Regards
Sharath
‎2009 Feb 09 1:38 PM
Hi
For Deleteing record from Database specify the where condtion.
DELETE FROM ztest_tab
WHERE field1 = w_tab-field1 AND
field2 = w_tab-field2 .
OR
To delete multiple records.
DELETE ztest_tab FROM TABLE t_tab.
OR
To delete single record.
DELETE ztest_tab FROM w_tab.
Regards,
Raghu
‎2009 Feb 09 1:50 PM
Hi Priyanka,
Do like this
LOOP AT t_tab INTO w_tab.
IF w_tab-check = 'X' AND
w_tab-flag = 'X'.
"DELETE t_tab . deleting the value in the internal table Dont use this
move-corresponding w_tab to ztest_tab. " no need for this
delete ztest_tab FORM w_tab.
ENDIF.
ENDLOOP.
DELETE t_tab WHERE check = 'X' and flag = 'X'. "if u need to delete such records
‎2009 Feb 09 1:50 PM
Hi friend,
Check the data type and length of fields declared in program and
fields in database table(ztest_tab) are same.
Thanks.....