Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

To UploadTo Upload

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 8
At a glance
Powered by AI
The report is used to create and maintain lead objects in SAP CRM. It uses various data structures to pass data between different functions for creating, updating and saving the lead object.

The report is used to create and maintain lead objects in the SAP CRM system.

The main data structures used are: it_lead to hold the lead header values, it_ctinput to pass field values to update, it_partner to hold contact person details, it_appoint to hold appointments related to the lead.

*&---------------------------------------------------------------------*

*& Report ZRP_ZLEAD


*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZRP_ZLEAD.
TYPE-POOLS : vrm.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME.
PARAMETERS : desc TYPE char20 OBLIGATORY, "description
prospect TYPE bu_partner OBLIGATORY, "PROSPECT BP
contact TYPE bu_partner OBLIGATORY, " CONTACT PERSON BP
salsrep TYPE bu_partner OBLIGATORY, "SALES REPRENTATIVE BP
qualify(20) TYPE c AS LISTBOX VISIBLE LENGTH 20, " QUALIFY
priority(20) TYPE c AS LISTBOX VISIBLE LENGTH 20, "IMPORTANCE
origin(20) TYPE c AS LISTBOX VISIBLE LENGTH 20, " SOURCE
st_date type BCOS_TSTMP MATCHCODE OBJECT CPE_TIMESTAMP,
END_date type BCOS_TSTMP MATCHCODE OBJECT CPE_TIMESTAMP.
SELECTION-SCREEN END OF BLOCK b1.
DATA : q_id TYPE vrm_id,
q_val TYPE vrm_values,
q_stat LIKE LINE OF q_val,
p_id TYPE vrm_id,
p_val TYPE vrm_values,
p_stat LIKE LINE OF p_val,
o_id TYPE vrm_id,
o_val TYPE vrm_values,
o_stat LIKE LINE OF o_val.
DATA : ls_q TYPE crmc_lead_ql_t.
DATA : ls_p TYPE crmc_oppimpor_t.
DATA : ls_o TYPE crmc_source_t.
DATA : lv_guid TYPE crmt_object_guid.
DATA : it_lead TYPE crmt_lead_h_comt,
is_lead TYPE crmt_lead_h_com.
DATA : it_partner TYPE crmt_partner_comt,
is_partner TYPE crmt_partner_com.
DATA : it_order_h TYPE crmt_orderadm_h_comt,
is_order_h TYPE crmt_orderadm_h_com.
DATA : it_ctinput TYPE crmt_input_field_tab,
is_ctinput TYPE crmt_input_field.
DATA : ls_saved TYPE crmt_return_objects.
DATA : is_saved like LINE OF ls_saved.
DATA : it_save TYPE crmt_object_guid_tab,
is_save LIKE LINE OF it_save.
DATA : ls_notsaved TYPE crmt_object_guid_tab.
DATA : ls_exception TYPE crmt_exception_t.
DATA : is_fields LIKE LINE OF is_ctinput-field_names.
DATA :it_appoint TYPE crmt_appointment_comt,
is_appoint LIKE LINE OF it_appoint.
AT SELECTION-SCREEN OUTPUT.
q_id = 'qualify'.
p_id = 'priority'.
o_id = 'origin'.
"QUALIFY LIST BOX
SELECT * FROM crmc_lead_ql_t INTO ls_q WHERE langu = 'E'.
q_stat-key = ls_q-qual_level.
q_stat-text = ls_q-description.
APPEND q_stat TO q_val.
ENDSELECT.
CALL FUNCTION 'VRM_SET_VALUES'
EXPORTING
id = q_id
values = q_val.
"IMPORTANCE LIST BOX
SELECT * FROM crmc_oppimpor_t INTO ls_p WHERE langu = 'E'.
p_stat-key = ls_p-importance.
p_stat-text = ls_p-description.
APPEND p_stat TO p_val.
ENDSELECT.
CALL FUNCTION 'VRM_SET_VALUES'
EXPORTING
id = p_id
values = p_val.
"SOURCE LIST BOX
SELECT * FROM crmc_source_t INTO ls_o WHERE langu = 'E'.
o_stat-key = ls_o-source.
o_stat-text = ls_o-description.
APPEND o_stat TO o_val.
ENDSELECT.
CALL FUNCTION 'VRM_SET_VALUES'
EXPORTING
id = o_id
values = o_val.
AT SELECTION-SCREEN.
" CREATING GUID
CALL FUNCTION 'CRM_GUID_CREATE'
IMPORTING
ev_guid = lv_guid.
"values to it_lead_h
is_lead-ref_guid = lv_guid. "GUID of a CRM Order Object
is_lead-importance = priority. "Opportunity/Lead Priority
is_lead-lead_type = '0007'. " Lead Group
is_lead-qual_level_man = qualify. "Lead Qualification Level
is_lead-source = origin. "Origin of Opportunity/Lead
APPEND is_lead TO it_lead.
" values to ct_input_fields
is_ctinput-objectname = 'LEAD_H'. "Business Transaction Subobject
is_ctinput-ref_guid = lv_guid. "GUID of a CRM Order Object
is_ctinput-ref_kind = 'A'. "Object Type A- administration header
is_ctinput-ref_handle = '0000000000'.
is_fields-fieldname = 'QUAL_LEVEL_MAN'.
INSERT is_fields INTO TABLE is_ctinput-field_names. "Table with Names of Fiel
ds to be Changed
is_fields-fieldname = 'IMPORTANCE'.
INSERT is_fields INTO TABLE is_ctinput-field_names. "Table with Names of Fiel
ds to be Changed
is_fields-fieldname = 'SOURCE'.
INSERT is_fields INTO TABLE is_ctinput-field_names. "Table with Names of Fiel
ds to be Changed
INSERT is_ctinput INTO TABLE it_ctinput.
"VALUES TO CT_ORDERM_H
is_order_h-guid = lv_guid. "GUID of a CRM Order Object
is_order_h-process_type = 'ZLEA'. "Business Transaction Type
is_order_h-description = desc. "Transaction Description
is_order_h-handle = '0000000000'.
is_order_h-mode = 'A'. "Processing Mode of Transaction A-create
is_order_h-descr_language ='E'.
APPEND is_order_h TO it_order_h.
CLEAR is_ctinput.
is_ctinput-objectname = 'ORDERADM_H'.
is_ctinput-ref_guid = lv_guid.
is_ctinput-ref_kind = 'A'.
is_ctinput-ref_handle = '0000000000'.
is_fields-fieldname = 'DESCRIPTION'.
INSERT is_fields INTO TABLE is_ctinput-field_names.
INSERT is_ctinput INTO TABLE it_ctinput.
CLEAR is_ctinput.
is_ctinput-objectname = 'APPOINTMENT'.
is_ctinput-ref_guid = lv_guid.
is_ctinput-ref_kind = 'A'.
is_ctinput-ref_handle = '0000000000'.
is_fields-fieldname = 'TIMESTAMP_FROM'.
is_ctinput-logical_key = 'LEAD_START'.
INSERT is_fields INTO TABLE is_ctinput-field_names.
INSERT is_ctinput INTO TABLE it_ctinput.
CLEAR is_ctinput.
is_ctinput-objectname = 'APPOINTMENT'.
is_ctinput-ref_guid = lv_guid.
is_ctinput-ref_kind = 'A'.
is_ctinput-ref_handle = '0000000000'.
is_fields-fieldname = 'TIMESTAMP_FROM'.
is_ctinput-logical_key = 'LEAD_END'.
INSERT is_fields INTO TABLE is_ctinput-field_names.
INSERT is_ctinput INTO TABLE it_ctinput.
*--------loading it_partner -------
is_partner-ref_guid = lv_guid. "Partner set GUID
is_partner-ref_kind = 'A'. "Object Type A-administration layer
is_partner-kind_of_entry = 'C'. "Partner Origin in a Transaction C-header e
xtension
is_partner-partner_fct = '00000021'. "Partner Function
is_partner-partner_no = prospect. "partner number
is_partner-display_type = 'BP'. "Object Type, for Which Partner Number is
to be Shown
is_partner-no_type = 'BP'. "Partner Number Type (e.g. GUID, Pers. No., ...
), Internal
is_partner-ref_partner_handle = '0001'.
INSERT is_partner INTO TABLE it_partner.
CLEAR is_ctinput.
is_ctinput-objectname = 'PARTNER'.
is_ctinput-ref_guid = lv_guid.
is_ctinput-ref_kind = 'A'.
is_ctinput-ref_handle = '0000000000'.
is_ctinput-logical_key = '0001'.
is_fields-fieldname = 'DISPLAY_TYPE'.
* is_fields-changeable = 'X'.
INSERT is_fields INTO TABLE is_ctinput-field_names.
is_fields-fieldname = 'KIND_OF_ENTRY'.
* is_fields-changeable = 'X'.
INSERT is_fields INTO TABLE is_ctinput-field_names.
is_fields-fieldname = 'NO_TYPE'.
* is_fields-changeable = 'X'.
INSERT is_fields INTO TABLE is_ctinput-field_names.
is_fields-fieldname = 'PARTNER_FCT'.
* is_fields-changeable = 'X'.
INSERT is_fields INTO TABLE is_ctinput-field_names.
is_fields-fieldname = 'PARTNER_NO'.
* is_fields-changeable = 'X'.
INSERT is_fields INTO TABLE is_ctinput-field_names.
INSERT is_ctinput INTO TABLE it_ctinput.
is_partner-ref_guid = lv_guid.
is_partner-ref_handle = '0000000000'.
is_partner-ref_kind = 'A'.
is_partner-kind_of_entry = 'C'.
is_partner-partner_fct = '00000015'.
is_partner-partner_no = contact.
is_partner-display_type = 'BP'.
is_partner-no_type = 'BP'.
is_partner-ref_partner_handle = '0002'.
INSERT is_partner INTO TABLE it_partner.
is_ctinput-logical_key = '0002'.
INSERT is_ctinput INTO TABLE it_ctinput.
is_partner-ref_guid = lv_guid.
is_partner-ref_kind = 'A'.
is_partner-kind_of_entry = 'C'.
is_partner-partner_fct = '00000012'.
is_partner-partner_no = salsrep.
is_partner-display_type = 'BP'.
is_partner-no_type = 'BP'.
is_partner-ref_partner_handle = '0003'.
INSERT is_partner INTO TABLE it_partner.
is_ctinput-logical_key = '0003'.
INSERT is_ctinput INTO TABLE it_ctinput.
"used to create and change an Order
is_appoint-ref_handle = '0000000000'.
is_appoint-ref_guid = lv_guid.
is_appoint-ref_kind = 'A'.
is_appoint-appt_type = 'LEAD_START'.
is_appoint-timestamp_from = st_date.
is_appoint-timezone_from = 'CET'.
is_appoint-rule_guid = '00000000000000000000000000000000'.
"is_appoint-rule_name = 'CONT009'.
is_appoint-timestamp_to = '0'.
is_appoint-duration = '0'.
INSERT is_appoint INTO TABLE it_appoint.
is_appoint-ref_handle = '0000000000'.
is_appoint-ref_guid = lv_guid.
is_appoint-ref_kind = 'A'.
is_appoint-appt_type = 'LEAD_END'.
is_appoint-timestamp_from = END_date.
is_appoint-timezone_from = 'CET'.
is_appoint-rule_guid = '00000000000000000000000000000000'.
is_appoint-rule_name = 'CONT009'.
is_appoint-timestamp_to = '0'.
is_appoint-duration = '0'.
INSERT is_appoint INTO TABLE it_appoint.
CALL FUNCTION 'CRM_ORDER_MAINTAIN'
EXPORTING
* IT_OPPORT_H =
it_lead_h = it_lead
* IT_ACTIVITY_H =
* IT_LAWREF_H =
* IT_SALES =
* IT_PRICING =
* IT_PRICING_I =
* IT_PRIDOC =
* IT_ORGMAN =
* IT_SHIPPING =
* IT_ACTIVITY_I =
* IT_PRODUCT_I =
* IT_BATCH =
* IT_FINPROD_I =
* IT_STRUCT_I =
* IT_CONFIG =
* IT_PAYPLAN =
* IT_PAYPLAN_D =
* IT_CUSTOMER_H =
* IT_CUSTOMER_I =
* IT_SERVICE_H =
* IT_SERVICE_I =
* IT_SERVICE_ASSIGN =
* IT_QUALIF =
IT_APPOINTMENT = it_appoint
* IT_TEXT =
* IT_SCHEDLIN_I =
it_partner = it_partner
* IT_SERVICE_OS =
* IT_REFOBJ =
* IT_SUBJECT =
* IT_CANCEL =
* IT_CANCEL_IR =
* IT_CANCEL_DATES =
* IT_STATUS =
* IT_BILLPLAN =
* IT_BILLING =
* IT_ORDPRP_I =
* IT_ORDPRP_I_D =
* IT_ORDPRP_OBJL_I_D =
* IT_CUMULATED_I =
* IT_SERVICEPLAN_I =
* IT_SERVICEPLAN_IE =
* IT_PRICE_AGREEMENTS_BBP =
* IT_PRICE_AGREEMENTS_CRM =
* IT_CONFIG_FILTER =
* IT_AC_ASSIGN =
* IT_SURVEY =
* IT_EXTENSION =
* IT_ACTIVE_SWITCH =
* IT_UBB_CTR_I =
* IT_UBB_CR_I =
* IT_UBB_VOL_I =
* IT_APO_I =
* IT_CHNGPROC_I =
* IT_EXT_REF =
* IT_DOC_FLOW_PNT =
* IT_CHNGPROC_H =
* IT_FUND_H =
* IT_CLA_H =
* IT_SRV_REQ_H =
* IT_APPROVAL =
* IT_EXTENSION2 =
* IT_CLA_I =
* IT_OPPORT_I =
IMPORTING
et_exception = ls_exception
CHANGING
ct_orderadm_h = it_order_h
* CT_ORDERADM_I =
ct_input_fields = it_ctinput
* CV_LOG_HANDLE =
* CT_PARTNER_ATTRIBUTES =
* CT_DOC_FLOW =
EXCEPTIONS
error_occurred = 1
document_locked = 2
no_change_allowed = 3
no_authority = 4
OTHERS = 5.
IF sy-subrc <> 0.
MESSAGE 'NOT CRAETED' TYPE'I'.
ELSE.
APPEND lv_guid TO it_save.
CLEAR ls_exception.
"SAVE CHANGES TO DB
CALL FUNCTION 'CRM_ORDER_SAVE'
EXPORTING
it_objects_to_save = it_save "guid of object
* IV_UPDATE_TASK_LOCAL = FALSE
* IV_SAVE_FRAME_LOG = FALSE
* IV_NO_BDOC_SEND = FALSE
* IT_ACTIVE_SWITCH =
IMPORTING
et_saved_objects = ls_saved
et_exception = ls_exception
et_objects_not_saved = ls_notsaved
* CHANGING
* CV_LOG_HANDLE =
EXCEPTIONS
document_not_saved = 1
OTHERS = 2
.
IF sy-subrc <> 0.
MESSAGE 'NOT SAVED' TYPE'I'.
ELSE.
loop at ls_saved INTO is_saved.
ENDLOOP.
MESSAGE I000(ZARRUN) with is_saved-object_id .
"MESSAGE ' CREATED' TYPE 'I'.
ENDIF.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
* EXPORTING
* WAIT =
* IMPORTING
* RETURN =
.
ENDIF.

You might also like