cancel
Showing results for 
Search instead for 
Did you mean: 

Bapi_PO_Create1 problem with POPARTNR

Former Member
0 Kudos

Hello All,

I am having problems now with doing a PO create from PR. The BAPI was working but now i have to overide the vendor for the partner function "Invoice Presented by" (PI). so i am going to try and use the table POPARTNER , but i get the error "Please enter a partner role ". i pass it the partner number which in this case is the vendor.

does anyone have any idea as to what is going on. thanks alot.

scott

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Are you filling all three fields of this structure?

PARTNERDESC

LANGU

BUSPARTNO

See this example.

PARTNERDESC = 'PI'.

LANGU = 'EN'.

BUSPARTNO = '0000001000'.

Former Member
0 Kudos

Hi Srinivas,

actuall no.. i am only filling in the BUSPARTNO.. Now that i see what have i now understand . I need the other fields to tell it which desc like PI or VN etc.. I will try this and it looks like it will work.

I will give it a quick try and then award you the points. thanks alot Srinivas.

Scott

Former Member
0 Kudos

Hello All,

well i added the other two fields to the BAPI and now i get the following errors :

1. "You can only maintain the partner role 'Vendor' using POHEADER".

2. "Only one Partner per Partner Role can be entered"

I get error one on all the records and error 2 only on a few. could be something with my test data also.

Any ideas.

thanks scott

Former Member
0 Kudos

Yes, it looks like it the data issue in conjunction with how the configuration is.

Are you passing the value of the VENDOR to POHEADER-VENDOR and the corresponding 'X' field checked? You should not fill the POPARTNER for this vendor.

For number two, I think you are trying to fill POPARTNER twice with the same partner function and your config does not allow you to have more than one partner for the same partner function.

Srinivas

Former Member
0 Kudos

Hello Everyone,

hey thanks for all the input, it helped me understand what was going on. I contacted the Functional person and we walked thru what was happening. Then they realized that with the config of this system and other issues we need to do it differently.

Then they found out that thru transaction MIRO they could do the function that was needed, so that was missed they said.

Now i do not have to do this change of the partner vendor.

thanks for all the help and i will award points does anyone know can i award everyone the very helpful selection.

Former Member
0 Kudos

You can give any reward to any number of posts <u>except</u> 'Problem Solved' which only one post can receive. If none qualify for that reqard, simply select 'Solved on my own' button next to your first post.

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi,

I had also faced a similar problem, but it was resolved later on.

I have posted the code below , hope it helps

REPORT ztest NO STANDARD PAGE HEADING.

TABLES: ekko,

ekpo,

lfa1.

&----


  • INTERNAL TABLES DECLARATIONS *

&----


DATA: t_popartner TYPE TABLE OF bapiekkop WITH HEADER LINE,

t_return LIKE bapiret2 OCCURS 0 WITH HEADER LINE,

t_poheader TYPE TABLE OF bapimepoheader WITH HEADER LINE,

t_poheaderx TYPE TABLE OF bapimepoheaderx WITH HEADER LINE.

  • Internal table t_data to store data from Purchasing Document

  • Header (EKKO) and Purchasing Document Item (EKPO).

DATA: BEGIN OF t_data OCCURS 0,

ebeln LIKE ekko-ebeln, " Purchasing Document Number(PO)

bukrs LIKE ekko-bukrs, " Company Code

lifnr LIKE ekko-lifnr, " Old Vendor

ekorg LIKE ekko-ekorg, " Purchasing Organization

werks LIKE ekpo-werks, " Plant

END OF t_data.

&----


  • S E L E C T I O N S C R E E N *

&----


SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.

PARAMETER: s_olifnr TYPE ekko-lifnr OBLIGATORY, " Old Vendor

s_nlifnr TYPE ekko-lifnr OBLIGATORY. " New Vendor

SELECT-OPTIONS: s_ekorg FOR ekko-ekorg NO INTERVALS OBLIGATORY,

" Purchasing Organization

s_bukrs FOR ekko-bukrs NO INTERVALS, " Company Code

s_ebeln FOR ekko-ebeln NO INTERVALS, " PO Number

s_werks FOR ekpo-werks NO INTERVALS. " Plant

SELECTION-SCREEN END OF BLOCK b1.

&----


*& A T S E L E C T I O N S C R E E N *

&----


AT SELECTION-SCREEN.

  • Field validation for the field New Vendor(s_nlifnr)

PERFORM field_validation.

&----


*& S T A R T O F S E L E C T I O N *

&----


START-OF-SELECTION.

  • Joining tables EKKO and EKPO

PERFORM join_data.

  • Updating Old Vendor with New Vendor

PERFORM vendor_update.

&----


*& Form join_data

&----


  • Joining tables EKKO and EKPO

----


FORM join_data .

SELECT ekko~ebeln

ekko~bukrs

ekko~lifnr

ekko~ekorg

ekpo~werks

INTO TABLE t_data

FROM ekko INNER JOIN ekpo

ON ( ekkoebeln = ekpoebeln )

WHERE ekko~ebeln IN s_ebeln

AND ekko~bukrs IN s_bukrs

AND ekko~lifnr = s_olifnr

AND ekko~ekorg IN s_ekorg

AND ekpo~werks IN s_werks.

IF sy-subrc EQ 0.

  • Deleting multiple line items based on PO Number

DELETE ADJACENT DUPLICATES FROM t_data COMPARING ebeln.

ELSE. " When no record found

MESSAGE i999(ze) WITH text-002.

LEAVE LIST-PROCESSING.

