Enterprise Resource Planning Blogs by Members
Gain new perspectives and knowledge about enterprise resource planning in blog posts from community members. Share your own comments and ERP insights today!
cancel
Showing results for 
Search instead for 
Did you mean: 
mickaelquesnot
Active Participant
1,042
Migration Cockpit Enhancement for Missing Migration Objects by using a new BAPI in SAP S/4HANA On premise

https://youtu.be/OiLfX-gLYw0

PDF > https://icedrive.net/s/APyBWPS1tfDC5XRWt6wgj4DwAWhV

Problem Statement: Migration Cockpit is a very user-friendly approach to upload master data. However, it does not cover all the migration objects so far.
However, with minimal efforts (and some ABAP knowledge), we/you can easily enhance Migration Cockpit functionality. This tutorial details the steps involved with screenshots for easy understanding step by step how to do.

Pre-requisite: Basic understanding of working with Migration Cockpit is expected like creation of Function Module, BAPI, Simple ABAP code, Migration Project, download and upload of template, execution of ‘Validation’ to ‘Migrate’ steps.
Needs:
Example : My customer would like to update 1500 addresses of storage locations .

 

 

 

 

Process Steps
Step 1: Select BAPI
BAPIs
Use
A Business Application Programming Interface (BAPI) is a programming interface by means of which you can access the business data and processes of the SAP system from a different application system.
Business Application Programming Interface (BAPI)
Use
The SAP business objects stored in the Business Object Repository (BOR) encapsulate their data and processes. External access to the data and processes is only possible by means of specific methods - BAPIs (Business Application Program Interfaces).
A BAPI is defined as a method of an SAP Business Object Type or of an SAP Interface Type.
Example
The functions that are implemented in the SAP business CostCenter object type include, for example, listing all the available cost centers. The business object type CostCenter provides the BAPI GetList() for this purpose.
The BAPIs in the SAP Systems are currently implemented as function modules, which are created and managed in the Function Builder. Each function module underlying a BAPI:
 Supports the Remote Function Call (RFC) protocol
 Has been assigned as a method to a SAP business object type in the Business Object Repository
 Is processed without returning any screen dialogs to the calling application Integration
Integration
The graphic below shows the relationship between an SAP business object type, its associated BAPIs and its function modules.

Business Object Type with BAPIs and Associated Function Modules
This architecture enables SAP to change the implementation of a BAPI without affecting external applications that are using the BAPI. For information on SAP policy for enhancing BAPIs, and SAP release strategy for BAPIs, see SAP Enhancements to Released BAPIs (CA-BFA).
Prerequisites
To use a BAPI method to access data in SAP business objects, an application program only needs to 'know' how to call the method. The following information is required:
 The name of the BAPI
 Details of the BAPI interface:
 Import parameters, which contain data to be transferred from the calling program to the BAPI
 Export parameters, which contain data to be transferred from the BAPI back to the calling program
 Import/export (table) parameters for both importing and exporting data
Application programmers can work with SAP business objects and implement their BAPIs without needing to know or consider the underlying implementation and coding details for the object.

A guide for beginners on user defined BAPI creation
Summary
A simple guide for beginners on creating a user defined BAPI and how to test it. The guide is prepared in a step by step format with almost all possible screenshots. This guide contains 5 stages which are explained in 30 simple steps. A basic knowledge in ABAP and Function module is preferred for the reader.
Table of Contents

Stage1: Creating a structure in SE11

 

 

Stage2: Creating the function module in SE37

 

Stage 3: Creating the business object in SWO1

Stage 4: Viewing the created BAPI in BAPI Explorer

Stage 5: Test your BAPI

