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

Fetch VBPA data

Former Member
0 Likes
2,662

Hi,

I was unable to fetch contract's header partner function where as my select query returning all partner function of that contract.

for example if 100 CSEs are there in contract I have to fetch CSE for that entire contract where POSNR is '000000'.

pl see my code .

SELECT vbeln

parvw

pernr

FROM vbpa

INTO TABLE it_vbpa

FOR ALL ENTRIES IN it_vbak

WHERE vbeln EQ it_vbak-vbeln

AND posnr EQ '000000'

AND parvw IN r_parvw.

Thanks,

Nag

15 REPLIES 15
Read only

Former Member
0 Likes
2,045

Hi,

try to write the code as below..


SELECT vbeln
parvw
pernr
FROM vbpa
INTO TABLE it_vbpa
FOR ALL ENTRIES IN it_vbak
WHERE vbeln EQ it_vbak-vbeln
AND posnr EQ space
AND parvw IN r_parvw.

Thanks

Arbind

Read only

0 Likes
2,045

Hi Arbind,

It doesn't work too..

Thanks,

Nag

Read only

0 Likes
2,045

Check for conversion exit for PARVW

Read only

0 Likes
2,045

PARVW condition is perfect..it is failing just becuase of the POSNR..

Thanks,

Nag

Read only

0 Likes
2,045

Hi,

Please check what values you are passing to Partner Function Range.

I thnik r_parvw may be the problem, since posnr you already passed as space.

So code is ok,check the ranges value in debug mode and pass it to VBPA table to see whether you are

getting the correct data.

Thanks

Arbind

Read only

0 Likes
2,045

Hi,

I have checked PARVW ranges in debug ..the table is populating fine....something we have to do with this POSNR.

Thanks,

Nag

Read only

0 Likes
2,045

Hi Nagajuna,

See since Posnr data type is Numc so you can pass '000000' or space.

as you found ranges is also ok.

Check that internal table for VBAK is populating correct data because sometimes it happens that if internal table in For entries is empty than no filter may work.

This may be the reason.

Check it once in debug.

Thanks

Arbind

Read only

0 Likes
2,045

Hi,

I agree with the previous post, i tried your code and getting data.

I think you should check that really for the given condn data exist in both VBAK and VBPA tables.

POSNR and PARVW already have conversion exit and i think you are using range/ select-options, so conversion part is being taken care by these statements.

Thanks,

Anmol.

Read only

0 Likes
2,045

Just for testing purpose comment the line and see if data is coming?

*AND parvw IN r_parvw.

If data is coming then loop at r_parvw and use conversion exit for each line.

Similarly comment the posnr line in where condition and then check the data

Read only

0 Likes
2,045

Hi All,

Thanks for ur suggestions, I need only header data but my internal table is populating with all header plus Item data....Ranges are perfect ..Have checked in debug mode It contains 4 records which I want...

But the problem is with posnr ...even if i give SPACE or '000000' then all the records of VBPA are getting fetched...hope u understand it clearly

Thanks

Nag

Read only

0 Likes
2,045

Hi Nagarjuna,

Actually your code is perfect I tried in my system its fetching data.

Do one thing directly goto se11--> Vbpa table ---> in Selection Screen Pass the the vales you are getting from it_vbak-vbeln

( you can take it in debug mode in excel from your program) and the Posnr field as '000000' and also the ranges for parvw as it contains only 4 records so no problem you can pass it in the table.

Check it once whther the output you are getting from your program and the output you are getting from Se11 are same or not.

You can judge it there.

I would also request you to find that it_vbak[] consist some data.

Thanks

Arbind

Read only

0 Likes
2,045

Hi Nagarjuna,

Try doing this :

Get all the data without mentioning the POSNR field in the select statement. Once you get the data into your internal table, loop the internal table something like below



Loop at itab into workarea where Posnr ne '000000'
append workarea to itab1.
clear workarea.
endloop.

(OR)
Loop at itab into workarea.
if  workarea-Posnr eq '000000'
append workarea to itab1.
clear workarea.
endif.
endloop.


** You can delete the entries inside the loop based on the condition but it tries to regenerate an index everytime u delete an entry.
So, to increase the performance, it is better to append the entries to another internal table which is faster.

Let me know if this is working.

Thanks,

Guru

Read only

Former Member
0 Likes
2,045

Yes just check the ranges, as this might be only problem. Rest everything is looking good.

Partner functions are not same as you see in VBPA.

For example if you pass AG in the partner you get SP.

So what ever you are getting in the ranges take same and go to table VBPA and try to fetch with them.

Hope this helps

Read only

Former Member
0 Likes
2,045

Hi Nagarjuna,

I had tried with the below code. It worked.

TYPES: begin of ty_vbak,

vbeln type vbak-vbeln,

end of ty_vbak.

data: it_vbpa type standard table of vbpa,

it_vbak type standard table of ty_vbak.

data: ls_vbak type ty_vbak,

ls_vbpa type vbpa.

Ranges: r_parvw FOR knvp-parvw.

Constants:c_inclusive(1) TYPE c VALUE 'I',

c_equal(2) TYPE c VALUE 'EQ'.

CLEAR r_parvw.

r_parvw-low = 'AG'.

r_parvw-option = c_equal.

r_parvw-sign = c_inclusive.

APPEND r_parvw.

CLEAR ls_vbak.

ls_vbak-vbeln = '0000000013'.

APPEND ls_vbak to it_vbak.

SELECT *

FROM vbpa

INTO TABLE it_vbpa

FOR ALL ENTRIES IN it_vbak

WHERE vbeln EQ it_vbak-vbeln

AND posnr EQ '000000'

AND parvw IN r_parvw.

Please cross check the it_vbak & r_parvw entries at the SELECT quey in debugging. Hope it should work.

Regards,

Satish Kanteti

Read only

Former Member
0 Likes
2,045

As POSNR is of type NUMC so in where condition put POSNR EQ 0. it works for me so i am sure will work for you as well.