SAP ISU Deregulation Infrastructure

33
Guideline Simple Data Transformation IS Migration Workbench Document Version 1.01 – April 30, 2010 SAP AG Dietmar-Hopp-Allee 16 D-69190 Walldorf

description

Deregulation Infrastructure technical reference

Transcript of SAP ISU Deregulation Infrastructure

Page 1: SAP ISU Deregulation Infrastructure

Guideline

Simple Data Transformation

IS Migration Workbench

Document Version 1.01 – April 30, 2010

SAP AGDietmar-Hopp-Allee 16

D-69190 Walldorf

Page 2: SAP ISU Deregulation Infrastructure

Simple Data Transformation – IS Migration Workbench

Version 1.01 2 @ Copyright SAP AG 2010

Copyright© 2010 by SAP AG.

All rights reserved. SAP, R/3, SAP NetWeaver, Duet, PartnerEdge, ByDesign, SAP BusinessByDesign, and other SAP products and services mentioned herein as well as their respectivelogos are trademarks or registered trademarks of SAP AG in Germany and other countries.

Business Objects and the Business Objects logo, BusinessObjects, Crystal Reports, CrystalDecisions, Web Intelligence, Xcelsius, and other Business Objects products and servicesmentioned herein as well as their respective logos are trademarks or registered trademarksof Business Objects S.A. in the United States and in other countries. Business Objects is anSAP company.

All other product and service names mentioned are the trademarks of their respectivecompanies. Data contained in this document serves informational purposes only. Nationalproduct specifications may vary.

These materials are subject to change without notice. SAP AG and its affiliated companies(“SAP Group”) provide these materials for informational purposes only, withoutrepresentation or warranty of any kind, and SAP Group shall not be liable for errors oromissions with respect to the materials. The only warranties for SAP Group products andservices are those that are set forth in the express warranty statements accompanying suchproducts and services, if any. Nothing herein should be construed as constituting anadditional warranty.

Document HistoryVersion Date Comment

1.01 30/04/2010 1st version of document published

Page 3: SAP ISU Deregulation Infrastructure

Simple Data Transformation – IS Migration Workbench

Version 1.01 3 @ Copyright SAP AG 2010

Typographic ConventionsType Style Description

Example Text Words or characters quoted from the screen. These include fieldnames, screen titles, pushbutton labels, menu names, menu paths,and menu options. Cross-references to other documentation

Example text Emphasized words or phrases in body text, graphic titles, and tabletitles

EXAMPLE TEXT Technical names of system objects. These include report names,program names, transaction codes, table names, and key conceptsof a programming language when they are surrounded by body text,for example, SELECT and INCLUDE.

Example text Output on the screen. This includes file and directory names andtheir paths, messages, names of variables and parameters, sourcetext, and names of installation, upgrade and database tools.

Example text Exact user entry. These are words or characters that you enter in thesystem exactly as they appear in the documentation.

<Example text> Variable user entry. Angle brackets indicate that you replace thesewords and characters with appropriate entries to make entries in thesystem.

IconsIcon Meaning

Caution

Example

Note

Page 4: SAP ISU Deregulation Infrastructure

Simple Data Transformation – IS Migration Workbench

Version 1.01 4 @ Copyright SAP AG 2010

MotivationThe guideline Simple Data Transformation – IS Migration Workbench is aimed atcustomers, SAP consultants and partners who are responsible for configuring and operatingthe IS Migration Workbench (ISMW). This document supplements the following:

o SAP course IUTW90o User Handbook in the IS Migration Workbencho Cookbook IS Migration Performanceo Guideline Data Migration of FI-CA-Based Industry Solutions – IS Migration Workbencho Further documentation is available on SAP Help Portal at http://help.sap.com

and in the SAP Service Marketplace at http://service.sap.com/ andhttp://service.sap.com/utilities.

o Release notes for ECC 6.0

The purpose of the document is to give guidelines as well as to share experience for asimple but efficient and high performance execution of the data transformation step as part ofthe general data migration process. Functions available in the IS Migration Workbench areexplained only if necessary to understand the solution of a problem. The document highlightsfunctions that are not often used.

The document has the following structure:

Chapter 1 introduces the data transformation as part of the data migration process

Chapter 2 introduces a transformation using text files as input

Chapter 3 introduces a transformation using customer-specific tables as input

Chapter 4 shows some examples how to enhance your development

AuthorFriedrich Keller, SAP AG

FeedbackWe would very much appreciate your feedback on this document. Please send yourcomments to mailto:[email protected].

Page 5: SAP ISU Deregulation Infrastructure

Simple Data Transformation – IS Migration Workbench

Version 1.01 5 @ Copyright SAP AG 2010

Table of contents1 Data Transformation............................................................................................... 61.1 Motivation ....................................................................................................................... 61.2 Transformation Tools ..................................................................................................... 71.2.1 SAP Data Migration Services......................................................................................... 71.2.2 Simple Data Transformation with the IS Migration Workbench ...................................... 7

2 Transformation from Text File ............................................................................... 82.1 Data Flow ........................................................................................................................ 82.2 Migration Object ........................................................................................................... 102.3 Text File (Input) ............................................................................................................. 102.4 Binary Import File (Output) .......................................................................................... 112.5 Transformation Function Module ................................................................................ 122.5.1 Parameter Interface ..................................................................................................... 142.5.2 Sample Transformation Function Module .................................................................... 152.5.3 Direct Data Migration with Import Function Module ...................................................... 17

3 Transformation from Customer-Specific Tables................................................ 183.1 Data Flow ...................................................................................................................... 183.2 Open Function Module ................................................................................................. 213.2.1 Parameter Interface ..................................................................................................... 213.2.2 Sample Open Function Module ................................................................................... 213.3 Read Function Module ................................................................................................. 223.3.1 Parameter Interface ..................................................................................................... 223.3.2 Sample Read Function Module .................................................................................... 233.4 Sample Transformation Function Module .................................................................. 243.4.1 Sample Transformation Function Module .................................................................... 253.5 Close Function Module ................................................................................................ 273.5.1 Parameter Interface ..................................................................................................... 273.5.2 Sample Close Function Module ................................................................................... 27

4 Enhancements ...................................................................................................... 284.1 Alternative Data Selection ........................................................................................... 284.1.1 Motivation .................................................................................................................... 284.1.2 Sample Open Function Module ................................................................................... 284.1.3 Sample Read Function Module .................................................................................... 294.1.4 Sample Close Function Module ................................................................................... 304.1.5 Sample TOP-Include ................................................................................................... 304.2 Application Log ............................................................................................................ 304.2.1 Motivation .................................................................................................................... 304.2.2 Sample Open Function Module ................................................................................... 304.2.3 Sample Close Function Module ................................................................................... 314.2.4 Sample TOP-Include ................................................................................................... 324.2.5 Message Handling ....................................................................................................... 32

5 Final Comments .................................................................................................... 33

Page 6: SAP ISU Deregulation Infrastructure

Simple Data Transformation – IS Migration Workbench

Version 1.01 6 @ Copyright SAP AG 2010

1 Data Transformation1.1 MotivationData transformation represents the second phase in the extraction, transformation andloading data migration process (ETL process). During data transformation, extracted data ofthe legacy system(s) is processed and manipulated in applying a series of rules or functionsto provide the data to be loaded into the target SAP system. Some data requires little or evenno manipulation while in other cases one or more of the transformation steps might berequired to meet business and technical requirements of the target system. Transformationsteps can be:o Replacing (for example, the legacy system stores the title of a business partner

unformatted such as Mrs. and Mr., while the SAP system requires the same informationas 0002 and 0001 according to the Customizing on the SAP system)

o Aligning (for example, the legacy system saves a number entity left-aligned while theSAP system requires the same right-aligned)

o Completing (for example, the legacy system data must be completed by leading ortrailing zeros, or the SAP system requires additional fields to be transferred for which thelegacy system does not store related information)

o Filtering (for example, not all data will have to be loaded into the SAP system accordingto selection criteria defined by business requirements)

