Skip to Content
avatar image
Former Member

Using report program to create lead with in prospect

Hi all,

I created Lead by Report Program in SAP CRM but I don't know input Prospect field to Lead.

Please help me to resolve this problem.

Thanks you so much.

My report program:

*&---------------------------------------------------------------------*
*& REPORT ZPGCREATELEAD
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT ZPGCREATELEAD.
DATA :IT_HDR TYPE TABLE OF BAPIBUS2000108_HEADER_INS,
WA_HDR LIKE LINE OF IT_HDR,
LS_BAPI_ACT_PARTNER TYPE TABLE OF BAPIBUS20001_PARTNER_INS,
WA_PARTNER LIKE LINE OF LS_BAPI_ACT_PARTNER,
LT_BAPI_ACT_RETURN TYPE TABLE OF BAPIRET2,
LT_BAPI_ACT_CREATED_PROCESS TYPE STANDARD TABLE OF BAPIBUS20001_HEADER_INS,
LS_BAPI_ACT_CREATED_PROCESS TYPE BAPIBUS20001_HEADER_INS,
LT_BAPI_SAVE_RETURN TYPE STANDARD TABLE OF BAPIRET2,
WA_BAPI_ACT_HEADERX TYPE BAPIBUS2000108_HEADER_INSX,
LT_BAPI_ACT_HEADERX TYPE STANDARD TABLE OF BAPIBUS2000108_HEADER_INSX,
WA_PARTNER_HEADERX TYPE BAPIBUS20001_PARTNER_INSX,
LT_PARTNER_HEADERX TYPE STANDARD TABLE OF BAPIBUS20001_PARTNER_INSX,
LS_OBJECTS_TO_SAVE TYPE BAPIBUS20001_GUID_DIS,
LT_OBJECTS_TO_SAVE TYPE STANDARD TABLE OF BAPIBUS20001_GUID_DIS,
LS_SAVED_OBJECTS TYPE BAPIBUS20001_OBJECT_ID,
LT_SAVED_OBJECTS TYPE STANDARD TABLE OF BAPIBUS20001_OBJECT_ID,
LV_GUID TYPE CRMT_OBJECT_GUID_C,
ET_RETURN TYPE TABLE OF BAPIRET2.

WA_HDR-GUID = '0'.
WA_HDR-HANDLE = '1'.
WA_HDR-PROCESS_TYPE = 'Y003'.
WA_HDR-OBJECT_ID = '0'.
WA_HDR-PREDECESSOR_PROCESS = '0'.
WA_HDR-PREDECESSOR_OBJECT_TYPE = '0'.
WA_HDR-PREDECESSOR_LOG_SYSTEM = '0'.
WA_HDR-BIN_RELATION_TYPE = '0'.
WA_HDR-DESCR_LANGUAGE = '0'.
WA_HDR-LANGU_ISO = '0'.
WA_HDR-DESCRIPTION = 'Create Lead by report'.
WA_HDR-POSTING_DATE = SY-DATUM.
WA_HDR-SOURCE = '806'.
WA_HDR-IMPORTANCE = '1'.
WA_HDR-LEAD_TYPE = '0002'.
WA_HDR-QUAL_LEVEL_MAN = '02'.
*WA_HDR-QUAL_LEVEL_SVY =
APPEND WA_HDR TO IT_HDR.

WA_BAPI_ACT_HEADERX-HANDLE = 'X'.
WA_BAPI_ACT_HEADERX-PROCESS_TYPE = 'X'.
WA_BAPI_ACT_HEADERX-DESCRIPTION = 'X'.
WA_BAPI_ACT_HEADERX-PREDECESSOR_PROCESS = 'X'.
WA_BAPI_ACT_HEADERX-PREDECESSOR_OBJECT_TYPE = 'X'.
WA_BAPI_ACT_HEADERX-PREDECESSOR_LOG_SYSTEM = 'X'.
WA_BAPI_ACT_HEADERX-BIN_RELATION_TYPE = 'X'.
WA_BAPI_ACT_HEADERX-POSTING_DATE = 'X'.
WA_BAPI_ACT_HEADERX-SOURCE = 'X'.
*WA_BAPI_ACT_HEADERX-LOGICAL_SYSTEM = 'X'.
WA_BAPI_ACT_HEADERX-IMPORTANCE = 'X'.
WA_BAPI_ACT_HEADERX-QUAL_LEVEL_MAN = 'X'.
APPEND WA_BAPI_ACT_HEADERX TO LT_BAPI_ACT_HEADERX.




WA_PARTNER-REF_GUID = '0'.
WA_PARTNER-REF_HANDLE = '1'.
WA_PARTNER-REF_PARTNER_HANDLE = '1'.
WA_PARTNER-REF_PARTNER_FCT = '00000021'.
WA_PARTNER-REF_PARTNER_NO = '005056ACF6831ED791CD41BF7B11C47E'.
WA_PARTNER-REF_NO_TYPE = 'BP'.
WA_PARTNER-REF_DISPLAY_TYPE = 'BP'.
WA_PARTNER-PARTNER_FCT = '00000021'.
WA_PARTNER-PARTNER_NO = '005056ACF6831ED791CD41BF7B11C47E'.
WA_PARTNER-NO_TYPE = 'BP'.
WA_PARTNER-DISPLAY_TYPE = 'BP'.
WA_PARTNER-MAINPARTNER = 'X'.
WA_PARTNER-KIND_OF_ENTRY = 'C'.
APPEND WA_PARTNER TO LS_BAPI_ACT_PARTNER.
*
WA_PARTNER_HEADERX-REF_HANDLE = 'X'.
WA_PARTNER_HEADERX-REF_PARTNER_HANDLE = 'X'.
WA_PARTNER_HEADERX-REF_PARTNER_FCT = 'X'.
WA_PARTNER_HEADERX-REF_PARTNER_NO = 'X'.
WA_PARTNER_HEADERX-REF_NO_TYPE = 'X'.
WA_PARTNER_HEADERX-REF_DISPLAY_TYPE = 'X'.
WA_PARTNER_HEADERX-PARTNER_FCT = 'X'.
WA_PARTNER_HEADERX-PARTNER_NO = 'X'.
WA_PARTNER_HEADERX-NO_TYPE = 'X'.
WA_PARTNER_HEADERX-DISPLAY_TYPE = 'X'.
WA_PARTNER_HEADERX-MAINPARTNER = 'X'.
WA_PARTNER_HEADERX-KIND_OF_ENTRY = 'X'.
APPEND WA_PARTNER_HEADERX TO LT_PARTNER_HEADERX.

CALL FUNCTION 'BAPI_LEAD_CREATEMULTI'
EXPORTING
TESTRUN = 'X'
TABLES
HEADERX = LT_BAPI_ACT_HEADERX
HEADER = IT_HDR
PARTNERX = LT_PARTNER_HEADERX
PARTNER = LS_BAPI_ACT_PARTNER
RETURN = LT_BAPI_ACT_RETURN
CREATED_PROCESS = LT_BAPI_ACT_CREATED_PROCESS.
IF NOT LT_BAPI_ACT_RETURN IS INITIAL.
APPEND LINES OF LT_BAPI_ACT_RETURN TO ET_RETURN.
ENDIF.

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

******* CALL SAVE-BAPI:

*********************************************
LOOP AT LT_BAPI_ACT_CREATED_PROCESS
INTO LS_BAPI_ACT_CREATED_PROCESS.
LS_OBJECTS_TO_SAVE-GUID = LS_BAPI_ACT_CREATED_PROCESS-GUID.
APPEND LS_OBJECTS_TO_SAVE TO LT_OBJECTS_TO_SAVE.
ENDLOOP.

* SAVE AND COMMIT IN THE FUNCTION MODULE ???
CALL FUNCTION 'BAPI_ACTIVITYCRM_SAVE'
EXPORTING
UPDATE_TASK_LOCAL = 'X' "TRUE IHB
TABLES
OBJECTS_TO_SAVE = LT_OBJECTS_TO_SAVE
SAVED_OBJECTS = LT_SAVED_OBJECTS
RETURN = LT_BAPI_SAVE_RETURN.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'.
WAIT UP TO 1 SECONDS.
WRITE:/ LS_BAPI_ACT_CREATED_PROCESS-GUID, 'TEST'.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

0 Answers