Skip to Content
0
Former Member
Mar 12, 2007 at 12:50 PM

**************LEAD CREATION****************

73 Views

Hi all,

I have tried creating a LEAD. This is the following code that i have written:

*&----


**& Report ZTESTS

**&

*&----


**&

**&

*&----


*

REPORT ZTESTS.

data:

ITAB_CREATED_PROCESS type table of BAPIBUS20001_HEADER_INS with header line,

ITAB_SAVED_PROCESS type table of BAPIBUS20001_OBJECT_ID ,

ITAB_INPUT_FIELDS type table of BAPIBUS20001_INPUT_FIELDS,

ITAB_HEADER type table of BAPIBUS2000108_HEADER_INS ,

itab_return type table of bapiret2,

itab_TESTRUN type BAPIFLAG-BAPIFLAG.

DATA : ITAB_OBJECTS_TO_SAVE TYPE STANDARD TABLE OF BAPIBUS20001_GUID_DIS.

DATA : WA_HEADER LIKE LINE OF ITAB_HEADER.

DATA : WA_OBJECTS_TO_SAVE LIKE LINE OF ITAB_OBJECTS_TO_SAVE.

DATA : WA_INPUT_FIELDS TYPE BAPIBUS20001_INPUT_FIELDS.

DATA : WA_CREATED_PROCESS LIKE LINE OF ITAB_CREATED_PROCESS.

DATA: BEGIN OF lt_objects_to_save OCCURS 2.

INCLUDE STRUCTURE bapibus20001_guid_dis.

DATA: END OF lt_objects_to_save.

DATA: BEGIN OF lt_saved_objects OCCURS 2.

INCLUDE STRUCTURE bapibus20001_object_id.

DATA: END OF lt_saved_objects.

DATA: BEGIN OF lt_return OCCURS 2.

INCLUDE STRUCTURE bapiret2.

DATA: END OF lt_return.

DATA: lt_inputfields TYPE TABLE OF bapibus20001_input_fields.

TYPES: ty_guid like BAPIBUS20001_GUID_DIS,

tt_guid type standard table of ty_guid.

DATA: w_return type bapiret2.

data: lt_header_bus20001 type table of bapibus20001_header_ins,

lt_lead_bus20001 type table of bapibus20001_lead_ins.

  • // Document flow

*lt_docflow_bus20001 type table of bapibus20001_doc_flow_ins,

  • // Products

*lt_product TYPE TABLE OF bapibus20001_product.

CLEAR WA_INPUT_FIELDS.

  • Passing values to the work area

WA_INPUT_FIELDS-REF_GUID = '0000000001'.

WA_INPUT_FIELDS-REF_KIND = 'A'.

WA_INPUT_FIELDS-OBJECTNAME = 'LEAD_H'.

WA_INPUT_FIELDS-LOGICAL_KEY = '0001'.

WA_INPUT_FIELDS-FIELDNAME = 'HANDLE'.

  • Appending the parameter table

APPEND WA_INPUT_FIELDS TO ITAB_INPUT_FIELDS.

*LOOP AT IT_DOC_FLOW INTO WA_DOC_FLOW.

*WA_HEADER-GUID = WA_DOC_FLOW-OBJKEY_B.

*APPEND WA_HEADER TO ITAB_HEADER.

*ENDLOOP.

WA_HEADER-GUID = 'E7022F9865DE6F40B752ADEF136E26E0'.

WA_HEADER-PROCESS_TYPE = 'LEAD'.

APPEND WA_HEADER TO ITAB_HEADER.

LOOP AT ITAB_HEADER INTO WA_HEADER.

WA_OBJECTS_TO_SAVE-GUID = WA_HEADER-GUID.

APPEND WA_OBJECTS_TO_SAVE TO ITAB_OBJECTS_TO_SAVE.

ENDLOOP.

WA_CREATED_PROCESS = 'E7022F9865DE6F40B752ADEF136E26E0'.

APPEND WA_CREATED_PROCESS TO ITAB_CREATED_PROCESS.

CALL FUNCTION 'BAPI_LEAD_CREATEMULTI' "Creates lead

*EXPORTING

*TESTRUN = itab_TESTRUN

TABLES

HEADER = itab_header

*ITEM = ITEM

*ORGANISATION = ORGANISATION

*PARTNER = PARTNER

*DATE = DATE

*TEXT = TEXT

*PRODUCT = PRODUCT

*SERVICE_OS = SERVICE_OS

*SCHED_LIN = SCHED_LIN

*DOCUMENT_FLOW = DOCUMENT_FLOW

INPUT_FIELDS = itab_INPUT_FIELDS

CREATED_PROCESS = itab_CREATED_PROCESS

RETURN = itab_RETURN

SAVED_PROCESS = itab_SAVED_PROCESS.

LOOP AT itab_created_process.

lt_objects_to_save-guid = itab_created_process-guid.

APPEND lt_objects_to_save.

ENDLOOP.

CALL FUNCTION 'BAPI_BUSPROCESSND_SAVE' "Saves the lead

  • EXPORTING

  • update_task_local = false

  • save_frame_log = true

  • IMPORTING

  • log_handle = lv_loghandle

TABLES

objects_to_save = lt_objects_to_save

saved_objects = lt_saved_objects

return = lt_return.

loop at lt_saved_objects.

write:/,'Lead', lt_saved_objects-object_id,'is created'.

endloop.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' "Commits the transaction

  • EXPORTING

  • WAIT =

  • IMPORTING

  • RETURN =

.

IF itab_RETURN IS NOT INITIAL.

loop at itab_return into w_return.

write:/, w_return-type, 30 w_return-message.

endloop.

else.

write:/, 'Lead is successfully created'.

ENDIF.

But when i execute it i get the following message displayed as follows:

<b>

A No status object is available for < Unknown Object>

X No status object is available for < Unknown Object>

E The document could not be saved.</b>

Can anyone suggest me in this regards.

Please provide me with exact code where in i can create a LEAD as early as possible.

Thanks in advance,

Shwetha Korlepara.