Skip to Content
0
Former Member
Apr 03, 2014 at 08:41 AM

NOT ABLE TO CREATE PARTNER USING BAPI_OPPORTUNITY_CREATEMULTI

33 Views

Hi,

i am trying to create opportunity using bapi BAPI_OPPORTUNITY_CREATEMULTI . using this i am to enter header ,opportunity , organisation ,item and product details, but not able to enter salesprospect and partner detail.

I code is as follows:

FUNCTION ZBAPI_OPPORTUNITY_CREATEMULTI.

*"----------------------------------------------------------------------

*"*"Local Interface:

*" IMPORTING

*" VALUE(P_DESC1) TYPE CRMT_PROCESS_DESCRIPTION OPTIONAL

*" VALUE(P_DESC2) TYPE BAPIBUS20001_OPPORTUNITY-DESCRIPTION_OPP

*" OPTIONAL

*" VALUE(P_SO) TYPE BAPIBUS20001_ORGMAN_INS-SALES_ORG OPTIONAL

*" VALUE(P_OWNER) TYPE BAPIBUS20001_PARTNER_INS-PARTNER_NO

*" OPTIONAL

*" VALUE(P_SP) TYPE BAPIBUS20001_PARTNER_INS-PARTNER_NO OPTIONAL

*" VALUE(P_CP) TYPE BAPIBUS20001_PARTNER_INS-PARTNER_NO OPTIONAL

*" VALUE(P_STA) TYPE BAPIBUS20001_STATUS_INS-STATUS OPTIONAL

*" VALUE(P_DC) TYPE BAPIBUS20001_ORGMAN_INS-DIS_CHANNEL OPTIONAL

*" VALUE(ENDDATE) TYPE BAPIBUS20001_OPPORTUNITY-EXPECT_END

*" OPTIONAL

*" VALUE(PROB) TYPE BAPIBUS20001_OPPORTUNITY-PROBABILITY OPTIONAL

*" VALUE(STATUS) TYPE BAPIBUS20001_STATUS_INS-STATUS OPTIONAL

*" VALUE(IV_PARTNER) TYPE CRMT_PARTNER_NUMBER OPTIONAL

*" TABLES

*" OPPORTUNITY STRUCTURE BAPIBUS20001_OPPORTUNITY OPTIONAL

*" PARTNER STRUCTURE BAPIBUS20001_PARTNER_INS OPTIONAL

*" RETURN STRUCTURE BAPIRET2 OPTIONAL

*"----------------------------------------------------------------------

*----------------------------------------------------------------------*

* INCLUDE CRM_OBJECT_NAMES_CON *

*----------------------------------------------------------------------*

DATA: IT_HEADER TYPE TABLE OF BAPIBUS20001_HEADER_INS WITH HEADER LINE,

IT_OPPORTUNITY TYPE TABLE OF BAPIBUS20001_OPPORTUNITY WITH HEADER LINE,

IT_ORGANISATION TYPE TABLE OF BAPIBUS20001_ORGMAN_INS WITH HEADER LINE,

IT_PARTNER TYPE TABLE OF BAPIBUS20001_PARTNER_INS WITH HEADER LINE,

ITEM TYPE TABLE OF BAPIBUS20001_ITEM WITH HEADER LINE,

PRODUCT TYPE TABLE OF BAPIBUS20001_PRODUCT WITH HEADER LINE,

SCHEDLIN TYPE TABLE OF BAPIBUS20001_SCHEDLIN WITH HEADER LINE,

IT_INPUT_FIELDS TYPE TABLE OF BAPIBUS20001_INPUT_FIELDS WITH HEADER LINE,

IT_RETURN TYPE TABLE OF BAPIRET2 WITH HEADER LINE,

IT_SAVED_PROCESS TYPE TABLE OF BAPIBUS20001_OBJECT_ID WITH HEADER LINE,

IT_STATUS TYPE TABLE OF BAPIBUS20001_STATUS_INS WITH HEADER LINE,

V_BLANK_GUID TYPE BAPIBUS20001_HEADER_INS-GUID VALUE '00000000000000000000000000000000',

"V_BLANK_GUID TYPE BAPIBUS20001_HEADER_INS-GUID VALUE '53331D8796415858E1000000C0A80046',