o Sorting (for example, data must be loaded into the SAP system in a certain order)o Joining (for example, data for a single entity on the SAP system is stored in multiple

database tables or legacy systems and needs to be merged)o Deriving a calculated value (for example, calculation of the balance to migrate a single

financial document in instead of migrating every non-paid invoice independently)o Validating (for example, rejection of data hence none or only some of the data is

handed over to the next transformation step)

You can execute a data transformation in one of the following ways:o Solely during the data extraction process: This approach is commonly implemented if

the source is only one single legacy system with a very simple data model.o Solely on a separate transformation system: This approach is implemented if

o A specialized transformation system is available and you must implement complextransformation rules

o More than one legacy systems form the source for the later data load and eachlegacy system stores data with dependencies to the other legacy system(s). Usuallysuch legacy systems are connected through interfaces.

o The database of the legacy system is dumped into text files instead of extracting datawith queries.

Of course, no single solution exists for all possible scenarios. Usually the first transformationphase is executed during extraction if any of the described transformation steps, such asfiltering, joining and aggregation leads to a significantly reduced dataset to be transformed orif the performance of the extraction can be improved significantly with specialized measures(for example, creation of an index table with data commonly used by subsequent extractionsteps). Also during the load process transformation steps can be executed but usually thisapproach covers only a very small part of the transformation process and is used only if theload tool, such as the IS Migration Workbench, supports transformation rules.

Page 7: SAP ISU Deregulation Infrastructure

Simple Data Transformation – IS Migration Workbench

Version 1.01 7 @ Copyright SAP AG 2010

1.2 Transformation ToolsThere exist many transformation tools on the market. Any of these tools requires hardware torun the transformation tool and specialized people to implement the transformation rules andfunctions.

1.2.1 SAP Data Migration ServicesThe transformation with SAP Data Migration Services consists of a framework, templates,methodology, tools and expertise to analyze, extract, cleanse, validate and reconcile legacydata into a SAP ERP environment. SAP Data Migration Services provide a mature andpowerful information management infrastructure and enables data governance best practicesthat live on after the project.

1.2.2 Simple Data Transformation with the IS Migration WorkbenchThis document focuses on a different and very simplified transformation process based on anABAP report. You can use the same SAP system for the data transformation as you use forthe execution of the data load with the IS Migration Workbench. The actual datatransformation is performed in customer-specific function modules that are called as eventsby an ABAP report. The output are import files that are ready to be loaded into the SAPsystem by the IS Migration Workbench.Typically, you use this report if you can abandon a comprehensive data transformationprocess in favor of a rapid implementation. This can be the case if you need to perform arapid data migration to support prototyping of your solution. All such use-cases imply thatyour transformation process is simple by nature.

The next chapters describe this framework in more details.

Page 8: SAP ISU Deregulation Infrastructure

Simple Data Transformation – IS Migration Workbench

Version 1.01 8 @ Copyright SAP AG 2010

2 Transformation from Text File2.1 Data FlowThe data transformation process uses the output of the data extraction process as input andcreates data files as its output. The IS Migration Workbench uses this file as import files forthe data load into the SAP system in the subsequent step of the ETL process. To avoidfurther conversion steps before the data load, the transformation process should create theimport files in the required binary file format and the correct layout of each data record in thefile.

The REMIG_FILE_CREATE report supports not only a simple data transformation processbut also the creation of import files in the correct format and correct layout based on themigration specific Customizing of the related migration object. The report allows a simpledata transformation using a text file as input in passing the information from the text to acustomer-specific function module for a data transformation.

You must develop an own transformation function module per migration object. Thefunction module processes the information and returns the transformed data. In a final step,the REMIG_FILE_CREATE report writes the data to the import file in the correct format andlayout ready to be processed by the related load program of the IS Migration Workbench.

Figure 2-1 shows a flow chart of the REMIG_FILE_CREATE report when performing atransformation from customer-specific database tables.

Figure 2-1: Flow Chart of the REMIG_FILE_CREATE Report

Page 9: SAP ISU Deregulation Infrastructure

Simple Data Transformation – IS Migration Workbench

Version 1.01 9 @ Copyright SAP AG 2010

Figure 2-3 shows the data flow of the described process.

Figure 2-2: Data Flow of the Simple Transformation Process

Figure 2-3 shows the selection screen of the REMIG_FILE_CREATE report. All parameterswill be explained in the following chapters.

Figure 2-3: Selection Screen of REMIG_FILE_CREATE Report

Page 10: SAP ISU Deregulation Infrastructure

Simple Data Transformation – IS Migration Workbench

Version 1.01 10 @ Copyright SAP AG 2010

2.2 Migration ObjectAn import file of the IS Migration Workbench can only be used for a data migration of aparticular migration object. A migration object in the IS Migration Workbench is a logicalunit that combines the functional and technical aspects for a migration of data into the SAPsystem. For example, you use the PARTNER migration object to migrate business partnersinto the SAP system. All migration objects belonging to one migration project form amigration company. The basis for the technical definition of a migration object is an ABAPfunction module and its parameter interface. The parameter interface of the function moduledefines the automation data of the migration object. A function module used in a migrationobject is called a service function module; its interface is called automation data structure.The service function module creates the requested business master data or transaction datausing the data in the automation data structure.

The automation data of a migration object represents all fields used by the service functionmodule to create a business object in the SAP system. The automation data structure(automation data) consists of one or more structures. You can reduce the number of fields tobe populated by the information in the import file with a migration object specificCustomizing. The remaining fields form the customer structure that defines the layout perdata record in the import file.For more information about the concepts of the IS Migration Workbench, such as, migration,object, migration company and customer structure, see chapter 2 Functions in Details in theGuideline Data Migration of FI-CA-Based Industry Solutions – IS Migration Workbench.

The transformation function module populates the fields of the customer structure and theREMIG_FILE_CREATE report writes the data in the correct binary format to the import file.

Figure 2-4 summarizes the migration object specific parameters.

Field Meaning

Company Name of migration company where your migrationobjects can be found

Migration Object Name of migration object for which the transformationtakes place.

Function Module Transformation function module to be used for atransformation based on the migration object specificCustomizing

Figure 2-4: Migration Object Parameters on the Selection Screen

2.3 Text File (Input)The REMIG_FILE_CREATE report requires a text file as input. Each data record in the textfile contains all required data to migrate one unique business object on the SAP system. Ifthe data is not sufficient, you can be complete the data during the data transformation or dataload process. Still, the data must be sufficient to identify and create one unique businessobject, for example a business partner, on the SAP system.

The REMIG_FILE_CREATE report reads each data record as a character line in the definedcharacter representation (code page). During data extraction, you can divide the fieldinformation in a data record by a field separator to simplify the identification of field relatedinformation during the transformation process. Otherwise, you have to split the characterstream in your customer-specific function module.In the first data record of your text file, you can transfer a field description, such as the fieldnames to help you identifying field data during data transformation.

Page 11: SAP ISU Deregulation Infrastructure

Simple Data Transformation – IS Migration Workbench

Version 1.01 11 @ Copyright SAP AG 2010

Figure 2-5 summarizes the parameters relevant for the text file.Field Meaning

Remote Server Current application server (display-only)

Migration Path Directory where your text file is located

Migration File Name Name of your text file

Legacy System Character Set Codepage you used to create the text file. TheREMIG_FILE_CREATE report translates the contents ofthe text file from the given codepage to the character setof the SAP system.

Field Separators Special character to separate field information in thedata records. The default separator character is thehorizontal tab stop character.

Indicator for Header If this field is marked, the REMIG_FILE_CREATE reportwill not transform the first data record in the text file.Instead, the report passes this data record as additionalinformation to the customer-specific transformationfunction module.

Figure 2-5: Text File Parameters on the Selection Screen

Figure 2-6 shows a sample text file with customer information ready for atransformation. The first data record contains the header line and the subsequent data

records the detailed information per customer. The special character | separates the fieldinformation.

Figure 2-6: Sample Text File with Customer Information

You can use the same text file as input for a data transformation of more than onebusiness object. This is particularly favorable if a business object in the SAP data

model does not exist in the legacy data model, for example the SAP business objectContract Account. In most cases, you can derive data for a creation of the related contractaccounts from the available customer data; you populate the remaining required fields withfixed (constant) values either during data transformation or during data load. In the lattercase, an appropriate migration Customizing of the related ACCOUNT migration object isrequired.

