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: 

Retrieve partner for each item in VBPA

Former Member
0 Kudos

Hi everyone.

I have an issue due to the way SAP stores the data in VBPA.

I explain : for each different partner (at item level), they only store one item in VBPA. It compress the data like they say in OSS note 380507.

My problem is how can i retrieve all the items for a document ?

Is there any FM for that ?

exemple : in my diocument i have the following :

posnr -kunnr

1------ 123

2------ 123

In VBPA, i will only find the first line. I need a solution to retrieve the second one.

Thanks for your help.

1 ACCEPTED SOLUTION

Clemenss
Active Contributor
0 Kudos

Hi Helder,

VPBPA POSNR zero (initial) will hold the header partners valid for all items unless specified otherwiese on item level.

Regards,

Clemens

8 REPLIES 8

Former Member
0 Kudos

Hi

If a partner is valid for all items of the document u can see only one hit in VBPA where the item has the value of the header => 000000

Only if a partner is valid for a certain item you should find an hit for that item.

So if you need to get all partners:

TABLES VBAK.

PARAMETERS: P_VBELN TYPE VBAK-VBELN.


DATA: T_VBAP LIKE STANDARD TABLE OF VBAP WITH HEADER LINE,
           T_VBPA LIKE STANDARD TABLE OF VBPA WITH HEADER LINE.



START-OF-SELECTION.

* Get Items
SELECT * FROM VBAP INTO TABLE T_VBAP WHERE VBELN = P_VBELN.
* Get partners
SELECT * FROM VBPA INTO TABLE T_VBPA WHERE VBELN = P_VBELN.

LOOP AT T_VBPA.

 IF T_VBPA-POSNR = '000000'. "<--- It means is valid for all items
   
   LOOP AT T_VBAP.
      WRITE: / T_VBAP-POSNR, T_VBPA-PARVW, T_VBPA-KUNNR.
   ENDLOOP.
 ELSE.                                      <--- It means is valid for only certain items
   LOOP T_VBAP WHERE POSNR = T_VBPA-POSNR.
      WRITE: / T_VBAP-POSNR, T_VBPA-PARVW, T_VBPA-KUNNR.
   ENDLOOP.
 ENDIF.
ENDLOOP.

Max

Clemenss
Active Contributor
0 Kudos

Hi Helder,

VPBPA POSNR zero (initial) will hold the header partners valid for all items unless specified otherwiese on item level.

Regards,

Clemens

Former Member
0 Kudos

In fact we can have different partners depending on the item. That's why we can't use the header partner related to the header.

Clemenss
Active Contributor
0 Kudos

Hi Helder,

that's what we are talking about.

If you have a partner at item level, it is populated for corresponding VBPA-POSNR. If you do not have a partner at VBPA-POSNR, then the partner is at item zero (initial POSNR).

Regards,

Clemens

Former Member
0 Kudos

I think you have misunderstood what i said.

Every item has a partner at his level, but in VBPA, SAP only stores one item for each partner.

Example :

This is what i have in the document

Posnr - Partner

1 - 10

2 - 10

3 - 20

4 - 20

In VBPA i will only have the following lines:

1 - 10

3 - 20

Clemenss
Active Contributor
0 Kudos

Hi Helder,

then partners for 2 and 4 are missing. I can hardly believe you have no record with initial POSNR in VBPA. Was the document created with SAP standard?

Regards,

Clemens

Former Member
0 Kudos

Hi,

The solution is to read the partner information with VBPA-POSNR=VBRP-POSPA in stead of VBPA-POSNR=VBRP-POSNR.

Kind regards,

Danië

Former Member
0 Kudos

This should be marked as the actual correct answer. It allows you to find the correct partner at a document item level.