V_ITEM_GUID TYPE BAPIBUS20001_HEADER_INS-GUID VALUE '00000000000000000000000000000000'.

IT_HEADER-GUID = V_BLANK_GUID.

IT_HEADER-HANDLE = '0000000001'.

" IT_HEADER-PROCESS_TYPE = 'CXOP'.

IT_HEADER-PROCESS_TYPE = 'ZTEN'.

IT_HEADER-BIN_RELATION_TYPE = 'VONA'.

IT_HEADER-DESCR_LANGUAGE = 'E'.

IT_HEADER-LANGU_ISO = 'EN'.

IT_HEADER-DESCRIPTION = P_DESC1. "'Opp for sales of com'.

"IT_HEADER-DESCRIPTION = 'persistent'.

IT_HEADER-POSTING_DATE = SY-DATUM.

IT_HEADER-CREATED_BY = SY-UNAME.

APPEND IT_HEADER.

CLEAR IT_HEADER.

IT_INPUT_FIELDS-REF_HANDLE = 1. "<== Must be set if the others are too. IT_INPUT_FIELDS-REF_GUID = V_BLANK_GUID.

IT_INPUT_FIELDS-OBJECTNAME = 'ORDERADM_H'. IT_INPUT_FIELDS-REF_KIND = ' '. "A <== No effect setting to A or leave blank.

IT_INPUT_FIELDS-LOGICAL_KEY = '0001'.

IT_INPUT_FIELDS-FIELDNAME = 'DESCRIPTION'.

APPEND IT_INPUT_FIELDS.

IT_INPUT_FIELDS-FIELDNAME = 'POSTING_DATE'.

APPEND IT_INPUT_FIELDS.

IT_INPUT_FIELDS-FIELDNAME = 'CREATED_BY'.

APPEND IT_INPUT_FIELDS.

IT_INPUT_FIELDS-FIELDNAME = 'LANGU_ISO'.

APPEND IT_INPUT_FIELDS.

IT_INPUT_FIELDS-FIELDNAME = 'DESCR_LANGUAGE'.

APPEND IT_INPUT_FIELDS.

IT_INPUT_FIELDS-FIELDNAME = 'PROCESS_TYPE'.

APPEND IT_INPUT_FIELDS.

CLEAR IT_INPUT_FIELDS.

IT_OPPORTUNITY-REF_HANDLE = '0000000001'. IT_OPPORTUNITY-REF_GUID = V_BLANK_GUID.

IT_OPPORTUNITY-STARTDATE = SY-DATUM. IT_OPPORTUNITY-FORECAST_REL = 'X'.

IT_OPPORTUNITY-SALESCYCLE = '2'. IT_OPPORTUNITY-TYPE = '0001'.

IT_OPPORTUNITY-STATUS_SINCE = SY-DATUM.

IT_OPPORTUNITY-DESCRIPTION_OPP = P_DESC2.

"IT_OPPORTUNITY-DESCRIPTION_OPP = 'description2'.

IT_OPPORTUNITY-EXPECT_END = ENDDATE .

IT_OPPORTUNITY-PROBABILITY = PROB .

IT_OPPORTUNITY-CURR_PHASE = 'ZD9'.

IT_OPPORTUNITY-EXP_REVENUE = '1700000'.

"IT_OPPORTUNITY-TYPE = 'WON'.

"'Cloned from master 369'.

APPEND IT_OPPORTUNITY.

CLEAR IT_OPPORTUNITY.

CLEAR IT_INPUT_FIELDS. IT_INPUT_FIELDS-REF_HANDLE = 1. "<== Must be set if the others are too.

IT_INPUT_FIELDS-REF_GUID = V_BLANK_GUID. IT_INPUT_FIELDS-OBJECTNAME = 'OPPORT_H'.

IT_INPUT_FIELDS-REF_KIND = 'A'. IT_INPUT_FIELDS-LOGICAL_KEY = '0001'.

IT_INPUT_FIELDS-FIELDNAME = 'STARTDATE'.

APPEND IT_INPUT_FIELDS.

IT_INPUT_FIELDS-FIELDNAME = 'FORECAST_REL'.

