Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Lead Creation Error thro ABAP Code

Former Member
0 Likes
469

Hi CRM ABAP Experts,

I have written a code for lead creation by referring SDN Code. when i execute code , lead is created and transaction get saved in to system. but atlast one error comes. plz help me. when i pass testrun = 'X' then i am not getting error but lead trasaction is not created. and when i passedtestrun = blank then lead is created but gives below error.Below error i am facing.

Short text

An exception occurred that was not caught.

What happened?

The exception 'CX_OS_OBJECT_NOT_FOUND' was raised, but it was not caught

anywhere along

the call hierarchy.

Since exceptions represent error situations and this error was not

adequately responded to, the running ABAP program

'CL_METHODCALL_PPF=============CP' has to be

terminated.

Error analysis

An exception occurred that is explained in detail below.

The exception, which is assigned to class 'CX_OS_OBJECT_NOT_FOUND', was not

caught in

procedure "IF_MEDIUM_PPF~EXECUTE" "(METHOD)", nor was it propagated by a

RAISING clause.

Since the caller of the procedure could not have anticipated that the

exception would occur, the current program is terminated.

The reason for the exception is:

Could not find the referenced object with the OID

"00000000000000000000000000000000" (instance GUID) and

**************************************************************************************************

My Code is as follows

DATA: it_HEADER type standard table of BAPIBUS2000108_HEADER_INS.

DATA: wa_HEADER like line of it_HEADER.

DATA:it_ORGANISATION TYPE STANDARD TABLE OF BAPIBUS20001_ORGMAN_INS,

wa_ORGANISATION LIKE LINE OF it_ORGANISATION.

DATA: it_partner type table of BAPIBUS20001_PARTNER_INS.

DATA: wa_partner like line of it_partner.

DATA:HEADERX TYPE STANDARD TABLE OF BAPIBUS2000108_HEADER_INSX,

st_headerx TYPE bapibus2000108_header_insx,

PARTNERX TYPE STANDARD TABLE OF BAPIBUS20001_PARTNER_INSX,

st_partnerx TYPE bapibus20001_partner_insx,

i_orgx TYPE STANDARD TABLE OF BAPIBUS20001_ORGMAN_INSX,

st_orgx TYPE bapibus20001_orgman_insx,

i_save TYPE TABLE OF bapibus20001_object_id,

i_return TYPE TABLE OF bapiret2,

DATEX TYPE STANDARD TABLE OF BAPIBUS20001_APPOINTMENT_INSX.

DATA:i_itemx TYPE TABLE OF bapibus20001_item_insx,

i_item TYPE TABLE OF bapibus20001_item,

st_itemx TYPE bapibus20001_item_insx,

st_item TYPE bapibus20001_item,

i_schedulex TYPE TABLE OF bapibus20001_schedlinx,

i_schedule TYPE TABLE OF bapibus20001_schedlin,

st_schedulex TYPE bapibus20001_schedlinx,

st_schedule TYPE bapibus20001_schedlin.

DATA :c_x TYPE char01 VALUE 'X',

TESTRUN type BAPIFLAG-BAPIFLAG.

data i_input TYPE TABLE OF bapibus20001_input_fields.

data st_input TYPE bapibus20001_input_fields.

DATA:ORG_NO TYPE OBJEKTID,

PARTNER_NO1 TYPE BU_PARTNER,

CUST_BP TYPE BU_PARTNER,

SALE_OFF TYPE CRMT_SALES_ORG_RESP.

DATA:msg TYPE ZRETURN_ERROR.

DATA:w_item TYPE CRMT_ITEM_NO,

w_handle TYPE CRMT_HANDLE.

CLEAR:st_headerx.

st_headerx-handle = c_x.

st_headerx-process_type = c_x.

st_headerx-DESCR_LANGUAGE = c_x.

st_headerx-POSTING_DATE = c_x.

st_headerx-lead_type = c_x.

st_headerx-importance = c_x.

st_headerx-source = c_x.

APPEND st_headerx TO headerx.

CLEAR wa_header.

wa_HEADER-HANDLE = '0000000001'.

