cancel
Showing results for 
Search instead for 
Did you mean: 

BAPI_LEAD_CHANGEMULTI change the PARTNER

Former Member
0 Kudos

Hello,

I want to update my lead with the BAPI_LEAD_CHANGEMULTI FM. I want to change existing partners to this LEAD especially the CONTACT PERSON and the ACTIVITY PARTNER because there 3 are provides by the CRM_LEAD_SEARCH FM and these are the most important BUPA to every lead.

So this is what I tried so far:

    

     0. Read every post in the SCN to this topic. Some people dealing with the same problem, some solved their case on their on, but none working          solutions is available.

  1. User the FM BAPI_LEAD_GETDETAILMULTI to get Information of an existing LEAd with some partners.
  2. Use this Information to build my call of BAPI_LEAD_CHANGEMULTI, especially the partner table.
  3. Set all X-Flags in the X-Tables
  4. Use the commit FM

I can Create a lead, and I can change everything in the header of the lead, but I cannot change the Partners.

There is no Error in the return code, only success messages, heres the code:

s_headerx-GUID                        = 'X'.

s_headerx-DESCRIPTION         = 'X'.

s_headerx-POSTING_DATE      = 'X'.

s_headerx-PROCESS_TYPE      = 'X'.

append s_headerx to headerx.

s_header-GUID           = '005056935F731EE2BFD5B7E3678BE620'."lead_in-GUID.

s_header-DESCRIPTION    = 'dummy change test'."lead_in-DESCRIPTION.

CONCATENATE sy-TIMLO s_header-DESCRIPTION INTO s_header-DESCRIPTION.

s_header-PROCESS_TYPE   = 'ZLEA'.

s_header-POSTING_DATE   = sy-DATUM.

append s_header to header.

s_partnerx-REF_GUID = 'X'.

s_partnerx-REF_HANDLE = 'X'.

s_partnerx-REF_KIND = 'X'.

s_partnerx-REF_PARTNER_HANDLE = 'X'.

s_partnerx-REF_PARTNER_FCT = 'X'.

s_partnerx-REF_PARTNER_NO = 'X'.

s_partnerx-REF_NO_TYPE = 'X'.

s_partnerx-REF_DISPLAY_TYPE = 'X'.

s_partnerx-PARTNER_FCT = 'X'.

s_partnerx-PARTNER_NO = 'X'.

s_partnerx-NO_TYPE = 'X'.

s_partnerx-DISPLAY_TYPE = 'X'.

s_partnerx-KIND_OF_ENTRY = 'X'.

s_partnerx-MAINPARTNER = 'X'.

s_partnerx-RELATION_PARTNER = 'X'.

s_partnerx-BUSINESSPARTNERGUID = 'X'.

s_partnerx-ADDR_NR = 'X'.

s_partnerx-ADDR_TYPE = 'X'.

s_partnerx-ADDR_ORIGIN = 'X'.

s_partnerx-STD_BP_ADDRESS = 'X'.

append s_partnerx to partnerx.

"my reference lead to extract the partner info

s_guid-GUID = '005056935F731EE2BBDD4FC5C5A70620'.

append s_guid to guid.

CALL FUNCTION 'BAPI_LEAD_GETDETAILMULTI'

   TABLES

     GUID                   = guid

     PARTNER                = partner_dis

           .

loop at partner_dis into s_partner_dis.

     "Zuständiger Mitarbeiter/Person Responsible

     IF s_partner_dis-REF_PARTNER_FCT eq '00000014'.

       MOVE-CORRESPONDING s_partner_dis to s_partner_ins.

       append s_partner_ins to partner_ins.

     "Ansprechpartner/Account / Contact Person

     ELSEIF s_partner_dis-REF_PARTNER_FCT eq '00000015'.

       MOVE-CORRESPONDING s_partner_dis to s_partner_ins.

       append s_partner_ins to partner_ins.

     "Account Interessent / Activity Partner

     ELSEIF s_partner_dis-REF_PARTNER_FCT eq '00000021'.

       MOVE-CORRESPONDING s_partner_dis to s_partner_ins.

       append s_partner_ins to partner_ins.

     ENDIF.

   endloop.

CALL FUNCTION 'BAPI_LEAD_CHANGEMULTI'

   TABLES

     HEADERX             = headerx

     PARTNERX            = partnerx

     HEADER              = header

     PARTNER             = partner_ins

     RETURN              = return

           .

IF RETURN[] IS NOT INITIAL.

   LOOP at return.

     if return-TYPE EQ 'E' or return-TYPE EQ 'W'.

       error = 'X'.

     ENDIF.

     if return-type EQ 'S'.

     endif.

   ENDLOOP.

ENDIF.

IF NOT error eq 'X'.

   CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

     EXPORTING

       WAIT   = ''

     IMPORTING

       RETURN = return_commit.

ENDIF.