APPEND IT_INPUT_FIELDS.

IT_INPUT_FIELDS-FIELDNAME = 'SALESCYCLE'.

APPEND IT_INPUT_FIELDS.

IT_INPUT_FIELDS-FIELDNAME = 'TYPE'.

APPEND IT_INPUT_FIELDS.

IT_INPUT_FIELDS-FIELDNAME = 'STATUS_SINCE'.

APPEND IT_INPUT_FIELDS.

IT_INPUT_FIELDS-FIELDNAME = 'DESCRIPTION_OPP'.

APPEND IT_INPUT_FIELDS.

IT_INPUT_FIELDS-FIELDNAME = 'EXPECT_END'.

APPEND IT_INPUT_FIELDS.

IT_INPUT_FIELDS-FIELDNAME = 'PROBABILITY'.

APPEND IT_INPUT_FIELDS.

IT_INPUT_FIELDS-FIELDNAME = 'CURR_PHASE'.

APPEND IT_INPUT_FIELDS.

IT_INPUT_FIELDS-FIELDNAME = 'EXP_REVENUE'.

APPEND IT_INPUT_FIELDS.

"IT_INPUT_FIELDS-FIELDNAME = 'TYPE'.

"APPEND IT_INPUT_FIELDS.

CLEAR IT_INPUT_FIELDS.

" for organisation......

IT_ORGANISATION-REF_GUID = V_BLANK_GUID.

IT_ORGANISATION-REF_HANDLE = '0000000001'.

IT_ORGANISATION-REF_KIND = 'A'.

IT_ORGANISATION-DIS_CHANNEL = P_DC. "'01'.

"IT_ORGANISATION-SALES_ORG = P_SO. "'O 50000832'.

"IT_ORGANISATION-SALES_ORG_RESP = P_SO. "'O 50000832'.

IT_ORGANISATION-SALES_ORG = 'ZMUM'. "'O 50000832'.

IT_ORGANISATION-SALES_ORG_RESP = 'ZMUM'. "'O 50000832'.

IT_ORGANISATION-SALES_OFFICE = 'MRM1'.

IT_ORGANISATION-SALES_GROUP = 'AMT M1'.

"IT_ORGANISATION-DIS_CHANNEL = '10'.

APPEND IT_ORGANISATION. CLEAR IT_ORGANISATION.

IT_INPUT_FIELDS-REF_HANDLE = 1. "<== Must be set if the others are too.

IT_INPUT_FIELDS-REF_GUID = V_BLANK_GUID.

IT_INPUT_FIELDS-OBJECTNAME = 'ORGMAN'.

IT_INPUT_FIELDS-REF_KIND = 'A'.

IT_INPUT_FIELDS-LOGICAL_KEY = '0001'.

" IT_INPUT_FIELDS-CHANGEABLE = ' '.

IT_INPUT_FIELDS-FIELDNAME = 'DIS_CHANNEL'.

APPEND IT_INPUT_FIELDS.

"IT_INPUT_FIELDS-CHANGEABLE = ' '.

IT_INPUT_FIELDS-FIELDNAME = 'SALES_ORG'.

APPEND IT_INPUT_FIELDS.

IT_INPUT_FIELDS-FIELDNAME = 'SALES_ORG_RESP'.

APPEND IT_INPUT_FIELDS.

IT_INPUT_FIELDS-FIELDNAME = 'SALES_OFFICE'.

APPEND IT_INPUT_FIELDS.

IT_INPUT_FIELDS-FIELDNAME = 'SALES_GROUP'.

APPEND IT_INPUT_FIELDS.

CLEAR IT_INPUT_FIELDS.

" for item level........

V_ITEM_GUID = V_ITEM_GUID.

ITEM-HANDLE = '0000000001'.

ITEM-HEADER_HANDLE = '0000000001'.

ITEM-HEADER = V_BLANK_GUID.

ITEM-PRODUCT = V_BLANK_GUID.

ITEM-ORDERED_PROD = 'BLACK COFFEE'. "IT_ITEM-PRODUCT.

ITEM-DESCRIPTION = 'BLACK COFFEE'. "IT_ITEM-DES1. ITEM-ITM_LANGUAGE = 'EN'. ITEM-LANGU_ISO = 'EN'.

