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

Help need in select statement?

Former Member
0 Likes
869

Hi experts...

I have an internal table with 2 records...i_mara with fields matnr and ersda

matnr ersda

2345 01/26/2007

3445 02/05/2007

i need to write a select statement to collect all MBLNR from MKPF table where BUDAT is in between 01/26/2007 and 02/05/2007..

Thanx

Giri

1 ACCEPTED SOLUTION
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
842
ranges: r_datum for sy-datum.
Data: imkpf type table of mkpf.

r_datum-sign = 'I'.
r_datum-option = 'BT'.

read table i_mara index 1.
r_datum-low = i_mara-ersda.

read table i_mara index 2.
r_datum-high = i_mara-ersda.

append r_datum.



select * into table imkpf from mkpf
               where BUDAT in R_DATUM.

You could try using a RANGE.

Regards,

Rich Heilman

8 REPLIES 8
Read only

Former Member
0 Likes
842

DATA: BEGIN OF IT_MBLNR OCCURS 0,

MBLNR LIKE MKPF-MBLNR,

BUDAT LIKE MKPF-BUDAT,

END OF IT_MBLNR.

IF NOT I_MARA[] IS INITIAL.

SELECT MBLNR BUDAT

INTO TABLE IT_MBLNR

FROM MKPF

FOR ALL ENTRIES IN I_MARA

WHERE BUDAT GE I_MARA-ERSDA AND BUDAT LE I_MARA-ERSDA.

ENDIF.

Thanks,

Santosh

Read only

Former Member
0 Likes
842

Hello,

Built a range table like this.

DATA: RA_BUDAT RANGE OF BUDAT WITH HEADER LINE.

Read table i_mara index 1.

RA_BUDAT-SIGN = 'I'.

RA_BUDAT-OPTION = 'BT'.

RA_BUDAT-LOW = i_mara-ersda.

Read table i_mara index 2.

RA_BUDAT-HIGH = i_mara-ersda.

APPEND RA_BUDAT.

SELCT MBLNR FROM MKPF INTO ITAB WHERE<b> BUDAT IN RA_BUDAT.</b>

Vasanth

Read only

0 Likes
842

Hello,

May I know the difference between my answer and Mr. Rich's answer.

Thanks

Vasanth

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
843
ranges: r_datum for sy-datum.
Data: imkpf type table of mkpf.

r_datum-sign = 'I'.
r_datum-option = 'BT'.

read table i_mara index 1.
r_datum-low = i_mara-ersda.

read table i_mara index 2.
r_datum-high = i_mara-ersda.

append r_datum.



select * into table imkpf from mkpf
               where BUDAT in R_DATUM.

You could try using a RANGE.

Regards,

Rich Heilman

Read only

0 Likes
842

HI vasanth and rich...

thanks for replies...

vasanth i am getting error with the statement.. so i assigned 6 points to u..

DATA: RA_BUDAT RANGE OF BUDAT WITH HEADER LINE.

Unable to interpret range.... Possible error with spelling or comma

Rich: ur solution worked good....

is there any possible simplest way... or this is the best way includes performance?

Regards

Giri

Read only

0 Likes
842

Vasanth's answer would have worked for you, but the TYPE keyword is missing in the DATA statement.

DATA: RA_BUDAT <b>TYPE</b> RANGE OF BUDAT WITH HEADER LINE.

Regards.

Rich Heilman

Read only

0 Likes
842

<i>is there any possible simplest way... or this is the best way includes performance?</i>

Well, there are always 3 different ways to accomplish the same thing in ABAP. Some good, some bad, some it doesn't really matter. I like to use RANGES when working with multple values for a field in a SELECT statement, I think it is easier to understand and hence, the next developer can easily modify. Also, it is a matter of personal preferenece.

Regards,

Rich Heilman

Read only

0 Likes
842

Thanks Rich & Vasanth.

I will appreciate your time and effort.

Regards

Giri