2.4 Binary Import File (Output)The IS Migration Workbench can read import files for a data load only if they are available ina special binary format. The layout per data record in the binary import file depends on themigration specific Customizing of the related migration object of the IS Migration Workbench.The automation data of a migration object represents all fields used by a service function

Page 12: SAP ISU Deregulation Infrastructure

Simple Data Transformation – IS Migration Workbench

Version 1.01 12 @ Copyright SAP AG 2010

module to create a business object in the SAP system. The automation data structure(automation data) consists of one or more structures. In the IS Migration Workbench, a fieldrule describes the unique rule with which an individual field in the automation data structureis processed during data import. You must define a field rule for each field of an automationdata structure. The default field rule is the processing of the initial value of the field.

There are fields of an automation data structure that you can switch off. This means that theyare not to be populated and are not required in the data migration process. You cannotswitch off mandatory fields. The remaining fields form the customer structure; this is thecustomized automation data structure reduced by a number of fields. Every field of acustomer structure has to have a rule other than the Initial or Fixed value field rule. This isbecause only fields for which you have transferred values in the import file are part of thecustomer structure. The load program of the IS Migration Workbench reads the data in thelayout of the customer structure.For more information about the import file, see chapter 2.4 Field Rules and chapter 2.6.1Import File and following in the Guideline Data Migration of FI-CA-Based IndustrySolutions – IS Migration Workbench.

Figure 2-7 summarizes the parameters relevant for binary import file.

Field Meaning

Remote Server Current application server (display-only)

Migration Path Directory where your new binary import text file shouldbe created

Migration File Name Name of your binary import file

Legacy System Character Set Codepage you want to use to create the binary importfile.The REMIG_FILE_CREATE report translates the datainto the defined character set before writing it to thebinary import file. During the data load, the IS MigrationWorkbench translate the data to the codepage the SAPsystems uses

Mass Import File Size Number of data objects per created binary import file.If you leave this field empty, the REMIG_FILE_CREATEreport creates only one single binary import file.

If you enter a number, the REMIG_FILE_CREATE reportcreates more than one binary import file. Each of themcontains the defined number of data objects except forthe last file. The Migration File Name field must containthe placeholder character &. The report replaces theplaceholder & with a consecutive number when creationa new binary import file.

Figure 2-7: Binary Import File Parameters on the Selection Screen

2.5 Transformation Function ModuleThe customer-specific function module is the central module of the transformation processwhile the REMIG_FILE_CREATE report represents the framework that is calling the functionmodule.The REMIG_FILE_CREATE report reads the text file and prepares the content of the readdata record for a processing by the function module. Then it calls the function moduletransferring the content of the data record, the name of the customer structure to be

Page 13: SAP ISU Deregulation Infrastructure

Simple Data Transformation – IS Migration Workbench

Version 1.01 13 @ Copyright SAP AG 2010

processed and the customer structure itself. The function module returns to the report whatactions it wants to perform on structure, object level and file level.

Figure 2-8 summarizes the possible actions for a forward navigation through the customerstructures. You must include the definition of the constants in your function module. Thename of the ABAP include is REMIG_FILE_CREATE_CONST.

Level Action Meaning

Structure CO_ACTION_STRUCTURE_SAVE_NEXT Save structure and process nextcustomer structure.This action is requested when thecurrent customer structure has beenupdated and the next customerstructure can be processed.

CO_ACTION_STRUCTURE_SAVE_SAME Save structure and process samecustomer structure again.This action is requested when thecurrent structure is a reoccurringstructure (for example, the BUT020structure of the PARTNER migrationobject that is used to transfer addressdata). The current customer structurehas been updated and the samecustomer structure is to be processedagain.

CO_ACTION_STRUCTURE_DROP Drop customer structure and processnext customer structure.This action is requested when thecurrent customer structure can bediscarded. The next customerstructure is to be processed.

CO_ACTION_STRUCTURE_SAVE_UP Save structure and process nextcustomer structure (1 level up)The automation structure can be adeep structure hence the customerstructure form also a hierarchy. Thisaction is requested when the currentcustomer structure has been updated.The next customer structure on thehierarchy level above is to beprocessed.

CO_ACTION_STRUCTURE_DROP_UP Drop customer structure and processnext customer structure (1 level up)This action is requested when thecurrent customer structure can bediscarded. The next customerstructure on the hierarchy level aboveis to be processed.

Object CO_ACTION_OBJECT_CONTINUE Continue processing of the currentdata object.This action is requested when thefurther processing of customerstructures of the current data object isrequired.

CO_ACTION_OBJECT__COMPLETE Complete data object and process

Page 14: SAP ISU Deregulation Infrastructure

Simple Data Transformation – IS Migration Workbench

Version 1.01 14 @ Copyright SAP AG 2010

next data record from text file.This action is requested when thedata object with all processed andupdated customer structures can bewritten to the binary import file andthe next data record in the text filecan be processed.

CO_ACTION_OBJECT_SAVE_SAME Complete data object and processsame data record againThis action is requested when thedata object with all processed andupdated customer structures can bewritten to the binary import file andthe same data record from the text fileshould be processed anew.

CO_ACTION_OBJECT_OBJECT_REF_DROP Drop object reference and processnext reference (hyper object)This action can be used only for hypermigration object. Thjis action isrequested to move forward to find therelevant reference of the realtedmigration object.

File CO_ACTION_FILE_CONTINUE Read next data record from text fileThis action is requested to read thenext data record from the text file.

CO_ACTION_FILE_EXIT Finish the data transformationprocess.

Figure 2-8: Summary of available Actions

The REMIG_FILE_CREATE report saves all updated customer structures in memoryand defers the update of the binary import file until the transformation function module

signals that the data object with its customer structures is complete. The relevant actions onfile level are CO_ACTION_OBJECT_COMPLETE and CO_ACTION_OBJECT_SAVE_SAME.

2.5.1 Parameter InterfaceThe following figure summarizes the parameter interface of the transformation functionmodule:

Direction Parameter DDIC Type Meaning

Importing X_FIRMA EMG_FIRMA Name of migration company

X_OBJECT EMG_OBJECT Name of migration object

X_REF_OBJECT EMG_OBJECT Name of referenced migration object(hyper migration object)

X_DTTYP EMG_DTTYP Name of actual customer structure

X_OCCURENCE SYINDEX Number how often the report has calledthe function module with the samecustomer structure for the actual dataobject.

Exporting Y_OLDKEY EMG_OLDKEY Legacy system key for the current dataobject

Y_ACTION_STRUCTURE EMG_WMODE Requested action on structure level

Page 15: SAP ISU Deregulation Infrastructure

Simple Data Transformation – IS Migration Workbench

Version 1.01 15 @ Copyright SAP AG 2010

Y_ACTION_OBJECT EMG_WMODE Requested action on object level

Y_ACTION_FILE EMG_WMODE Requested action on text file level

Tables XT_HEADER_TAB table Header line of text file

XT_DATA_TAB table Actual data record of text file

Changing XY_CUSTOMER Actual customer structure

Figure 2-9: Parameter Interface of a Transformation Function Module

o The Y_OLDKEY parameter must be unique for each data object of a specific migrationobject. For more information about legacy system keys or oldkeys, see chapter 2.5 Keyand Status Management in the Guideline Data Migration of FI-CA-Based IndustrySolutions – IS Migration Workbench.

o The XT_HEADER_TAB parameter transfers the header line and the XT_DATA_TABparameter the current data record of the text file in internal tables. TheREMIG_FILE_CREATE report separates the data records according to the sequence ofthe specified field separator contained in the data record (see Figure 2-5 for furtherdetails about the field separator). The results are stored in the lines of the internal table.Before the separation, the report initializes the internal table.The report searches the data record from right to left for all occurrences of the fieldseparator. The search is case-sensitive. All content from the start of the data record tothe first found location, between the found locations, and from the last found location tothe end of the data record are appended to the internal table.If the specified field separator is found immediately at the start of the data record, oroccurs in direct succession, the result of the separation is an empty line in the internaltable. If the field separator is at the end of the data record, the search is terminated andno further separation takes place to the right of this point.If the field separator is not found or is an empty string, the result of the separation is asingle field that contains the whole data record, and which is assigned to the first line ofthe internal table.

o The XY_CUSTOMER parameter represents the actual customer structure the functionmodule must process next. Macros are available to simplify the transfer of values to thefields of the related customer structure. The macro definition can be found in the code ofthe sample transformation module in chapter 2.5.2 Sample Transformation FunctionModule.o MAC_FIELD_VALUE &1 &2:

&1: fieldname of customer structure&2: value to be moved to the field of the customer structure

Example: MAC_FIELD_VALUE 'WAKLASS' '0001'.(Move the value ‘0001’ to the WAKLASS field)

o MAC_FIELD_TAB_VALUE &1 &2:&1: fieldname of customer structure&2: line number of the XT_DATA_TAB internal table

Example: MAC_FIELD_TAB_VALUE 'NAME_LAST' 3.(Move the content of the third line of the XT_DATA_TAB internal table to theNAME_LAST field)

2.5.2 Sample Transformation Function ModuleFigure 2-10 shows a sample transformation function module that is also available in yourSAP system. The function module transforms the text file of Figure 2-6 into a binary importfile. The right column explains the details of the implementation.

Page 16: SAP ISU Deregulation Infrastructure

Simple Data Transformation – IS Migration Workbench

Version 1.01 16 @ Copyright SAP AG 2010

ABAP Code of Function Module Comments

FUNCTION ISU_M_SAMPLE_CONVERT.*"-----------------------------------------------------------*"*"Local Interface:*" IMPORTING*" REFERENCE(X_FIRMA) TYPE EMG_FIRMA*" REFERENCE(X_OBJECT) TYPE EMG_OBJECT*" REFERENCE(X_REF_OBJECT) TYPE EMG_OBJECT*" REFERENCE(X_DTTYP) TYPE EMG_DTTYP*" REFERENCE(X_OCCURENCE) TYPE SYINDEX*" EXPORTING*" REFERENCE(Y_OLDKEY) TYPE EMG_OLDKEY*" REFERENCE(Y_ACTION_STRUCTURE) TYPE EMG_WMODE*" REFERENCE(Y_ACTION_OBJECT) TYPE EMG_WMODE*" REFERENCE(Y_ACTION_FILE) TYPE EMG_WMODE*" TABLES*" XT_HEADER_TAB*" XT_DATA_TAB*" CHANGING*" REFERENCE(XY_CUSTOMER)*"-----------------------------------------------------------

* field symbols FIELD-SYMBOLS: <fs_field_value> TYPE ANY.

* includes INCLUDE remig_file_create_const.

* macros to simplify value assignment DEFINE mac_field_value. assign component &1 of structure xy_customer to <fs_field_value>. if sy-subrc eq 0. <fs_field_value> = &2. endif. END-OF-DEFINITION.

DEFINE mac_field_tab_value. assign component &1 of structure xy_customer to <fs_field_value>. if sy-subrc eq 0. read table xt_data_tab into <fs_field_value> index &2. endif. END-OF-DEFINITION.

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

* assign oldkey which can be found at row #1 READ TABLE xt_data_tab INTO y_oldkey INDEX 1.

* value assignment in dependancy of record data type CASE x_dttyp. WHEN 'INIT'. “ structure contains only fields with fixed value rule. y_action_structure = co_action_structure_save_next. y_action_object = co_action_object_continue. WHEN 'EKUN'. mac_field_value ' KTOKLASSE' '0002'. y_action_structure = co_action_structure_save_next. y_action_object = co_action_object_continue. WHEN 'BUT000'. mac_field_tab_value 'NAME_FIRST' 2. mac_field_tab_value 'NAME_LAST' 3. mac_field_value 'TITLE' '003'. y_action_structure = co_action_structure_save_next. y_action_object = co_action_object_continue. WHEN 'BUT020'. IF x_occurence = 1. mac_field_tab_value 'POST_CODE1' 4. mac_field_tab_value 'CITY1' 5. mac_field_tab_value 'STREET' 6. mac_field_tab_value 'HOUSE_NUM1' 7. “ fill some more fields if BUT020 occurs 1st time

Parameter interface of thefunction module as described

Field symbol for macros

Include constant values todescribe the actions

Definition ofMAC_FIELD_VALUE macro

Definition ofMAC_FIELD_TAB_VALUE macro

Assign the oldkey using theID field from the text file

Fill INIT structure

Save structure and get nextData object not ready yetFill EKUN structure Field for account classSave structure and get nextData object not ready yetFill BUT000 structure Field for first name Field for last name Field for titleSave structure and get nextData object not ready yetFill BUT020 structure When occurs the 1st time Fields for zip code, Field for city name Field for street name Field for house number

Page 17: SAP ISU Deregulation Infrastructure

Simple Data Transformation – IS Migration Workbench

Version 1.01 17 @ Copyright SAP AG 2010

“ mac_field_tab_value … y_action_structure = co_action_structure_save_same. y_action_object = co_action_object_continue. ELSE. “ fill some more fields if BUT020 occurs 2nd time

“ mac_field_tab_value … y_action_structure = co_action_structure_save_next. y_action_object = co_action_object_complete. ENDIF. WHEN OTHERS. y_action_structure = co_action_structure_drop. ENDCASE.

* read file till end-of-file y_action_file = co_action_file_continue.

ENDFUNCTION.

Save structure and get sameData object not ready yet

… other/more fields ifBUT020 occurs the 2nd timeSave structureData object can be saved

No other structures toprocess

Continue reading import file

Figure 2-10: Sample Transformation Function Module

2.5.3 Direct Data Migration with Import Function ModuleInstead of creating a binary import file, you can choose a direct data migration of thetransformed data object. This option is only available on the selection screen of theREMIG_FILE_CREATE report if the Import Function Module field on the Parameters subscreen, which is in the Object Maintenance screen, has been marked The import functionmodule is generated by the IS Migration Workbench when it generates the load report of themigration object. For more information about the import function module, see chapter 2.6.3Import File Editor in the Guideline Data Migration of FI-CA-Based Industry Solutions – ISMigration Workbench.Figure 2-11 shows the radio button and the name of the active import function module (displayonly) on the selection screen of the REMIG_FILE_CREATE report you must select to force adirect data migration.

Figure 2-11: Selection Screen of REMIG_FILE_CREATE Report (Direct Import)

Page 18: SAP ISU Deregulation Infrastructure

Simple Data Transformation – IS Migration Workbench

Version 1.01 18 @ Copyright SAP AG 2010

3 Transformation from Customer-Specific Tables3.1 Data FlowThe REMIG_FILE_CREATE report allows not only a simple data transformation using a textfile as input but also customer-specific database tables on an SAP system. For this, the textfiles are loaded into the SAP database before starting the transformation process with theREMIG_FILE_CREATE report.

You can load the text files into the customer-specific database tables with a database-specific load tool or, alternatively, with an ABAP report. A database tool is usually the

preferred option due to performance reasons.The customer-specific function modules retrieve the source data from the customer-specifictables and move them forward to the transformation function module for a transformation intocustomer structures. A transformation of data from customer-specific tables is available as ofSAP Enhancement Package 5 for SAP ERP 6.0.In addition to the transformation function module, you must develop the following functionmodules:o Open function module: Preparation of the data selection (for example, with the ABAP

statement OPEN CURSOR)o Read function module: Read the data from the customer-specific tables and move them

into the internal table XT_DATA_TAB to be passed to the transformation function module(for example, with ABAP statement SELECT)

o Close function module: Close data selection (for example, CLOSE CURSOR)Figure 3-1 shows a flow chart of the REMIG_FILE_CREATE report when performing atransformation from customer-specific database tables.

Figure 3-1: Flow Chart of the REMIG_FILE_CREATE Report

Page 19: SAP ISU Deregulation Infrastructure

Simple Data Transformation – IS Migration Workbench

Version 1.01 19 @ Copyright SAP AG 2010

SAP delivers sample function modules you can use as a basis for your own development.You find the sample function modules in the EMIG_SAMPLE_CONVERT function group.

Like the transformation function module, the function modules are normally migrationobject specific. However, you can use the same function modules for a data selection