ITEM-NUMBER_INT = '10'. "IT_ITEM-ITEM. ITEM-ITM_TYPE = 'OPPT'. "IT_ITEM-ITEMCATEGORY.

APPEND ITEM.

* CLEAR ITEM.

IT_INPUT_FIELDS-REF_HANDLE = '0000000001'.

IT_INPUT_FIELDS-REF_GUID = V_ITEM_GUID. "00000000000000000000000000000000

IT_INPUT_FIELDS-REF_KIND = ' '.

IT_INPUT_FIELDS-OBJECTNAME = 'ORDERADM_I'.

IT_INPUT_FIELDS-LOGICAL_KEY = ' '.

IT_INPUT_FIELDS-FIELDNAME = 'ORDERED_PROD'.

APPEND IT_INPUT_FIELDS.

IT_INPUT_FIELDS-FIELDNAME = 'MODE'.

APPEND IT_INPUT_FIELDS.

CLEAR IT_INPUT_FIELDS.

CLEAR SCHEDLIN. SCHEDLIN-ITEM_GUID = V_ITEM_GUID. SCHEDLIN-ITEM_HANDLE = '0000000001'.

SCHEDLIN-GUID = V_BLANK_GUID. SCHEDLIN-HANDLE = '0000000001'. SCHEDLIN-QUANTITY = '20'. "IT_ITEM-QUANTITY. "20. APPEND SCHEDLIN. * CLEAR SCHEDLIN.

IT_INPUT_FIELDS-REF_HANDLE = '0000000001'. IT_INPUT_FIELDS-REF_GUID = V_ITEM_GUID. "00000000000000000000000000000000

IT_INPUT_FIELDS-REF_KIND = 'B'. IT_INPUT_FIELDS-OBJECTNAME = 'SCHEDLIN'. IT_INPUT_FIELDS-LOGICAL_KEY = ' '.

IT_INPUT_FIELDS-FIELDNAME = 'LOGICAL_KEY'. APPEND IT_INPUT_FIELDS. IT_INPUT_FIELDS-FIELDNAME = 'QUANTITY'.

APPEND IT_INPUT_FIELDS. CLEAR IT_INPUT_FIELDS.

" for product

PRODUCT-REF_GUID = V_ITEM_GUID.

PRODUCT-REF_HANDLE = '0000000001'.

PRODUCT-PROCESS_QTY_NUM = '1'.

PRODUCT-PROCESS_QTY_DEN = '1'.

PRODUCT-PROCESS_QTY_UNIT = 'EA'. "IT_ITEM-SALESUNIT. "'EA'. PRODUCT-PROCESS_QTY_UNIT_ISO = 'EA'. "IT_ITEM-SALESUNIT. "'EA'. * PRODUCT-BASE_QTY_UNIT = IT_ITEM-SALESUNIT. "'EA'.

"PRODUCT-BASE_QTY_UNIT_ISO = IT_ITEM-SALESUNIT. "'EA'. APPEND PRODUCT. * CLEAR PRODUCT.

CLEAR IT_INPUT_FIELDS.

IT_INPUT_FIELDS-REF_HANDLE = '0000000001'.

IT_INPUT_FIELDS-REF_GUID = V_ITEM_GUID. "DE81864202E8FFF1BBA2001517895069

IT_INPUT_FIELDS-REF_KIND = 'B'.

IT_INPUT_FIELDS-OBJECTNAME = 'PRODUCT_I'.

IT_INPUT_FIELDS-LOGICAL_KEY = ' '.

IT_INPUT_FIELDS-FIELDNAME = 'PROCESS_QTY_UNIT '.

APPEND IT_INPUT_FIELDS.

CLEAR IT_INPUT_FIELDS.

ITEM-HANDLE = '0000000002'.

ITEM-HEADER_HANDLE = '0000000001'.

ITEM-HEADER = V_BLANK_GUID.

ITEM-PRODUCT = V_BLANK_GUID.

ITEM-ORDERED_PROD = 'BATHTUB'. "IT_ITEM-PRODUCT.

ITEM-DESCRIPTION = 'BATHTUB'. "IT_ITEM-DES1.

