cancel
Showing results for 
Search instead for 
Did you mean: 

Sales AGENT determination Badi in Service Order

Former Member
0 Kudos

Hi Experts,

In web UI service order details->General Data when sold to party is entered and user press enter button

In parties involved list Sales agent should display.

I am currently using CRM_PARTNER_READ_OW to find partners

and populate sales agent in sales order at run time I am using

CRM_PARTNER_MAINTAIN_SINGLE_OW however, I am able hold sales order data, sales agent is not coming in Web UI.

Please advice. How to populate sales agent in parties involved tab.

Thanks

Anee

Accepted Solutions (0)

Answers (2)

Answers (2)

valentin_catalin2
Active Participant
0 Kudos

Hi Anne,

For this I'm using the COM_PARTNER_BADI badi - method DETERMINATION_ADD_IN_1.

For the system to run this badi you have to maintain an entry in the allocated access sequence.

So, in SPRO-> "Customer Relationship Management" -> "Basic Settings" -> "Partner processing" in the "Define Partner Determination Procedure" for your document procedure and your partner function you have assigned an Access Sequence.

Get this access sequence and go to:

SPRO-> "Customer Relationship Management" -> "Basic Settings" -> "Partner processing -> "Define Access Sequence"

here, for your access sequence you need a step in which field Source should be "COM_PARTNER_X". Doing this setting you will call the COM_PARTNER_BADI-DETERMINATION_ADD_IN_1.

In this badi you have internal table it_existing_partners with already determined partners.

You have to fill the et_found_partners with resulting partners.

Code sample (just a part of it, internal table lt_partners is already filled with some identified partners based on a particular case...):

loop at lt_partners into ls_partners.
  ls_found_partners-partner_number = ls_partners-partner.
  ls_found_partners-no_type        = 'BP'.
  ls_found_partners-display_type   = 'BP'.
  append ls_found_partners to et_found_partners.
  clear ls_found_partners.
endloop.

Former Member
0 Kudos

I have resolved this issue by calling FM CRM_PARTNER_MAINTAIN_SINGLE_OW.

Thanks

Former Member
0 Kudos

I have resolved this issue by calling FM CRM_PARTNER_MAINTAIN_SINGLE_OW.

Thanks

prasenjit_sharma
Active Contributor
0 Kudos

You need to maintain the INPUT_FIELDS table to be able to update the partner in the transaction.

Regards

Prasenjit

Former Member
0 Kudos

Hi,

I have added input fields, here is my coding pls suggest possible solution.

 fill the communication structure for the partner
*              REFRESH LT_PARTNER_COM.
*              REFRESH LT_INPUT_FIELDS.
*              clear: ls_partner_com.
**Filling of exporting parameter
*              LS_PARTNER_COM-REF_GUID    = lw_guid.
*              LS_PARTNER_COM-REF_HANDLE = '00000000000'.
*              LS_PARTNER_COM-REF_KIND    = 'A'.
*              LS_PARTNER_COM-REF_PARTNER_HANDLE = '0000'.
*              ls_partner_com-PARTNER_GUID = ls_but000-PARTNER_GUID. " Sales Agent Guid
*              ls_partner_com-partner_no   = ls_but000-PARTNER. " Sales Agent No
*              LS_PARTNER_COM-KIND_OF_ENTRY = 'C'.
*              ls_partner_com-partner_fct  = 'Y0000012'." Sales Partner
*              LS_PARTNER_COM-DISPLAY_TYPE = 'BP'.
*              ls_partner_com-no_type      = 'BP'.
*              LS_PARTNER_COM-MAINPARTNER = 'X'.
*              INSERT LS_PARTNER_COM INTO TABLE LT_PARTNER_COM.
*
*              CLEAR ls_input_fields.
**filling changing parameters
*
*              ls_input_field_names-fieldname =  'PARTNER_NO'.
*              INSERT ls_input_field_names INTO TABLE lt_input_field_names.
*              ls_input_field_names-fieldname = 'NO_TYPE'.
*              INSERT ls_input_field_names INTO TABLE lt_input_field_names.
*              ls_input_field_names-fieldname = 'DISPLAY_TYPE'.
*              INSERT ls_input_field_names INTO TABLE lt_input_field_names.
*              ls_input_field_names-fieldname = 'KIND_OF_ENTRY'.
*              INSERT ls_input_field_names INTO TABLE lt_input_field_names.
*
*              move lw_guid         to  ls_input_fields-ref_guid.
*              move 'PARTNER'           to ls_input_fields-objectname.
*              move lt_input_field_names   to ls_input_fields-field_names.
*              insert ls_input_fields into table lt_input_fields.
*            