for more than one business object. This is possible if a business object in the SAP datamodel does not exist in the legacy data model, for example the SAP business objectContract Account. In most cases, you can derive data for a creation of the related contractaccounts from the available customer data.

Figure 3-2 shows the data flow of the process.

Figure 3-2: Data Flow for a Transformation from SAP Database

Figure 3-3 shows the selection screen of the REMIG_FILE_CREATE report that changedslightly compared to the previous version. You can use the additional parameters SelectionInterval 1 – 3 to pass additional information in particular to the open and read functionmodules. You can use this information, for example, to define ranges or a selection of data ofonly a group of customers. This allows a parallelization of the transformation process withmultiple jobs. Alternatively, you can pass a list of customer IDs to the REMIG_FILE_CREATEreport for a selective transformation of only the customers on this list.

Page 20: SAP ISU Deregulation Infrastructure

Simple Data Transformation – IS Migration Workbench

Version 1.01 20 @ Copyright SAP AG 2010

Figure 3-3: Selection Screen of REMIG_FILE_CREATE Report (as of ECC 6.0 EhP 5)

Figure 3-4 summarizes the parameters on the selection screen that are relevant for a dataselection from customer-specific tables.

Field Meaning

Function Module OPEN Function module to prepare the data selection

Function Module READ Function module to select the data from database

Function Module CONVERT Function module for transform the data

Function Module CLOSE Function module to close the data selection

Selection Interval 1 - 3 Additional Parameter for data selection

Figure 3-4: Text File Parameters on the Selection Screen

Page 21: SAP ISU Deregulation Infrastructure

Simple Data Transformation – IS Migration Workbench

Version 1.01 21 @ Copyright SAP AG 2010

3.2 Open Function Module3.2.1 Parameter InterfaceThe following figure summarizes the parameter interface of the open function module:

Direction Parameter DDIC Type Meaning

Importing X_FIRMA EMG_FIRMA Name of migration company

X_OBJECT EMG_OBJECT Name of migration object

Exporting Y_ACTION_FILE EMG_WMODE Requested action on text file level

Tables XT_INTERVAL_1…3 table Additional data from selection screen

XT_HEADER_TAB table Field names related to data inXT_DATA_TAB

XT_ADD_DATA_1…5 table Additional data exchange betweenfunction modules.

Figure 3-5: Parameter Interface of the Open Function Module

o You can use the XT_HEADER_TAB parameter to transfer field names to thetransformation function module. The XT_HEADER_TAB table corresponds to the headerline of the text file.

o You can use the XT_ADD_DATA_1 to _5 parameters to exchange information betweenyour function modules during the transformation process. In addition, you can exchangedata through variables you define in the global memory of your function group (TOPInclude)

3.2.2 Sample Open Function ModuleFigure 3-6 shows a sample open function module. The function module accesses thecustomer-specific ZZCUSTOMER table to select the customer data. The right column explainsthe details of the implementation.

ABAP Code of Function Module Comments

FUNCTION ZZ_PARTNER_OPEN.*"-----------------------------------------------------------*"*"Local Interface:*" IMPORTING*" REFERENCE(X_FIRMA) TYPE EMG_FIRMA OPTIONAL*" REFERENCE(X_OBJECT) TYPE EMG_OBJECT OPTIONAL*" EXPORTING*" REFERENCE(Y_ACTION_FILE) TYPE EMG_WMODE*" TABLES*" XT_INTERVAL_1 STRUCTURE EMG_CONVERT_SELOPT OPTIONAL*" XT_INTERVAL_2 STRUCTURE EMG_CONVERT_SELOPT OPTIONAL*" XT_INTERVAL_3 STRUCTURE EMG_CONVERT_SELOPT OPTIONAL*" XT_HEADER_TAB OPTIONAL*" XT_ADD_DATA_1 OPTIONAL*" XT_ADD_DATA_2 OPTIONAL*" XT_ADD_DATA_3 OPTIONAL*" XT_ADD_DATA_4 OPTIONAL*" XT_ADD_DATA_5 OPTIONAL*"-----------------------------------------------------------

* Open Database Cursor OPEN CURSOR cs_customer FOR SELECT * FROM zzcustomer WHERE id IN xt_interval_1. IF sy-subrc EQ 0.

" data selection ok y_action_file = co_action_file_ok. ELSE.

" all selected data processed => end-of-file

Parameter interface of thefunction module as described

Variable CS_CUSTOMER isdefined in TOP-Include as oftype CURSOR.

Page 22: SAP ISU Deregulation Infrastructure

Simple Data Transformation – IS Migration Workbench

Version 1.01 22 @ Copyright SAP AG 2010

y_action_file = co_action_file_eof. ENDIF.

* fill field name table (optional) xt_header_tab = 'ID'. " customer ID APPEND xt_header_tab. xt_header_tab = 'NAME'. " customer name APPEND xt_header_tab. xt_header_tab = 'SURNAME'. " customer surname APPEND xt_header_tab. xt_header_tab = 'POSTCODE'. " postal code APPEND xt_header_tab. xt_header_tab = 'CITY'. " city name APPEND xt_header_tab. xt_header_tab = 'STREET'. " street name APPEND xt_header_tab. xt_header_tab = 'NUMBER'. " house number APPEND xt_header_tab.

ENDFUNCTION.

The header table can befilled with the relatedfield names.

Figure 3-6: Sample Open Function Module

Figure 3-7 shows the TOP-Include of the related function group.

ABAP Code of Function Module Comments

FUNCTION-POOL zzmig_partner MESSAGE-ID em.

INCLUDE remig_file_create_const.

* Global Variables to be accessible from all function modulesDATA: cs_customer TYPE cursor.

Include with constant valuesfor actions

Database cursor

Figure 3-7: TOP-Include of Function Group

3.3 Read Function Module3.3.1 Parameter InterfaceThe following figure summarizes the parameter interface of the open function module:

Direction Parameter DDIC Type Meaning

Importing X_FIRMA EMG_FIRMA Name of migration company

X_OBJECT EMG_OBJECT Name of migration object

Exporting Y_ACTION_FILE EMG_WMODE Requested action on text file level

Tables XT_HEADER_TAB table Field names related to data inXT_DATA_TAB (filled in Open functionmodule)

XT_DATA_TAB table Actual data for transformation

XT_ADD_DATA_1…5 table Additional data exchange betweenfunction modules.

Figure 3-8: Parameter Interface of the Read Function Module

o You can use the XT_HEADER_TAB parameter to transfer field names to thetransformation function module. The XT_HEADER_TAB table corresponds to the headerline of the text file.

Page 23: SAP ISU Deregulation Infrastructure

Simple Data Transformation – IS Migration Workbench

Version 1.01 23 @ Copyright SAP AG 2010

o The read function module fills the XT_DATA_TAB table to transfer field values to thetransformation function module. The XT_DATA_TAB table corresponds to a data recordin an import text file.

o You can use the XT_ADD_DATA_1 to _5 parameters to exchange information betweenyour function modules during the transformation process. In addition, you can exchangedata through variables you define in the global memory of your function group (TOPInclude)

3.3.2 Sample Read Function ModuleFigure 3-9 shows a sample read function module. The function module fetches the nextrelevant row from the customer-specific ZZCUSTOMER table. The right column explains thedetails of the implementation.

ABAP Code of Function Module Comments

FUNCTION ZZ_PARTNER_READ.*"-----------------------------------------------------------*"*"Local Interface:*" IMPORTING*" REFERENCE(X_FIRMA) TYPE EMG_FIRMA OPTIONAL*" REFERENCE(X_OBJECT) TYPE EMG_OBJECT OPTIONAL*" EXPORTING*" REFERENCE(Y_ACTION_FILE) TYPE EMG_WMODE*" TABLES*" XT_HEADER_TAB OPTIONAL*" XT_DATA_TAB OPTIONAL*" XT_ADD_DATA_1 OPTIONAL*" XT_ADD_DATA_2 OPTIONAL*" XT_ADD_DATA_3 OPTIONAL*" XT_ADD_DATA_4 OPTIONAL*" XT_ADD_DATA_5 OPTIONAL*"-----------------------------------------------------------

