Download as pdf or txt
Download as pdf or txt
You are on page 1of 9

9/21/23, 8:53 AM Custom COPY function using AMDP | SAP Blogs

Community

 A New Home in the New Year for 


SAP Community!

Exciting times ahead for the SAP


Read all about the SAP Community Migration
Community! We've outgrown our
home, so we'll be migrating to a new
platform later this year. Let's continue
the journey together!

Ask a Question Write a Blog Post Login

Technical Articles

Sayani Ghosal
June 17, 2019 | 3 minute read

Custom COPY function using AMDP


 5  6  4,497

Follow In this blog, I will explain how to implement custom COPY planning function using
AMDP.

 Like Background

Business requirement was to develop an AMDP script to copy data from source to
 RSS Feed target cube and also implement the additional features as below:

1. While copying data from source to target, invert few key figures

e.g. source KF1 =100 -> target KF1 = -100

2. Read customer master attributes for few fields, in case, value for attribute is null
in transactional data replace attribute value with the master data.

https://blogs.sap.com/2019/06/17/custom-copy-function-using-amdp/ 1/9
9/21/23, 8:53 AM Custom COPY function using AMDP | SAP Blogs

e.g. Master data -> Emp ID Attribute to be read -> Emp Location

Desired Output:

1. Data should be copied from Source cube to target cube and source cube data
will be unchanged (standard copy functionality achieved).
2. Customer attributes to be populated in target from master data wherever
source cube data is null
3. Key figures(where inversion is implemented) should have reverse sign in the
target cube

Planning Class Creation

1. Create a new class in SE24 transaction

2. Logon to ABAP Modeller in SAP HANA Studio.

https://blogs.sap.com/2019/06/17/custom-copy-function-using-amdp/ 2/9
9/21/23, 8:53 AM Custom COPY function using AMDP | SAP Blogs

3. Navigate to Package -> Source Code Library -> Classes, open the new class.

4. Include the below interfaces in the public section of the class.

5. Create a structure adding all info-objects of the aggregation level and define a
standard table.

eg.

6. In the public section, specify a suitable method name for the procedure and its
import export parameters.

In AMDP,

i_view : Refers to the source data set which is to be used for planning

i_view_ref : Refers to the reference data to be used by the planning


function(optional)

e_view : Denotes the result of the planning function post all manipulations

https://blogs.sap.com/2019/06/17/custom-copy-function-using-amdp/ 3/9
9/21/23, 8:53 AM Custom COPY function using AMDP | SAP Blogs

Other than these parameters, if there is any additional parameter specific to the
planning function type it can also be passed to the method.

7. Include the below code inside the class implementation to implement the
standard methods inherited by the interfaces.

8. Implement the below method to set the reference data selection parameter (our
reference data is actually the source data for copy).

https://blogs.sap.com/2019/06/17/custom-copy-function-using-amdp/ 4/9
9/21/23, 8:53 AM Custom COPY function using AMDP | SAP Blogs

9. Implement the TREX_EXECUTE method to call the AMDP procedure from the
ABAP class.

10. Implement the AMDP procedure.

11. Select the master data (inside the method DAPLR_DATA_COPY).

12. Join reference data and master data to populate the output (e_view).

Planning function class is now ready!

Planning Function Creation and execution

1. Create new planning function type in RSPLF1 and include the class created
above in it.

https://blogs.sap.com/2019/06/17/custom-copy-function-using-amdp/ 5/9
9/21/23, 8:53 AM Custom COPY function using AMDP | SAP Blogs

2. Also ensure that below parameters are set in the function type.

3. Create new planning function using the newly created Planning function type
and use it in a planning sequence with relevant filter to implement the custom
COPY functionality.

Alert Moderator

Assigned Tags

BW (SAP Business Warehouse)

BW Planning

Similar Blog Posts 


HANA based BW Transformation
By Torsten Kessler May 24, 2016

HANA based BW Transformation - Analyzing and debugging


By Torsten Kessler Jun 23, 2016

SAP BW/4HANA Transformation - HANA Pushdown


By Soundravel A.K May 04, 2017

Related Questions 
BW Planning: AMDP_DERIVE not found in catalog!
By Michele Gaddi Aug 21, 2020

Debugging AMDP in BW 7.4 on HANA


By Rajesh Pattnaik Feb 11, 2020

Custom planning function with AMDP : how to pass multiple values in a variable
https://blogs.sap.com/2019/06/17/custom-copy-function-using-amdp/ 6/9
9/21/23, 8:53 AM Custom COPY function using AMDP | SAP Blogs

By Wouter Vanhoutte Jul 03, 2017

5 Comments

You must be Logged on to comment or reply to a post.

Haishan Zheng
November 16, 2019 at 10:01 am

have created a Planning Function Type based on AMDP class.

But when the Planning Function is executed, it cannot call

IF_RSPLFA_SRVTYPE_TREX_EXEC~TREX_EXECUTE.

would you please tell the steps to do the type of plan function?

Like 0 | Share

Anup Kulkami
May 27, 2020 at 2:26 pm

Nice writeup, but it is recommended to follow template code generated by program


RSPLS_SQL_SCRIPT_TOOL as starting point and enhance from there.

If you directly start coding, there is always a chance to miss a parameter or setting and then you go scratching
your head, clueless about different kinds of error message and short dumps generated by PAK.

The error handling of this PAK is terrible.

Like 0 | Share

Sayani Ghosal | Blog Post Author


July 12, 2020 at 9:32 am
https://blogs.sap.com/2019/06/17/custom-copy-function-using-amdp/ 7/9
9/21/23, 8:53 AM Custom COPY function using AMDP | SAP Blogs

Thank you and you are right! Its better to use the script tool to start with.

Mainly this blog is for understanding purpose where we know what the generated code is doing rather
than blindly copying it.

Like 0 | Share

Johan Fourie
July 17, 2020 at 9:41 am

Hi.

Thanks for this.

Do you maybe have any info or directions on how to call HANA SQL Script in BPC11 Standard on BW4/HANA

Like 0 | Share

Gopi NA
September 18, 2020 at 7:54 pm

Hi Sayani,

Thanks for the document. But I see some missing interface in your code.

METHOD IF_RSPLFA_SRVTYPE_TREX_EXEC~TREX_EXECUTE. where is this declared?

I have similar request to do with custom plan function like take data from reference and do calculations with
another DSO data .

I got syntax error when I did similar to your code. any idea to resolve?

Regards

https://blogs.sap.com/2019/06/17/custom-copy-function-using-amdp/ 8/9
9/21/23, 8:53 AM Custom COPY function using AMDP | SAP Blogs

Like 0 | Share

Find us on

Privacy Terms of Use

Legal Disclosure Copyright

Trademark Cookie Preferences

Newsletter Support

https://blogs.sap.com/2019/06/17/custom-copy-function-using-amdp/ 9/9

You might also like