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: 

Unable to add partner function in PO using BAdI ME_PROCESS_PO_CUST

0 Kudos
2,344

Hello,

I want to add a partner function, CR, in partner tab of PO based on some conditions. This is required during PO creation i.e. T code ME21N.

I implemented BAdI ME_PROCESS_PO_CUST and wrote a code in method PROCESS_HEADER. I used FM MM_READ_PARTNERS to fetch partners from buffer and FM MM_MAINTAIN_PARTNERS to add the partner function.

After the execution of this BAdI I can see my partner function in partner tab but it is not accepted. It looks like below:

capture.png

And when I save it, the partner function disappears and is not saved in the PO.

I have gone through a lot of SCN blogs on this topic and tried different ways but couldn't achieve the goal. Please let me know if I am missing any thing.

Thanks,

Punit

1 ACCEPTED SOLUTION

478

I resolved it myself.

Even though the partner function is CR, I had to pass SP to parvw in the code. I don,t know why, but this solved it for me!

14 REPLIES 14

JL23
Active Contributor
0 Kudos
478

I assume you want the BAdI because you only want this partner based on certain conditions.

But the question is: Can you assign this partner role and the partner number just so in ME21N, without having the BAdI to restrict it?

If not, then there is certainly your partner determination customizing incomplete.

If yes, then you might have moved the partner number into the wrong field. The Dynpro has just 1 field, while the master data table behind has 3 different fields.

Unfortunately we do not know what the the role CR is and how it is defined in customizing, and what 854 is, whether it is a vendor, a person or a contact.

0 Kudos
478

Hi Jurgen,

Thanks for your response.

CR is forwarding agent, you can ignore 854 as its just a vendor number.

This CR partner function should get determined only if there's a particular Inco Term value. I couldnt find partner determination functionality in SAP based on Incoterm field. So I decided to write a code to check this condition and allow CR only if the condition is satisfied.

I referred the below blog to achieve this but unfortunately its not working for me:

https://blogs.sap.com/2014/09/18/add-partner-to-purchase-order-partners-tab-during-po-creation-me21n...

JL23
Active Contributor
0 Kudos
478

There is no partner determination based on Incoterms, it is okay to use code for such a condition. But more important is that you have to have the customizing in place that allows to use CR at all as a partner in the PO, otherwise a restriction or adding through coding will not work.

0 Kudos
478

Yes, I do have customization in place to allow CR, as if I add it manually it works.

479

I resolved it myself.

Even though the partner function is CR, I had to pass SP to parvw in the code. I don,t know why, but this solved it for me!

0 Kudos
478

because the key for the partner role is subject to translation

forwarding agent = Spedition = SP

0 Kudos
478

This is something new to me, will you please elaborate more on this or provide me a link which has more details on it.

Can you please tell me table which has partner function and key stored in?

0 Kudos
478

see tables TPAR and TPART

0 Kudos
478

I just researched further and got to know the table is TPAUM.

Thanks Jurgen for continuously responding to my queries, appreciate your help!!

0 Kudos
478

you're right, TPAUM is it, I am not on a system, said good bye to it for the next 3 weeks some hours ago.

former_member491087
Discoverer
0 Kudos
478

Hi Punit

I'm also having the same requirement but should flow from PR i.e from ME59N. I'm adding the correct partner function and vendor no. But I couldn't getting the desired result. Partner function is not getting added. Can you pls paste the code if possible

Regards

Shekhar

former_member491087
Discoverer
0 Kudos
478

Hi all,

Below is the code i have written . Can you pls help in finding the flaw, if any

refresh gt_ekpa[].

CALL FUNCTION 'MM_READ_PARTNERS'
EXPORTING
APPLICATION = 'P'
TABLES
X_EKPA = gt_ekpa.

SELECT SINGLE pargr
FROM t161
INTO lv_pargr
WHERE bsart EQ ls_header-bsart
AND bstyp EQ ls_header-bstyp.

CHECK not lv_pargr IS INITIAL.

refresh gt_mmpa[].
LOOP AT gt_ekpa INTO gs_ekpa.

CLEAR gs_mmpa.

MOVE-CORRESPONDING gs_ekpa TO gs_mmpa.
APPEND gs_mmpa TO gt_mmpa.
endloop.

if not gt_ekpa is initial.
clear gs_mmpa1.
read table gt_mmpa into gs_mmpa1 with key parvw = 'WL'
lifn2 = 'ABCD0004'.
if sy-subrc <> 0.
gs_mmpa-parvw = 'WL'.
gs_mmpa-lifn2 = 'ABCD0004'.
append gs_mmpa to gt_mmpa.
endif.

endif.

if not gt_mmpa is initial.
CALL FUNCTION 'MM_MAINTAIN_PARTNERS'
EXPORTING
application = 'P'
EBELN = ls_header-ebeln
BSTYP = ls_header-bstyp
EKORG = ls_header-ekorg
LIFNR = ls_header-lifnr
pargr = lv_pargr
* SCREEN_INVISIBLE = 'X'
TABLES
X_MMPA = gt_mmpa.

endif.
endif.

Regards

Shekhar

0 Kudos
478

Hi Mahesh,

Your code seems to be perfect, but there's something called as language conversion for partner functions.

So if you check in table TPAUM you will find language specific (EN) partner function for partnere function WL. It should be GS. Pass GS instead of WL in your code and try. It should work, at least it worked for me.

Thanks,

Punit

0 Kudos
478

Won't ls_header-ebeln still be undefined if you're doing a create with ME21N ? That's the problem I'm running into.