‎2008 May 07 7:24 AM
Hi Experts,
I need to select data from one table such that the date field of the table should be either today's date or earlier date.
How can I write such comparison statement in select query.
‎2008 May 07 7:27 AM
Try with a query similar as below:
SELECT <fld1> <fld2> ...
INTO TABLE <itab>
FROM <TAB>
WHERE <date> <= sy-datum
....
‎2008 May 07 7:27 AM
Try with a query similar as below:
SELECT <fld1> <fld2> ...
INTO TABLE <itab>
FROM <TAB>
WHERE <date> <= sy-datum
....
‎2008 May 07 7:45 AM
Thanks a lot Eswar . it's working.. Can u tell me how i can write "" for all entries in <itab>""" in the same. I
Edited by: Shridhar Patil on May 7, 2008 8:46 AM
‎2008 May 07 7:49 AM
Something like below???
SELECT <fld1> <fld2> ...
INTO TABLE <itab>
FROM <TAB>
FOR ALL ENTRIES OF <itab1>
WHERE <fld1> = <itab1>-fld1
AND <date> <= sy-datum
....
‎2008 May 07 7:49 AM
Hi Sridhar,
"For all entries" key word is used to interact with the more than one internal table.
Example program:
My requirement is to get the sales order numbers from given range of dates. For each sales order number
i need to get the available item numbers.
Program:
select-options: s_date for sy-datum.
Data: it_vbak type table of vbak with header line.(sales order header data),
it_vbap type table of vbap with header line.(sales order item infomration).
getting the sales order header data with in given range of dates
select * from vbak
into table it_vbak
where erdat in s_date.
getting the item data for each record in it_vbak using the "for all entries"
If not it_vbak[] is initial.
Select * from vbap
into table it_vbap
for all entries in it_vbak
where vbeln = it_vbak-vbeln.
endif.
when using for all entries we need to remember some condiitons:
1) We must check if the first internal table is empty or not. If we are we are not checking this
conditons: "If not it_vbak[] is initial".If first internal table is empty it extract all the data from the
database. It is very dangerous.
2) U make sure to poulate all the key fields in first internal table.
If it is helpful rewards points
Regards.
Eshwar.
‎2008 May 07 8:39 AM
‎2008 May 07 7:28 AM
select * from ur_table into i_table
where date_frm_table LE sy-datumI hope it helps.
Let me know if any doubts.
Best Regards,
Vibha
Please mark all the helpful answers
‎2008 May 07 7:28 AM
Hi,
today_date = sy-datum.
yesterday-date = sy-datum - 1.
select * from table
into table i_tab
where date = today_date
or date = yesterday_date.
Regards,
Shiva