Sunteți pe pagina 1din 8

How to Update Master Data during an upload of transactional data

BUSINESS INFORMATION WAREHOUSE

ASAP How to Paper

Applicable Releases: BW 2.0B, 2.1C May 2001


SAP (SAP America, Inc. and SAP AG) assumes no responsibility for errors or omissions in these materials. These materials are provided as is without a warranty of any kind, either express or implied, including but not limited to, the implied warranties of merchantability, fitness for a particular purpose, or non-infringement. SAP shall not be liable for damages of any kind including without limitation direct, special, indirect, or consequential damages that may result from the use of these materials. SAP does not warrant the accuracy or completeness of the information, text, graphics, links or other items contained within these materials. SAP has no control over the information that you may access through the use of hot links contained in these materials and does not endorse your use of third party web pages nor provide any warranty whatsoever relating to third party web pages.

HOW TO UPDATE MASTER DATA DURING AN UPLOAD OF TRANSACTIONAL DATA

1 Business Scenario
Data from legacy systems do not distinguish between transactional data and master data very often. For example you can find the customer number, customer name, period and revenue in one single record.

2 The Result
The SAP Business Information Warehouse stores master data and transactional data in different tables and therefore the data has to be split in the appropriate master data tables and in the fact table from the InfoCube. Example: The file with the transactional data contains the name of the customer: 20010315;1000;10;1;CN00S1;6000;Smith&Co.;10000;USD 20010315;1000;12;2;CN00S2;6001;Bush Transport;5000;USD Customer number 6000: Smith&Co. Customer number 6001: Bush Transport. During the upload of the transaction data, the master data is updated as well.

2001 SAP AMERICA, INC. AND SAP AG

HOW TO UPDATE MASTER DATA DURING AN UPLOAD OF TRANSACTIONAL DATA

3 The Step By Step Solution


1. Create an InfoSource for transaction data. Define the transfer structure according to layout of your file. In this example the InfoObject 0TXTSH - Short description is added to the transfer structure.

2. Define the Update Rules. Create a Startroutine by pressing the Icon.

2001 SAP AMERICA, INC. AND SAP AG

HOW TO UPDATE MASTER DATA DURING AN UPLOAD OF TRANSACTIONAL DATA

3. Add in the global part a definition for the type-pool RSSM and a definition for an internal table. The internal table will collect all customer numbers and names. The complete coding can be found in the appendix. 4. In the routine the internal table is filled with the customer number and name. The internal table DATA_PACKAGE contains all records from one package of the upload.

5. After the collection of all customer numbers and names the internal table custtxt is handed over to the function module RSDMD_WRITE_ATTRIBUTES_TE XTS. Tip: With this function module its also possible to update attributes. An example is shown in the appendix.

2001 SAP AMERICA, INC. AND SAP AG

HOW TO UPDATE MASTER DATA DURING AN UPLOAD OF TRANSACTIONAL DATA

2001 SAP AMERICA, INC. AND SAP AG

HOW TO UPDATE MASTER DATA DURING AN UPLOAD OF TRANSACTIONAL DATA

4 Tips & Tricks


The function module "RSDMD_WRITE_ATTRIBUTES_TEXTS" can also be used for the update/upload of attributes. The I_TABCLASS has to be 'M' (=MASTER) in this case. In I_T_TABLE you have to pass a table (like the structure of the M-VIEW, keep OBJVERS empty) with all records you would like to upload. The following example shows the usage in an ABAP.
REPORT Z_UPLOAD_ATTR .

data: begin of custattr occurs 5000. include structure /BI0/MD_SOLD_TO. data: end of custattr. "M-view

start-of-selection.

*fill internal table all values in internal format (e.g. leading zeros) custattr-D_SOLD_TO custattr-D_COUNTRY = '0000006000'. = 'US'.

custattr-D_INDUSTRY = '111'. append custattr.

custattr-D_SOLD_TO custattr-D_COUNTRY

= '0000006001'. = 'CA'.

custattr-D_INDUSTRY = '222'. append custattr.

call function 'RSDMD_WRITE_ATTRIBUTES_TEXTS' exporting i_iobjnm i_tabclass tables i_t_table exceptions attribute_name_error iobj_not_found = 1 = 2 = custattr = '0D_SOLD_TO' = 'M'

generate_program_error = 3 others = 4.

2001 SAP AMERICA, INC. AND SAP AG

HOW TO UPDATE MASTER DATA DURING AN UPLOAD OF TRANSACTIONAL DATA

5 Appendix
PROGRAM UPDATE_ROUTINE. *$*$ begin of global - insert your declaration only below this line * TABLES: ... type-pools: rssm. data: begin of custtxt occurs 5000. include structure /BI0/TD_SOLD_TO. data: end of custtxt. * DATA: ... *-* "TEXTTABLE *-*

*$*$ end of global - insert your declaration only before this line

FORM startup TABLES MONITOR STRUCTURE RSMONITOR "user defined monitoring DATA_PACKAGE STRUCTURE /BIC/CS0000000092 USING RECORD_ALL LIKE SY-TABIX SOURCE_SYSTEM LIKE RSUPDSIMULH-LOGSYS CHANGING ABORT LIKE SY-SUBRC. "set ABORT <> 0 to cancel update * *$*$ begin of routine - insert your code only below this line * fill the internal table "MONITOR", to make monitor entries *-*

field-symbols: <l_requnr> type rssm_s_minfo-requnr. data: l_requnr type fieldname. data: l_s_minfo type rssm_s_minfo.

* empty internal table refresh custtxt.

* fill internal table with customernumber and customertext loop at DATA_PACKAGE. custtxt-d_sold_to = DATA_PACKAGE-d_sold_to. custtxt-txtsh collect custtxt. endloop. = DATA_PACKAGE-txtsh.

* get requestnumber l_requnr = 'I_REQUNR'. assign (l_requnr) to <l_requnr>. l_s_minfo-requnr = <l_requnr>.

* call text transfer call function 'RSDMD_WRITE_ATTRIBUTES_TEXTS'

2001 SAP AMERICA, INC. AND SAP AG

HOW TO UPDATE MASTER DATA DURING AN UPLOAD OF TRANSACTIONAL DATA


exporting i_iobjnm i_tabclass i_s_minfo tables i_t_table exceptions attribute_name_error iobj_not_found = 1 = 2 = custtxt = '0D_SOLD_TO' = 'T' = l_s_minfo

generate_program_error = 3 others = 4.

* if abort is not equal zero, the update process will be canceled ABORT = 0.

*$*$ end of routine - insert your code only before this line * ENDFORM.

*-*

2001 SAP AMERICA, INC. AND SAP AG

S-ar putea să vă placă și