ENDIF. " check on sy-subrc

ENDFORM. " join_data

&----


*& Form vendor_update

&----


  • Updating Old Vendor with New Vendor

----


FORM vendor_update .

  • Displaying the header

PERFORM display_header.

LOOP AT t_data.

  • Selecting partner profile from ekpa based on PO No.

SELECT SINGLE parvw lifn2

FROM ekpa

INTO (t_popartner-partnerdesc, t_popartner-buspartno)

WHERE ebeln = t_data-ebeln

AND parvw = 'RS'.

IF sy-subrc = 0. " when data is found

t_popartner-langu = sy-langu.

t_popartner-buspartno = s_nlifnr.

APPEND t_popartner.

CLEAR t_popartner.

ENDIF. " chck on sy-subrc

  • Modifying partner profile from 'RS' to 'PI' ,in order

  • to pass to the bapi_po_change

READ TABLE t_popartner INDEX 1.

IF sy-subrc EQ 0.

t_popartner-partnerdesc = 'PI'.

MODIFY t_popartner INDEX 1.

CLEAR t_popartner.

ENDIF. " chck on sy-subrc

  • Calling BAPI for updating the vendor

CALL FUNCTION 'BAPI_PO_CHANGE'

EXPORTING

purchaseorder = t_data-ebeln

TABLES

return = t_return

popartner = t_popartner[].

  • CALL commit or rollback the bapi

DATA : l_color TYPE c,

l_ponum(10) TYPE c.

l_ponum = t_data-ebeln.

  • Reading errors in the return table of BAPI

READ TABLE t_return WITH KEY type = 'E'.

IF sy-subrc = 0 .

CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.

  • Display the error messages.

PERFORM print_bapimessages TABLES t_return

USING l_ponum.

ELSE.

  • Try to COMMIT the call. And wait for the V1 processing.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

WAIT UP TO 2 SECONDS.

PERFORM print_bapimessages TABLES t_return

USING l_ponum.

ENDIF. " check on message type

CLEAR t_data.

ENDLOOP. " looping at t_data

ENDFORM. " vendor_update

&----


*& Form print_bapimessages

&----


  • To Display the error messages

----


FORM print_bapimessages TABLES t_return STRUCTURE bapiret2

USING l_ponum.

DATA: l_errortext TYPE string.

CLEAR t_return.

  • Print the error messages

LOOP AT t_return.

  • Create the full message text

CALL FUNCTION 'FORMAT_MESSAGE'

EXPORTING

id = t_return-id

lang = sy-langu

no = t_return-number

v1 = t_return-message_v1

v2 = t_return-message_v2

v3 = t_return-message_v3

v4 = t_return-message_v4

IMPORTING

msg = l_errortext

EXCEPTIONS

not_found = 1

OTHERS = 2.

CONCATENATE '| PO NUMBER-' l_ponum '|' 'MESSAGE TYPE' t_return-type

'| -' l_errortext '|' INTO l_errortext SEPARATED BY space.

IF t_return-type = 'E'.

WRITE: /1 l_errortext COLOR COL_NEGATIVE.

ELSEIF t_return-type = 'S'.

WRITE: /1 l_errortext COLOR COL_POSITIVE.

ELSE.

WRITE: /1 l_errortext COLOR COL_TOTAL.

ENDIF. " chck on color type

CLEAR t_return.

ENDLOOP. " looping at t_return

ENDFORM. "print_bapimessages

&----


*& Form display_header

&----


  • Display the header

----


FORM display_header .

WRITE: /40 'LIST OF ALL THE POs CHANGED WITH THE MESSAGES GENERATED'

COLOR COL_HEADING.

WRITE:/40 '----


'.

SKIP.

ENDFORM. " display_header

&----


*& Form field_validation

&----


  • Field validation for the field New Vendor(s_nlifnr)

----


FORM field_validation .

  • Validation for New Vendor

SELECT * UP TO 1 ROWS FROM lfa1

WHERE lifnr = s_nlifnr.

ENDSELECT .

IF sy-subrc NE 0.

MESSAGE e999(ze) WITH text-003.

" The field New Vendor doesn't Exist

LEAVE LIST-PROCESSING.

ENDIF. " check on sy-subrc

ENDFORM. " field_validation

former_member181966
Active Contributor
0 Kudos

Hey scott!!

Check out the OSS note # 900620

FYI

Symptom

While creating/changing a Purchase Order via BAPI_PO_CREATE1 and/or BAPI_PO_CHANGE, error WY017 occurs (Vendor &1 not assigned to purchasing organization &2) . This happens with Partner Function where the Partner has no purchasing organization data even though Partner general data is created in vendor master.

Other terms

LFA1 LFM1 Partner Vendor BAPI_PO_CREATE1 WY017 WY 017

Reason and Prerequisites

Definition that partner function should have partners with purchasing organization data. Not all partners need purchasing organization data to be partner of a vendor.

For example OA - ordering address, the vendor assigned to this partner function can be created in Vendor Master only with general data.

Solution

Apply source code correction

Thanks

Saquib

Former Member
0 Kudos

Hi Saquib,

Ok i bet this is part of my problem, the test data we have in our GD1 system is pretty bad. I will take a look at the note and also check out the data.

thanks again..

Scott

former_member181962
Active Contributor
0 Kudos

Hi Scott:

See the documentation.

Here is an excerpt:

<i><b>" Partner roles

The partners can be maintained individually via the table PoPartner

(with the exception of the partner role "vendor").

"</b></i>

Regards,

Ravi