Introduction
A Business Application Programming Interface (BAPI) is a precisely defined interface providing access to processes and data in business application systems such as SAP. BAPIs are defined as API methods of SAP business object types. These business object types and their BAPIs are described and stored in the Business Object Repository (BOR). A BAPI is implemented as a function module, that is stored and described in the Function Builder.
BAPIs can be called within the SAP-System from external application systems and other programs. BAPIs are the communication standard for business applications. BAPI interface technology forms the basis for the following developments:
• Connecting:
• New SAP components, for example, Advanced Planner and Optimizer (APO) and Business Information Warehouse (BW).
• Non-SAP software
• Legacy systems
• Isolating components within the SAPSystem in the context of Business Framework
• Distributed SAPscenarios with asynchronous connections using Application Link Enabling (ALE)
• Connecting SAPSystems to the Internet using Internet Application Components (IACs)
• PC programs as frontends to the SAPSystem, for example, Visual Basic (Microsoft) or Visual Age for Java (IBM).
• Workflow applications that extend beyond system boundaries
• Customers' and partners' own developments
BAPI is basically a RFC enabled function module. The difference between RFC enabled function module and BAPI is business objects. You create business objects and those are then registered in your BOR (Business Object Repository) which can be accessed outside the SAP system by using some other applications (Non-SAP) such as VB or JAVA. In this case you only specify the business object and its method from external system. In BAPI there is no direct system call, while RFC are direct system call. Some BAPIs provide basic functions and can be used for most SAP business object types. These BAPIs should be implemented the same for all business object types. In short BAPI is a RFC enabled function module on the wrapper of Business object.
In this guide I have started with creating a structure in dictionary. Then I am creating a simple remote enabled function module. The next step is creating a business object using SWO1 and we are adding the above function module as a method of that business object. After completing the steps in SWO1 we will find our created BAPI in BAPI Explorer. Then we will do the testing of BAPI by inputting some values.
Stage1: Creating a structure in SE11
Step 1: Go to transaction SE11 and create a structure as shown or as per your requirement.

Do not forget to save it in a package. Check the structure (ctrl + F2) and activate (ctrl + F3) the structure.

 

 

 

 

 

Stage2: Creating the function module in SE37
Step 2: Go to transaction SE37 where you create function modules.
Click on create after you enter the name of the function module. Enter the function group and short text. Now click on save button.

 

 

 

 

 

Note: If function group is not already made, you could create it from Goto > Function group > Create Group from the initial screen of SE37 or SE80:

SE80

 

 

SE37

 

Step 3: A message will be displayed ‘Function module name is reserved for SAP’. Just click continue.
Step 4: A screen will be displayed as below. In the attributes tab, make the processing type as ‘Remote-Enabled Module’.

 

 

 

Step 5: Now go to the Import tab and enter the details as follows or as per your requirement.

PV_WERKS TYPE ZBAPITWLAD-WERKS Plant
PV_LGORT TYPE ZBAPITWLAD-LGORT Storage location
PV_LFDNR TYPE ZBAPITWLAD-LFDNR '10' Sequential address number
PV_TITLE TYPE ZBAPITWLAD-TITLE Form-of-Address Key
PV_NAME1 TYPE ZBAPITWLAD-NAME1 Name 1
PV_SORT1 TYPE ZBAPITWLAD-SORT1 Search Term 1
PV_SORT2 TYPE ZBAPITWLAD-SORT2 Search Term 2
PV_STREET TYPE ZBAPITWLAD-STREET Street
PV_HOUSE_NUM1 TYPE ZBAPITWLAD-HOUSE_NUM1 House Number
PV_POST_CODE1 TYPE ZBAPITWLAD-POST_CODE1 City postal code
PV_CITY1 TYPE ZBAPITWLAD-CITY1 City
PV_COUNTRY TYPE ZBAPITWLAD-COUNTRY Country/Region Key
PV_REGION TYPE ZBAPITWLAD-REGION Region (State, Province, County)
PV_TIME_ZONE TYPE ZBAPITWLAD-TIME_ZONE Address time zone
PV_LANGU_CREA TYPE ZBAPITWLAD-LANGU_CREA Address record creation original language

 

 

 

 

 

 

Step 6: In the export tab enter the details as below.

 

*” EXPORT
*” RT_BAPIRET2
STRUCTURE BAPIRET2



In the changing tab, nothing to do.

 

Step 7: In the Tables tab enter the details as below.

