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 data from BKPF for a date range

Former Member
0 Likes
4,501

Hi,

I want to select data from BKPF depending upon the date range given in the selection screen.

SELECTION-SCREEN : BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.

" Selection Criteria

SELECT-OPTIONS : S_DATE FOR SY-DATUM OBLIGATORY.

SELECTION-SCREEN : END OF BLOCK B1.

How do I do that??.. Please help.

Thank You,

SB.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,762

HI SB,

Create Indexes and select the data ...

i.e,

SELECTION-SCREEN : BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.

" Selection Criteria

<b>SELECT-OPTIONS : S_DATE FOR BKPF-BLDAT OBLIGATORY.</b>

SELECTION-SCREEN : END OF BLOCK B1.

<b> SELECT * FROM BKPF WHERE BLDAT IN s_date.</b>

Regards,

Santosh P

Message was edited by: Santosh Kumar Patha

11 REPLIES 11
Read only

Former Member
0 Likes
1,762
TABLES: BKPF.
DATA itab LIKE TABLE OF bkpf WITH HEADER LINE.
SELECTION-SCREEN : BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
" Selection Criteria
SELECT-OPTIONS : S_DATE FOR <b>BKPF-BLDAT</b> OBLIGATORY.
SELECTION-SCREEN : END OF BLOCK B1.

<b>SELECT *
 FROM BKPF
 INTO TABLE itab
 WHERE BLDAT IN s_date.</b>
Read only

Former Member
0 Likes
1,763

HI SB,

Create Indexes and select the data ...

i.e,

SELECTION-SCREEN : BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.

" Selection Criteria

<b>SELECT-OPTIONS : S_DATE FOR BKPF-BLDAT OBLIGATORY.</b>

SELECTION-SCREEN : END OF BLOCK B1.

<b> SELECT * FROM BKPF WHERE BLDAT IN s_date.</b>

Regards,

Santosh P

Message was edited by: Santosh Kumar Patha

Read only

0 Likes
1,762

Hi SB,

Santhosh is right.. An INDEX will be very useful if you are not using the key fields BUKRS,BELNR & GJAHR in the WHERE clause and just want to SELECT by BLDAT (Document date) or BUDAT (Posting Date).

Regards,

Suresh Datti

Read only

0 Likes
1,762

Hi,

But will this selection select all the dates in the "from" date "to" date & between date ranges also ??

Thank You,

SB.

Read only

0 Likes
1,762

YES

Suresh

Read only

0 Likes
1,762

Yes,

In the selection screen enter the date from and to in the field.

It will retrieve all the results.

Read only

0 Likes
1,762

Thank You Santosh

Read only

Former Member
0 Likes
1,762

hi SB,

data : itab like table of bkpf with header line.
  tables :bkpf.
 SELECTION-SCREEN : BEGIN OF BLOCK B1 WITH FRAME TITLE  TEXT-001.
" Selection Criteria
SELECT-OPTIONS : S_DATE FOR bkpf-bldat OBLIGATORY.
SELECTION-SCREEN : END OF BLOCK B1.
 
 select * from bkbf 
  into table itab 
  where bldat in s_date.

regards

satesh

Read only

Former Member
0 Likes
1,762

hi Sb,

yes..it will select ..

if you want to select only either one of them ..

use

select * from bkpf into table itab where bldat eq s_date-low.

simliarly s_date-high.

regards

satesh

Read only

Former Member
0 Likes
1,762

Hi,

Declare internal table of BKPF.

In select statement compare the date in select-option with BUDAT .

select * from BKPF into where budat in S_date.

I think this will help u out....

Thanks,

Sreevani

Read only

Former Member
0 Likes
1,762

There's no need to create an index. There already is one on budat. If you construct your select properly, you'll be able to use it.

Rob