wa_HEADER-PROCESS_TYPE = 'ZCDL'.

wa_HEADER-DESCR_LANGUAGE = 'EN'.

wa_HEADER-POSTING_DATE = '20100603'.

wa_HEADER-IMPORTANCE = '5'.

wa_HEADER-SOURCE = '019'.

wa_HEADER-LEAD_TYPE = '0016'.

APPEND WA_HEADER TO IT_HEADER.

CLEAR:st_input.

st_input-ref_handle = '0000000001'.

st_input-ref_kind = 'A'.

st_input-objectname = 'ORDERADM_H'.

st_input-fieldname = 'PROCESS_TYPE'.

APPEND st_input TO i_input.

CLEAR st_input.

st_input-ref_handle = '0000000001'.

st_input-ref_kind = 'A'.

st_input-objectname = 'LEAD_H'.

st_input-fieldname = 'SOURCE'.

APPEND st_input TO i_input.

st_input-fieldname = 'IMPORTANCE'.

APPEND st_input TO i_input.

st_input-fieldname = 'LEAD_TYPE'.

APPEND st_input TO i_input.

*To fill the Organization X Structure

CLEAR:st_orgx.

st_orgx-ref_handle = c_x.

st_orgx-ref_kind = c_x.

st_orgx-dis_channel = c_x.

st_orgx-sales_org_resp = c_x.

APPEND st_orgx TO i_orgx.

*To fill the Organization Structure

CLEAR:wa_ORGANISATION.

wa_ORGANISATION-ref_handle = '0000000001'.

wa_ORGANISATION-ref_kind = 'A'.

wa_ORGANISATION-dis_channel = '01'.

wa_ORGANISATION-sales_org_resp = 'O 50000041'.

APPEND wa_ORGANISATION TO it_ORGANISATION.

*Fill input fields for Organization data

CLEAR st_input.

st_input-ref_handle = '0000000001'.

st_input-ref_kind = 'A'.

st_input-objectname = 'ORGMAN'.

st_input-fieldname = 'DIS_CHANNEL'.

APPEND st_input TO i_input.

st_input-fieldname = 'SALES_ORG'.

APPEND st_input TO i_input.

*To fill the Partner X Structure

st_partnerx-ref_handle = c_x.

st_partnerx-ref_kind = c_x.

st_partnerx-ref_partner_handle = c_x.

st_partnerx-kind_of_entry = c_x.

st_partnerx-partner_no = c_x.

st_partnerx-partner_fct = c_x.

st_partnerx-no_type = c_x.

st_partnerx-display_type = c_x.

st_partnerx-MAINPARTNER = c_x.

APPEND st_partnerx TO partnerx.

*To fill the Partner Structure

*CLEAR:wa_partner.

*

*wa_partner-ref_handle = '0000000001'.

*wa_partner-ref_kind = 'A'.

*wa_partner-ref_partner_handle = '0001'.

*wa_partner-kind_of_entry = 'C'. """""""A

*wa_partner-partner_no = '62563'.

*wa_partner-partner_fct = '00000022'.

*wa_partner-no_type = 'BP'.

*wa_partner-display_type = 'BP'.

*wa_partner-MAINPARTNER = 'X'.

*APPEND wa_partner TO it_partner.

CLEAR:wa_partner.

wa_partner-ref_handle = '0000000001'.

wa_partner-ref_kind = 'A'.

wa_partner-ref_partner_handle = '0001'.

wa_partner-kind_of_entry = 'C'. """""""A

wa_partner-partner_no = '62564'.

wa_partner-partner_fct = '00000021'.

wa_partner-no_type = 'BP'.

wa_partner-display_type = 'BP'.

wa_partner-MAINPARTNER = 'X'.

APPEND wa_partner TO it_partner.

CLEAR:wa_partner.

wa_partner-ref_handle = '0000000001'.

wa_partner-ref_kind = 'A'.

wa_partner-ref_partner_handle = '0001'.

wa_partner-kind_of_entry = 'C'. """"""""A

wa_partner-partner_no = '71024'.

wa_partner-partner_fct = 'ZCDLSM'.