ITEM-ITM_LANGUAGE = 'EN'.

ITEM-LANGU_ISO = 'EN'.

ITEM-NUMBER_INT = '10'. "IT_ITEM-ITEM.

ITEM-ITM_TYPE = 'OPPT'. "IT_ITEM-ITEMCATEGORY.

APPEND ITEM.

IT_INPUT_FIELDS-REF_HANDLE = '0000000001'.

IT_INPUT_FIELDS-REF_GUID = V_ITEM_GUID. "00000000000000000000000000000000

IT_INPUT_FIELDS-REF_KIND = ' '.

IT_INPUT_FIELDS-OBJECTNAME = 'ORDERADM_I'.

IT_INPUT_FIELDS-LOGICAL_KEY = ' '.

IT_INPUT_FIELDS-FIELDNAME = 'ORDERED_PROD'.

APPEND IT_INPUT_FIELDS.

IT_INPUT_FIELDS-FIELDNAME = 'MODE'.

APPEND IT_INPUT_FIELDS.

CLEAR IT_INPUT_FIELDS.

SCHEDLIN-ITEM_GUID = V_ITEM_GUID.

SCHEDLIN-ITEM_HANDLE = '0000000001'.

SCHEDLIN-GUID = V_BLANK_GUID.

SCHEDLIN-HANDLE = '0000000001'.

SCHEDLIN-QUANTITY = '20'. "IT_ITEM-QUANTITY. "20.

APPEND SCHEDLIN.

IT_INPUT_FIELDS-REF_HANDLE = '0000000001'.

IT_INPUT_FIELDS-REF_GUID = V_ITEM_GUID. "00000000000000000000000000000000

IT_INPUT_FIELDS-REF_KIND = 'B'.

IT_INPUT_FIELDS-OBJECTNAME = 'SCHEDLIN'.

IT_INPUT_FIELDS-LOGICAL_KEY = ' '.

IT_INPUT_FIELDS-FIELDNAME = 'LOGICAL_KEY'.

APPEND IT_INPUT_FIELDS.

IT_INPUT_FIELDS-FIELDNAME = 'QUANTITY'.

APPEND IT_INPUT_FIELDS.

CLEAR IT_INPUT_FIELDS.

PRODUCT-REF_GUID = V_ITEM_GUID.

PRODUCT-REF_HANDLE = '0000000001'.

PRODUCT-PROCESS_QTY_NUM = '1'.

PRODUCT-PROCESS_QTY_DEN = '1'.

PRODUCT-PROCESS_QTY_UNIT = 'EA'. "IT_ITEM-SALESUNIT. "'EA'.

PRODUCT-PROCESS_QTY_UNIT_ISO = 'EA'. "IT_ITEM-SALESUNIT. "'EA'.

"PRODUCT-BASE_QTY_UNIT = IT_ITEM-SALESUNIT. "'EA'.

"PRODUCT-BASE_QTY_UNIT_ISO = IT_ITEM-SALESUNIT. "'EA'.

APPEND PRODUCT.

CLEAR PRODUCT.

CLEAR IT_INPUT_FIELDS.

IT_INPUT_FIELDS-REF_HANDLE = '0000000001'.

IT_INPUT_FIELDS-REF_GUID = V_ITEM_GUID. "DE81864202E8FFF1BBA2001517895069

IT_INPUT_FIELDS-REF_KIND = 'B'.

IT_INPUT_FIELDS-OBJECTNAME = 'PRODUCT_I'.

IT_INPUT_FIELDS-LOGICAL_KEY = ' '.

IT_INPUT_FIELDS-FIELDNAME = 'PROCESS_QTY_UNIT '.

APPEND IT_INPUT_FIELDS.

CLEAR IT_INPUT_FIELDS.

"for status.............

IT_STATUS-REF_GUID = V_ITEM_GUID.

IT_STATUS-REF_HANDLE = '0000000001'.

IT_STATUS-REF_KIND = 'A'.

IT_STATUS-STATUS = 'WON'.

APPEND IT_STATUS.

CLEAR IT_STATUS.

IT_INPUT_FIELDS-REF_HANDLE = '0000000001'.

