crm products: customer enhancements for downloading...

40
CRM Products: Customer Enhancements for Downloading and Uploading Product Master Data (Release 3.0)

Upload: others

Post on 24-Apr-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

CRM Products: Customer Enhancements for

Downloading and Uploading Product Master Data

(Release 3.0)

SAP online help 01.12.2003

Copyright © Copyright 2001 SAP AG. All rights reserved. No part of this brochure may be reproduced or transmitted in any form or for any purpose without the express permission of SAP AG. The information contained herein may be changed without prior notice. Some software products marketed by SAP AG and its distributors contain proprietary software components of other software vendors. Microsoft®, WINDOWS®, NT®, EXCEL®, Word® and SQL Server® are registered trademarks of Microsoft Corporation. IBM®, DB2®, OS/2®, DB2/6000®, Parallel Sysplex®, MVS/ESA®, RS/6000®, AIX®, S/390®, AS/400®, OS/390®, and OS/400® are registered trademarks of IBM Corporation. ORACLE® is a registered trademark of ORACLE Corporation, California, USA. INFORMIX®-OnLine for SAP and Informix® Dynamic Server

TM are registered trademarks of

Informix Software Incorporated. UNIX®, X/Open®, OSF/1®, and Motif® are registered trademarks of The Open Group. HTML, DHTML, XML, XHTML are trademarks or registered trademarks of W3C®, World Wide Web Consortium, Laboratory for Computer Science NE43-358, Massachusetts Institute of Technology, 545 Technology Square, Cambridge, MA 02139. JAVA® is a registered trademark of Sun Microsystems, Inc. , 901 San Antonio Road, Palo Alto, CA 94303 USA. JAVASCRIPT® is a registered trademark of Sun Microsystems, Inc., used under license for technology invented and implemented by Netscape. SAP, SAP Logo, mySAP.com, mySAP.com Marketplace, mySAP.com Workplace, mySAP.com Business Scenarios, mySAP.com Application Hosting, WebFlow, R/2, R/3, RIVA, ABAP, SAP Business Workflow, SAP EarlyWatch, SAP ArchiveLink, BAPI, SAPPHIRE, Management Cockpit, SEM, are trademarks or registered trademarks of SAP AG in Germany and in several other countries all over the world. All other products mentioned are trademarks or registered trademarks of their respective companies.

CRM Products: Customer Enhancements 3.0 2

SAP online help 01.12.2003

Icons

Icon Meaning

Caution

Example

Note

Recommendation

Syntax

Tip

CRM Products: Customer Enhancements 3.0 3

SAP online help 01.12.2003

Copyright ................................................................................................................................... 2

Icons .......................................................................................................................................... 3

1 Preface ............................................................................................................................... 5

2 Introduction......................................................................................................................... 6

3 Overview............................................................................................................................. 7

4 Enhancements to Product Master Data ............................................................................. 9

4.1 Create New Set Types in the Product Master............................................................. 9

4.2 Extend SMO Tables (CDB)......................................................................................... 9

4.3 Regenerate BDOCs .................................................................................................. 10

5 Product Master Download................................................................................................ 11

5.1 Create Customer Enhancement in the OLTP System .............................................. 11

5.2 Create Customer Enhancement (Methods) in the CRM System.............................. 16

5.3 Create Customer Enhancement (Methods) in the CRM System for Data Exchange with the Mobile Client........................................................................................................... 25

6 Product Master Upload..................................................................................................... 32

6.1 Create Customer Enhancement in the CRM System ............................................... 32

CRM Products: Customer Enhancements 3.0 4

SAP online help 01.12.2003

1 Preface Constraints The text and graphics contained in this manual have been compiled with utmost care; nevertheless, it is impossible to guarantee that they are fully without error. SAP cannot assume any responsibility for the correctness or completeness of the following documentation; the user alone is responsible for verifying the information contained therein.

SAP will only assume liability for damage arising from the use of this documentation – irrespective of the pertinent legal basis – in the case of intentional or active negligence, under no other circumstances will a warranty be made.

Goal This step-by-step guide is intended to help customers and consultants when implementing customer enhancements for the Products component.

The guide

• combines technical and business information in a document

• contains code examples

• is practise-near

Notes on use The basis for understanding this step-by-step guide is the SAP Library, which, amongst others, provides information about the individual functions.

Access via SAPNet: http://helpportal.wdf.sap-ag.de:1080/ Access via the Internet: http://helpportal.wdf.sap-ag.de:1080/

CRM Products: Customer Enhancements 3.0 5

SAP online help 01.12.2003

2 Introduction This guide describes how the process of downloading and uploading product master data between an OLTP R/3 System and the CRM System can be enhanced to meet customer-specific requirements.

Customer enhancements are required in the download/upload context when customers have created additional data of their own which needs to be transferred between the systems involved. This generally involves additional standard fields created in the material master, or fields and tables customers have defined themselves. It may also include operations, such as additional selection or filter conditions which cannot be defined with standard transactions.

This guide takes you through the necessary steps to enable this additional data to be downloaded and uploaded correctly. Three scenarios representing typical cases where user enhancements are required are followed through, and illustrate the changes necessary at each stage.

Example 1

You want to transfer additional standard fields from the material master. These are the shelf-life fields Minimum remaining shelf life (MARA-MHDRZ), Total shelf life (MARA-MHDHB), and the related Period indicator for shelf life expiration date (MARA-IPRKZ).

Example 2

You want to transfer customer fields. These are the 20-character MVKE fields ZFLD1 and ZFLD2, which are assigned to the customer append structure ZZMVKE.

Example 3

You would like to use an additional filter condition based on OLTP data so that you can import only those materials that are assigned to purchasing group 007 in plant 0001 into the CRM System.

Prerequisites You have installed the following system components and software:

• OLTP R/3 System

And one of the following:

• CRM System Release 3.0 as of Support Package 2

This guide is aimed at customers using a 3.0 CRM System with Support Packages 1 and 2. There is a separate document for customers with a 2.0C or 2.0B CRM System.

CRM Products: Customer Enhancements 3.0 6

SAP online help 01.12.2003

3 Overview

Customer fields in the R/3 material master or fields that have not yet been transferred need to be transferred from the OLTP System to CRM Online. These fields are saved in generated set types. It is also possible to make the customer fields available on the mobile client. To do this, the customer fields have to be written to the CDB (Consolidated Database) tables corresponding to those in the material master.

The following graphic shows an overview of the data flow between an OLTP R/3 System and a CRM 3.0 System for the object MATERIAL. The points are indicated where the customer will need to make adjustments.

R/3 (Backend) CRM System

Plug-In

R/3 A

dapter

CRM Online CDBV

alidation

Extractor

Event

Mobile B

ridge

UI

CDB Service2 3

4

5

Material

Product

RFCUpload

Download

6

1

The following steps have to be carried out so that the customer fields can be transferred from the R/3 System to the CRM System or consolidated database (CDB), or from CRM Online to the R/3 OLTP System:

1. New set types in CRM Online

When new set types are created, functionality for maintaining and storing customer-defined data is generated in the CRM System. The various Product BDocs (PRODUCT_MAT, PRODUCT_SRV, and PRODUCT_FIN) required by the middleware for the data transport in CRM Online are automatically extended by these fields. The procedure is described in Chapter 4.1.

2. Enhancements in the OLTP R/3 System

A function module has to be created in which the additional data is read for the download and placed in a suitable container for the transport to CRM. Where filtering is concerned, the standard container for the transport can be reduced by the data not required (Chapter 5.1). This module is called in the middleware during data transfer from R/3 to CRM.

CRM Products: Customer Enhancements 3.0 7

SAP online help 01.12.2003

3. Enhancements in CRM Inbound

An implementation of the BAdI PRODUCT_CUSTOMER2 has to be created. It contains suitable methods which can be used to unpack the transport container with the data from R/3. After it has been unpacked, the customer-defined data is transferred to the structures of the generated set types and placed in the messaging BDoc PRODUCT_MAT (or PRODUCT_SRV). It is then passed to the middleware flow (Chapter 5.2). The data is then available in CRM Online. It may be necessary to recreate an assignment between a product and a category if the generated set type was not assigned to a standard category.

4. Adjustments to the CDB and the BDoc PRDCT_OBJECT

The tables in the CDB corresponding to those in the material master must be extended by the missing fields. The BDoc PRDCT_OBJECT must also be extended by the missing fields and the middleware services regenerated. The procedure is described in Chapters 4.2 and 4.3.

5. Enhancements in the mobile bridge

There is a separate method within the BAdI PRODUCT_CUSTOMER2 for mapping the CRM online data to the CDB structures. The data of the generated set types can be added to the BDoc PRDCT_OBJECT there. It is then passed to the middleware CDB service (Chapter 5.3), which is used to write all data to the CDB tables.

6. Enhancements for uploading product data in CRM Online

If a product was created in CRM Online, it can be transferred to the material master of the R/3 OLTP System. The customer-defined data must be mapped to the R/3 structures in an appropriate method defined in the BAdI PRODUCT_CUSTOMER. The procedure is described in Chapter 6.

Depending on your specific requirements, it may not be necessary to make all the modifications shown in the diagram above. If it is only a question of transferring additional data from R/3 to CRM Online, the adjustments described in 1 to 3 are sufficient. If the data is also to be made available on the mobile client, the adjustments described in 1 to 5 have to be made. For uploading customer-defined data, the adjustments in 1 and 6 are sufficient.

CRM Products: Customer Enhancements 3.0 8

SAP online help 01.12.2003

4 Enhancements to Product Master Data

4.1 Create New Set Types in the Product Master Using the Maintain Set Types and Attributes function (transaction COMM_ATTRSET), create new attributes for the additional data and assign these attributes to one or more new set types.

The messaging BDocs PRODUCT_MAT (Materials), PRODUCT_SRV (Services), and PRODUCT_FIN (Financing) are extended automatically when a transport request is created manually for the newly generated set type. (To do this, use transaction COMM_ATTRSET and choose Attributes/Set Types -> Transport -> Include in Request. Make sure that the Create API Append flag is set.) In addition, the name of the CDB table should be maintained in set type maintenance. This is the table to which the attributes of the set type are written when the data is passed to the mobile client.

This set type must be assigned to a category in hierarchy and category maintenance (transaction COMM_HIERARCHY) so that the attributes of this set type can be maintained. In the examples given below, it is assumed that the example set type is assigned to the category MAT_HALB in the category hierarchy R3PRODS (Product subtype).

Example 1 You create the attributes ZMINREMLIFE, ZSHELF_LIFE, and ZPERIOD_IND. You then create the set type ZMINREM_DATA with these attributes. SMOMARA is entered as the CDB table in set type maintenance.

Example 2 You create the attributes ZFLD1 and ZFLD2. You then create the distribution-chain-specific set type ZSETTYPE with these attributes. SMOMARA is entered as the CDB table in set type maintenance.

4.2 Extend SMO Tables (CDB) The CDB tables (SMO tables) corresponding to the material master tables in R/3 must be extended by appropriate append structures. The table name consists of the prefix SMO and the name of the relevant material master table in R/3. However, this is only necessary if this data is also to be made available on the mobile client.

Example 1 The table SMOMARA should be extended with an append structure with the fields MHDRZ, MHDHB, and IPRKZ.

Example 2 The table SMOMVKE should be extended with an append structure with the fields ZFLD1 and ZFLD2.

CRM Products: Customer Enhancements 3.0 9

SAP online help 01.12.2003

4.3 Regenerate BDOCs Structures and services have to be regenerated for the synchronization BDoc PRDCT_OBJECT. This is necessary to write the data to the CDB via the middleware flow.

For more information, see note 484597.

CRM Products: Customer Enhancements 3.0 10

SAP online help 01.12.2003

5 Product Master Download

5.1 Create Customer Enhancement in the OLTP System

Use You require this enhancement so that data that is not normally included in the download in the standard system can be downloaded to the middleware server. A standard download will normally include all fields that are contained in the BAPI structure corresponding to the relevant R/3 table that is to be downloaded (for example, BAPIMATMRA for the table MARA).

You will therefore generally only require this enhancement for customer-defined append fields. However, you may also want to use it to implement filter conditions or selection criteria which cannot be specified in the filter conditions for a business object in the CRM System.

Procedure 1. Create a function module which reads the additional data required on the product and

then evaluates this data and writes it to the table T_OTHER_INFO.

The function module interface should consist of four table parameters:

- T_INT_TABLES (reference structure BAPIMTCS)

This table contains the data records of the OLTP tables. The field DATA contains the data from the table specified in the field TABNAME (for example, MARA).

- T_BAPISTRUCT (reference structure BAPIMTCS)

This table contains the data from the OLTP. The field DATA contains the data from the table specified in the field TABNAME (for example, BAPIMATMRA). The table specified in TABNAME is not a transparent table but a BAPI structure (this is the difference to T_INT_TABLES).

- T_MESSAGES (reference structure BAPICRMMSG) Log information from the OLTP System.

- T_OTHER_INFO (reference structure BAPIEXTC)

This table has to be filled in the user exit. It contains the data not transferred in the standard system.

The reference structure of this table contains four freely interpretable character fields 250 characters long. Make sure that this table is interpreted in the appropriate exit in the middleware process (see Create Customer Enhancement (Methods) in the CRM System [Page 16]) in exactly the same way as here.

CRM Products: Customer Enhancements 3.0 11

SAP online help 01.12.2003

Example: Function Z_U_EXIT_MAT_MAP_OLTP *"*"Local interface: *" TABLES *" T_INT_TABLES STRUCTURE BAPIMTCS *" T_BAPISTRUCT STRUCTURE BAPIMTCS *" T_MESSAGES STRUCTURE BAPICRMMSG *" T_OTHER_INFO STRUCTURE BAPIEXTC *"----------------------------------------------------------------------

DATA: lv_length_matnr TYPE i,

lv_matnr TYPE matnr,

ls_mara TYPE mara,

ls_marc TYPE marc,

ls_mvke TYPE mvke.

* Communication structure (key)

DATA: BEGIN OF ls_com_key,

struc_name(20),

matnr(40),

vkorg(4),

vtweg(2),

END OF ls_com_key.

* Communication structure (additional mara data)

DATA: BEGIN OF ls_com_data,

zfld1(20),

zfld2(20),

END OF ls_com_data. * Field Symbol for Casting BAPIMTCS FIELD-SYMBOLS: <source_x> TYPE x,

<target_x> TYPE x.

* Example 1:

* No special treatment is necessary for standard fields

* that are in the corresponding BAPI structure (for example,

* BAPIMATMRA)

* Example 2: see below

CRM Products: Customer Enhancements 3.0 12

SAP online help 01.12.2003

* Example 3:

* Take into account customer-defined filter conditions

DESCRIBE FIELD ls_mara-matnr LENGTH lv_length_matnr.

LOOP AT t_int_tables.

lv_matnr = t_int_tables-data+3(lv_length_matnr).

CLEAR ls_marc.

CALL FUNCTION 'MARC_SINGLE_READ'

EXPORTING

matnr = lv_matnr

werks = '0001'

IMPORTING

wmarc = ls_marc

EXCEPTIONS

OTHERS = 5.

IF ls_marc-ekgrp <> '007'.

DELETE t_int_tables.

ENDIF.

ENDLOOP.

LOOP AT t_bapistruct.

lv_matnr = t_bapistruct-data+3(lv_length_matnr).

CLEAR ls_marc.

CALL FUNCTION 'MARC_SINGLE_READ'

EXPORTING

matnr = lv_matnr

werks = '0001'

IMPORTING

wmarc = ls_marc

EXCEPTIONS

OTHERS = 5.

IF ls_marc-ekgrp <> '007'.

DELETE t_bapistruct.

ENDIF.

ENDLOOP.

CRM Products: Customer Enhancements 3.0 13

SAP online help 01.12.2003

* Example 2:

* Mapping of customer-defined MVKE fields into transport container

* t_other_info:

LOOP AT t_int_tables WHERE tabname = 'MVKE'.

* Assign with cast to avoid UNICODE conflicts

assign ls_mvke to <target_x> casting.

assign t_int_tables-data to <source_x> casting.

if <source_x> is assigned and

<target_x> is assigned.

<target_x> = <source_x>.

endif.

ls_com_key-struc_name = 'ZZMVKE'.

ls_com_key-matnr = ls_mvke-matnr.

ls_com_key-vkorg = ls_mvke-vkorg.

ls_com_key-vtweg = ls_mvke-vtweg.

ls_com_data-zfld1 = ls_mvke-zfld1.

ls_com_data-zfld2 = ls_mvke-zfld2.

t_other_info-field1 = ls_com_key.

t_other_info-field2 = ls_com_data.

APPEND t_other_info.

ENDLOOP.

ENDFUNCTION.

2. Create a function module which establishes a connection between the OLTP/R3 adapter process and the function module created in step 1.

To ensure that it has the correct interface, this function module should be created as a copy of the function module SAMPLE_PROCESS_CRM0_200. Its task is to call the function module created in step 1.

Example: Function Z_USER_EXIT_BEFORE_SEND_TO_MW *"---------------------------------------------------------------------- *"*"Local interface: *" IMPORTING *" VALUE(I_OBJ_CLASS) LIKE BAPICRMOBJ-OBJCLASS *" VALUE(I_OBJ_NAME) LIKE BAPICRMOBJ-OBJ_NAME *" VALUE(I_BAPICRMDH2) LIKE BAPICRMDH2 *" STRUCTURE BAPICRMDH2 *" VALUE(I_KEYWORD_IN) LIKE CRM_PARA-KEYWORD_IN *" VALUE(I_CRMRFCPAR) LIKE CRMRFCPAR STRUCTURE CRMRFCPAR *" EXPORTING

CRM Products: Customer Enhancements 3.0 14

SAP online help 01.12.2003

*" VALUE(E_DO_NOT_SEND) LIKE CRM_PARA-XFELD *" TABLES *" T_INT_TABLES STRUCTURE BAPIMTCS *" T_BAPISTRUCT STRUCTURE BAPIMTCS *" T_MESSAGES STRUCTURE BAPICRMMSG *" T_KEY_INFO STRUCTURE BAPICRMKEY *" T_OTHER_INFO STRUCTURE BAPIEXTC *"---------------------------------------------------------------------- CASE I_OBJ_NAME.

WHEN 'MATERIAL'.

CALL FUNCTION 'Z_U_EXIT_MAT_MAP_OLTP'

TABLES

T_INT_TABLES = T_INT_TABLES

T_BAPISTRUCT = T_BAPISTRUCT

T_MESSAGES = T_MESSAGES

T_OTHER_INFO = T_OTHER_INFO.

ENDCASE. ENDFUNCTION.

3. Using general table maintenance (transaction SM30), create an entry in table TPS34 Customer function modules per process interface. This will indicate to the process that the customer enhancement exists. The user exit is only executed if an entry is made in the field Additional product developed by customers.

TPS34

Description Value

Process interface CRM0_200

Country Initial

Application indicator for BTE Initial

Customer function module Z_USER_EXIT_BEFORE_SEND_TO_MW

Additional product developed by customers <Product from TBE24>

TBE24

Description Value

Product <Product for TPS34>

Text

RFC destination Optional

Active X

CRM Products: Customer Enhancements 3.0 15

SAP online help 01.12.2003

5.2 Create Customer Enhancement (Methods) in the CRM System

Use The customer enhancement is called when the R/3 data is unpacked and mapped to the CRM structures in the R/3 adapter of the CRM System. There is a separate enhancement (method) for the product types Material and Service:

• Material: MAP_R3_TO_CRM_MATERIAL

• Service: MAP_R3_TO_CRM_SERVICE.

Before the data can be mapped to the CRM structures, you need to check which set types are assigned to the category MAT_HALB (also see Chapter 4.1). Based on this list of set types, the data can be mapped so that the customer-defined data is only transferred for those materials assigned to the category MAT_HALB.

