cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to Add Partner(ship to party)

AB069
Active Participant
0 Kudos

Hi Frds,

I am trying to add partner( Ship to party)  at run time. Below is the code.  At the end of FM Sy-subrc is 0. But when i check UI partner is adding.

Code is in CRM_ORDERADM_H_BADI.

CALL FUNCTION 'CRM_PARTNER_READ_OW'
EXPORTING
iv_ref_guid
= IS_ORDERADM_H_WRK-GUID
iv_ref_kind
= 'A'
IMPORTING
et_partner_wrk
= lt_partner .

READ TABLE lt_partner INTO lS_partner WITH KEY REF_PARTNER_FCT = '00000001'.            "Reading sold to party
if sy-subrc = 0.
data: lt_partner_com TYPE crmt_partner_comt,
ls_partner_com
TYPE crmt_partner_com,
lt_input_field_names
TYPE crmt_input_field_names_tab,
ls_field_names
TYPE crmt_input_field_names,
lt_input_fields
TYPE crmt_input_field_tab,
ls_input_fields
TYPE crmt_input_field.

MOVE-CORRESPONDING ls_partner TO ls_partner_com.
ls_partner_com
-partner_fct = '00000002'.                   "ship to party
ls_partner_com
-ref_partner_fct = '00000002'.
ls_partner_com
-ref_partner_handle = '0001'.
ls_partner_com
-ref_display_type = space.
ls_partner_com
-kind_of_entry = 'B'.
ls_partner_com
-partner_no = ls_partner-partner_no.
ls_partner_com
-partner_guid = IS_ORDERADM_H_WRK-GUID.
ls_partner_com
-no_type = 'BP'.
ls_partner_com
-display_type = 'BP'.
INSERT ls_partner_com INTO TABLE lt_partner_com.

ls_field_names
-fieldname = 'PARTNER_FCT'.
INSERT ls_field_names INTO TABLE lt_input_field_names.
ls_field_names
-fieldname = 'DISPLAY_TYPE'.
INSERT ls_field_names INTO TABLE lt_input_field_names.
ls_field_names
-fieldname = 'NO_TYPE'.
INSERT ls_field_names INTO TABLE lt_input_field_names.
ls_field_names
-fieldname = 'KIND_OF_ENTRY'.
INSERT ls_field_names INTO TABLE lt_input_field_names.
ls_field_names
-fieldname = 'PARTNER_NO'.
INSERT ls_field_names INTO TABLE lt_input_field_names.
ls_field_names
-fieldname = 'ADDR_NR'.
INSERT ls_field_names INTO TABLE lt_input_field_names.

ls_input_fields
-field_names  lt_input_field_names.
ls_input_fields
-ref_guid        IS_ORDERADM_H_WRK-GUID.
ls_input_fields
-ref_kind        'A'.
ls_input_fields
-objectname   'PARTNER'.
CONCATENATE '000000000002' ls_partner-partner_no ' BPBP'
INTO ls_input_fields-logical_key.

INSERT ls_input_fields INTO TABLE lt_input_fields.

CALL FUNCTION 'CRM_PARTNER_MAINTAIN_MULTI_OW'
EXPORTING
it_partner_com
= lt_partner_com
iv_ref_guid
= IS_ORDERADM_H_WRK-GUID
iv_ref_kind
= 'A'
IMPORTING
et_created_partnerset_guid
= lt_return
CHANGING
ct_input_fields
= lt_input_fields
EXCEPTIONS
error_occurred
= 1
OTHERS = 2.

endif.

Please take a look and suggest me.

Thanks

Imran

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Imran ,

Take an order and try changing its ship-to-party from T-code CRMD_ORDER putting a break point at FM crm_order_maintain , then check the values being passed to the parameters lt_partner and lt_input_fields , use the same values in your code , it should work then .

Thanks ,

Vaibhav

Answers (5)

Answers (5)

AB069
Active Participant
0 Kudos

Hi Deepika and All,

Thanks for all your explainsation. I understood, and successfully adding the partner.

One point i stuck . Actually. for particular partner i have to maitain NAME and Street field to be blank and rest all address field should be same.

I added the Partner but i coundnt structure which show all the partner address so that i will make blank those field and pass the same structure.

Any suggestion.

Thanks

Imran

AB069
Active Participant
0 Kudos

Hi JP,

Both GUID is same. So it wont effect.

I tried with BOL prog also but it getting behaving very unexpected.

Act i have both field Ship to party and Sold to party at Header level with address field. when Sold to party is givien an pop up open which is use to select the Shipto party. Now here is the tricky part, if user cancel popup then sold to party make as defaut to ship to party.