If you know the solution please let me know. Working since 2 days on this. Guess I'm still not the only one who has trouble with this.

I know there are other FM's to use and different ways to solve this problem. But I dont want to use the more general CRM_ORDER FM. This makes the whole applikation to complicated I think. There has to be a way to do it with the BAPI_LEAD_CHANGEMULTI FM.

Greetings and thanks for reading

David

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi David

I didn't try using BAPI which you mentioned but i tried using CRM_ORDER_MAINTAIN function module and changed the partner functions...

*** In the above code i noticed that you didn't pass the tables parameter INPUT_FIELDS

only PARTNER and INPUT_FIELDS tables parameters are necessary for this BAPI

*** In the INPUT_FIELDS

WA_LOGIC_KEY is mandatory

first get the partner number which is in lead transaction into a variable LV_PARTNER

CONCATENATE '0000' wa_partner-partner_fct lv_partner INTO lv_partner.

wa_logic_key = lv_partner.

now pass the DISPLAY_TYPE & NO_TYPE

CONCATENATE wa_partner-display_type wa_partner-no_type INTO lt_part.

wa_logic_key+32 = lt_part.

wa_field_names-ref_handle = wa_appoin-ref_handle.
wa_field_names-ref_guid   = wa_appoin-ref_guid.
wa_field_names-ref_kind   = wa_appoin-ref_kind
wa_field_names-objectname = 'PARTNER'.
wa_field_names-logical_key= wa_logic_key. 

wa_field_names-fieldname = 'PARTNER_NO'.

APPEND wa_field_names TO it_inputfields

*** if you want to get clear on the parameters

Place a break point in the CRM_ORDER_MAINTAIN and now go to lead transaction , change any partner and click enter . Immediately this FM will trigger.

In the Debugging you  can check the parameters CT_INPUT_FIELDS & IT_PARTNER

Hope this will resolve your issue

Regards

Dinesh Gurram

Former Member
0 Kudos

This message was moderated.

Former Member
0 Kudos

Hey Dinesh,

thanks for your Input. I checked the CRM_ORDER_MAINTAIN FM.

It is called by BAPI_LEAD_CHANGEMULTI and the INPUT_FIELDS are entered in a correct way, I guess, automatically.

So if I call BAPI_LEAD_CHANGEMULTI in the way my coding shows I don't get an error return code, only two success messages that say, "Your request is proccessed".

So I read many other post to this questions, and many people assume to use the lower-level CRM_ORDER_XXX FM.

But I'm searching for a way to use the Higher Level BAPI_LEAD_CHANGEMULTI or BAPI_LEAD_CREATEEMULTI FM's, because I have to build a lot of services, and the use of the

higher level FM's would save  a lot of coding.

I'm really stuck on this, so if anyone has any idea I would be thankful.

Greetings

David

Former Member
0 Kudos

Hi David

Did you check the below link

http://scn.sap.com/thread/1737734

Former Member
0 Kudos

Hi David

Call both the CRM_ORDER_SAVE function module and BAPI_TRANSACTION_COMMIT fm in the program.

Also don't forget to pass the GUID which you want to save to the FM CRM_ORDER_SAVE.

Answers (3)

Answers (3)

Former Member
0 Kudos

So thanks to you two for helping me!

I finally combined your input and with that I was able to figure out how to use the BAPI_LEAD_CHANGEMULTI FM.

Here's the solution:

The BAPI_LEAD_CHANGEMULTI works direct with the CRM_ORDER_MAINTAIN but it provided some methods that do the ct_input_fields filling part for you. Everything you mark in the X-Tables will be a a FIELDNAME in the ct_input_fields-field_names table.

Ex: If you mark for it_partnerx

Partner_Fct than there will be an column in the ct_input_fields-field_names with the value 'PARTNER_FCT'. So by marking something in the X-Tables you can build your request against the crm_order_maintain FM.

The very important logical key value of the ct_input_fields is filled automatically if you use BAPI_LEAD_CHANGEMULTI Fm correct.

The logical_key field is filld everytime with values from the REF-Fields. Fields that have the REF in their name are simply fields with the previous state. All other fields contain the values that sould be entered by chaging. So REF = OLD VALUEs , other = new values.

The logical-key Field in the context of changing partners always means the old partner.

So this tree cases worked for me.

1.  DELETE A PARTNER:

s_partnerx-PARTNER_FCT           = 'X'.

append s_partnerx to partnerx.

s_partner_ins-REF_GUID                            = lead_to_change.

s_partner_ins-REF_KIND                                     = 'A'.

s_partner_ins-REF_PARTNER_FCT             = s_partner_dis-PARTNER_FCT.

s_partner_ins-REF_PARTNER_NO               = '100000431'.//old_partner_no to be deleted

s_partner_ins-REF_DISPLAY_TYPE            = 'BP'

s_partner_ins-REF_NO_TYPE                      = 'BP'

append s_partner_ins to partner_ins.

