2008 Nov 11 8:21 AM
hi all,
i am using 3 tables: T1, T2 and T3
all are having same key field say K1
i am selecting all the records from table T2 whose key fields matches with T1.
now, i have to extract date from table T3 which falls within the range of FROM DATE and TO DATE.
its range of FROM DATE and TO DATE is specified in table T2.
thank you in advance.
hi all,
i am using 3 tables: T1, T2 and T3
all are having same key field say K1
i am selecting all the records from table T2 whose key fields matches with T1.
now, i have to extract date from table T3 which falls within the range of FROM DATE and TO DATE.
its range of FROM DATE and TO DATE is specified in table T2.
thank you in advance.
2008 Nov 11 8:26 AM
Hi Siddhi,
What exactly do u want? Do u want the code for the above logic?
For dates you can do one thing. Write the following condition to get the date between FROM DATE and TO DATE.
where date >= from_date and
date <= to_date.Hope this is helpful.
Regards,
Saba
2008 Nov 11 8:29 AM
Hi Siddhi,
Here is the sample code for you.
Loop at T2.
Read table T1 with key key1 = T2-key1.
if sy-subrc = 0.
Read table T3 with key fromdate = T2-fromdate
todate = T2-todate.
if sy-subrc = 0.
"Append data into the final table.
endif.
endif.
Endloop.
This way you can achieve your solution.
Thanks,
Chdianand
2008 Nov 11 8:36 AM
In such case
Loop on the internal table where data is minimum so that to avoid extra looping in your case I think it will be T3 table, then put a read on T2 and on sy-subrc of T2 read T1 as explained above.
Hope this helps
Regards
Bikas
2008 Nov 11 8:45 AM
data: r_date type range of sy-datum,
wa_date like line of r_date.
...........................................
...........................................
loop at t1.
loop at t2 where ...... "all key fields matched with t1.
wa_date-sign = 'I'. "I = include, E = exclude
wa_date-option = 'BT'. "EQ, BT, NE ....
wa_date-low = t2-fromdate.
wa_date-high = t2-todate
append wa_date to r_date.
loop at t3 where date in r_date. " date is the field in t3
....................
...................
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |