how to extract classification data multi values into bw sap version

14
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com © 2011 SAP AG 1 How to Extract Data for Multi- Value Characteristics to SAP BW Applies to: SAP BW 3.5 & 7.0. Summary To extract classification data to BW we need to configure and generate the datasources in transaction CTBW. While configuring these datasources, system does not allow the entry of multi-value characteristics, as a result data for multi-value characteristics cannot be extracted. This article focuses on prerequisites and possible workarounds to extract data for multi-value characteristics to BW. A step by step procedure of extracting HSE classification data for multi-value characteristics is also discussed in this article. Author: Ramakrishna Gattikoppula Company: Infosys Ltd. Created on: 25 September 2011 Author Bio Ramakrishna Gattikoppula is a Technology Analyst at Infosys Ltd. He has 4+ years of experience in SAP BW and has been involved in SAP BW/BO implementation projects.

Upload: pmscribd12

Post on 17-Dec-2015

615 views

Category:

Documents


14 download

DESCRIPTION

How to Extract Classification Data Multi Values Into BW Sap Version

TRANSCRIPT

  • SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com

    2011 SAP AG 1

    How to Extract Data for Multi-

    Value Characteristics to SAP BW

    Applies to:

    SAP BW 3.5 & 7.0.

    Summary

    To extract classification data to BW we need to configure and generate the datasources in transaction CTBW. While configuring these datasources, system does not allow the entry of multi-value characteristics, as a result data for multi-value characteristics cannot be extracted.

    This article focuses on prerequisites and possible workarounds to extract data for multi-value characteristics to BW. A step by step procedure of extracting HSE classification data for multi-value characteristics is also discussed in this article.

    Author: Ramakrishna Gattikoppula

    Company: Infosys Ltd.

    Created on: 25 September 2011

    Author Bio

    Ramakrishna Gattikoppula is a Technology Analyst at Infosys Ltd. He has 4+ years of experience in SAP BW and has been involved in SAP BW/BO implementation projects.

  • How to Extract Data for Multi-Value Characteristics to SAP BW

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com

    2011 SAP AG 2

    Table of Contents

    Problem Statement: ............................................................................................................................................ 3

    Solution: .............................................................................................................................................................. 4

    The R/3 Classification System ........................................................................................................................ 4

    Reason for this error ....................................................................................................................................... 4

    Prerequisites and Possible Workarounds provided by SAP for extracting the classification data to BW ...... 5

    Step by step procedure of extracting Multi-Value Characteristic data to BW ................................................. 6 Step1: Generation of datasource for Classification Data ............................................................................................. 6

    Step 2: Enhancing the generated datasource/extract structure to add additional fields so that additional values can be extracted from Multi-Value Characteristics .............................................................................................................. 8

    Step 3: Implement BADI to update the data in the additional fields in the Enhanced Extract Structure ....................... 9

    Step 4: Define additional attributes in the BW system ............................................................................................... 11

    Related Content ................................................................................................................................................ 13

    Disclaimer and Liability Notice .......................................................................................................................... 14

  • How to Extract Data for Multi-Value Characteristics to SAP BW

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com

    2011 SAP AG 3

    Problem Statement:

    How to extract data for multi-value characteristics to BW

    Scenario:

    Let us suppose, an Organization is using HSE (Health, Safety and Environment) solution provided by SAP (transaction CBIH82) to capture all HSE data and want to use this data to create Analytical Reports & Interactive Dashboards to allow proper insight into this HSE data across the organization.

    After analysis, ECC team concluded that standard HSE solution provided by SAP did not satisfy the complete requirements of the organization; as a result SAP ECC team did some customizations to the existing application using classification system to capture the complete HSE data. For e.g. - As a part of this customization ECC team created some classes and assigned various objects to these classes. In one of these classes a multi-valued characteristic Fire Type was added along with two other single valued characteristics Explosion Type and Area of Damage.

    Following is the screenshot of the customized application.

    Now, to extract this classification data into BW, BW team needs to configure the datasources for the classification data using transaction CTBW. While configuring these datasources in transaction CTBW an error was faced when characteristic Fire Type was added as one of the fields in the Data Source.

    Following is the error message:

  • How to Extract Data for Multi-Value Characteristics to SAP BW

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com

    2011 SAP AG 4

    Solution:

    In this article I have tried to explain:

    The R/3 Classification System,

    Reason for the above error,

    Prerequisites and Possible Workarounds provided by SAP for extracting the classification data to

    BW and

    Step by step procedure of extracting Multi-Value Characteristic data to BW.

    The R/3 Classification System

    R/3 supports many ways of customizing it to store additional data fields. For e.g., many tables support customer defined additions, but there is also the Cross Application Classification System.

    The classification system allows you to use characteristics to describe all types of objects and to group similar objects in classes to classify objects, in other words, so that you can find them more easily later. The classification system allows R/3 to hold many varied additional fields against many different sorts of R/3 object, for e.g. it might allow you to store a color against a material. Here is some terminology:

    Object type (Material, Documents, Debitor,...)

    The underlying table which is used for classified objects.(MARA, DRAW, KNA1,...)

    Object A predefined business entity such as vendor, material, equipment or customer.

    Class type Defines which object type can be classified with the class of that class type.

    Class It groups similar objects or classes. By assigning an object to a class the objects can be evaluated with values of characteristics of this class.

    Characteristic A property of an object, this is the new field being added. For e.g. a new characteristic might be the Weight of a material.

    Characteristic Value A value describes a certain specification of a characteristic. For e.g. Weight of a material might be 100 KG.

    Reason for this error

    The classification system supports entering multiple single values, ranges, free text, and values from pre-defined lists or other tables. It is very flexible, and it is this flexibility that makes it sometimes tricky to extract data to BW.

    BW system cannot manage multiple values for a characteristic of an InfoObject. Therefore, when creating datasources for classifications (transaction CTBW), you cannot use multiple-value characteristics.

  • How to Extract Data for Multi-Value Characteristics to SAP BW

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com

    2011 SAP AG 5

    Prerequisites and Possible Workarounds provided by SAP for extracting the classification data to BW

    Following are two prerequisites that needs to be considered if you are planning to extract classification data to BW

    1. If the characteristic value has been setup to accept multiple values, then BW cannot extract all the values without additional configuration. For e.g., say the characteristic hobbies has been setup to accept multiple values. In R/3 you could therefore store the values Football, Literature and Cricket all against that single characteristic. This does not match the way BW stores data, in BW a characteristic is expected to store only a single value.

    2. The classification definitions must be the same in all R/3 clients. For e.g. if hobbies is defined as accepting only a single value in the R/3 client 100, it must be defined in the same way in R/3 client 110 and all other clients in all systems. This is because the extractor is defined cross-client.

    According to the first prerequisite we need to perform some additional configuration/workarounds to extract data to BW. These configurations/Workarounds are discussed in the following section.

    1. Apply OSS Notes 350296 and 535370, with this the error message can be changed to a warning

    message; the modification is not implemented in the standard system. After this modification only

    one value is transferred during the extraction i.e. if a multi-value characteristic Hobbies has values

    Football, Literature and Cricket then only one of these values is transferred during extraction. In

    these kind of scenarios where characteristic is assigned multiple values it is not possible to predict

    which of the assigned values are extracted, if Several values are specified in the classification

    system only the first value is extracted to BW and this first value extracted may differ even if same

    set of Hobbies are defined for different persons.

    In general this workaround is not recommended as there is loss of data and also confusion about the

    characteristic value that is extracted.

    2. Configure all the characteristics in the classification system to accept only a single value. In the above example you could configure hobbies1, hobbies2 and hobbies3 to store all the values. Doing this limits the no. of valuations, However, you can work around this in R/3 by using an additional multiple-value characteristic i.e. first three hobbies can be stored in hobbies1, hobbies2 and hobbies3 and the remaining valuations can be stored to an additional multi-value characteristic. This solution causes restrictions in the usage of classifications (for e.g., finding objects in classes (transaction CL30N)). Check whether you can work with these restrictions. The most important criteria for this check are: - The necessary changes in the modeling in the classification system and the level of effort required when the valuations in existing classifications have to be distributed amongst several characteristics. - The effects of these changes (for e.g., the effects on the object search in the classification system).

    3. Another approach would be to modify the extractor to add additional fields so that the additional values are extracted. These values must then be assigned several attributes in BW. The number of possible values is restricted by the number of additional attributes that you define. In order for this solution to work: - You would need to add extra fields for the additional attributes to the datasource that is created using transaction CTBW. - You would have to enlarge the extractor in order to be able to deliver the additional values. This would probably require a lot of effort. - You would have to define additional attributes in the BW system. In the following section I have explained the step by step procedure to extract multi-value Characteristic values to BW using one of workarounds mentioned above (Workaround No. 3 i.e. to modify the extractor to add additional fields).

  • How to Extract Data for Multi-Value Characteristics to SAP BW

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com

    2011 SAP AG 6

    Step by step procedure of extracting Multi-Value Characteristic data to BW

    Step1: Generation of datasource for Classification Data

    Once the R/3 team has finished their configuration in classification system, you can generate the datasource and extractors to extract classification data.

    This can be done using transaction CTBW, to generate datasource for classification you need to specify the basic datasource you want to extend, then the client which you want to extract the data from and the class type for the master data.

    In this example we are extracting HSE data, so basic datasource would be 0EHS_IAL_ATTR and the class type would be 100. Following is the screenshot of datasource in CTBW.

    Generally generated data source name would be concatenation of 1CL_, first four characters of Basic datasource and a 3 digit number.

    Once the datasource has been entered, select the datasource line and double click on Characteristics in the left hand tree.

    In the characteristics screen you can enter the characteristic names which you want to include in this datasource. Click new entries on the top left of the screen to add some characteristics. Enter Characteristic Names, and the other fields will default correctly.

    Once all the Characteristics have been entered, click save and generate source.

  • How to Extract Data for Multi-Value Characteristics to SAP BW

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com

    2011 SAP AG 7

    This step will generate a datasource and an Extract Structure, in transaction RSA6 you can check all the characteristics added to the generated extract structure. In the generated extract structure ACTN, RECN, DATEFROM and DATETO will be added by default along with the characteristics specified in transaction CTBW.

  • How to Extract Data for Multi-Value Characteristics to SAP BW

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com

    2011 SAP AG 8

    Step 2: Enhancing the generated datasource/extract structure to add additional fields so that additional values can be extracted from Multi-Value Characteristics

    As discussed earlier a multi-value characteristic Fire Type (whose values are preconfigured by ECC team as Phrases (i.e. Phrase Key & Phrase Text)) is added to the Class Fire & Explosion in the HSE application.

    Following is the possible set of Characteristic values for this multi-value characteristic.

    Phrase Key Phrase Text

    CUST-ZEHSC0000000060 Ordinary Combustibles (wood, paper, plastics)

    CUST-ZEHSC0000000061 Flammable Liquid /gases (gasoline, diesel, natural gas)

    CUST-ZEHSC0000000062 Electrical

    CUST-ZEHSC0000000063 Flammable Solids/Metals (sodium, magnesium, potassium)

    Therefore for any Incident/Accident, characteristic Fire Type can be assigned with one or more values from the above table.

    For e.g.: For Incident/Accident 1001, Fire Type can be CUST-ZEHSC0000000060.

    For Incident/Accident 1002, Fire Type can be CUST-ZEHSC0000000060, CUST- ZEHSC0000000061 and CUST-ZEHSC0000000063

    In this example we know that there can be a maximum of four Fire types for any Incident/Accident, therefore we need to add four additional fields to the Extract Structure of the generated datasource to extract Fire type.

    Following is the screenshot of the modified extract structure:

    ZZFIRETYPE1, ZZFIRETYPE2, ZZFIRETYPE3 and ZZFIRETYPE4 are added to the extract structure to store the different values of Fire Type for a particular Incident.

  • How to Extract Data for Multi-Value Characteristics to SAP BW

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com

    2011 SAP AG 9

    As the generated datasource does not contain the Incident/Accident ID, an additional field ZZIALID is also added to the extract structure to extract the Incident/Accident ID so that it is easier to identify the Fire Types and Explosion types for each Incident.

    Step 3: Implement BADI to update the data in the additional fields in the Enhanced Extract Structure

    In the above example, the additional fields which are added to extract structure will not extract the exact value of the fire type but a flag will be set based on the value of the fire type. This will be explained in the following sections. If you do not wish to set a flag and extract the actual value you can do that by slightly modifying the code given in the following sections.

    For E.g.: Extracted data for Incident/Accidents 1001 and 1002 is as shown below

    ACTN Date From Date To RECN Explosion Type

    Area of Damage

    Fire Type 1

    Fire Type 2

    Fire Type 3

    Fire Type 4

    IAL ID

    0 01/01/1000 12/31/9999 1234 Ballistics 11 - 100 Y 1001

    0 01/01/1000 12/31/9999 1235 Ballistics 11 - 100 Y Y Y 1002

    A BADI needs to be implemented in order to update the values (flags) for Fire Types and IAL ID (Incident/Accident ID) in the extract structure. To implement BADI go to transaction SE24 and enter the Class/Interface name in the Object type.

    Once you have entered the Object type click on Change, in the following screen click on tab Methods. In Methods tab enter the generated datasource name (1CL_0EHS0**) as Method, while doing this remove the first character of the datasource name i.e. method name should be as shown in the following screenshot.

    After creating the method, double click on the method name. A new screen will appear where you can write the code to extract values for Fire Type and IAL ID.

  • How to Extract Data for Multi-Value Characteristics to SAP BW

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com

    2011 SAP AG 10

    Following is the sample code:

    To extract the IAL ID and characteristic values for Fire Type (i.e. multi-value Characteristic) we need to use RECN and ACTN which are extracted by default in the Extractor.

    IAL ID can be derived from tables CCIHT_IHVA and CCIHT_IAL by passing the RECN and ACTN.

    Following is the sample code to derive IAL ID:

    * Derive IAL ID using RECN and ACTN extracted

    READ TABLE INT_CCIHT_IHVA INTO wa_CCIHT_IHVA

    WITH KEY RECN = -RECN

    ACTN = -ACTN BINARY SEARCH.

    IF sy-subrc = 0.

    READ TABLE INT_CCIHT_IAL INTO wa_CCIHT_IAL

    WITH KEY RECNROOT = wa_CCIHT_IHVA-RECNROOT BINARY SEARCH.

    -ZZIALID = wa_CCIHT_IAL-IALID.

    ENDIF.

    Data for Multi value characteristics is mainly stored in tables AUSP and INOB, so we need to create an inner join for these two table based on OBJEK in AUSP and CUOBJ in INOB to extract the characteristic values.

    Following is the sample code to extract the characteristic values for multi-value Characteristic Fire Type from the tables AUSP and INOB.

    * Concatenate RECN and ACTN to get OBJEK

    concatenate -recn -actn into v_objek.

    * Get the Characteristic values for Multi value field Fire

    Type by joining tables AUSP and INOB

    select i~objek a~atwrt a~atinn

    into corresponding fields of table itab_multival

    from ( ausp as a inner join inob as i on a~objek = i~cuobj ) where a~mafid = 'O' and a~klart = '1

    00' and i~objek = v_objek and a~atinn = '0000004961'.

    In the above statement mafid is Indicator: Object/Class which is restricted to Object, klart is the Class Type, here it is 100 and atinn is the Internal characteristic in this case internal characteristic number for Fire type is 0000004961. You can find the internal characteristic number for any calssification characteristic from table CABN.

    Above select statement will return a maximum of four rows for a particular RECN and ACTN (i.e. for a particular IAL ID) as Characteristic Fire Type can be assigned a maximum of four values as mentioned in step 1.

    Now to update the fields in the extract structure a simple case statement can be used as shown below.

    LOOP AT itab_multival INTO wa_multival.

    CASE wa_multival-atwrt.

    WHEN 'CUST-ZEHSC0000000060'.

    -ZZFIRETYPE1 = 'Y'.

    WHEN 'CUST-ZEHSC0000000061'.

    -ZZFIRETYPE2 = 'Y'.

    WHEN 'CUST-ZEHSC0000000062'.

    -ZZFIRETYPE3 = 'Y'.

    WHEN 'CUST-ZEHSC0000000063'.

    -ZZFIRETYPE4 = 'Y'.

    WHEN OTHERS.

    ENDCASE.

    ENDLOOP.

  • How to Extract Data for Multi-Value Characteristics to SAP BW

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com

    2011 SAP AG 11

    In the above statement ZZFIRETYPE1, ZZFIRETYPE2, ZZFIRETYPE3 and ZZFIRETYPE4 will be updated based on the values entered for characteristic Fire Type in the Application (See the example data in Step 2 & Step 3).

    Snapshot of Data in AUSP table is as shown in the below table:

    OBJEK ATINN ATWRT

    000000000000001234 0000004961 CUST-ZEHSC0000000060

    000000000000001235 0000004961 CUST-ZEHSC0000000060

    000000000000001235 0000004961 CUST-ZEHSC0000000061

    000000000000001235 0000004961 CUST-ZEHSC0000000063

    If you test the extraction in transaction RSA3, extracted data for Incident/Accidents 1001 and 1002 will be as shown in the below table:

    Snapshot of Data after extraction in RSA3:

    ACTN Date From Date To RECN Explosion Type

    Area of Damage

    Fire Type 1

    Fire Type 2

    Fire Type 3

    Fire Type 4

    IAL ID

    0 01/01/1000 12/31/9999 1234 Ballistics 11 - 100 Y 1001

    0 01/01/1000 12/31/9999 1235 Ballistics 11 - 100 Y Y Y 1002

    Step 4: Define additional attributes in the BW system

    With the above steps, configuration on ECC side is completed. Now we would have to define additional attributes in the BW system to accommodate data from these additional fields. To identify the attributes easily for multi-value fields you can include a prefix for the field names e.g. FT_Ordinary Combustible, FT_ Flammable Liquid /gases etc.

  • How to Extract Data for Multi-Value Characteristics to SAP BW

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com

    2011 SAP AG 12

    Once you have defined the additional attributes, you can map these attributes directly with the corresponding fields in the datasource.

    Following is the snapshot of the data after extraction to BW.

    0EHS_IAL FT_Ordinary Combustibles

    FT_Flamable Liquid/gases FT_Electrical

    FT_Flamable Solids/Metals

    Explosion Type

    Area of Damage .

    1001 Y Ballistics 11 - 100 .

    1002 Y Y Y Ballistics 11 - 100 .

  • How to Extract Data for Multi-Value Characteristics to SAP BW

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com

    2011 SAP AG 13

    Related Content

    SAP Note 350296: https://service.sap.com/sap/support/notes/350296

    SAP Note Number: 1002105: https://service.sap.com/sap/support/notes/1002105

    http://wiki.sdn.sap.com/wiki/display/PLM/Classification+at+a+glance

    http://www.google.co.in/url?sa=t&rct=j&q=affine%20uk&source=web&cd=3&sqi=2&ved=0CC0QFjAC&url=http%3A%2F%2Faffine.co.uk%2Fcms%2Fuploads%2FHow_to_Extract_Classification_Data_into_BW.pdf&ei=VWyETuC3BoLKrAeLxZTvDA&usg=AFQjCNGT3DkUVMNWdtQO4Knid_JrTdyZgw

  • How to Extract Data for Multi-Value Characteristics to SAP BW

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com

    2011 SAP AG 14

    Disclaimer and Liability Notice

    This document may discuss sample coding or other information that does not include SAP official interfaces and therefore is not supported by SAP. Changes made based on this information are not supported and can be overwritten during an upgrade.

    SAP will not be held liable for any damages caused by using or misusing the information, code or methods suggested in this document, and anyone using these methods does so at his/her own risk.

    SAP offers no guarantees and assumes no responsibility or liability of any type with respect to the content of this technical article or code sample, including any liability resulting from incompatibility between the content within this document and the materials and services offered by SAP. You agree that you will not hold, or seek to hold, SAP responsible or liable with respect to the content of this document.