2. CREATE NEW PARTNER

s_partnerx-PARTNER_NO     = 'X'.

s_partnerx-PARTNER_FCT   = 'X'.

s_partnerx-NO_TYPE           = 'X'.

s_partnerx-DISPLAY_TYPE = 'X'

append s_partnerx to partnerx.

s_partner_ins-REF_GUID             = lead_to_change.

s_partner_ins-REF_KIND             = 'A'.

s_partner_ins-PARTNER_NO        = '100000431' // new partner to be created

s_partner_ins-DISPLAY_TYPE     = 'BP'.

s_partner_ins-NO_TYPE               =  'BP'.

s_partner_ins-PARTNER_FCT      = s_partner_dis-PARTNER_FCT. //e.g. 00000014

3. CHANGE EXISTING PARTNER:

s_partnerx-PARTNER_NO= 'X'.
s_partnerx-PARTNER_FCT= 'X'.
s_partnerx-NO_TYPE= 'X'.

s_partnerx-DISPLAY_TYPE = 'X'.

append s_partnerx to partnerx.

s_partner_ins-REF_GUID            = lead_to_change.

s_partner_ins-REF_KIND          = 'A'.

s_partner_ins-REF_PARTNER_FCT     = '00000014'.

s_partner_ins-REF_PARTNER_NO      = '100000393'.//old partner for logical_key filling

s_partner_ins-REF_DISPLAY_TYPE    = 'BP'

s_partner_ins-REF_NO_TYPE         = 'BP'

s_partner_ins-PARTNER_NO          = '100000431'. // new partner

s_partner_ins-DISPLAY_TYPE        = 'BP'

s_partner_ins-NO_TYPE             =  'BP'

s_partner_ins-PARTNER_FCT         = '00000014'.

append s_partner_ins to partner_ins.

Hope this helps, took me 4 day to figure out. If anyone know how to get any kind of feedback on the inputs let be know. Because the FM doesn't not provide any useful return messages, so its more like try and error.

Greetings

David

Former Member
0 Kudos

Hey Caique, Hey Dinesh

thanks for answering. Sadly I must say I already did so (call from WebUI and breakpoint the CRM_ORDER_MAINTAIN FM), with no success.

I write down the input for the CRM_ORDER_MAINTAIN FM for  various changes and rebuild the call of the CRM_ORDER_MAINTAIN FM directly or via BAPI_LEAD_CHAGEMULIT. If I use BAPI_LEADCHANGE_MULTI FM the input for CRM_ORDER_MAINTAIN is build up through the previous coding. And the input looks correkt, its similar to a call from the webui which in fact works.

I also tried the code sample from Dinesh and took a look at the post he provided. I tried with the "Transaction Commit" FM and the CRM_ORDER_SAVE FM to store my changes. When I try to change the status the changes are also not stored, like for partner, but the status required much less fields. There is not so much which could be done wrong.

What makes me wonder, is that there is no error message. Only the success Message: "Beginn der Verarbeitung Einzelbeleg" which means as much as "Start to process single sheet".

Own full priviliges on the system. Thats not the problem. So I guess I oversee something very important or there is something wrong with the system. If I get it running I'll write a docu here on how to call this api in a tested way, that should work.

Greetings

David

Caique
Employee
Employee
0 Kudos

Hi David,

I tested CRM_ORDER_MAINTAIN and I guess you have to maintain exactly these parameters:

ct_input_fields[1]

REF_HANDLE 0000000000
REF_GUID 0050569B033D1ED380D4B8C47168CB1E
REF_KIND A
OBJECTNAME PARTNER
LOGICAL_KEY 000000000015400226              BPBP
FIELD_NAMES Table[4x64]

ct_input_fields[1]-FIELD_NAMES

FIELDNAME:

DISPLAY_TYPE
NO_TYPE
PARTNER_NO
RELATION_PARTNER


IT_partner

REF_GUID  0050569B033D1ED380D4B8C47168CB1E
REF_KIND  A
REF_PARTNER_FCT  00000015
REF_PARTNER_NO  400226
REF_NO_TYPE  BP
REF_DISPLAY_TYPE BP
PARTNER_NO  0000000130
DISPLAY_TYPE  BP
NO_TYPE C  BP
RELATION_PARTNER D0A086A6E245D411917308000627B381

Are you trying to change the partners in a BadI or via action?

After call CRM_ORDER_MAINTAIN are you calling CRM_ORDER_SAVE and doing a commit work?

Regards,

Caíque

Caique
Employee
Employee
0 Kudos

Dear David,

Set on a break-point on function CRM_ORDER_MAINTAIN.

Go to the WebUI and open a Lead.

Change the partner.

Debug will be raised on screen,see what are the parameters assigned to the function.

assigned the same parameters on your call to FM.

Note that there is table named INPUT FIELDS.This one is important.

This for sure will help you and solve your issue because you will copy the Standard behavior.

Regards,

Caíque