* local data definition DATA: lv_zzcustomer TYPE zzcustomer.

* Read customer-specific table from cursor FETCH NEXT CURSOR cs_customer INTO lv_zzcustomer. IF sy-subrc EQ 0.

" data selection ok y_action_file = co_action_file_ok. ELSE.

" all selected data processed => end-of-file y_action_file = co_action_file_eof. ENDIF.

*+ Alternative approach (internal table):*+*+ local data definition (alternative approach)*+ DATA: lv_tabix TYPE sy-tabix.*+*+ get current index to access internal table*+ READ TABLE xt_add_data_1 INTO lv_tabix INDEX 1.*+* select data from internal table*+ READ TABLE gt_customer INTO lv_zzcustomer INDEX lv_tabix.*+ IF sy-subrc EQ 0.*+ " data selection ok*+ y_action_file = co_action_file_ok.*+ ELSE.*+ " all selected data processed => end-of-file*+ y_action_file = co_action_file_eof.*+ ENDIF.*+*+ prepare next selection*+ lv_tabix = lv_tabix + 1.*+ xt_add_data_1 = lv_tabix.*+ MODIFY xt_add_data_1 INDEX 1.

* Additional selects if necessary ...

Parameter interface of thefunction module as described

Alternative 1: get next rowusing the opened databasecursor. The cursor isdefined in the TOP-Includeand was opened in the OPENfunction module

Alternative 2: dataselection from globalinternal table where theindex is maintained in theXT_ADD_DATA_1 variable.

Page 24: SAP ISU Deregulation Infrastructure

Simple Data Transformation – IS Migration Workbench

Version 1.01 24 @ Copyright SAP AG 2010

* SELECT ... FROM ... INTO ...WHERE id = lv_zzcustomer-id.

* move selected customer data to XT_DATA_TAB table REFRESH xt_data_tab. xt_data_tab = lv_zzcustomer-id. APPEND xt_data_tab. xt_data_tab = lv_zzcustomer-name_first. APPEND xt_data_tab. xt_data_tab = lv_zzcustomer-name_last. APPEND xt_data_tab. xt_data_tab = lv_zzcustomer-postcode. APPEND xt_data_tab. xt_data_tab = lv_zzcustomer-city. APPEND xt_data_tab. xt_data_tab = lv_zzcustomer-street. APPEND xt_data_tab. xt_data_tab = lv_zzcustomer-housenumber. APPEND xt_data_tab.

ENDFUNCTION.

Completion of selected datawith additional queries.

Fill the XT_DATA_TAB tablewith the selected data for atransformation in theCONVERT function module.

Figure 3-9: Sample Read Function Module

3.4 Sample Transformation Function ModuleThe following figure summarizes the parameter interface of the transformation functionmodule:

Direction Parameter DDIC Type Meaning

Importing X_FIRMA EMG_FIRMA Name of migration company

X_OBJECT EMG_OBJECT Name of migration object

X_REF_OBJECT EMG_OBJECT Name of referenced migration object(hyper migration object)

X_DTTYP EMG_DTTYP Name of actual customer structure

X_OCCURENCE SYINDEX Number how often the report has calledthe function module with the samecustomer structure for the actual dataobject.

Exporting Y_OLDKEY EMG_OLDKEY Legacy system key for the current dataobject

Y_ACTION_STRUCTURE EMG_WMODE Requested action on structure level

Y_ACTION_OBJECT EMG_WMODE Requested action on object level

Y_ACTION_FILE EMG_WMODE Requested action on text file level

Tables XT_HEADER_TAB table Field names related to data inXT_DATA_TAB (filled in Open functionmodule)

XT_DATA_TAB table Actual data record of text file

XT_ADD_DATA_1…5 table Additional data exchange betweenfunction modules.

Changing XY_CUSTOMER Actual customer structure

Figure 3-10: Parameter Interface of a Transformation Function Module

Page 25: SAP ISU Deregulation Infrastructure

Simple Data Transformation – IS Migration Workbench

Version 1.01 25 @ Copyright SAP AG 2010

o The Y_OLDKEY parameter must be unique for each data object of a specific migrationobject. For more information about legacy system keys or oldkeys, see chapter 2.5 Keyand Status Management in the Guideline Data Migration of FI-CA-Based IndustrySolutions – IS Migration Workbench.

o You can use the XT_HEADER_TAB parameter to transfer field names to thetransformation function module. The XT_HEADER_TAB table corresponds to the headerline of the text file.

o The XT_DATA_TAB table contains the data to be transformed. The read function modulefilled the XT_DATA_TAB table. The XT_DATA_TAB table corresponds to a data record inan import text file.

o You can use the XT_ADD_DATA_1 to _5 parameters to exchange information betweenyour function modules during the transformation process. In addition, you can exchangedata through variables you define in the global memory of your function group (TOPInclude)

o The XY_CUSTOMER parameter represents the actual customer structure the functionmodule must process next. Macros are available to simplify the transfer of values to thefields of the related customer structure. The macro definition can be found in the code ofthe sample transformation module in chapter 2.5.2 Sample Transformation FunctionModule.o MAC_FIELD_VALUE &1 &2:

&1: fieldname of customer structure&2: value to be moved to the field of the customer structure

Example: MAC_FIELD_VALUE 'WAKLASS' '0001'.(Move the value ‘0001’ to the WAKLASS field)

o MAC_FIELD_TAB_VALUE &1 &2:&1: fieldname of customer structure&2: line number of the XT_DATA_TAB internal table

Example: MAC_FIELD_TAB_VALUE 'NAME_LAST' 3.(Move the content of the third line of the XT_DATA_TAB internal table to theNAME_LAST field)

3.4.1 Sample Transformation Function ModuleFigure 3-11 shows a sample transformation function module that is also available in yourSAP system. The function module transforms the data in the XT_DATA_TAB table into abinary import file. The function is the same as shown in Figure 2-10 except for the additionalXT_ADD_DATA_1…5 tables in the parameter interface of the function module. The rightcolumn explains the details of the implementation.

ABAP Code of Function Module Comments

FUNCTION ISU_M_SAMPLE_CONVERT.*"-----------------------------------------------------------*"*"Local Interface:*" IMPORTING*" REFERENCE(X_FIRMA) TYPE EMG_FIRMA*" REFERENCE(X_OBJECT) TYPE EMG_OBJECT*" REFERENCE(X_REF_OBJECT) TYPE EMG_OBJECT*" REFERENCE(X_DTTYP) TYPE EMG_DTTYP*" REFERENCE(X_OCCURENCE) TYPE SYINDEX*" EXPORTING*" REFERENCE(Y_OLDKEY) TYPE EMG_OLDKEY*" REFERENCE(Y_ACTION_STRUCTURE) TYPE EMG_WMODE*" REFERENCE(Y_ACTION_OBJECT) TYPE EMG_WMODE*" REFERENCE(Y_ACTION_FILE) TYPE EMG_WMODE*" TABLES*" XT_HEADER_TAB*" XT_DATA_TAB

Parameter interface of thefunction module as described

Page 26: SAP ISU Deregulation Infrastructure

Simple Data Transformation – IS Migration Workbench

Version 1.01 26 @ Copyright SAP AG 2010

*" XT_ADD_DATA_1 OPTIONAL*" XT_ADD_DATA_2 OPTIONAL*" XT_ADD_DATA_3 OPTIONAL*" XT_ADD_DATA_4 OPTIONAL*" XT_ADD_DATA_5 OPTIONAL*" CHANGING*" REFERENCE(XY_CUSTOMER)*"-----------------------------------------------------------

* field symbols FIELD-SYMBOLS: <fs_field_value> TYPE ANY.

* includes INCLUDE remig_file_create_const.

* macros to simplify value assignment DEFINE mac_field_value. assign component &1 of structure xy_customer to <fs_field_value>. if sy-subrc eq 0. <fs_field_value> = &2. endif. END-OF-DEFINITION.

DEFINE mac_field_tab_value. assign component &1 of structure xy_customer to <fs_field_value>. if sy-subrc eq 0. read table xt_data_tab into <fs_field_value> index &2. endif. END-OF-DEFINITION.

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

* assign oldkey which can be found at row #1 READ TABLE xt_data_tab INTO y_oldkey INDEX 1.

