Documente Academic
Documente Profesional
Documente Cultură
Summary
This document illustrates the method to programmatically create IBASE(s) within SAP CRM, in a CRM Service
Scenario.
Section 2 gives a summary of the requirements and the corresponding mapping of the same into SAP CRM.
However, the functional illustration is given only for understanding the basis behind the use of IBASE(s) within CRM to
capture the billing. The document is only a technical document that explains the code which is used for creating
IBASE(s), creating a hierarchy of IBASE (s) i.e. creating Individual Components, creating IBASE counters and IBASE
Readings using an ABAP code.
The target audience for the document are SAP Technical Consultants, who work in CRM Service Scenarios, and use
the IBASE technology for their systems. Knowledge of basic transactions and concept of IBASE for SAP CRM is
required to understand the following document.
The document is technical in nature and illustrates:
1.
2.
3.
4.
Creation of Counters.
5.
Creation of Readings.
Please note all code mentioned in this document is to be used only as an example to be used in actual
scenarios of development.
Author(s):
Company:
Created on:
18-AUG-2010
Author(s) Bio
Priyanka Bansal is an SAP CRM Advisory Consultant with IBM India Private Limited. She has 6 years of SAP
experience, and has worked as techno-functional consultant in CRM domain across industries like Electronics, Banking
and Professional Services.
Table of Contents
Summary of CRM Service Scenario
Technical Section
Create Installed Base (IBASE) in SAP CRM using ABAP
Create Components of IBASE in SAP CRM using ABAP
Create Counters for IBASE in SAP CRM using ABAP
Create/Change Readings for counters of IBASE in SAP CRM using ABAP
Client 'ABC' is a global client who sells Advertisement space on internet to customers. They have an e-portal where the
customer can login, and configure his/her own advertisement.
Based on the configured advertisement (configured product), area of advertisement, size of advertisement and the time
duration for the advertisement to be published, the invoice is to be generated for the customer 'XYZ'.
Following points illustrate how the above scenario is mapped within SAP CRM. The technical landscape of the client
'ABC' is on SOA architecture, whereby the SAP CRM system serves as a backend, a middleware system is used to call
SAP services and publish them to the Portal, which serves as the front end for customer.
A) Products are to be made configurable within SAP CRM; hence the products of client 'ABC' are set up within SAP
using Variant Configuration.
B) When the customer 'XYZ' configures his/her advertisement and adds it to the shopping basket, a quotation is created
within SAP CRM programmatically.
C) When the quotation is saved; an IBASE is created within SAP CRM.
D) Different IBASE categories are used to define different product groupings.
E) IBASE hierarchy is used to represent the Advert Branch Classification i.e. it maps to every product that is added to
the quotation.
F) Counters will be created for Pay-As-You-Go (PAYG) option.
G) Once the product in the shopping basket is checked out, an order will be created within SAP CRM. The
corresponding quotation and the linked IBASE(s) will now be used. A reading will be associated with the IBASE. This
reading will be incremented by 1, every time the customer's advertisement is published. Based on the reading, an
invoice is generated for the customer using CRM Billing.
Technical Section:
Create Installed Base in SAP CRM using ABAP
CALL FUNCTION 'CRM_ICSS_CREATE_IBASE'
EXPORTING
i_ibase_type
= <ibase category>
i_extid
= <quotation external reference number>
i_descr
= <Text object - CRM_ORDERI and text id - 1000>
*
I_ADDRESS_DATA
=
i_partner
= <Sold-to-party from quotation>
IMPORTING
e_ibib1
= lv_ibib1
EXCEPTIONS
data_not_consistent
= 1
ibase_locked
= 2
not_succesful
= 3
description_required
= 4
ibase_category_required
= 5
ace_authorization
= 6
OTHERS
= 7
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
DATA: ls_comp_det
TYPE crmt_icss_ibase_component2.
DATA: lt_attr
TYPE TABLE OF crmt_icss_attr_values,
ls_father
TYPE ibap_dat1,
lv_object_id
TYPE comt_product_id.
CLEAR ls_father.
ls_father-ibase = p_ibase.
* IBASE as component of another IBASE
ls_comp_det-ibase = '504'.
ls_comp_det-extobjtyp = 'IBASE'.
* Save IBASE
CALL FUNCTION 'CRM_IBASE_SAVE'.
COMMIT WORK AND WAIT.
DATA: ls_comp_det
TYPE crmt_icss_ibase_component2.
DATA: lt_attr
TYPE TABLE OF crmt_icss_attr_values,
ls_father
TYPE ibap_dat1,
lv_object_id
TYPE comt_product_id.
CLEAR ls_father.
ls_father-ibase = p_ibase.
* Product as Component
ls_comp_det-product_id = 'HT1000'.
ls_comp_det-descr = 'Test component1'. " 20/11
ls_comp_det-objnr = '472073E3B4F14176E1008000097C2FFA'.
"Ibase Guid
ls_comp_det-product_guid_c = '45C74BF4B28940D000000000097C2FFA'.
" Product_guid
lv_object_id = 'HT1000'. 20/11
CALL FUNCTION 'CRM_ICSS_CREATE_COMPONENT'
EXPORTING
i_father
= ls_father
i_comp_det
= ls_comp_det
*
I_ADDRESS_DATA
=
*
I_PARTNER
=
*
iv_iobject_id
= lv_object_id 20/11
*
IV_CATEGORY_GUID
=
* IMPORTING
*
E_COMP
=
TABLES
it_attr
= lt_attr
* EXCEPTIONS
*
DATA_NOT_CONSISTENT
= 1
*
IBASE_LOCKED
= 2
*
NOT_SUCCESFUL
= 3
*
PRODUCT_NOT_FOUND
= 4
*
IOBJECT_EXIST
= 5
*
IOBJECT_USED_BY_ANOTHER_COMP
= 6
*
NOT_VALID_RANGE
= 7
*
OTHERS
= 8
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* Save IBASE
CALL FUNCTION 'CRM_IBASE_SAVE'.
COMMIT WORK AND WAIT.
Counter TP- 1
*************
** Counter creation
* Steps: 1. Fill in all the data in a counter work area of type CRMT_MPK_MPOINT_WRK. The
*
APPL_GROUP, TYPE, UNIT, STATUS, FUNCTION. Separately take care of fields VAL
*
and VALUE_PLAN.
*
2. Check data i.e. check unit exists or not in the logon language, check Applic
*
3. Save the counter
*
4. Link the counter to the IBASE component
*************
DATA: lcl_mpk_mpoint
lcl_mpk_counter
ls_mpk_mpoint
lo_mpoint
TYPE
TYPE
TYPE
TYPE
REF TO cl_mpk_mpoint,
REF TO cl_mpk_counter,
crmt_mpk_mpoint_wrk,
REF TO cl_mpk_mpoint,
lv_cc
lv_guid
lv_unit
lv_unit_new
lt_messages
lt_return
TYPE
TYPE
TYPE
TYPE
TYPE
TYPE
ls_mpk_mpoint-description
ls_mpk_mpoint-category
ls_mpk_mpoint-appl_group
ls_mpk_mpoint-type
ls_mpk_mpoint-unit
ls_mpk_mpoint-status
ls_mpk_mpoint-function
char1,
crmt_object_guid,
msehi,
msehi,
comt_il_error_tab,
bapiret2.
=
=
=
=
=
=
=
'Prtest5'.
'ZCC'.
'UBB'.
'1'.
'D'.
'1'.
'0MET'.
ls_mpk_mpoint-unit = lv_unit_new.
IF lv_cc EQ 'X'.
lo_mpoint->create( EXPORTING is_data
= ls_mpk_mpoint
EXCEPTIONS create_failed = 1 ).
ELSE.
CALL METHOD lo_mpoint->change
EXPORTING
is_data
= ls_mpk_mpoint
EXCEPTIONS
change_failed = 1
OTHERS
= 2.
ENDIF.
IF sy-subrc NE 0.
CALL FUNCTION 'CRM_MPK_GET_APPLOG_FOR_CNT'
EXPORTING
iv_counter_guid
= ls_mpk_mpoint-guid
iv_screen_0400_prepare = 'X'
EXCEPTIONS
counter_not_found
= 1
OTHERS
= 2.
IF sy-subrc <> 0.
"#EC NEEDED
ENDIF.
RAISE save_failed.
ENDIF.
*IF iv_active_switch EQ 'X'.
* PERFORM counter_active_switch USING ls_counter_wrk-status
*
ls_counter_wrk-object_id.
*ENDIF.
*
*IF iv_buffer_only NE 'X'.
CALL METHOD cl_mpk_mpoint=>save_all( ).
* IF iv_commit_work EQ 'X'.
*
COMMIT WORK AND WAIT.
* ENDIF.
*ENDIF.
*ls_counter_new_wrk = go_mpoint->get_data( iv_skip_buffer = 'X' ).
*PERFORM convert_chars_do_p USING ls_counter_new_wrk.
*gs_counter_wrk = ls_counter_new_wrk.
COMMIT WORK AND WAIT.
* Link with IBASE
*CALL FUNCTION 'CRM_MPK_IL_CREATE_LINK'
* EXPORTING
*
iv_reltype
= 'IBCMP'
*
iv_source_guid
= '46E72670D8C96571E10000000A011621'
*
iv_counter_guid
= '473DAC4F8BE939DFE10000000A011621'
**
IV_MAIN_COUNTER
= ' '
*
iv_1o_link_kind
= 'B'
* IMPORTING
*
et_messages
= lt_messages
**
EV_ERROR
= LT_ERROR
* EXCEPTIONS
*
lock_failed
= 1
*
other_il_error
= 2
*
unknown_il_type
= 3
*
OTHERS
= 4.
*IF sy-subrc <> 0.
** MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
**
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
*ENDIF.
CALL FUNCTION 'CRM_MPK_IL_LINK_MAINTAIN'
EXPORTING
iv_operation
= '01'
iv_reltype
= 'IBCMP'
*
iv_source_guid
= '473C7C47486339E1E10000000A011621'
iv_source_guid
= '46E72670D8C96571E10000000A011621'
iv_counter_guid
= ls_mpk_mpoint-guid
*
iv_counter_guid
= '473C7C32486339E1E10000000A011621'
*
IV_MAIN_COUNTER
= ' '
*
IV_IL_SAVE_CALL
= ' '
iv_1o_link_kind
= 'B'
IMPORTING
et_messages
= lt_messages
*
EV_ERROR
=
EXCEPTIONS
lock_failed
= 1
other_il_error
= 2
unknown_il_type
= 3
unknown_operation
= 4
OTHERS
= 5
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
"Instance 12571
"Instance 12462 i
*&---------------------------------------------------------------------*
*& Report ZSS_CREATE_IBASE_READING
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT
ZSS_CREATE_IBASE_READING.
" create_reading
"Instance 12571
"Instance 12462
*&---------------------------------------------------------------------*
*&
Form change_reading
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
* --> p1
text
* <-- p2
text
*----------------------------------------------------------------------*
FORM change_reading.
data : iv_counter_guid TYPE CRMT_MPK_OBJECT_GUID ,
lo_mpoint TYPE REF TO CL_MPK_MPOINT.
data : ls_reading type CRMT_MPK_READING_WRK,
lv_guid TYPE CRMT_MPK_OBJECT_GUID.
iv_counter_guid = '473C5975486239E4E10000000A011621'.
cl_mpk_mpoint=>get_instance(
EXPORTING
iv_guid = iv_counter_guid
**iv_object_id = iv_counter_id
RECEIVING
ro_mpoint = lo_mpoint
EXCEPTIONS
OTHERS = 1 ).
if sy-subrc eq 1.
write : / 'Problem'...
return.
endif.
data : lv_time_stamp_from type CRMT_MPK_TIMESTAMP_FROM.
* Create object LCL_MPK_COUNTER.
ls_reading-guid = '473C59E2486239E4E10000000A011621'.
ls_reading-mp_guid = iv_counter_guid.
ls_reading-value = 15.
ls_reading-object_id = 230.
get time stamp field lv_time_stamp_from.
ls_reading-timestamp_from = lv_time_stamp_from.
CALL METHOD LO_MPOINT->CHANGE_READING
EXPORTING
IS_READING
= ls_reading
*
IV_CHECK_ONLY =
*
IV_CLEAR_LOG = 'X'
EXCEPTIONS
CHANGE_FAILED = 1
others
= 2
.
IF SY-SUBRC <> 0.
write : / 'Error Counter Creation'.
else.
write : ' Done'...
ENDIF.
data :
lt_messages
lt_return
CALL METHOD cl_mpk_mpoint=>save_all( ).
COMMIT WORK AND WAIT.
TYPE comt_il_error_tab,
TYPE bapiret2.
COMMIT WORK.
ENDFORM.
" change_reading