01-15-2007 9:01 PM
How do I select a range of values? For instance, I need to write a select statement that, among others, selects documents based on a date range. What I am doing is trying to pick billing documents that have a billing date within the last 365 days. Also I need to figure out a way (an easy way) to determine if a particular day is a weekend.
Regards,
Aaron
01-15-2007 9:25 PM
Ok, thanks to all for the wonderful help! I have one quick addition to this question before I mark it answered. Right now, as it stands, I have (theoretically) a list of document numbers (with their data) that is in a date range (the last 365). I then want to restrict the material numbers to certain material groups. Each time this report is run the material groups will change and it could be one to all material groups. How would I do a "range" in this instance?
Thanks,
Aaron
01-15-2007 9:04 PM
01-15-2007 9:10 PM
Hello Rich,
First off, thanks for the quick reply. After I set up the range, as you outlined, can I add other requirements on the select statement like normal? I assume I can. One more thing (its related). I am doing a select off the table VBRP_VRPMA but that is a joined table. Can I treat this table like any other table? I am attempting to determine the 5 largest, consecutive, shipping days per Mat#. Do you know of a better way to do this besides going through every billing document one at a time? Sorry for all of the questions.
01-15-2007 9:14 PM
> can I add other
> requirements on the select statement like normal? I
> assume I can.
Yes you can
> doing a select off the table VBRP_VRPMA but that is a
> joined table. Can I treat this table like any other
> table?
Yes u can.
Aaron, by 5 largest and consecutive shipping days what do you exactly mean? Can you illustrate your requirement with sample data?
01-15-2007 9:04 PM
Aaron
data: YearAgo like sy-datum.
YearAgo = sy-datum - 365.
select * from SomeTable into i_table
where BillDate >= YearAgo
and BillDate <= sy-datum.
01-15-2007 9:07 PM
01-15-2007 9:09 PM
RANGES: s_date FOR ekko-aedat.
DATA: lv_day TYPE scal-indicator.
s_date-high = sy-datum.
s_date-low = sy-datum - 365.
s_date-option = 'BT'.
s_date-sign = 'I'.
APPEND s_date.
DATA: t_ekko TYPE STANDARD TABLE OF ekko.
SELECT * FROM ekko
INTO TABLE t_ekko
WHERE aedat IN s_date.
CALL FUNCTION 'DATE_COMPUTE_DAY'
EXPORTING
date = sy-datum
IMPORTING
day = lv_day.
IF sy-subrc = 0.
ENDIF.
LV_DAY = '6' for saturday and '7' for sunday.
01-15-2007 9:25 PM
Ok, thanks to all for the wonderful help! I have one quick addition to this question before I mark it answered. Right now, as it stands, I have (theoretically) a list of document numbers (with their data) that is in a date range (the last 365). I then want to restrict the material numbers to certain material groups. Each time this report is run the material groups will change and it could be one to all material groups. How would I do a "range" in this instance?
Thanks,
Aaron
01-15-2007 9:27 PM
I am not sure i follow your question. You can provide material range as part of the selection screen and then include it in your selection statement..
01-15-2007 9:30 PM
If the material groups are going to change, I would suggest using a SELECT-OPTION in the selection screen instead of the RANGE. There is no difference between the two other than the SO, will produce fields on the selection-screen. So you can put the values in the selection screen as single entries and save this as a screen variant. Then when the material groups change, you can simply change the variant without having to change the program coding.
Regards,
Rich HEilman
01-15-2007 9:33 PM
Thanks Rich. When I use the SO is each field on the Selection Screen a different variable? What I'm getting at is how would I put them in a select statement?
01-15-2007 9:37 PM
Say that you want to select data based on one or more material groups. You would set up the SELECT-OPTION, then on the screen, add the material groups that you want. Then you just use the IN operator like you did for the RANGE.
tables: mara.
Select-options: s_matkl for mara-matkl.
select * into table it023
from t023
where matkl in s_matkl.
Regards,
Rich Heilman
01-15-2007 9:39 PM
you would define a select option (assuming u are selecting from material master)
select-optionS s_matkl for mara-matkl.
SELECT * from MARA
where matkl in S_MATKL.
When u define a select option, you can enter multiple values by clicking on the button at the end of your input box.
01-15-2007 9:41 PM
Rich, thank you SO MUCH for your help! I appreciate the help everybody gave me!
Thanks again,
Aaron