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

Need help with a select statement..?

Former Member
0 Likes
1,785

Gurus,

I have written a select statement that select records from the BKPF table..It gets the FI GL documents that are parked..

select BUKRS BELNR GJAHR from BKPF into TABLE i_vbkpf where BLART = 'SY'
                                                              AND CPUDT eq p_cpudt
                                                              AND PPNAM is not null.

But if i debug and see i_vbkpf internal table it also has documents that were just posted in the system...is using

PPNAM is not Null"

valid....

Please suggest.....

Thanks

Sam

18 REPLIES 18
Read only

Former Member
0 Likes
1,761

What is your question? Sorry, i did not understand from your comments. Can you please tell in detail?

Read only

0 Likes
1,761

I have to write a select statement that picks up company code document number fiscal year from BKPF for FI documents that were parked...I have written this select but this select statement also picks up documents that were posted...What changes shud i make in the where co ndition to solve this issue....

Thanks

Sam

Read only

ferry_lianto
Active Contributor
0 Likes
1,761

Hi,

Please try this.


select BUKRS BELNR GJAHR 
from BKPF 
into TABLE i_vbkpf 
where BLART = 'SY'
   and CPUDT eq p_cpudt
   and PPNAM ne space.

Regards,

Ferry Lianto

Read only

0 Likes
1,761

Ferry,

When i executed this it just picked up one parked document but i had parked 2 documents on that date...is there any other change that i have to do....It did not picked up posted documents which is what i wanted...but why is it not picking up all the parked documents of that date...?

Thanks

Sam

Read only

0 Likes
1,761

Hi Sam,

Just go to SE16 and see the table data. Are you able to see the two entries with the same selection.

Regards,

Atish

Read only

0 Likes
1,761

You were right Atish...The PPNAM field doesnt get poulated for parked documents....it gets populated only for documents those were parked first and then posted...how shud i change the selection criteria to include these documents also....

The scenario is i have to write a select statement that picks up parked documents from the database...The Document type (BLART) field will be 'SY' and CPUDT will be the date entered on...what else can be the condition so that it picks up all the parked documents...I cannot use STATUS field because then we will not get documenst that were parked forst and then posted as for the posted documents the ststus changes...

I know its confusing but u guys can only help....Please suggest...

Thanks

Sam

Read only

0 Likes
1,761

Hi Sam,

try with PPNAM = space.

Regards,

Atish

Read only

0 Likes
1,761

u can use the below select query to select the parked document from BKPF table.

there is an field STAT in BKPF check the table field entries for parked documents.

select BUKRS BELNR GJAHR from BKPF into TABLE i_vbkpf where BLART = 'SY'

AND CPUDT eq p_cpudt

AND PPNAM is not null

AND BSTAT EQ 'V'.

please rewad points if its helpfull

thanks

Sukumar

Read only

0 Likes
1,761

No buddy it doesnt work....it picked up the posted doc and the parked doc but no the one that was parked first and then posted.....I just want to have docs that were parked at some stage and out of those parked ones some were posted also...right...

Thanks

Sam

Read only

0 Likes
1,761

Sam,

you are saying there are 2 documents.

Can you check if for these 2 documents Document type is "SY", date is same as that of used in SELECT and PPNAM is not equal to space.

Can you confirm this again?

ashish

Read only

0 Likes
1,761

Suku thanks for the reply...but please read my previous post...u will understand what i am saying....

Thanks

Sam

Read only

0 Likes
1,761

I will explain again ashish...There are 3 documents...for all three documents BLART = SY and CPUDT is same....

doc 1: Parked

doc 2: Posted

doc 3: parked and then posted.

Now i have to get docs that were parked at some stage...so i shud get doc 1 and doc 3...

but i just get doc 3 for the current select statement with PPNAM <> space...

am I able to explain now...

Thanks

Sam

Read only

0 Likes
1,761

hi sam

for this u can use the BSTAT = 'V'. in select query .

regards

sukumar

Read only

0 Likes
1,761

Hi Sam,

I think by using BSTAT as V or W or Z you will get all the parked documents. No need to give BLART.

Regards,

Atish

Read only

0 Likes
1,761

Atish, please understand for document that is parked the status is V fro docs that are posted status is space...

so

doc 1: Parked BSTAT = V

doc 2: Posted BSTAT = space

doc 3: parked and then posted. BSTAT = space

But i want to retrive documents 1 and 3..as they were or are in parked status at some point of time....

Can we do it....i am sure i am explaining everything in detail....

Thanks

Sam

Read only

0 Likes
1,761

Hi Sam,

Why don't you write two different queries on BKPF

1 to get parked documents

2 to get parked and posted documents

and then combine the result or just use the APPENDING option in second query so no need to use two internal tables.

Regards,

Atish

Read only

Former Member
0 Likes
1,761

Hi Sam,

Try with PPNAM <> space.

Regards,

Atish

Read only

ferry_lianto
Active Contributor
0 Likes
1,761

Hi Sam,

Please try this and see whether pick up both documents.


select BUKRS BELNR GJAHR 
from BKPF 
into TABLE i_vbkpf 
where BLART = 'SY'
   and CPUDT eq p_cpudt.
   

Regards,

Ferry Lianto