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

SQL query and Delete the data based on condition

Former Member
0 Likes
617

Hi All,

I have one requirement like I need to fetch the data from the table, In that table one filed (XXXXX) domain type is STAMP.

delete the data if the sy-datum ( length 😎 is greater than field XXXXX which has length 14.

Please suggest me how to delete or fetch the data with the same length.

I have used below code..but did not work..

"Concatenate sy-datum '%' into gv_var1.

select *

from DD03l

into itab

where XXXX like gv_var1."

and tried this one as well

1. DELETE itab WHERE XXXXX GT sy-datum.

2. DELETE itab WHERE XXXXX GT gv_var1.

1 ACCEPTED SOLUTION
Read only

shwetha_hs
Product and Topic Expert
Product and Topic Expert
0 Likes
512

Hi,

When dates are in different formats you have to always convert them into one common format and then do the checks. Its better to convert the date in the variable into timestamp(using CONVERT DATE statement-look for abapdocu for its usage) and then compare it with the date on database.

data: gv_var1 TYPE timestamp.

convert date sy-datum into time stamp gv_var1.

select *

from DD03l

into itab

where XXXX like gv_var1.

should work now.

Hope this helps.

Shwetha

2 REPLIES 2
Read only

shwetha_hs
Product and Topic Expert
Product and Topic Expert
0 Likes
513

Hi,

When dates are in different formats you have to always convert them into one common format and then do the checks. Its better to convert the date in the variable into timestamp(using CONVERT DATE statement-look for abapdocu for its usage) and then compare it with the date on database.

data: gv_var1 TYPE timestamp.

convert date sy-datum into time stamp gv_var1.

select *

from DD03l

into itab

where XXXX like gv_var1.

should work now.

Hope this helps.

Shwetha

Read only

Former Member
0 Likes
512

Thanks Shwetha for your reply..Whatever you have given that did not work for me..

However I got the solution.