‎2007 Feb 09 3:44 PM
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
‎2007 Feb 09 3:50 PM
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
‎2007 Feb 09 3:49 PM
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
‎2007 Feb 09 3:49 PM
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
‎2007 Feb 09 4:12 PM
Hello,
May I know the difference between my answer and Mr. Rich's answer.
Thanks
Vasanth
‎2007 Feb 09 3:50 PM
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
‎2007 Feb 09 4:12 PM
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
‎2007 Feb 09 4:19 PM
‎2007 Feb 09 4:21 PM
<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
‎2007 Feb 09 4:22 PM
Thanks Rich & Vasanth.
I will appreciate your time and effort.
Regards
Giri