* value assignment in dependancy of record data type CASE x_dttyp. WHEN 'INIT'. “ structure contains only fields with fixed value rule. y_action_structure = co_action_structure_save_next. y_action_object = co_action_object_continue. WHEN 'EKUN'. mac_field_value ' KTOKLASSE' '0002'. y_action_structure = co_action_structure_save_next. y_action_object = co_action_object_continue. WHEN 'BUT000'. mac_field_tab_value 'NAME_FIRST' 2. mac_field_tab_value 'NAME_LAST' 3. mac_field_value 'TITLE' '003'. y_action_structure = co_action_structure_save_next. y_action_object = co_action_object_continue. WHEN 'BUT020'. IF x_occurence = 1. mac_field_tab_value 'POST_CODE1' 4. mac_field_tab_value 'CITY1' 5. mac_field_tab_value 'STREET' 6. mac_field_tab_value 'HOUSE_NUM1' 7. “ fill some more fields if BUT020 occurs 1st time

“ mac_field_tab_value … y_action_structure = co_action_structure_save_same. y_action_object = co_action_object_continue. ELSE. “ fill some more fields if BUT020 occurs 2nd time

“ mac_field_tab_value … y_action_structure = co_action_structure_save_next. y_action_object = co_action_object_complete. ENDIF. WHEN OTHERS. y_action_structure = co_action_structure_drop. ENDCASE.

* read file till end-of-file

Field symbol for macros

Include constant values todescribe the actions

Definition ofMAC_FIELD_VALUE macro

Definition ofMAC_FIELD_TAB_VALUE macro

Assign the oldkey using theID field from the text file

Fill INIT structure

Save structure and get nextData object not ready yetFill EKUN structure Field for account classSave structure and get nextData object not ready yetFill BUT000 structure Field for first name Field for last name Field for titleSave structure and get nextData object not ready yetFill BUT020 structure When occurs the 1st time Fields for zip code, Field for city name Field for street name Field for house number

Save structure and get sameData object not ready yet

… other/more fields ifBUT020 occurs the 2nd timeSave structureData object can be saved

No other structures toprocess

Page 27: SAP ISU Deregulation Infrastructure

Simple Data Transformation – IS Migration Workbench

Version 1.01 27 @ Copyright SAP AG 2010

y_action_file = co_action_file_continue.

ENDFUNCTION.

Continue reading import file

Figure 3-11: Sample Transformation Function Module

3.5 Close Function Module3.5.1 Parameter InterfaceThe following figure summarizes the parameter interface of the close function module:

Direction Parameter DDIC Type Meaning

Importing X_FIRMA EMG_FIRMA Name of migration company

X_OBJECT EMG_OBJECT Name of migration object

Figure 3-12: Parameter Interface of the Close Function Module

3.5.2 Sample Close Function ModuleFigure 3-6 shows a sample close function module. The function module closes the databaseaccess to the customer-specific ZZCUSTOMER table. The right column explains the details ofthe implementation.

ABAP Code of Function Module Comments

FUNCTION ZZ_PARTNER_CLOSE.*"-----------------------------------------------------------*"*"Local Interface:*" IMPORTING*" REFERENCE(X_FIRMA) TYPE EMG_FIRMA OPTIONAL*" REFERENCE(X_OBJECT) TYPE EMG_OBJECT OPTIONAL*"-----------------------------------------------------------

* Close Database Cursor CLOSE CURSOR cs_customer.

*+ Alternative approach (internal table):*+ no action required

ENDFUNCTION.

Parameter interface of thefunction module as described

Figure 3-13: Sample Close Function Module

Page 28: SAP ISU Deregulation Infrastructure

Simple Data Transformation – IS Migration Workbench

Version 1.01 28 @ Copyright SAP AG 2010

4 Enhancements4.1 Alternative Data Selection4.1.1 MotivationThe examples in the previous chapters show a data selection from the customer-specificdatabase table by means of a database cursor (ABAP statements OPEN CURSOR, FETCHand CLOSE CURSOR). You may want to choose an alternative way in extracting the data intoan internal table and process it from there. There might be a performance improvement if youneed to select the data from more than one database table in the preparation (open) phase.The following chapters show the required implementation of the open, read and closefunction module. The parameter interface of the function modules remain the same.

4.1.2 Sample Open Function Module

ABAP Code of Function Module Comments

FUNCTION ZZ_PARTNER_OPEN.*"-----------------------------------------------------------*"*"Local Interface:*" IMPORTING*" REFERENCE(X_FIRMA) TYPE EMG_FIRMA OPTIONAL*" REFERENCE(X_OBJECT) TYPE EMG_OBJECT OPTIONAL*" EXPORTING*" REFERENCE(Y_ACTION_FILE) TYPE EMG_WMODE*" TABLES*" XT_INTERVAL_1 STRUCTURE EMG_CONVERT_SELOPT OPTIONAL*" XT_INTERVAL_2 STRUCTURE EMG_CONVERT_SELOPT OPTIONAL*" XT_INTERVAL_3 STRUCTURE EMG_CONVERT_SELOPT OPTIONAL*" XT_HEADER_TAB OPTIONAL*" XT_ADD_DATA_1 OPTIONAL*" XT_ADD_DATA_2 OPTIONAL*" XT_ADD_DATA_3 OPTIONAL*" XT_ADD_DATA_4 OPTIONAL*" XT_ADD_DATA_5 OPTIONAL*"-----------------------------------------------------------

* Extract selected customer into an internal table that* is defined in the global memory of function group

SELECT * FROM zzcustomer INTO TABLE gt_customerWHERE id IN xt_interval_1.

IF sy-subrc EQ 0." data selection ok

y_action_file = co_action_file_ok. ELSE.

" all selected data processed => end-of-file y_action_file = co_action_file_eof. ENDIF.

* Initialize first selection from internal table in* read function module gv_tabix = 1.

* Additional selects if necessary ...* SELECT * FROM zzcustomer1 INTO TABLE gt_customer1* FOR ALL ENTRIES IN gt_customer* WHERE id = gt_customer-id.

* fill field name table (optional) xt_header_tab = 'ID'. " customer ID APPEND xt_header_tab. xt_header_tab = 'NAME'. " customer name APPEND xt_header_tab. xt_header_tab = 'SURNAME'. " customer surname APPEND xt_header_tab. xt_header_tab = 'POSTCODE'. " postal code APPEND xt_header_tab.

Parameter interface of thefunction module as described

Data extraction into aglobal internal table thatis defined in the globalmemory of the function group(TOP-Include)

Completion of data selectionwith mass queries.

The header table can befilled with the relatedfield names.

Page 29: SAP ISU Deregulation Infrastructure

Simple Data Transformation – IS Migration Workbench

Version 1.01 29 @ Copyright SAP AG 2010

xt_header_tab = 'CITY'. " city name APPEND xt_header_tab. xt_header_tab = 'STREET'. " street name APPEND xt_header_tab. xt_header_tab = 'NUMBER'. " house number APPEND xt_header_tab.

ENDFUNCTION.

4.1.3 Sample Read Function ModuleABAP Code of Function Module Comments

FUNCTION ZZ_PARTNER_READ.*"-----------------------------------------------------------*"*"Local Interface:*" IMPORTING*" REFERENCE(X_FIRMA) TYPE EMG_FIRMA OPTIONAL*" REFERENCE(X_OBJECT) TYPE EMG_OBJECT OPTIONAL*" EXPORTING*" REFERENCE(Y_ACTION_FILE) TYPE EMG_WMODE*" TABLES*" XT_HEADER_TAB OPTIONAL*" XT_DATA_TAB OPTIONAL*" XT_ADD_DATA_1 OPTIONAL*" XT_ADD_DATA_2 OPTIONAL*" XT_ADD_DATA_3 OPTIONAL*" XT_ADD_DATA_4 OPTIONAL*" XT_ADD_DATA_5 OPTIONAL*"-----------------------------------------------------------

* local data definition DATA: lv_zzcustomer TYPE zzcustomer.

* select data from internal tableREAD TABLE gt_customer INTO lv_zzcustomer INDEX gv_tabix.

IF sy-subrc EQ 0." data selection ok

y_action_file = co_action_file_ok. ELSE.

" all selected data processed => end-of-file y_action_file = co_action_file_eof. ENDIF.

* prepare next selectiongv_tabix = gv_tabix + 1.

* Additional selects if necessary ...* SELECT ... FROM ... INTO ...WHERE id = lv_zzcustomer-id.

* move selected customer data to XT_DATA_TAB table REFRESH xt_data_tab. xt_data_tab = lv_zzcustomer-id. APPEND xt_data_tab. xt_data_tab = lv_zzcustomer-name_first. APPEND xt_data_tab. xt_data_tab = lv_zzcustomer-name_last. APPEND xt_data_tab. xt_data_tab = lv_zzcustomer-postcode. APPEND xt_data_tab. xt_data_tab = lv_zzcustomer-city. APPEND xt_data_tab. xt_data_tab = lv_zzcustomer-street. APPEND xt_data_tab. xt_data_tab = lv_zzcustomer-housenumber. APPEND xt_data_tab.

ENDFUNCTION.

Parameter interface of thefunction module as described

Data selection from globalinternal table where theindex is maintained in theGV_TABIX variable in theTOP-Include of the functiongroup.

Completion of selected datawith additional queries.

Fill the XT_DATA_TAB tablewith the selected data for atransformation in theCONVERT function module.

Page 30: SAP ISU Deregulation Infrastructure

Simple Data Transformation – IS Migration Workbench

Version 1.01 30 @ Copyright SAP AG 2010

4.1.4 Sample Close Function Module

ABAP Code of Function Module Comments

FUNCTION ZZ_PARTNER_CLOSE.*"-----------------------------------------------------------*"*"Local Interface:*" IMPORTING*" REFERENCE(X_FIRMA) TYPE EMG_FIRMA OPTIONAL*" REFERENCE(X_OBJECT) TYPE EMG_OBJECT OPTIONAL*"-----------------------------------------------------------

ENDFUNCTION.

Parameter interface of thefunction module as described

No special action required

4.1.5 Sample TOP-Include

ABAP Code of Function Module Comments

FUNCTION-POOL zzmig_partner MESSAGE-ID em.

INCLUDE remig_file_create_const.

* Global Variables to be accessible from all function modulesDATA: gv_tabix TYPE sy-tabix.

Include with constant valuesfor actions

Internal Table forextraction of customer data

4.2 Application Log4.2.1 MotivationYou may want to add error message to an application log for a subsequent evaluation ofidentified problems during the transformation process. You can evaluate the createdapplication with transaction SLG1 (Analyze Application Log).

The following chapters show the required implementation in the open and close functionmodules. In addition, the ABAP code is described how to create messages in the applicationlog. The example uses the IUMI object name to create the application logs. You may chooseto use custom-specific object and subobject names to identify application logs.

4.2.2 Sample Open Function Module

ABAP Code of Function Module Comments

FUNCTION ZZ_PARTNER_OPEN.*"-----------------------------------------------------------*"*"Local Interface:*" IMPORTING*" REFERENCE(X_FIRMA) TYPE EMG_FIRMA OPTIONAL*" REFERENCE(X_OBJECT) TYPE EMG_OBJECT OPTIONAL*" EXPORTING*" REFERENCE(Y_ACTION_FILE) TYPE EMG_WMODE*" TABLES*" XT_INTERVAL_1 STRUCTURE EMG_CONVERT_SELOPT OPTIONAL*" XT_INTERVAL_2 STRUCTURE EMG_CONVERT_SELOPT OPTIONAL*" XT_INTERVAL_3 STRUCTURE EMG_CONVERT_SELOPT OPTIONAL*" XT_HEADER_TAB OPTIONAL*" XT_ADD_DATA_1 OPTIONAL*" XT_ADD_DATA_2 OPTIONAL*" XT_ADD_DATA_3 OPTIONAL*" XT_ADD_DATA_4 OPTIONAL*" XT_ADD_DATA_5 OPTIONAL*"-----------------------------------------------------------

Page 31: SAP ISU Deregulation Infrastructure

Simple Data Transformation – IS Migration Workbench

Version 1.01 31 @ Copyright SAP AG 2010

[…]

* Initialize application log identification parameters DATA: msg_parm TYPE eemsg_parm_open. msg_parm-appl_log = 'IUMI'. msg_parm-extnumber = x_object. msg_parm-prog = 'REMIG_FILE_CREATE'.

* Create application log CALL FUNCTION 'MSG_OPEN' EXPORTING x_no_dialog = 'X' x_log = 'X' IMPORTING y_msg_handle = msg_handle CHANGING xy_parm = msg_parm EXCEPTIONS failed = 1 subs_invalid = 2 log_invalid = 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.

ENDFUNCTION.

ABAP code as shown in theprevious examples

4.2.3 Sample Close Function Module

ABAP Code of Function Module Comments

FUNCTION ZZ_PARTNER_CLOSE.*"-----------------------------------------------------------*"*"Local Interface:*" IMPORTING*" REFERENCE(X_FIRMA) TYPE EMG_FIRMA OPTIONAL*" REFERENCE(X_OBJECT) TYPE EMG_OBJECT OPTIONAL*"-----------------------------------------------------------

[…]

* Prepare closure of application log DATA: lv_changed LIKE emggen-kennzx. CALL FUNCTION 'MSG_PREPARE_CLOSE' EXPORTING x_msg_handle = msg_handle IMPORTING y_changed = lv_changed EXCEPTIONS not_found = 1 handle_invalid = 2 OTHERS = 3. IF sy-subrc <> 0. MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. ENDIF.

IF NOT lv_changed IS INITIAL.* save application log on database CALL FUNCTION 'MSG_ACTION' EXPORTING x_msg_handle = msg_handle x_action = co_msg_save EXCEPTIONS action_not_supported = 1 handle_invalid = 2

ABAP code as shown in theprevious examples

Check whether at least onemessage is to be written tothe application log

Save messages on database

Page 32: SAP ISU Deregulation Infrastructure

Simple Data Transformation – IS Migration Workbench

Version 1.01 32 @ Copyright SAP AG 2010

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

ENDIF.

* Close application log CALL FUNCTION 'MSG_CLOSE' EXPORTING x_msg_handle = msg_handle EXCEPTIONS not_found = 1 handle_invalid = 2 OTHERS = 3. IF sy-subrc <> 0. MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. ENDIF.

ENDFUNCTION.

Close application log

4.2.4 Sample TOP-Include

ABAP Code of Function Module Comments

FUNCTION-POOL zzmig_partner MESSAGE-ID em.

[…]

* Data for application logTYPE-POOLS eemsg.DATA: msg_handle LIKE emsg_gen-handle.INCLUDE emsg.

ABAP code as shown in theprevious examples

Required data for messagehandling with applicationlog

4.2.5 Message HandlingYou can save messages in the application log using the MAC_MSG_PUTX macro. The macrohas the following parameters:

Parameter Meaning

&1 Severity (for example, CO_MSG_ERROR)

&2 Message number

&3 Message class

&4 - &7 Message variables 1 - 4

&8 Exception (use space)

Figure 4-1: Parameter of the MAC_MSG_PUTX Macro

The following example saves the message ‘Hello World’ in the application log:MAC_MSG_PUTX CO_MSG_ERROR ‘000’ ‘EM’ ‘Hello World’ space space space space.

You can use the macro in any of your function modules to after you opened the applicationlog in the open function module and before you closed it in the close function module.

Page 33: SAP ISU Deregulation Infrastructure

Simple Data Transformation – IS Migration Workbench

Version 1.01 33 @ Copyright SAP AG 2010

5 Final CommentsThe REMIG_FILE_CREATE report is just a framework to support a simple datatransformation process. It allows you a high level of flexibility to develop your owntransformation. It is very important that you do not underestimate the effort for animplementation. In particular, a high number of customer-specific database tables andsophisticated business requirements for data transformation can add a high level ofcomplexity.In addition, any data transformation based on a high data volume can be very timeconsuming. We would therefore recommend to keep the number of database accesses in thecustomer-specific database tables to a minimum. A parallelization of the execution of thetransformation processes is also supportive to reduce the transformation period.