Application Development 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: 

fiscal year/fiscal period

Former Member
0 Kudos

Hi Friends,

I have a case where I need an optimized select statement.

For Last posting FY/period: for each G/L account, Company code combination, determine the MAX (Doc. No) in BSEG, and look up the corresponding document in BKPF table to get the last posting FY/Period.

Please get back to ASAP.

Thanks,

Prakash.

5 REPLIES 5

naimesh_patel
Active Contributor
0 Kudos

Hello,

Use the tables BSAS and BSIS instead of BSEG and BKPF.

Regards,

naimesh

Former Member
0 Kudos

HI,

Try this :

data : v_belnr like belnr-bseg.

Parameters : p_GJAHR like GJAHR-BSEG,

p_BUKRS LIKE BUKRS-BSEG.

Select max(belnr) from bseg into v_belnr groupby saknr

where gjahr = p_gjahr and bukrs = p_bukrs.

check sy-subrc = 0 .

select single gjahr monat from bkpf where belnr = v_belnr.

Reward if helpful.

Regards

Former Member
0 Kudos

Hi,

Also refer TABLE BSIS. You cannot join tables BSEG and BKPF as BSEG is a cluster table.

Regards

andreas_mann3
Active Contributor
0 Kudos

Hi,

the last posting period you get with table <b>GLT0</b>

or fm READ_SKC1A

Message was edited by: Andreas Mann

Former Member
0 Kudos

Attach is the logic please replace it with corresponding field names from the table.

select glacc company fy per docno into table itab

from bseg.

sort glacc company fy descending per descending docno descending.

loop at itab.

ldocno = itab-docno.

at new company.

select fields into table ibkpf

from bkpf

where docno = ldocno.

endat.

endloop.

Regards

anurag