ZBAPITWLAD LIKE ZBAPITWLAD Structure BAPI update addresses of storage locations
ZRETURN LIKE BAPIRET2 Return Parameter

In the exception tab, nothing to do.

 

Step 8: Now go to the source code tab and enter the code as shown below.


FUNCTION Z_BAPI_TWLAD_ADRC_UPDATE.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" VALUE(PV_WERKS) TYPE ZBAPITWLAD-WERKS OPTIONAL
*" VALUE(PV_LGORT) TYPE ZBAPITWLAD-LGORT OPTIONAL
*" VALUE(PV_LFDNR) TYPE ZBAPITWLAD-LFDNR DEFAULT '10'
*" VALUE(PV_TITLE) TYPE ZBAPITWLAD-TITLE OPTIONAL
*" VALUE(PV_NAME1) TYPE ZBAPITWLAD-NAME1 OPTIONAL
*" VALUE(PV_SORT1) TYPE ZBAPITWLAD-SORT1 OPTIONAL
*" VALUE(PV_SORT2) TYPE ZBAPITWLAD-SORT2 OPTIONAL
*" VALUE(PV_STREET) TYPE ZBAPITWLAD-STREET OPTIONAL
*" VALUE(PV_HOUSE_NUM1) TYPE ZBAPITWLAD-HOUSE_NUM1 OPTIONAL
*" VALUE(PV_POST_CODE1) TYPE ZBAPITWLAD-POST_CODE1 OPTIONAL
*" VALUE(PV_CITY1) TYPE ZBAPITWLAD-CITY1 OPTIONAL
*" VALUE(PV_COUNTRY) TYPE ZBAPITWLAD-COUNTRY OPTIONAL
*" VALUE(PV_REGION) TYPE ZBAPITWLAD-REGION OPTIONAL
*" VALUE(PV_TIME_ZONE) TYPE ZBAPITWLAD-TIME_ZONE OPTIONAL
*" VALUE(PV_LANGU_CREA) TYPE ZBAPITWLAD-LANGU_CREA OPTIONAL
*" VALUE(PV_SIM) TYPE P06_FLOW_SIMULATION OPTIONAL
*" EXPORTING
*" VALUE(RETURN) TYPE BAPIRET2
*" TABLES
*" ZBAPITWLAD STRUCTURE ZBAPITWLAD
*" ZRETURN STRUCTURE BAPIRET2
*"----------------------------------------------------------------------

DATA GV_ADRNR TYPE TWLAD-ADRNR.
DATA GS_ADRC TYPE ADRC.

*Determination of Address from Plant and Storage Location

CLEAR GV_ADRNR.
CALL FUNCTION 'MM_DELIVERY_ADDRESS_PROPOSE'
EXPORTING
I_WERKS = PV_WERKS
I_LGORT = PV_LGORT
IMPORTING
E_ADRNR = GV_ADRNR.

IF NOT GV_ADRNR IS INITIAL.

*Reads from DB-table adrc
CALL FUNCTION 'RTP_US_DB_ADRC_READ'
EXPORTING
I_ADDRESS_NUMBER = GV_ADRNR
* I_NATION = ' '
* I_READ_DB=
IMPORTING
E_ADRC = GS_ADRC
EXCEPTIONS
NOT_FOUND = 1
OTHERS = 2.

IF SY-SUBRC = 0.

IF NOT PV_TITLE IS INITIAL AND PV_TITLE NE GS_ADRC-TITLE.
GS_ADRC-TITLE = PV_TITLE.
ENDIF.

IF NOT PV_NAME1 IS INITIAL AND PV_NAME1 NE GS_ADRC-NAME1.
GS_ADRC-NAME1 = PV_NAME1.
ENDIF.

IF NOT PV_SORT1 IS INITIAL AND PV_SORT1 NE GS_ADRC-SORT1.
GS_ADRC-SORT1 = PV_SORT1.
ENDIF.

IF NOT PV_SORT2 IS INITIAL AND PV_SORT2 NE GS_ADRC-SORT2.
GS_ADRC-SORT2 = PV_SORT2.
ENDIF.

