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

Problem in Select Query

Former Member
0 Likes
721

Hi,

I am getting header details from table BKPF. and then i am getting item details from BSEG table based on the document no and fiscal year.

SELECT BELNR BSCHL HKONT BUKRS WRBTR

SGTXT FROM BSEG INTO TABLE I_BSEG

FOR ALL ENTRIES IN I_BKPF WHERE

BELNR EQ I_BKPF-BELNR AND

GJAHR EQ P_GJAHR.

this query is working fine for all document but in some document no while checking in table it have 10 items but while running this program its having only 7 items i am wondering about this thing please give some idea to fix this issue.

Thanks in Advance

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
690

Hi,

It looks like other documents are having different fiscal year you check the Fiscal year in Bseg.

donu2019t use bseg table in our query because Its Custer table.

Reagrds

6 REPLIES 6
Read only

Pawan_Kesari
Active Contributor
0 Likes
690

>

>

> SELECT BELNR BSCHL HKONT BUKRS WRBTR

> SGTXT FROM BSEG INTO TABLE I_BSEG

> FOR ALL ENTRIES IN I_BKPF WHERE

> BELNR EQ I_BKPF-BELNR AND

> GJAHR EQ P_GJAHR.

>

You should include all key fields in query, in this particular case include fields

BUKRS

BELNR

GJAHR

BUZEI.

Edited by: Pawan Kesari on Aug 5, 2009 6:49 PM

Read only

Former Member
0 Likes
690

HI,

FOR ALL ENTRIES will remove duplicate records.

So just fetch the entire key fields from BSEG into your internal table.

Regards,

Ankur Parab

Read only

Former Member
0 Likes
690

Hi Hema,

While using FOR ALL ENTRIES statement if the values are same in the all fields it will delete the duplicate records from the database table itself.

Inorder to avoid this problem you have to add some unique fileds for example in BSEG table BUZEI field is act like a index field so

while selecting data from BSEG table add this field then it can select all the 10 records from the database table..

and also before getting data from the item table check the header table have data...

if i_bkpf[] is not initial.

Regards,

John Victor

Read only

0 Likes
690

Thanks John & all for your quick reply now its working fine thanks for your timely help.

Read only

Former Member
0 Likes
691

Hi,

It looks like other documents are having different fiscal year you check the Fiscal year in Bseg.

donu2019t use bseg table in our query because Its Custer table.

Reagrds

Read only

Former Member
0 Likes
690

Hi,

try to use all primary keys fields while fetching from BSEG table..BUKRS,BELNR,GJAHR,BUZEI.

Because while you are using for all entries it will remove duplicates and actuals also, so for all entries will fail

Prabhudas