IT_INPUT_FIELDS-REF_GUID = V_ITEM_GUID. "00000000000000000000000000000000

IT_INPUT_FIELDS-REF_KIND = 'B'.

IT_INPUT_FIELDS-OBJECTNAME = 'STATUS_H'.

IT_INPUT_FIELDS-LOGICAL_KEY = ' '.

IT_INPUT_FIELDS-FIELDNAME = 'STATUS'.

APPEND IT_INPUT_FIELDS.

CLEAR IT_INPUT_FIELDS.

"for partner.......

IT_PARTNER-REF_GUID = V_BLANK_GUID.

IT_PARTNER-REF_HANDLE = '0000000001'.

IT_PARTNER-REF_KIND = 'A'.

IT_PARTNER-partner_fct = '00000021'.

IT_PARTNER-PARTNER_NO = '0000900125'.

IT_PARTNER-ref_partner_handle = '0000'.

IT_PARTNER-NO_TYPE = 'BP'.

IT_PARTNER-DISPLAY_TYPE = 'BP'.

IT_PARTNER-KIND_OF_ENTRY = 'C'.

APPEND IT_PARTNER.

CLEAR IT_PARTNER.

CLEAR IT_INPUT_FIELDS. IT_INPUT_FIELDS-REF_HANDLE = 1. "<== Must be set if the others are too.

IT_INPUT_FIELDS-REF_GUID = V_BLANK_GUID.

IT_INPUT_FIELDS-OBJECTNAME = 'PARTNER'.

IT_INPUT_FIELDS-REF_KIND = 'A'.

IT_INPUT_FIELDS-LOGICAL_KEY = '0000'.

IT_INPUT_FIELDS-FIELDNAME = 'partner_fct'.

APPEND IT_INPUT_FIELDS.

IT_INPUT_FIELDS-FIELDNAME = 'PARTNER_NO'.

APPEND IT_INPUT_FIELDS.

IT_INPUT_FIELDS-FIELDNAME = 'DISPLAY_TYPE'.

APPEND IT_INPUT_FIELDS.

IT_INPUT_FIELDS-FIELDNAME = 'NO_TYPE'.

APPEND IT_INPUT_FIELDS.

IT_INPUT_FIELDS-FIELDNAME = 'KIND_OF_ENTRY'.

APPEND IT_INPUT_FIELDS.

IT_INPUT_FIELDS-FIELDNAME = 'ref_partner_handle'.

APPEND IT_INPUT_FIELDS.

CLEAR IT_INPUT_FIELDS.

CALL FUNCTION 'BAPI_OPPORTUNITY_CREATEMULTI'

EXPORTING

TESTRUN = ' '

TABLES

HEADER = it_header

OPPORTUNITY = IT_OPPORTUNITY

ORGANISATION = IT_ORGANISATION

PARTNER = IT_PARTNER

* TEXT =

PRODUCT = PRODUCT

* PRICING =

INPUT_FIELDS = IT_INPUT_FIELDS

* CREATED_PROCESS =

" RETURN = IT_RETURN

RETURN = RETURN

SAVED_PROCESS = IT_SAVED_PROCESS

ITEM = ITEM

SCHEDULELINE = SCHEDLIN

* APPOINTMENT =

* SERVICE_OS =

STATUS = IT_STATUS

* CUSTOMER_HEAD =

* CUSTOMER_ITEM =

* DOCUMENT_FLOW =

* PRICING_ITEM =

* CONFIG_CFG =

* CONFIG_BLB =

* CONFIG_INS =

* CONFIG_PRT =

* CONFIG_VAL =

* CONFIG_VK =

* CONFIG_REF =

* CONDITION_CREATE =

* EXTENSIONIN =

.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

* EXPORTING

* WAIT =

* IMPORTING

* RETURN =

.

LOOP AT IT_RETURN.

WRITE:/ IT_RETURN-MESSAGE.

ENDLOOP.

LOOP AT IT_SAVED_PROCESS.

WRITE:/ IT_SAVED_PROCESS.

ENDLOOP.

OPPORTUNITY[] = IT_OPPORTUNITY[].

PARTNER[] = IT_PARTNER[].

ENDFUNCTION.