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

Select Staement

Former Member
0 Likes
343

Hi Experts,

In table PA0002 we are having active and future records. Can any body tell me how to fetch active and future records.

urgent.........

2 REPLIES 2
Read only

Former Member
0 Likes
325

Hi,

Use like this:

SELECT *

FROM PA0002

INTO TABLE t_pa0002

WHERE BEGDA LE sy-datum

AND ENDDA GE sy-datum.

Thanks and Best Regards,

Vikas Bittera.

Read only

Former Member
0 Likes
325

Which records you select will be determined by the dates you use for getting the information. If you use the GET PERNR statement in your program (logical database programming), you can use this to get the latest available record:

rp-provide-from-last p0002 space w_begda w_endda.

Use sy-datum for w_begda and '99991231' for w_endda if you want to get the last record available (including a future record). Use sy-datum for both w_begda and w_endda if you want to get the record that is valid as of today.

If you want to do a direct table select, use this to get all records valid from today going forward:

SELECT * FROM PA0002 INTO wa_0002

WHERE begda >= sy-datum AND endda >= sy-datum.

    • put code here for manipulating the records

ENDSELECT.

Or to just get the last record, whether it is from today or the future, use this:

SELECT SINGLE * FROM PA0002 INTO wa_0002 WHERE endda = '99991231'.

I hope this helps.

- April King