If the customer-defined set type was assigned to a category created in CRM, the assignment between the product and this category also needs to be created during the download. This involves adding a new entry to the table cs_product_bdoc-header-categories during the download. The following fields have to be filled:

• Product_GUID

• Category_GUID

• Hierarchy_GUID

• Category_ID

• Logsys.

Procedure 1. Create an implementation of the BAdI PRODUCT_CUSTOMER2.

For more information about using the Business Add-In (BAdI) enhancement technique, see SAP Library → Basis Components → ABAP Workbench (BC-DWB) → Changing the SAP Standard (BC) → Business Add-Ins.

2. Define the mapping of the R/3 data to the relevant CRM attributes in the respective methods. If data is required in CRM which was written to the container table ti_other_info in R/3, this needs to be unpacked from this container before being mapped. The method IF_EX_PRODUCT_CUSTOMER2~R3_TO_CRM_MATERIAL should be used for downloading materials, and the method IF_EX_PRODUCT_CUSTOMER2~R3_TO_CRM_SERVICE for downloading services.

Refer to the code example given below.

CRM Products: Customer Enhancements 3.0 16

SAP online help 01.12.2003

Example: Method IF_EX_PRODUCT_CUSTOMER2~R3_TO_CRM_MATERIAL

METHOD if_ex_product_customer2~map_r3_to_crm_material . CONSTANTS: on TYPE comt_boolean VALUE 'X', off TYPE comt_boolean VALUE ' ', gc_org_scenario_sales TYPE om_attrscn VALUE 'SALE'. DATA: lv_sales_org TYPE crmt_sales_org, lv_distr_chan TYPE crmt_distribution_channel. DATA: ls_category_bdoc TYPE comt_prod_cat_rel_maintain, ls_category TYPE comt_prod_cat_rel, lt_categories TYPE comt_prod_cat_rel_tab, ls_settype TYPE comt_settype_ext, ls_cat_settype_rel TYPE comt_cat_frag_rel, lt_cat_settype_rel TYPE comt_cat_frag_rel_tab, lt_cat_settype_rel_all TYPE comt_cat_frag_rel_tab. DATA: ls_marc TYPE /1crmg0/plant_object01, ls_mvke TYPE /1crmg0/sales_area01. * get all categories related to the product from CRM online: CALL FUNCTION 'COM_PROD_CAT_REL_READ_WITH_PR' EXPORTING iv_product_guid = cs_product_bdoc-header-com_product-product_guid iv_update_buffer = space IMPORTING et_set = lt_categories. * add all categories related to the product from BDOC: LOOP AT cs_product_bdoc-header-categories INTO ls_category_bdoc. MOVE-CORRESPONDING ls_category_bdoc-data TO ls_category. READ TABLE lt_categories WITH KEY hierarchy_guid = ls_category-hierarchy_guid TRANSPORTING NO FIELDS. IF sy-subrc = 0. MODIFY lt_categories FROM ls_category. ELSE. APPEND ls_category TO lt_categories. ENDIF. ENDLOOP. LOOP AT lt_categories INTO ls_category. * get category set type relations: CALL FUNCTION 'COM_CAT_FRAG_REL_READ' EXPORTING iv_category_guid = ls_category-category_guid IMPORTING et_cat_frag_rel = lt_cat_settype_rel EXCEPTIONS

CRM Products: Customer Enhancements 3.0 17

SAP online help 01.12.2003

wrong_call = 1 OTHERS = 2. IF sy-subrc = 0. APPEND LINES OF lt_cat_settype_rel TO lt_cat_settype_rel_all. ENDIF. ENDLOOP. DELETE ADJACENT DUPLICATES FROM lt_cat_settype_rel_all.

CRM Products: Customer Enhancements 3.0 18

SAP online help 01.12.2003

* Example 1: * 1) Field MARA-MHDRZ should be stored in the field Z0001 of the * generic set type ZMINREM_DATA (generated set type) * 2) Field MARA-MHDHB should be stored in the field Z0002 of the * generic set type ZMINREM_DATA * 3) Field MARA-IPRKZ should be stored in the field Z0003 of the * generic set type ZMINREM_DATA * The field names Z0001, Z0002, and Z0003 are taken from the database * table of the generic set type * data declaration: data: ls_ZMINREM_DATA type ZMINREM_DATA_maintain. * begin of coding loop at lt_cat_settype_rel_all into ls_cat_settype_rel. * read comc_settype record: CALL FUNCTION 'COM_SETTYPE_READ_SINGLE' EXPORTING IV_SETTYPE_GUID = ls_cat_settype_rel-frgtype_guid IMPORTING ES_SETTYPE = ls_settype EXCEPTIONS NOT_FOUND = 1 NO_IMPORT_VALUES = 2 NO_TEXT_FOUND = 3. IF SY-SUBRC <> 0. * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO * WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. continue. ENDIF. Case ls_settype-frgtype_id. When ‘ZMINREM_DATA’.

ls_ZMINREM_DATA-relation-owner = on.

ls_ZMINREM_DATA-relation-logsys =

cs_product_bdoc-header-com_product-logsys.

ls_ZMINREM_DATA-data-Z0001 = is_mara-MINREMLIFE.

ls_ZMINREM_DATA-data-Z0002 = is_mara-SHELF_LIFE.

ls_ZMINREM_DATA-data-Z0003 = is_mara-PRDIND_EXP.

Append ls_ZMINREM_DATA to cs_product_bdoc-data-ZMINREM_DATA. Append ls_settype-frgtype_id to cs_produc_bdoc-data-mnt_settype. Endcase.

Endloop.

* end of coding

CRM Products: Customer Enhancements 3.0 19

SAP online help 01.12.2003

* Example 2: * Field MVKE-ZFLD1 should be stored in the field Z0010 of the generic * set type ZSETTYPE, and the field MVKE-ZFLD2 in the field Z0011: * data declaration: Data: Begin of ls_mat_info, Struc_name (20), Matnr (40), End of ls_mat_info. Data: Begin of ls_ZZMVKE_key, struc_name (20), matnr (40), vkorg type vkorg, vtweg type vtweg, End of ls_ZZMVKE_key. Data: Begin of ls_ZZMVKE_data, zld1 type zfld1, zld2 type zfld2, End of ls_ZZMVKE_data. Data: Ls_other_info type bapiextc. Field-symbols: <source_x> type x, <target_x> type x. data: ls_ZSETTYPE type ZSETTYPE_maintain. * begin of coding

loop at it_other_info into ls_other_info.

* Get records from transport container t_other_info. Working with

* field symbols is necessary because of Unicode!

assign ls_other_info-field1 to <source_x> casting.

assign ls_mat_info to <target_x> casting.

if <source_x> is assigned and

<target_x> is assigned.

<target_x> = <source_x>.

else.

Continue.

Endif.

If ls_mat_info-matnr ne is_mara-material.

Continue.

Endif.

CRM Products: Customer Enhancements 3.0 20

SAP online help 01.12.2003

Case ls_mat_info-struc_name.

When ‘ZZMVKE’.

* assign key fields:

assign ls_other_info-field1 to <source_x> casting.

assign ls_ZZMVKE_key to <target_x> casting.

if <source_x> is assigned and

<target_x> is assigned.

<target_x> = <source_x>.

else.

Continue.

Endif.

* assign data fields:

assign ls_other_info-field2 to <source_x> casting.

assign ls_ZZMVKE_data to <target_x> casting.

if <source_x> is assigned and

<target_x> is assigned.

<target_x> = <source_x>.

else.

Continue.

Endif.

* end of coding

* Begin of the coding for mapping the R/3 distribution chain to the

* CRM distribution chain

* begin of coding

call function 'COM_OM_R3VKORG_TO_CRM'

exporting

r3vkorg = ls_ZZMVKE_key-vkorg

scenario = gc_org_scenario_sales

SELDATE = SY-DATUM

importing

crmvkorg = lv_sales_org

exceptions

not_unique = 1

not_found = 2

others = 3.

if sy-subrc ne 0.

continue.

CRM Products: Customer Enhancements 3.0 21

SAP online help 01.12.2003

else.

Lv_distr_chan = ls_ZZMVKE_key-vtweg.

endif.

CALL FUNCTION 'CRM_PR_SALES_CHECK_DISTR_CHAIN'

EXPORTING

iv_sales_org = lv_sales_org

iv_distr_chan = lv_distr_chan

iv_check_sales_org = ' '

EXCEPTIONS

OTHERS = 6.

if sy-subrc ne 0.

continue.

endif.

* Begin of mapping data into BDoc:

loop at lt_cat_settype_rel_all into ls_cat_settype_rel.

* read comc_settype record: CALL FUNCTION 'COM_SETTYPE_READ_SINGLE' EXPORTING IV_SETTYPE_GUID = ls_cat_settype_rel-frgtype_guid IMPORTING ES_SETTYPE = ls_settype EXCEPTIONS NOT_FOUND = 1 NO_IMPORT_VALUES = 2 NO_TEXT_FOUND = 3. IF SY-SUBRC <> 0. * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. continue. ENDIF. Check ls_settype-org_unit = ‘01’.

CRM Products: Customer Enhancements 3.0 22

SAP online help 01.12.2003

Case ls_settype-frgtype_id.

When ‘ZSETTYPE’.

ls_ZSETTYPE-relation-sales_org = lv_sales_org.

ls_ZSETTYPE-relation-distr_chan = lv_distr_chan.

ls_ZSETTYPE-relation-owner = on.

ls_ZSETTYPE-relation-logsys =

cs_product_bdoc-header-com_product-logsys.

ls_ZSETTYPE-data-Z0010 = ls_ZZMVKE_data-zfld1.

ls_ZSETTYPE-data-Z0011 = ls_ZZMVKE_data-zfld2.

Append ls_ZSETTYPE to cs_product_bdoc-data-ZSETTYPE.

Append ls_settype-frgtype_id to cs_product_bdoc-data-mnt_settype.

Endcase.

Endloop.

Endcase.

endloop.

* End of coding

CRM Products: Customer Enhancements 3.0 23

SAP online help 01.12.2003

* Example 3: * Field MARC-LADGR should be stored in the field Z0100 of the generic * set type ZSETMARC * Prerequisite: You have created appropriate filter settings for the * object MATERIAL in the middleware menu. * Example: WERKS = '0001' * data declaration: data: ls_ZSETMARC type ZSETMARC_maintain. * begin of coding

loop at it_marc into ls_marc

where werks = '0001'.

Loop at lt_cat_settype_rel_all into ls_cat_settype_rel.

* read comc_settype record: CALL FUNCTION 'COM_SETTYPE_READ_SINGLE' EXPORTING IV_SETTYPE_GUID = ls_cat_settype_rel-frgtype_guid IMPORTING ES_SETTYPE = ls_settype EXCEPTIONS NOT_FOUND = 1 NO_IMPORT_VALUES = 2 NO_TEXT_FOUND = 3. IF SY-SUBRC <> 0. * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO * WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. continue. ENDIF. Check ls_settype-org_unit is initial.

Case ls_settype-frgtype_id.

When ‘ZSETMARC’.

ls_ZSETMARC-relation-owner = on.

ls_ZSETMARC-relation-logsys =

cs_product_bdoc-header-com_product-logsys.

ls_ZSETMARC-data-ZFLD1 = ls_marc-ladgr.

Append ls_ZSETMARC to cs_product_bdoc-data-ZSETMARC.

Append ls_settype-frgtype_id to cs_produc_bdoc-data-mnt_settype.

Endcase.

Endloop.

endloop.

* end of coding

endmethod.

CRM Products: Customer Enhancements 3.0 24

SAP online help 01.12.2003

5.3 Create Customer Enhancement (Methods) in the CRM System for Data Exchange with the Mobile Client

Prerequisites The CDB tables were extended by the customer-defined fields, as described in Chapter 4.2, and the structures and services regenerated for the BDoc PRDCT_OBJECT (see Chapter 4.3).

Use The customer enhancements in CRM Online should also be available on the mobile client. The customer-defined attributes therefore need to be written to the CDB tables, which are used to provide the mobile client with data. There is a separate enhancement (method) in CRM for each product type (Material and Service), in which the CRM attributes are mapped to the CDB data structures.

Procedure 1. Create an implementation of the BAdI PRODUCT_CUSTOMER2 if this has not yet been

done for the data exchange between R/3 and CRM Online.

For more information about using the Business Add-In (BAdI) enhancement technique, see SAP Library → Basis Components → ABAP Workbench (BC-DWB) → Changing the SAP Standard (BC) → Business Add-Ins.

2. Implement the mapping of the CRM Online data to the corresponding attributes of the CDB data structures of the BDoc PRDCT_OBJECT. The method IF_EX_PRODUCT_CUSTOMER2~MAP_CRM_MATERIAL_TO_MOBILE should be used for downloading materials, and the method IF_EX_PRODUCT_CUSTOMER2~ MAP_CRM_SERVICE_TO_MOBILE for downloading services.

Refer to the code example given below.

CRM Products: Customer Enhancements 3.0 25

SAP online help 01.12.2003

Example: Method IF_EX_PRODUCT_CUSTOMER2~MAP_CRM_MATERIAL_TO_MOBILE

method IF_EX_PRODUCT_CUSTOMER2~MAP_CRM_MATERIAL_TO_MOBILE.