Note: this popup is customise by functional so we cannot deal with it.

I tried with BOl Pro.

At do_prepare_output. I add ship to party entity in PARTNER_SET collection . Initially it filled both ship to party and sold to party but on second run sold to party get empty.

Thanks

Imran 

kutjohn
Active Participant
0 Kudos

Can you share your bol program code?

Might be able to find out if it had any issue

Regards JP

kutjohn
Active Participant
0 Kudos

Hi Imran,

I guess you are passing a wrong GUID.

ls_partner_com-partner_guid = IS_ORDERADM_H_WRK-GUID.


I guess this should be the partner guid and not the orderadm_h guid.

And if this is also not working try using BOL programming.



Regards JP

AB069
Active Participant
0 Kudos

Hi Gaurav,

I added but found no change. I wonder what going wrong even though no error coming.

I have a doubt, I created a logical key shown below. Is this the right way. pls check

CONCATENATE '000000000002'    ls_partner-partner_no   '         BPBP'
INTO ls_input_fields-logical_key.

First time am doing this object . I found whole code on sdn. not sure its right or wrong.

Thanks

Imran


kumar5
Active Contributor
0 Kudos

Hi ,

Put a break-point in FM  'CRM_PARTNER_MAINTAIN_MULTI_OW' and try to add Ship-To-Party under TC 'CRMD_ORDER' and check the value of the logical key which system is passing to the FM and try to use the same.

Thanks

Kumar

AB069
Active Participant
0 Kudos

Hi Kumar,

Thanks Kumar. your guidline works.

One doubt, where is the difference make when we need to delete or add or modify partner. i have seen lots of post all are looking same. Either for delete or for add.

And for others : To add partner only below field have to maintain in FM importing it_partner_com .

clear ls_partner_com.

ref_guid ,  ref_kind,   ref_partner_handle, kind_of_entry, parrtner_fct,  partner_no, display_type, no_type'.

Thanks

Imran

kumar5
Active Contributor
0 Kudos

Hi Imran,

I could not check as I do not have System with me.

But I remember in FM 'CRM_ORDER_MAINTAIN' we have the Variable named as MODE with data element 'CRMT_MODE'  which decides the creation deletion and change for the Order.

Hope it helps.

Thanks

Kumar

AB069
Active Participant
0 Kudos


Hi Gaurav,

I didnt found as such varible in the FM.

Thanks

Imran

deepika_chandrasekar
Active Contributor
0 Kudos

Hi Imran,

To delete you need to pass logical key in partner . but for add you no need to to pass logical key.

To delete you need to use logical key from partner structure this code

    LOOP AT lt_partner_doc INTO ls_partner_doc WHERE partner_fct NE 'partnerfunctionvalue'.

        CLEAR ls_logkey.

        MOVE-CORRESPONDING ls_partner_doc TO ls_logkey.

       MOVE-CORRESPONDING ls_logkey TO ls_partner_com.

        ls_partner_com-ref_guid   = iv_header_guid.

        ls_partner_com-ref_kind   = 'A'.

        ls_input_field-logical_key  = ls_logkey.

        INSERT ls_input_field INTO TABLE lt_input_fields1.

        APPEND ls_partner_com TO lt_partner_fct_del.

        CLEAR: ls_partner_doc,ls_partner_com,ls_logkey.

      ENDLOOP.

To modify you need to delete current partner line and then you need to add new partner and you no need to fill logical key from partner structure..

      LOOP AT lt_partner INTO ls_partner WHERE partner_fct NE 'partnerfunctionvalue'.

        CLEAR ls_partner_fct.

        ls_partner_fct-ref_guid   = iv_header_guid.

        ls_partner_fct-ref_kind   = 'A'.

        ls_partner_fct-ref_partner_handle   = '0001'.

        ls_partner_fct-partner_fct = ls_partner-partner_fct.

        ls_partner_fct-partner_no = ls_partner-partner_no.

        ls_partner_fct-display_type = 'BP'.

        ls_partner_fct-no_type = 'BP'.

        ls_partner_fct-kind_of_entry = 'C'.

        APPEND ls_partner_fct TO lt_partner_fct.

        CLEAR: ls_partner,ls_partner_fct.

      ENDLOOP.

Regards,

Deepika.

kumar5
Active Contributor
0 Kudos

Hi Imran,

Please check by adding below lines to your code

ls_partner_com-ref_partner_handle = '0002'.

ls_partner_com-ref_display_type = space.

ls_partner_com-REF_KIND  = 'A'

ls_partner_com-kind_of_entry = 'C'.

Kind_of_entry should be 'C' if you are adding Partners manually.

Thanks

Kumar.