‎2009 Sep 16 1:23 PM
Hi All,
I want to write a query on SOOD table like:
SELECT OBJTP OBJYR OBJNO OBJDES OWNNAM FROM SOOD INTO TABLE IT_SOOD
WHERE OBJDES LIKE 'String%' AND
( SDDAT BETWEEN LV_LASTRUN AND SY-DATUM ) AND
( SDTIM BETWEEN LV_LASTTIM AND SY-UZEIT ).
but this is not returning me data between the last run date/ last run time and current date/ time.
Can anybody suggest how to modify the above query in order to fetch correct data.
Thanks in Advance !!
Vivek
‎2009 Sep 16 1:45 PM
Hi Vivek Kulkarni,
Using Range is better option..
Also please check how you declared the fileds as mentioned below or not..
LV_LASTRUN type sy-datum.
LV_LASTTIM type SY-UZEIT.Better to write code for Range and populate it and then pass it in select where condition using IN.
Searcg SCN for more help on how to use RANGE
Hope it will solve your problem..
Thanks & Regards
ilesh 24x7
ilesh Nandaniya
‎2009 Sep 16 1:28 PM
Hi,
Try this
SELECT OBJTP OBJYR OBJNO OBJDES OWNNAM FROM SOOD INTO TABLE IT_SOOD
WHERE OBJDES LIKE 'String%' AND
( SDDAT BETWEEN LV_LASTRUN AND SY-DATUM ) *OR*
( SDTIM BETWEEN LV_LASTTIM AND SY-UZEIT ).Regards,
Nandha
‎2009 Sep 16 1:30 PM
You can pass the last run date , Current date into a range and last run time , current time into another range
and pass this in the where conditions ...
SELECT OBJTP OBJYR OBJNO OBJDES OWNNAM FROM SOOD INTO TABLE IT_SOOD
WHERE OBJDES LIKE 'String%' AND
SDDAT in r_sddat AND
SDTIM in r_UZEIT.
or ... U can write the coding as ...
SELECT OBJTP OBJYR OBJNO OBJDES OWNNAM FROM SOOD INTO TABLE IT_SOOD
WHERE OBJDES LIKE 'String%' AND
SDDAT >= LV_LASTRUN AND
SDDAT <= SY-DATUM AND
SDTIM >= LV_LASTTIM AND
SDTIM <= SY-UZEIT .
‎2009 Sep 16 1:45 PM
Hi Vivek Kulkarni,
Using Range is better option..
Also please check how you declared the fileds as mentioned below or not..
LV_LASTRUN type sy-datum.
LV_LASTTIM type SY-UZEIT.Better to write code for Range and populate it and then pass it in select where condition using IN.
Searcg SCN for more help on how to use RANGE
Hope it will solve your problem..
Thanks & Regards
ilesh 24x7
ilesh Nandaniya
‎2009 Sep 16 1:50 PM
are you sure that, the value 'String%' is of this pattern? i mean the S being upper case and others being in lower case?
because the domain for this field is LOWER CASE ticked, it stores the exact pattern
and you can also try creating a range for the date and time.
data: lv_datum type range of sy-datum,
lv_uzeit type srange of sy-uzeit.
‎2009 Sep 16 2:04 PM
Hi All,
Thanks for replies.
problem solved using the comparison operators.
Thanks a Lot !!
‎2009 Sep 16 2:07 PM
Hi,
Can you post the final select query you used so that it will be helpful for others who face similar problem?
Regards,
Vikranth
‎2009 Sep 16 2:02 PM
Hi,
Try this
SELECT OBJTP OBJYR OBJNO OBJDES OWNNAM FROM SOOD INTO TABLE IT_SOOD
WHERE OBJDES LIKE 'String%' AND
( SDDAT >= LV_LASTRUN AND SDTIM >= LV_LASTTIM )
AND
( SDDAT <= SY-DATUM AND SDTIM <= SY-UZEIT ).
Hope this helps.
BR,
Advait
‎2009 Sep 16 2:04 PM
>
> Hi All,
>
> I want to write a query on SOOD table like:
>
> SELECT OBJTP OBJYR OBJNO OBJDES OWNNAM FROM SOOD INTO TABLE IT_SOOD
> WHERE OBJDES LIKE 'String%' AND
> ( SDDAT BETWEEN LV_LASTRUN AND SY-DATUM ) AND
> ( SDTIM BETWEEN LV_LASTTIM AND SY-UZEIT ).
>
> but this is not returning me data between the last run date/ last run time and current date/ time.
>
> Can anybody suggest how to modify the above query in order to fetch correct data.
>
> Thanks in Advance !!
> Vivek
If the last run date was 01.09.2009 and the last run time was 11:00, this code will pick up data for all dates from 01.09.2009 but only if the time value is > 11:00; so if there was a run at 09:00 on 03.09.2009 you won't pick up that record - and I'm assuming that you would want to pick up that record.
I think you should only be applying the time check to records where the date = LV_LASTRUN and for later records you should just be checking the date. Something like:
WHERE ( ( sddat = lv_lastrun
AND sdtim > lv_lasttim )
OR ( sddat > lv_lastrun )
)
‎2009 Sep 16 2:13 PM
‎2009 Sep 17 1:31 PM
Hi All,
I have revised the query using comparison operators as follows:
SELECT OBJTP OBJYR OBJNO OBJDES OWNNAM FROM SOOD INTO TABLE IT_SOOD
WHERE SDTIM >= LV_LASTTIM and SDDAT >= LV_LASTRUN and
OBJDES LIKE 'XXXXXX Purchasing Document%'.
So, now it is giving me desired output as: Selecting OBJTP OBJYR OBJNO OBJDES OWNNAM from SOOD table into internal table IT_SOOD where the time is greater than or equal to last run time and the date is greater than or equal to last run date and the string (OBJDES) like 'XXXXXX Purchasing Document%'.
Thanks for you support !!
Vivek