2006 Sep 21 5:11 AM
I have data for:
month1 = m1
year1 = y1
month2 = m2
year2 = y2.
Now I want to go to bkpf and give the data for bukrs, belnr, gjahr (from y1 to y2), monat (from m1 to m2) and get all the corresponding entries.
For example: If month1 = 3, year1 = 2003
month2 = 5, year2 = 2005, I want to get all the entries as explained above for:
(3,2003) to (12,2003)
(1,2004) to (12,2004)
(1,2005) to (12,2005)
(and not just for months 3 to 5 for years 2003 to 2005 as normally many abappers will do)
Can you give me a sample code here with out affecting performance please?
Thanks,
Krishen
P.S.Shall definitely award points for helpful answers and thanks in advance for your input.
2006 Sep 21 5:25 AM
Hi Krishnen,
In BKPF table... u have a field called BUDAT (Posting date) / BLDAT (Document date) ....
Check whether on what criteria u r going to fetch data from the database ... either by Posting date / document date ???
Say for ex.. u need to fetch records based on document date BLDAT ..
BLDAT is a date field.... of the form YYYYMMDD ...
so u can query like this ....
SELECT BUKRS BELNR GJAHR FROM BKPF
INTO TABLE ITAB_BKPF
WHERE ( ( BLDAT >= '20030301' AND
BLDAT <= '20051231' ) .
the above query will help in fetching up of all the records which falls bet march 2003 to december 2005 ....
Hope it helps u
Cheers
Kripa Rangachari ...................................
Krishnen,
yes .... Posting period is nothing but the month of posting ... which will definitely fall in an year
Just check with ur consultants whether they are in need of a report based on Posting date / document date ... and query ur database based on that ......
Cheers
Kripa Rangachari .............
2006 Sep 21 5:25 AM
Hi Krishnen,
In BKPF table... u have a field called BUDAT (Posting date) / BLDAT (Document date) ....
Check whether on what criteria u r going to fetch data from the database ... either by Posting date / document date ???
Say for ex.. u need to fetch records based on document date BLDAT ..
BLDAT is a date field.... of the form YYYYMMDD ...
so u can query like this ....
SELECT BUKRS BELNR GJAHR FROM BKPF
INTO TABLE ITAB_BKPF
WHERE ( ( BLDAT >= '20030301' AND
BLDAT <= '20051231' ) .
the above query will help in fetching up of all the records which falls bet march 2003 to december 2005 ....
Hope it helps u
Cheers
Kripa Rangachari ...................................
2006 Sep 21 5:32 AM
Hi,
Try like this:
N = ( year2 - year1 ) + 1
M1 = month 1.
M2 = Month2.
Y = year1.
IF N GT 1.
Do N times.
case sy-tabix.
when 1.
select .... from bkpf
into table IT_BKPF
Where gjahr = Y
and monat GE M1
and monat LE 12.
when N.
select .... from bkpf
Appending table IT_BKPF
Where gjahr = Y
and monat GE 1
and monat LE M2.
when others.
select .... from bkpf
Appending table IT_BKPF
Where gjahr = Y
and monat GE 1
and monat LE 12.
endcase.
add 1 to Y.
enddo.
ENDIF.
Hope it help you,
Regards
2006 Sep 21 5:35 AM
Thank you Kripa and Jatra.
Kripa, I have a question for you. Is posting date (BUDAT) always lies in posting period (MONAT) ?
Please clarify this. Your solution seems to be helpful.
Thanks,
Krishen
2006 Sep 21 5:40 AM
Krishnen,
yes .... Posting period is nothing but the month of posting ... which will definitely fall in an year
Just check with ur consultants whether they are in need of a report based on Posting date / document date ... and query ur database based on that ......
Cheers
Kripa Rangachari .............
2006 Sep 21 5:41 AM
Hi kris ,
make use of MM_ARRANG_SPMON_RANGE.
as per ur requirement u have to get o/p month wise , in that case :
first u have to get the data from given period ( user input ) after that u have to manipulate with the data to get in month wise.
1. select * from BKPF into corresponding field of i_bkpf
where bukrs in s_bukrs
and budat in s_budat.
2. After that Divied ur output month wise by using the that FM
Regards
Prabhu
| User | Count |
|---|---|
| 6 | |
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |