cancel
Showing results for 
Search instead for 
Did you mean: 

Changing the Partner in Opportunity by Funciton module

Former Member
0 Kudos

Hi,

I am trying to change the employee responsible partner of an opportunity.

I was unable to find the correct code. I tried using the below code but i am unable to do.

Please help me in this regard. I have tried with FM 'BAPI_OPPORTUNITY_CHANGEMULTI' But I am unable to understand how to pass the partner values to it.

L_Guid = it_CRMD_ORDERADM_H-guid.      ."'4582EEBA723000A500000000837FBA1A'.
  INSERT L_Guid INTO TABLE Lt_Header.
*move  '43A15126B7A2006502000000837FBA1A' to Lt_Header.
  CALL FUNCTION 'CRM_ORDER_READ'
    EXPORTING
      IT_HEADER_GUID       = Lt_Header
    IMPORTING
      ET_PARTNER           = Lt_GetPartner
    EXCEPTIONS
      DOCUMENT_NOT_FOUND   = 1
      ERROR_OCCURRED       = 2
      DOCUMENT_LOCKED      = 3
      NO_CHANGE_AUTHORITY  = 4
      NO_DISPLAY_AUTHORITY = 5
      NO_CHANGE_ALLOWED    = 6
      OTHERS               = 7.
  IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.
READ TABLE Lt_GetPartner INTO wa_GetPartner WITH KEY PARTNER_FCT = '00000014'.
if sy-subrc = 0.
data v_index like sy-tabix.

v_index = sy-tabix.
w_uname = 'salesrep1.
ls_partner_com-partner_no = w_uname.
    INSERT ls_partner_com INTO TABLE it_partner.
ls_input_field_names-fieldname = 'PARTNER_NO'.
    INSERT ls_input_field_names INTO TABLE ls_input_field-field_names.
    INSERT ls_input_field  INTO TABLE  lt_input_fields.

CALL FUNCTION 'CRM_ORDER_MAINTAIN'
 EXPORTING
   IT_PARTNER                    = it_partner.
CHANGING
  CT_ORDERADM_H                  = CT_ORDERADM_H
  CT_INPUT_FIELDS                = lt_input_fields
 EXCEPTIONS
   ERROR_OCCURRED                = 1
   DOCUMENT_LOCKED               = 2
   NO_CHANGE_ALLOWED             = 3
   NO_AUTHORITY                  = 4
   OTHERS                        = 5
          .
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

 append  L_Guid to lt_guids.
CALL FUNCTION 'CRM_ORDER_SAVE'
  EXPORTING
    IT_OBJECTS_TO_SAVE         = lt_guids
 EXCEPTIONS
   DOCUMENT_NOT_SAVED         = 1
   OTHERS                     = 2

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Resolved

Former Member
0 Kudos

Hi Naveen,

can you please post how you solved this? because i am currently facing issue in changing the partner.

Regards,

Heera

Former Member
0 Kudos

Hi,

Two problems that I found in the mentioned code are:

<b>1. ls_input_field_names-fieldname = 'PARTNER_NO'.

INSERT ls_input_field_names INTO TABLE ls_input_field-field_names.</b>

In between these two lines you should also add the following line:

<b>ls_input_field_names-changeable = space.</b>

<b>2. w_uname = 'salesrep1.</b>

I am not sure if you can pass the user name directly instead of the BP number. There are some standard function modules for getting the BP number from user name. You can use that and then assign the BP number.

Hope this helps!

Jash

Former Member
0 Kudos

Hi,

I am also trying to add a partner to Opportunity using BAPI_OPPORTUNITY_CHANGEMULTI. I am passing all the partner details to the BAPI but not able to create one. Did you get any response to your query posted earlier.

Please let me know.

You can also mail me at shyamak@rediffmail.com

Regards,

Shyamak.

Former Member
0 Kudos

Did you ever find a solution to this problem? I am also running into the same issue.