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

extracting date from on internal table

Former Member
0 Likes
1,117

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.

4 REPLIES 4
Read only

Former Member
0 Likes
813

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

Read only

Former Member
0 Likes
813

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

Read only

Former Member
0 Likes
813

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

Read only

Former Member
0 Likes
813

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

....................

...................