*
*              if not lt_partner_com is initial.
*                CALL FUNCTION 'CRM_PARTNER_MAINTAIN_MULTI_OW'
*                  EXPORTING
*                    IT_PARTNER_COM  = lt_partner_com
*                    IV_REF_GUID     = lw_guid
*                    IV_REF_KIND     = 'A'
*                  CHANGING
*                    CT_INPUT_FIELDS = lt_input_fields
*                  EXCEPTIONS
*                    ERROR_OCCURRED  = 1
*                    OTHERS          = 2.
*
*                IF SY-SUBRC = 0.
*                  commit work.
*                ENDIF. 

Thanks

prasenjit_sharma
Active Contributor
0 Kudos

We do not use the commit statements in BADIs. Try removing that. Also try to find out if there are any error messages that are raised.

Regards

Prasenjit

Former Member
0 Kudos

Hi,

I m successfully able to execute FM CRM_PARTNER_MAINTAIN_MULTI_OW.

However in result page Sales agent partner no does not populate once User press enter after putting sold to party.

Pls suggest

Former Member
0 Kudos

Hi,

Still it does not work. somebody respond here ?

prasenjit_sharma
Active Contributor
0 Kudos

It still did not work after removing the commit? Can you debug into the FM CRM_PARTNER_MAINTAIN_MULTI_OW and try to find out where it fails? The code actually looks correct. Also check if the inside the document if there is any error message raised, and also check if the partner can be added to the document manually i.e. if some config is preventing it.

Also let me know which BADI you are using for this purpose? Since you are using web ui you may also be able to use the do_prepare_output method to add the partner to the UI screen.

Regards

Prasenjit

Former Member
0 Kudos

Hi Experts,

I am trying to pick sales agent partner from crmd_order, once sold to party is entered, and press clickd. However

fm CRM_PARTNER_MAINTAIN_SINGLE_OW execute successfully not populating partner in crmd_order.

Please help.

Thanks

data: lw_guid TYPE crmt_object_guid.

DATA:

LW_PARTNER_WRK TYPE CRMT_PARTNER_EXTERNAL_WRK,

lt_current_partner_attributes TYPE crmt_partner_attribute_com_tab.

" lt_input_field_names TYPE crmt_input_field_names_tab.

data: lt_partner type CRMT_PARTNER_COMT.

"ls_input_field_names TYPE crmt_input_field_names.

data: ls_but000 type but000,

lt_adrc type standard table of adrc,

ls_adrc type adrc,

ls_crm_sales type zcrmsales_agent,

lv_partner type BU_PARTNER.

DATA: LT_PARTNER_COM TYPE CRMT_PARTNER_COMT,

lt_input_fields type CRMT_INPUT_FIELD_TAB,

LS_LOGIC_KEY TYPE CRMT_PARTNER_LOGIC_PARTNER_KEY,

LT_PARTNER_WRK TYPE CRMT_PARTNER_EXTERNAL_WRKT,

LS_PARTNER_WRK TYPE CRMT_PARTNER_EXTERNAL_WRK,

LS_PARTNER_COM TYPE CRMT_PARTNER_COM,

ls_input_fields type CRMT_INPUT_FIELD,

LS_FIELD_NAMES TYPE CRMT_INPUT_FIELD_NAMES,

lv_subrc type sy-subrc.

data: lv_handle type crmt_handle,

lv_ref_handle type numc4.

clear: LW_PARTNER_WRK,ls_partner_wrk.

refresh: LT_PARTNER_WRK.

clear: lw_guid.

lw_guid = is_partner_control-document_id.

*