Data:

Lv_lines type I,

Lv_tabix type sy-tabix.

DATA:

ls_changed_fields type dfies,

ls_key_fields type comt_selection_table,

lt_key_fields type comt_selection_table_tab.

Data:

Ls_prdct_object type /1CRMG0/PRDCT_OBJECT01,

ls_sales_area type /1CRMG0/SALES_AREA01.

* Example 1:

* Set type ZMINREM_DATA was assigned to SMOMARA within set type and

* attribute maintenance:

data:

ls_ZMINREM_DATA type ZMINREM_DATA_maintain.

Loop at is_prod_mat_bdoc-data-ZMINREM_DATA into ls_ZMINREM_DATA.

* get line from BDoc:

read table cs_prdct_object-prdct_object

with key sfamara = is_prod_mat_bdoc-header-com_product-product_guid

into ls_prdct_object.

If sy-subrc ne 0.

Continue.

Else.

Lv_tabix = sy-tabix.

Endif.

* map data to CDB structure:

CRM Products: Customer Enhancements 3.0 26

SAP online help 01.12.2003

ls_prdct_object-mhdrz = ls_ZMINREM_DATA-data-z0001.

Ls_prdct_object-mhdhb = ls_ZMINREM_DATA-data-z0002.

Ls_prdct_object-iprkz = ls_ZMINREM_DATA-data-z0003.

* collect changed fields for CDB to determine sendbits:

ls_changed_fields-tabname = ‘SMOMARA’.

ls_changed_fields-position = lv_tabix.

ls_changed_fields-fieldname = ‘MHDRZ’.

append ls_changed_fields to ct_changed_fields.

ls_changed_fields-fieldname = ‘MHDHB’.

append ls_changed_fields to ct_changed_fields.

ls_changed_fields-fieldname = ‘IPRKZ’.

append ls_changed_fields to ct_changed_fields.

* determine value of task field according to CRM update type:

* collect key fields of corresponding CDB table:

if is_prod_mat_bdoc-control is initial.

Ls_key_fields-table_name = ‘SMOMARA’.

Ls_key_fields-field_name = ‘SFAMARA’.

Ls_key_fields-low_value = ls_prdct_object-sfamara.

Append ls_key_fields to lt_key_fields.

* check update type of CDB table:

Call function ‘COM_PRODUCT_SET_UPDATE_TYPE’

Exporting

iv_tablename = ‘SMOMARA’

it_key_fields = lt_key_fields

changing

cv_update_type = ls_ZMINREM_DATA-update_type

exceptions

table_missing = 1

key_values_missing = 2

others = 3.

If sy-subrc ne 0.

* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO * WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

Endif.

* set task field for CDB table:

IF ls_ZMINREM_DATA-update_type = 'I'.

CRM Products: Customer Enhancements 3.0 27

SAP online help 01.12.2003

Ls_prdct_object-task = 2. ELSEIF ls_ZMINREM_DATA-update_type = 'U'. Ls_prdct_object-task = 1. ELSEIF ls_ZMINREM_DATA-update_type = 'D'. Ls_prdct_object-task = 3. ENDIF.

Endif.

* write new fields into BDoc PRDCT_OBJECT:

Modify cs_prdct_object-prdct_object from ls_prdct_object

Index lv_tabix.

Endloop.

CRM Products: Customer Enhancements 3.0 28

SAP online help 01.12.2003

* Example 2:

* Set type ZSETTYPE was assigned to SMOMVKE within set type and

* attribute maintenance:

data:

ls_ZSETTYPE type ZSETTYPE_maintain.

Loop at is_prod_mat_bdoc-data-ZSETTYPE into ls_ZSETTYPE.

* get line from BDoc:

read table cs_prdct_object-sales_area

with key sfamara = ls_ZSETTYPE-relation-product_guid

vkorg = ls_ZSETTYPE-relation-sales_org

vtweg = ls_ZSETTYPE-relation-distr_chan

into ls_sales_area.

If sy-subrc ne 0.

Ls_sales_area-sfamara = ls_ZSETTYPE-relation-product_guid.

Ls_sales_area-vkorg = ls_ZSETTYPE-relation-sales_org.

Ls_sales_area-vtweg = ls_ZSETTYPE-relation-sales_org.

Ls_sales_area-matnr =

is_prod_mat_bdoc-header-com_product-product_id.

Clear: lv_tabix.

Describe table cs_prdct_object-sales_area lines lv_lines.

Lv_lines = lv_lines + 1.

Else.

Lv_tabix = sy-tabix.

Lv_lines = lv_tabix.

Endif.

* map data to CDB structure:

Ls_sales_area-zfld1 = ls_ZSETTYPE-data-z0010.

Ls_sales_area-zfld2 = ls_ZSETTYPE-data-z0011.

* collect changed fields for CDB to determine sendbits:

ls_changed_fields-tabname = ‘SMOMVKE’.

ls_changed_fields-position = lv_lines.

If lv_tabix is initial.

ls_changed_fields-fieldname = ‘MANDT’.

CRM Products: Customer Enhancements 3.0 29

SAP online help 01.12.2003

append ls_changed_fields to ct_changed_fields.

ls_changed_fields-fieldname = ‘SFAMARA’.

append ls_changed_fields to ct_changed_fields.

ls_changed_fields-fieldname = ‘MATNR’.

append ls_changed_fields to ct_changed_fields.

ls_changed_fields-fieldname = ‘VKORG’.

append ls_changed_fields to ct_changed_fields.

ls_changed_fields-fieldname = ‘VTWEG’.

append ls_changed_fields to ct_changed_fields.

Endif.

ls_changed_fields-fieldname = ‘ZFLD1’.

append ls_changed_fields to ct_changed_fields.

ls_changed_fields-fieldname = ‘ZFLD2’.

append ls_changed_fields to ct_changed_fields.

* determine value of task field according to CRM update type:

if is_prod_mat_bdoc-control is initial.

Ls_key_fields-table_name = ‘SMOMVKE’.

Ls_key_fields-field_name = ‘SFAMARA’.

Ls_key_fields-low_value = ls_sales_area-sfamara.

Append ls_key_fields to lt_key_fields.

Ls_key_fields-field_name = ‘VKORG’.

Ls_key_fields-low_value = ls_sales_area-vkorg.

Append ls_key_fields to lt_key_fields.

Ls_key_fields-field_name = ‘VTWEG’.

Ls_key_fields-low_value = ls_sales_area-vtweg.

Append ls_key_fields to lt_key_fields.

Call function ‘COM_PRODUCT_SET_UPDATE_TYPE’

Exporting

iv_tablename = ‘SMOMVKE’

it_key_fields = lt_key_fields

changing

cv_update_type = ls_ZSETTYPE-update_type