wa_partner-no_type = 'BP'.

wa_partner-display_type = 'BP'.

wa_partner-MAINPARTNER = 'X'.

APPEND wa_partner TO it_partner.

*Fill input fields for Partner data

CLEAR st_input.

st_input-ref_handle = '0000000001'.

st_input-ref_kind = 'A'.

st_input-objectname = 'PARTNER'.

*st_input-logical_key = w_logickey_partner.

st_input-fieldname = 'DISPLAY_TYPE'.

APPEND st_input TO i_input.

st_input-fieldname = 'KIND_OF_ENTRY'.

APPEND st_input TO i_input.

st_input-fieldname = 'NO_TYPE'.

APPEND st_input TO i_input.

st_input-fieldname = 'PARTNER_FCT'.

APPEND st_input TO i_input.

st_input-fieldname = 'PARTNER_NO'.

APPEND st_input TO i_input.

st_input-fieldname = 'MAINPARTNER'.

APPEND st_input TO i_input.

*To fill the Item X Structure

st_itemx-handle = c_x.

st_itemx-header_handle = c_x.

st_itemx-ordered_prod = c_x.

st_itemx-number_int = c_x.

st_item-mode = c_x.

APPEND st_itemx TO i_itemx.

*To fill Schedule line X Structure

st_schedulex-item_handle = c_x.

st_schedulex-handle = c_x.

st_schedulex-quantity = c_x.

st_schedulex-logical_key = c_x.

APPEND st_schedulex TO i_schedulex.

CLEAR: w_item, w_handle.

w_item = '0000000010'.

*To fill the Item Structure

w_handle = 1.

st_item-handle = w_handle.

st_item-header_handle = '0000000001'.

st_item-ordered_prod = '400000120' .

st_item-number_int = w_item.

st_item-mode = 'A'.

APPEND st_item TO i_item.

*To fill Schedule line Structure

DATA:qty TYPE CRMT_SCHEDLIN_QUAN VALUE '1'.

st_schedule-item_handle = w_handle.

st_schedule-quantity = qty.

APPEND st_schedule TO i_schedule.

*Fill input fields for Item data

CLEAR st_input.

st_input-ref_handle = w_handle.

st_input-ref_kind = 'B'.

st_input-objectname = 'ORDERADM_I'.

st_input-fieldname = 'MODE'.

APPEND st_input TO i_input.

st_input-fieldname = 'NUMBER_INT'.

APPEND st_input TO i_input.

st_input-fieldname = 'ORDERED_PROD'.

APPEND st_input TO i_input.

  • Fill input fields for schedule line data

CLEAR st_input.

st_input-ref_handle = w_handle.

st_input-ref_kind = 'B'.

st_input-objectname = 'SCHEDLIN'.

st_input-fieldname = 'LOGICAL_KEY'.

APPEND st_input TO i_input.

st_input-fieldname = 'QUANTITY'.

APPEND st_input TO i_input.

CLEAR testrun.

*Testrun = 'X'.

CALL FUNCTION 'BAPI_LEAD_CREATEMULTI'

EXPORTING

TESTRUN = Testrun

TABLES

HEADERX = headerx

PARTNERX = partnerx

ORGANISATIONX = i_orgx

itemx = i_itemx

sched_linx = i_schedulex

HEADER = it_header

ORGANISATION = it_ORGANISATION

PARTNER = it_partner

item = i_item

SCHED_LIN = i_schedule

INPUT_FIELDS = i_input

RETURN = i_return

SAVED_PROCESS = i_save .

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

WAIT = 'x'.

IF SY-SUBRC = 0.

IF sy-subrc = 0.

ENDIF.

ENDIF.

2 REPLIES 2
Read only

Former Member
0 Likes
414

Hi,

Look at the post. No one will be able to understand anything out of this. Kindly Repaste code using markup.

Regards,

Harsh.

Edited by: Harsh Saxena on Aug 28, 2010 11:40 AM

Read only

0 Likes
414

hi Harsh,

Thnx,

Edited by: abhiiesh mahaajan on Aug 28, 2010 10:54 AM