CALL FUNCTION 'CRM_PARTNER_READ_OW'

EXPORTING

IV_REF_GUID = lw_guid

IV_REF_KIND = 'A'

  • IV_PARTNER_FCT =

  • IV_PARTNER_PFT =

  • IV_PFT_SUBTYPE =

  • IV_MAINPARTNER_ONLY = ' '

  • IV_GET_BP_NUMBERS = ' '

  • IV_REFRESH_ADDRESS_REF = ' '

IMPORTING

ET_PARTNER_WRK = LT_PARTNER_WRK

ES_PARTNER_WRK = LS_PARTNER_WRK

  • ES_MORE_THAN_ONE_MAINPARTNER =

EXCEPTIONS

ERROR_OCCURRED = 1

PARAMETER_ERROR = 2

ENTRY_DOES_NOT_EXIST = 3

OTHERS = 4

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

if not lt_partner_wrk is initial.

*sales agent is deternmined

read table lt_partner_wrk into LW_PARTNER_WRK with key PARTNER_FCT = 'Y0000012'.

if ( sy-subrc NE 0 ).

*Sold to party

read table lt_partner_wrk into LW_PARTNER_WRK with key PARTNER_FCT = '00000001'.

if sy-subrc = 0.

select single * from adrc into ls_adrc where ADDRNUMBER = LW_PARTNER_WRK-addr_nr.

if sy-subrc = 0.

select single * from zcrmsales_agent into ls_crm_sales where PSTLZ = ls_adrc-POST_CODE1.

select single * from but000 into ls_but000 where PERNO = ls_crm_sales-PERNR.

if sy-subrc = 0.

daTA: ls_input_field_names TYPE crmt_input_field_names,

lt_input_field_names TYPE crmt_input_field_names_tab.

REFRESH lt_input_field_names.

CLEAR ls_partner_com.

ls_partner_com-ref_guid = LW_GUID.

ls_partner_com-ref_kind = 'B'.

ls_partner_com-partner_no = LS_BUT000-PARTNER.

ls_partner_com-partner_fct = 'Y0000012'.

ls_partner_com-display_type = 'BP'.

ls_partner_com-no_type = 'BP'.

"ls_partner_com-kind_of_entry = 'A'.

"ls_partner_com-mainpartner = 'X'.

ls_input_field_names-fieldname = 'PARTNER_NO'.

INSERT ls_input_field_names INTO TABLE lt_input_field_names.

ls_input_field_names-fieldname = 'PARTNER_FCT'.

INSERT ls_input_field_names INTO TABLE lt_input_field_names.

ls_input_field_names-fieldname = 'DISPLAY_TYPE'.

INSERT ls_input_field_names INTO TABLE lt_input_field_names.

ls_input_field_names-fieldname = 'NO_TYPE'.

INSERT ls_input_field_names INTO TABLE lt_input_field_names.

  • ls_input_field_names-fieldname = 'KIND_OF_ENTRY'.

  • INSERT ls_input_field_names INTO TABLE lt_input_field_names.

  • ls_input_field_names-fieldname = 'MAINPARTNER'.

  • INSERT ls_input_field_names INTO TABLE lt_input_field_names.

CALL FUNCTION 'CRM_PARTNER_MAINTAIN_SINGLE_OW'

EXPORTING

IV_REF_GUID = lw_guid

IV_REF_KIND = 'A'

IS_PARTNER_COM = ls_partner_com

  • IV_POPULATE_MODE = ' '

  • IV_CHECK_PARTNER_ONLY = ' '

  • IS_PARTNER_CONTROL =

  • IS_COM_STRUCTURE =

  • IV_EXTERNAL_CALL = FALSE

  • IMPORTING

  • EV_CREATED_PARTNERSET_GUID =

CHANGING

CT_INPUT_FIELD_NAMES = lt_input_field_names

  • CT_PARTNER_ATTRIBUTES_COM =

EXCEPTIONS

ERROR_OCCURRED = 1

OTHERS = 2.

Former Member
0 Kudos

Hi,

I am using IF_EX_COM_PARTNER_BADI~COM_PARTNER_MERGE method.