exceptions

table_missing = 1

key_values_missing = 2

others = 3.

CRM Products: Customer Enhancements 3.0 30

SAP online help 01.12.2003

If sy-subrc ne 0.

* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO * WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

Endif.

IF ls_ZSETTYPE-update_type = 'I'. ls_sales_area-task = 2. ELSEIF ls_ZSETTYPE-update_type = 'U'. ls_sales_area-task = 1. ELSEIF ls_ZSETTYPE-update_type = 'D'. ls_sales_area-task = 3. ENDIF.

Endif.

* write new fields into BDoc PRDCT_OBJECT:

If lv_tabix is initial.

Append ls_sales_area to cs_prdct_object-sales_area.

Else.

Modify cs_prdct_object-sales_area from ls_sales_area

Index lv_tabix.

Endif.

Endloop.

* Example 3: see example 1

* Set type ZSETMARC was assigned to SMOMARA within set type and

* attribute maintenance:

* The coding is similar to example 1 as SMOMARC is not used

* any longer in the mobile client application. So, the set data has

* to be mapped to SMOMARA.

CRM Products: Customer Enhancements 3.0 31

SAP online help 01.12.2003

6 Product Master Upload

6.1 Create Customer Enhancement in the CRM System

Use The customer enhancement described in this section will enable you to upload product master data stored in generic set types in the CRM System to the R/3 material master or article master.

The enhancement is based on the method IF_EX_PRODUCT_CUSTOMER~CRM_TO_R3_PRODUCT, which is implemented using the Business Add-In (BADI) enhancement technique. For more information about using this technique, see SAP Library → Basis Components → ABAP Workbench (BC-DWB) → Changing the SAP Standard (BC) → Business Add-Ins.

The mapping between the product master data and material or article master data needs to be implemented within this method.

Prerequisites Before you can implement the method required for this enhancement, you need to have created a class to implement the interface IF_EX_PRODUCT_CUSTOMER (see Create Customer Enhancement (Methods) in the CRM System [Page 16]). If you wish, you can use the same class that you used for downloading materials.

Procedure 1. You define two local parameters which serve as data containers for customer-defined set

types (for example, ls_ZMINREM_DATA and lt_ZMINREM_DATA). ZMINREM_DATA stands for the name of the customer-defined set type and should be changed to the name of your own set type.

2. The data of the customer-defined set types is read in this step. The name of the set type has to be passed to the function module (for example, ZMINREM_DATA).

3. The data read is then transferred to the internal table (lt_ZMINREM_DATA). This is only allowed for those product types specified for the set type in the Maintain Set Types and Attributes function.

4. In this step, the data is actually transferred to the relevant R/3 structures. In addition, all fields that are to be changed in the R/3 System must be registered in an update field table. This task is performed by the function module COM_PRODUCT_FILL_TAB_FIELDS. The material number, the name of the target structure in the R/3 System, and the appropriate field name need to be passed to the function module. The name of the target structure and the related field name will depend on whether an industrial material or a retail material (article) is to be created in the R/3 System. This is determined by the two fields SCR_MATERIAL and SCR_ARTICLE in the structure IS_SCR_FIELDS. In the case of sales data, a distribution chain also has to be specified.

The table below provides an overview of the target structures which have to be passed to the function module COM_PRODUCT_FILL_TAB_FIELDS when a particular material master table is to be changed. Note that the names of the structures differ depending on whether an industrial or retail material (article) is to be created or changed in the R/3 System.

CRM Products: Customer Enhancements 3.0 32

SAP online help 01.12.2003

R/3 Target Table Structure: Material Master Structure: Retail

MARA E1MARAM E1BPE1MARART

MARM E1MARMM E1BPE1MARMRT

MVKE E1MVKEM E1BPE1MVKERT

Example: Method IF_EX_PRODUCT_CUSTOMER~CRM_TO_R3_PRODUCT

method IF_EX_PRODUCT_CUSTOMER~CRM_TO_R3_PRODUCT.

constants:

lc_yes type comt_boolean value 'X'.

data:

lv_subrc type sy-subrc,

lv_tabix type sy-tabix.

data:

ls_set_mat type comt_prod_mat_maintain_api,

ls_set_srv type comt_prod_srv_maintain_api,

ls_set_fin type comt_prod_fin_maintain_api.

data:

lv_vkorg_oltp type vkorg.

data:

lv_orgman type ref to cl_crm_org_management.

CRM Products: Customer Enhancements 3.0 33

SAP online help 01.12.2003

* Example 1: * You have created a new set type called ZMINREM_DATA which contains * the three fields MINREMLIFE, SHELF_LIFE, and PRDIND_EXP * 1) Field Z0001 of the generic set type ZMINREM_DATA should be * stored in the field MARA-MHDRZ * 2) Field Z0002 of the generic set type ZMINREM_DATA should be * stored in the field MARA-MHDHB * 3) Field Z0003 of the generic set type ZMINREM_DATA should be * stored in the field MARA-IPRKZ * Step 1: * Define internal table:

data:

ls_ZMINREM_DATA type ZMINREM_DATA_MAINTAIN,

lt_ZMINREM_DATA type ZMINREM_DATA_MAINT_T.

* Step 2: * Read data from generic set type ZMINREM_DATA:

CALL FUNCTION 'COM_PR_UPLOAD_READ_GEN_WITH_P'

EXPORTING

IV_PRODUCT_GUID =

is_product-com_product-product_guid

IV_PRODUCT_TYPE =

is_product-com_product-product_type

IV_SETTYPE_ID = 'ZMINREM_DATA'

IMPORTING

ES_SET_MAT = ls_set_mat

ES_SET_SRV = ls_set_srv

ES_SET_FIN = ls_set_fin

EXCEPTIONS

WRONG_CALL = 1

SETTYPE_NOT_FOUND = 2

NO_DATA = 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.

ELSE.

CRM Products: Customer Enhancements 3.0 34

SAP online help 01.12.2003

* Step 3: * Set the data in the internal table. This only makes sense * if the generic set type is allowed for the product type. * If not: DO NOT implement the WHEN statement for the corresponding * product type

case is_product-com_product-product_type.

when '01'.

lt_ZMINREM_DATA[] = ls_set_mat-ZMINREM_DATA[].

when '02'.

lt_ZMINREM_DATA[] = ls_set_srv-ZMINREM_DATA[].

when '03'.

lt_ZMINREM_DATA[] = ls_set_fin-ZMINREM_DATA[].

endcase.

* Step 4: * Map corresponding fields:

loop at lt_ZMINREM_DATA into ls_ZMINREM_DATA.

* Repeat this coding for each field: --- Begin Repeat ---

CS_MARA-UNITPO = ls_ZMINREM_DATA-DATA-Z0001.