IF NOT PV_STREET IS INITIAL AND PV_STREET NE GS_ADRC-STREET.
GS_ADRC-STREET = PV_STREET .
ENDIF.

IF NOT PV_HOUSE_NUM1 IS INITIAL AND PV_HOUSE_NUM1 NE GS_ADRC-HOUSE_NUM1.
GS_ADRC-HOUSE_NUM1 = PV_HOUSE_NUM1 .
ENDIF.

IF NOT PV_POST_CODE1 IS INITIAL AND PV_POST_CODE1 NE GS_ADRC-POST_CODE1.
GS_ADRC-POST_CODE1 = PV_POST_CODE1 .
ENDIF.

IF NOT PV_CITY1 IS INITIAL AND PV_CITY1 NE GS_ADRC-CITY1.
GS_ADRC-CITY1 = PV_CITY1.
ENDIF.

IF NOT PV_COUNTRY IS INITIAL AND PV_COUNTRY NE GS_ADRC-COUNTRY.
GS_ADRC-COUNTRY = PV_COUNTRY.
ENDIF.

IF NOT PV_REGION IS INITIAL AND PV_REGION NE GS_ADRC-REGION.
GS_ADRC-REGION = PV_REGION .
ENDIF.

IF NOT PV_TIME_ZONE IS INITIAL AND PV_TIME_ZONE NE GS_ADRC-TIME_ZONE.
GS_ADRC-TIME_ZONE = PV_TIME_ZONE.
ENDIF.

IF NOT PV_LANGU_CREA IS INITIAL AND PV_LANGU_CREA NE GS_ADRC-LANGU_CREA.
GS_ADRC-LANGU_CREA = PV_LANGU_CREA .
ENDIF.

*update ADRC
IF NOT GS_ADRC IS INITIAL.

CASE PV_SIM.

*simulation
WHEN 'X'.

MESSAGE A031(KC) INTO ZRETURN-MESSAGE.
APPEND ZRETURN.
MESSAGE A031(KC) INTO RETURN-MESSAGE.

WHEN OTHERS.

UPDATE ADRC FROM GS_ADRC.

IF SY-SUBRC NE 0.
* abort: error during update
MESSAGE A017(KC) WITH 'UPDATE ADRC' SY-SUBRC INTO ZRETURN-MESSAGE.
APPEND ZRETURN.
MESSAGE A017(KC) WITH 'UPDATE ADRC' SY-SUBRC INTO RETURN-MESSAGE.
ELSE.
MESSAGE A031(KC) INTO RETURN-MESSAGE.
ENDIF.

ENDCASE.

ENDIF.

ENDIF.

 

ENDIF.

ENDFUNCTION.

Step 9: Next we have to release the function module by Function Module>Release>Release.

 

 

 