* Update table fields from R/3: if you want to update table MARA * for a material, you have to fill IV_TABLENAME with 'E1MARAM'. * For articles, you have to use 'E1BPE1MARART'. You will find * a complete list of the mapping in this guide.

if is_scr_fields-scr_material = lc_yes.

CALL FUNCTION 'COM_PRODUCT_FILL_TAB_FIELDS'

EXPORTING

IV_MATNR_OLTP = iv_mat_number

IV_TABLENAME = 'E1MARAM'

IV_FIELDNAME = 'MHDRZ'

TABLES

ET_TAB_FIELDS_UPD = CT_TAB_FIELDS_UPD[]

EXCEPTIONS

OTHERS = 1.

elseif is_scr_fields-scr_article = lc_yes.

CALL FUNCTION 'COM_PRODUCT_FILL_TAB_FIELDS'

EXPORTING

CRM Products: Customer Enhancements 3.0 35

SAP online help 01.12.2003

IV_MATNR_OLTP = iv_mat_number

IV_TABLENAME = 'E1BPE1MARART'

IV_FIELDNAME = 'MHDRZ'

TABLES

ET_TAB_FIELDS_UPD = CT_TAB_FIELDS_UPD[]

EXCEPTIONS

OTHERS = 1.

endif.

* Repeat the coding within this loop for fields Z0002 and * Z0003 by changing the field names: --- End Repeat ---

endloop.

* If any field is transported which does not have the status K or

* V on the R/3 side, the status has to be introduced into

* CS_MARA-MAINT_STAT. The status of these fields can be seen in OLTP

* in table T130F:

if cs_mara-maint_stat na ‘L’.

concatenate cs_mara-maint_stat ‘L’ into cs_mara-maint_stat.

endif.

ENDIF.

CRM Products: Customer Enhancements 3.0 36

SAP online help 01.12.2003

* Example 2: * You have created a new set type called ZSETTYPE which contains the * field Z0010 * The field ZFLD2 of the generic set type ZSETTYPE should be stored * in the field MVKE-ZFLD1 * Step 1: * Define internal table:

data:

ls_ZSETTYPE type ZSETTYPE_MAINTAIN,

lt_ZSETTYPE type ZSETTYPE_MAINT_T.

* Step 2: * Read data from generic set type ZSETTYPE:

CALL FUNCTION 'COM_PR_UPLOAD_READ_GEN_WITH_P'

EXPORTING

IV_PRODUCT_GUID =

is_product-com_product-product_guid

IV_PRODUCT_TYPE =

is_product-com_product-product_type

IV_SETTYPE_ID = 'ZSETTYPE'

IMPORTING

ES_SET_MAT = ls_set_mat

ES_SET_SRV = ls_set_srv

ES_SET_FIN = ls_set_fin

EXCEPTIONS

WRONG_CALL = 1

SETTYPE_NOT_FOUND = 2

NO_DATA = 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.

ELSE.

CRM Products: Customer Enhancements 3.0 37

SAP online help 01.12.2003

* Step 3: * Set the data in the internal table. This only makes sense * if the generic set type is allowed for the product type.

case is_product-com_product-product_type.

when '01'.

lt_ZSETTYPE[] = ls_set_mat-ZZSETTYPE[].

when '02'.

lt_ZSETTYPE[] = ls_set_mat-ZZSETTYPE[].

when '03'.

lt_ZSETTYPE[] = ls_set_mat-ZZSETTYPE[].

endcase.

* Step 4: * Map the CRM distribution chain to the R/3 distribution chain and * map relevant fields to MVKE:

CALL METHOD CL_CRM_ORG_MANAGEMENT=>GET_INSTANCE

IMPORTING

EV_INSTANCE = LV_ORGMAN.

loop at lt_ZSETTYPE into ls_ZSETTYPE.

call method lv_orgman->get_vkorg_of_sales_org

EXPORTING

IV_SALES_ORG = ls_ZSETTYPE-relation-sales_org

IMPORTING

EV_VKORG = lv_vkorg_oltp

EXCEPTIONS

R3_KEY_NOT_DEFINED = 1

OTHERS = 2.

if sy-subrc ne 0.

continue.

endif.

CRM Products: Customer Enhancements 3.0 38

SAP online help 01.12.2003

read table ct_mvke

with key material = iv_mat_number

salesorg = lv_vkorg_oltp

distr_chan =

ls_ZSETTYPE-relation-distr_chan.

lv_subrc = sy-subrc.

lv_tabix = sy-tabix.

if sy-subrc ne 0.

clear ct_mvke.

ct_mvke-material = iv_mat_number.

ct_mvke-salesorg = lv_vkorg_oltp.

ct_mvke-distr_chan = ls_ZSETTYPE-relation-distr_chan.

endif.

* Repeat this coding for each field: --- Begin Repeat ---

ct_mvke-zfld1 = ls_ZSETTYPE-data-Z0010.

if is_scr_fields-scr_material = lc_yes.

CALL FUNCTION 'COM_PRODUCT_FILL_TAB_FIELDS'

EXPORTING

IV_MATNR_OLTP = iv_mat_number

IV_VKORG = ct_mvke-salesorg

IV_VTWEG = ct_mvke-distr_chan

IV_TABLENAME = 'E1MVKEM'

IV_FIELDNAME = 'ZFLD1'

TABLES

ET_TAB_FIELDS_UPD = CT_TAB_FIELDS_UPD[].

EXCEPTIONS

OTHERS = 1.

elseif is_scr_fields-scr_article = lc_yes.

CALL FUNCTION 'COM_PRODUCT_FILL_TAB_FIELDS'

EXPORTING

IV_MATNR_OLTP = iv_mat_number

IV_VKORG = ct_mvke-salesorg

IV_VTWEG = ct_mvke-distr_chan

IV_TABLENAME = 'E1BPE1MVKERT'

IV_FIELDNAME = 'ZFLD1'

TABLES

CRM Products: Customer Enhancements 3.0 39

SAP online help 01.12.2003

CRM Products: Customer Enhancements 3.0 40

ET_TAB_FIELDS_UPD = CT_TAB_FIELDS_UPD[].

EXCEPTIONS

OTHERS = 1.

endif.

* Repeat this coding for each field here: --- End Repeat ---

if not lv_subrc is initial.

append ct_mvke.

else.

modify ct_mvke index lv_tabix.

endif.

endloop.

* If any field is transported which does not have the status K or

* V on the R/3 side, the status has to be introduced into

* CS_MARA-MAINT_STAT. The status of these fields can be seen in OLTP

* in table T130F:

if cs_mara-maint_stat na ‘L’.

concatenate cs_mara-maint_stat ‘L’ into cs_mara-maint_stat.

endif.

endif.

endmethod.