Stage 3: Creating the business object in SWO1
Step 10: Go to transaction SWO1 and enter the name of the BAPI you would like to create and click create. Here I have given the name ZBAPIADRC (Z_API_TWLAD_ADRC_UPDATE. In the coming screen Enter the details as below or as per requirement and click continue. That will ask you to save the object. Save it in a package.

 

 

 

Step 11: In the resulting screen click on the methods to drop down and see what methods are provided by default. There would be two methods, showing in red color which comes by default while creating the BAPI. Now select ‘Add Method’ from Utilities > API Methods > Add Method.

 

 

 

Step 12: On the screen that follows, provide the function module name that we just created in the previous stage and click on the continue icon. In the coming pop-up, click the next step icon. We observe that the information is predefined in the fields.

 

 

 

Step 13: This is the next screen where you would just click on the “next” icon.

Step 14: A popup will be displayed as below.

 

 

 

Click on Yes. You can see an information message reading “ ZZZZ” inserted.

Step 15: Now save after you add the method. Select & Double click on the API method.

 

Go to Tab: ABAP Check 'API Function' as shown below.


Select the Radio button reading “API Function” as already said above.

Step 16: Now select the Object “ZBAPI_TWLAD_ADRC_UPDATE” as shown below.

Step 17: Now Go to : Edit > Change Release Status > Object type > To Modeled.

Step 18: The below shown screen will be displayed. Click on yes.

The message shows, The object type status set to modeled. ( or already modeled )

 

Step 19: Now go to: Edit > Change Release Status > Object type >To Implemented. You can see a message reading “Object type status set to implemented” .

 

 

Step 20: Now, go to: Edit > Change Release Status > Object > To Released. There would be two pop ups coming up. Click continue on the Pop Ups.

 

 

 

Step 21: Keep the cursor on the 'Method'. Now go to: Edit > Change Release Status > Object type component > To Modeled. (Shown as below).

 

Step 22: Now, go to: Edit > Change Release Status > Object type component > To Implemented. You can see the message reading “ status for method ‘ZZ’ set to implemented”.

 

 

Step 23: Now go to: Edit > Change Releasse Status > Object type component > To Released. You can see the message reading “ status for method ‘zz’ set to Released”.

 

Step 24: Click on ‘Generate’ from Object Type as shown below.

 

After clicking on the generate button, you can see the message reading “Object type 'ZBAPI_TWLAD_ADRC_UPDATE' generated successfully”. Now we are done with the creation of a BAPI.

Stage 4: Viewing the created BAPI in BAPI Explorer

Step 25: Go to BAPI Explorer (Transaction code is ‘BAPI’) there we can find the BAPI (our BAPI). You can click on the Alphabetical tab so that you can browse the BAPI’s in an alphabetical order. Find your BAPI as shown.

 

 

Stage 5: Test your BAPI
Step 26: Enter the name of your BAPI in the transaction SWO1 and click on ‘Test’.

 

Step 27: The below screen is displayed. Click on the Execute icon (circled in red) against the BAPI as shown

Step 28: The below screen will be displayed where you would require entering the data against the empty input fields.

Step 29: You could use the input help as shown below; here I have selected ‘0001’. And click the execute button.

Step 30: The resulting screen is displayed below, where you can see ‘N Entries’ against ZZ. Double click on ‘ Entries’.

The results as per our input are as shown below.

By this, we would get it confirmed that our BAPI is working properly. We can even check it by passing different values again. Come back to the input and execution screen.
We are now done with the creation and successful execution of a BAPI.


Step 2: Create Migration Project
Execute Migrate your data app. If Migration Project already exists, we can use that also.

Step 3: Create Migration Object
Execute t-code LTMOM.


Select the Migration Project as shown below: –

 


Create a Migration Object within our Migration Project as shown below: –


Please note that we have mapped the relevant BAPI in the above screenshot.

We can confirm the entered details in the ‘Target Structures’ link, as shown below: –


Step 4: Target Structures – Standard Fields
Double click on tabs available under ‘Target Structures’, as shown below, to display the list of standard fields available for upload.

Using this, we can make a list of relevant fields to be uploaded as per client requirements as all the fields are not required to be uploaded.

Step 5: Create Source Structures
Open the Migration Object in edit mode, as shown below: –

 

Create ‘Source Structure’, as shown below, as per required tabs in the template file. In our case, we will have two tabs in our template.



For each tab, create fields as shown below. Copy-paste from the excel file prepared above.

 

Note that we are using it (it can have any name, data type and description) to establish relationship between different tabs of the template.

 

Save.

Step 6: Structure Mapping

 

As shown above, drag and drop the tabs under ‘Source Structures’ (in the middle) to tabs under ‘Target Structures’ (on the right side)

Save.

Step 7: Field Mapping

 

As shown above, map each field of our template to the standard field (just drag and drop), so that data is uploaded in the correct fields. System will throw errors if the data types of source and target fields do not match.

Save.

Step 8: Generate the Migration Object



Save.

SE37

Set breakpoint:

 

Step 9: Upload Legacy Data
Execute Migrate your data:

 

Click on the highlighted Migration Object to download the template and upload data from legacy system:

 

 

After filling legacy data in this template, we can upload it using standard Migrate your data process.

 

Conclusion
This tutorial will help us to avoid custom developments for missing Migration Objects in the Migration Cockpit saving us time, money, and efforts.

 
2 Comments
Labels in this area