Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
Torsten_
Advisor
Advisor

3 Analyzing and debugging HANA based BW Transformations


 

This blog is part of the blog series HANA based BW Transformation

 

In this part I’ll describe how a BW transformation can be analyzed and debugged if they would be executed in the database. Debugging refers primarily BW transformation with a SQL Scripts but in this part I’ll also describe the way to get the INSERT / SELECT statement.


3.1      Analyzing HANA based BW transformation


 

When a DTP with the option “HANA Execution mode” is executed the runtime framework will generate a SQL statement.  The SQL statement will select the data from the source and insert the data directly into the target in one step. Therefore the generated SQL statement (INSERT AS SELECT) will be used in the ColumnView which is based on the CalculationScenario (SAP HANA Transformation), see blog HANA based Transformation (deep dive).


The DTP runtime framework provides the option to generate various SQL statements in simulation mode without executing them, see Figure 3.1. The SQL statements can then be used for further analyses purposes.


A SQL query based on a CalculationScenario (encapsulated in a ColumnView) is executed by the calculation engine (CalcEngine). Variables of a CalculationScenario are passed on by PLACEHOLDER to the CalcEngine, i.e. the DTP filter values would be handover by one or more filter PLACEHOLDER , depending on the designed data flow. Therefore we will not find the DTP filter directly in the WHERE condition.


In addition to DTP filter values there are more technical filters passed on by PLACEHOLDER . For example, one placeholder is used to read data in packages. Another is used to specify which source table will be used to read the data.


In addition to filtering a SQL statement based on a CalculationScenario in the form of PLACEHOLDER values it is also possible to use an additional WHERE condition. This is, for example, necessary if no variables are defined inside the CalculationScenario for these field, see WHERE condition of INSERT AS SELECT statement in Figure 3.1.



Figure 3.1: Generated SQL Segments based on the CalculationView”


 


In case ABAP logic is used to specify the DTP filter values, the DTP framework will execute the ABAP logic in a pre-step before generating the SQL statement. The resulting DTP filter values from the ABAP logic will be integrated into the SQL statement.  The following filter placeholder (TR_3UFAFGH3GRHWINN06BPB0WEA91.$$filter$$) includes the technical filter condition based on the fields REQUEST and DATAPAKID to build the packages additionally a DTP filter for the field COSTCENTER:


    'PLACEHOLDER'=('TR_3UFAFGH3GRHWINN06BPB0WEA91.$$filter$$', 


                  '( "COSTCENTER"=''0000001000'' ) AND


                    ( ( "REQUEST" = ''REQU_CY3V82RJ5IBTOIYX0XK0OJTD5'' AND


                      ( "DATAPAKID" >= ''000001'' AND "DATAPAKID" <= ''000009'' ) ) ) '),


In this sample the COSTCENTER value comes from an ABAP based filter (Selection type 6 (ABAP Routine)).


The DTP simulation mode, see Figure 3.1, could be used to generate the SQL statements to analyze the data read requests.  The simulation mode does not execute the generated SQL statements, neither the SELECT nor the INSERT statement. In simulation mode both statements are only generated for analyses purposes.


The first step to analyze a BW transformation with a SAP HANA Expert Script is to check the procedure import and export data. In many cases the issue can be identified by checking the result data. For example for initial or NULL values, or too many rows, etc.


Next I’ll describe the steps to check the input and / or the output data of a SAP HANA Expert Script.


Figure 3.2  shows in (1) a data flow with a BW transformation with a SAP HANA Expert Script (named as SQL).


 


(2) shows the CalculationViews from the corresponding CalculationScenario for the BW transformation.


 














CalculationScenario in a stacked data flow
Keep in mind that the data flow is a stacked one as explained in the blog »HANA based Transformation (deep dive)« the CalculationScenario from the BW transformation will be reused in case of a stacked data flow!

 


We need the three marked CalculationViews to investigate the procedure behavior:

  • OPERATION.FUNCTION_CALL.INPUT

  • OPERATION.FUNCTION_CALL

  • OPERATION.FUNCTION_CALL.OUTPUT


 



Figure 3.2: Analyzing a SAP HANA Expert Script


To analyze each view it is necessary to capture the SQL statement from the DTP simulation mode and change some small parts, see (3) in Figure 3.2 :

 

  1. Change the named field list to »*«. This is necessary because the list could differ from the overall view

  2. Add the digit 1 at the end of the ColumnView name. This step is necessary because our SAP HANA Expert Script is embedded BW transformation of a stacked data flow.

  3. Add the CalculationView name separated by a dot to the ColumnView name


 


The CalculationView OPERATION.FUNCTION_CALL.INPUT can be used to check the procedure input parameter inTab. Both CalculationViews, OPERATION.FUNCTION_CALL and OPERATION.FUNCTION_CALL.OUTPUT, deliver the same data content. The column naming could be different but the content is the same. That means both views can be used to analyze the procedure result table outTab.


If the input and output data of the procedure does not help to identify the unexpected procedure behavior it is necessary to go deeper into the procedure analyses. It is possible to debug the corresponding database procedure for the SAP HANA Expert Script.


A new AMDP debugger for AMDP procedures is available with SAP NetWeaver 7.50 (SAP HANA Revision 97 or higher required).


 


3.1.1      Temporary Storage




 

Similar to the ABAP mode it is possible to keep the result after a simulation in a temporary storage. For a BW transformation running in the SAP HANA mode it is only possible to keep the result data after the whole transformation. It is not possible to keep intermediate result as in the ABAP mode. The reason is the runtime behavior. A SAP HANA executed BW transformation processes the data in chunks, see INSERT AS SELECT in the first blog of the series HANA based BW Transformation.


 

Figure 3.3 shows the necessary steps to keep the result data available if the DTP is run in simulation mode.  To achieve this enable Expert Mode, see (1) and ensure that the flag After Transformation is set, see (2).




Figure 3.3: Temporary Storage – HANA


 


In the DTP monitor you can check the result if you expand the Data Package node, see (3). The icon can be used to inspect the data in detail, see (4).


 



3.1.2      Debugging in BW 7.40 and SAP HANA < SP09


 


To enable customers on an older release and / or older revision, the BW transformation framework provides an option to generate a prepared database debug procedure to run the SAP HANA Expert Script in a native SAP HANA runtime environment.














Feature availability
The feature described here to create a debug procedure should only be used in a BW 7.40 system. In a release higher than BW 7.40 it is recommended to use directly the AMPD debugger, see paragraph »AMDP Debugger (BW 7.50 and HANA SP09 or higher)«. The feature will be disabled in BW 7.50.

To use the debug feature in BW 7.40 it is necessary to add the RSADMIN parameter DTP_HANA_DEBUG_SCRIPT and set it to ‘X’.



 


To check if the AMDP debugger is available on your system just try to add a break point in your AMDP method PROCEDURE, see Figure 3.4. Just double click in the field to the left of the line number to add an AMDP break point. If the AMDP debugger is available the line will be marked with a dot. If the debugger is not available you will get a message like in figure 3.4. If the AMDP debugger is available it is not necessary to generate a debugger procedure and you can go forward to paragraph »AMDP Debugger (BW 7.50 and HANA SP09 or higher)«.


 



Figure 3.4: AMDP Debugger in BW 7.40


 


If no AMDP debugger is available we can create a debug procedure to analyze the SAP HANA Expert Script behavior. Below I will describe the steps to analyze an SAP HANA Expert Script.


The AMDP debug procedure can be generated in the DTP simulation mode. Switch the processing mode of the corresponding DTP to Serially in the Dialog Process (for Debugging), see (1) in Figure 3.5 and enable the Expert Mode and execute the simulation. Switch to the tab Script Generation In the upcoming dialog Debug Request, see (2) and mark the SAP HANA Expert Script below your BW transformation. In case of a stacked data flow with more than one SAP HANA Expert Script (and more BW transformations), the list Generate Procedure for will offer one checkbox for each SAP HANA Expert Script per BW transformation. If you’ve marked the procedure you want to create, execute the debug request. In the result monitor of the simulation request is a new tab called Script Generation, see (3). Copy the entire procedure name into your clipboard (CTRL + C) and do not close the request monitor.


 



Figure 3.5: Steps to create an AMDP debug procedure


Next we will prepare for debugging. To start, it is necessary to create a debug configuration. Before we start to create the debug configuration we will add a filter on the procedure folder to reduce the list of available procedures in your system, see (1) in Figure 3.6. The debug configuration dialog does not offer any search functionalities. If the filter is applied you may notice some additional procedures. These are used internally and can be disregarded.














AMDP database procedure

Sometime, in BW 7.40, it could be happen that the corresponding database procedure is not generated. The report RSDBGEN_AMDP can be used to generate the database procedures for a given AMDP class.



Do not remove the filter on the procedure folder. We need the filter later on if we create the debug configuration.


 



Figure 3.6: Prepare database procedure debugging


Open the <CLASSNAME>=>DEBUG_PROCEDURE and add a breakpoint (2) on each step where you want to stop to inspect your code during the execution. Keep in mind that the SQL Script debug only has the continue button to execute the code until the next breakpoint or the end. There is no option like Step In or Step Over as in the ABAP Debugger. As a consequence it is necessary to add a breakpoint on each code position before you start the process.


 

















Structure of the debug procedure

The debug procedure is divided in two parts. The first part of the procedure is to create the input table (inTab) for the SAP HANA Expert Script procedure, see Figure 3.6 line 11 to line 45. To get the correct input data for the procedure the corresponding CalculationView from the CalculationScenario will be selected. Therefore the view name OPERATION.FUNCTION_CALL.INPUT is added to the ColumnView name in the select statement.


Below the first part we’ll find the copied source code from the SAP HANA Expert Script.



 














Table for temp placeholder values during debugging

The placeholder values will be read from the table /1BCAMDP/0BW:DAP:PLACEHOLDER_TABLE to keep the debug procedure as generic as possible.


Do not use the table inside customer coding!



 


Next we will create a debug configuration. Therefore we switch to the debug perspective (Window => Perspective => Open Perspective => Other… => Debug).


To create a new debug configuration open the Debug Configurations dialog (Run => Debug Configurations…), see Figure 3.7. For reuse purposes you can name your new debug configuration (1). Ensure that the option Procedure to Debug is selected and choose Catalog schema (2). Use the Browse… button (3) to select your debug procedure. Select your debug procedure in the upcoming dialog from the Procedure folder in your database schema, see (4).


 



Figure 3.7: Create Debug Configuration


The button Debug will store the debug configuration and starts the debugging process immediately. The debug perspective provides several views to get information about the procedure execution. Figure 3.8 shows the most important views in the context of SAP HANA database procedure debugging.


The Debug View (1) displays the stack frame for the suspended threads for the procedure you are debugging. On the lowest level you can see the number of the current processing lines.


The SQLScript view (2) shows the database procedure source code. On the left side next to the line number you can see a pointer indicating the currently processing line number (here line 72 at the end of the procedure).


 



Figure 3.8: Database procedure debugging


The Variable view (3) shows all defined variables. For a scalar variable, the value is displayed directly within the view (see column value). For variables based on a table type only the number of rows will be displayed in the view. For further detail of a table type variable opens the data preview (context menu of the table type variable => Open Data Preview). The data preview can be used to inspect the result, see (4). Further on the data preview provides the option to inspect the data types of each column, see (5). This feature is quite interesting in case of dynamic generated columns based on constant selection or calculations.



3.1.3 AMDP Debugger (BW 7.50 and HANA SP09 or higher)


 

The blog How to debug ABAP Managed Database Procedures using ADT - Basics provides good basic information around AMDP and the new AMDP Debugger.


To check if the AMDP debugger is available in your release just try to create an AMDP breakpoint. The procedure is described in paragraph »Debugging in BW 7.40 and SAP HANA < SP09«, see above.


In this paragraph I’ll provide a step by step description to debug a SAP HANA Expert Script by using the AMDP debugger.


To use the AMDP debugger open the BW transformation with the SAP HANA Expert Script. It is necessary to use the embed version of the Data Warehousing Workbench (RSA1) within the Modeling Tools for SAP BW powered by SAP HANA.


Use the button Expert Routine in the BW transformation UI, see (1) in Figure 3.9, to open the corresponding AMDP class with the implemented AMDP procedure (2).


 



Figure 3.9: Prepare AMDP debugger


An AMDP breakpoint can added by double clicking to the left of the line number. For each AMDP breakpoint a dot will be created. In case the AMDP debugger is active the dot will be green and the tooltip also provides information about the AMDP debugger status. In case the AMDP debugger is not active the dot is gray and the AMDP debugger can be activated by double clicking the gray dot.


The breakpoint context menu provides further AMDP debugger options.


To start the AMDP debugger it is necessary to execute the DTP in the processing mode Parallel SAP HANA Execution, see (1) in Figure 3.10. Do not run the DTP in the simulation mode! The DTP simulation mode for a BW transformation will not execute the generated SQL statements.



Figure 3.10: Start the AMDP debugging process


 

If the process is caught by the AMDP debugger the popup dialog, see (2) in Figure 3.10, Confirm Perspective Switch will be appear. If you confirm the dialog the IDE switches to the debug perspective, see Figure 3.11.


The debugging process now is similar to the database procedure debugging in paragraph »Debugging in BW 7.40 and SAP HANA < SP09«. (1) shows the call stack, (2) shows the procedure source code, (3) provides an overview of the available variables from the procedure and (4) shows a data preview.



Figure 3.11: Debugging an AMDP method / procedure


 


 


 


 

24 Comments
former_member202516
Participant
0 Kudos

Great guide! Quick question though, I don't see "Script generation" tab when Simulate DTP. Our ABAP, BASIS and BW components are currently 7.40 SP 11. Maybe we need SP12?

Best regards

Torsten_
Advisor
Advisor
0 Kudos

Hi,

if the note

2159872 - SAP HANA Processing: BW 7.40 SP9 - SP11: HANA Analysis Processes and HANA Transformations (Part 12)

is implemented in the newest version (currently 26) the debug procedure feature should be available.

Torsten

0 Kudos
HI Torsten,

 

This blog is very informative, thanks for placing all the content at one place.

 

Santosh
0 Kudos
Hi Torsten,

I have a question regarding AMDP debugging. We are on BW 7.5 SP9.

When I try to debug the already loaded request in non-prod system, it does not work.

It is giving following error.



On the other hand, this error was present while loading the request normally. But after activation of the whole flow, this error was gone. But the errors are unpredictable and needs activation of class and transformation in non-productions landscape.

Could you please suggest

Thanks,

Mamta
Torsten_
Advisor
Advisor
0 Kudos
Hi,

this is a very generic error message and a "not stable (unpredictable)" error is quite difficult to investigate via screenshot 😉

Please create an incident so that we are able to check the behavior in your system.

Do not forget to open the R/3 connection and please add the technical DTP name in the incident to avoid unnecessary ping pongs.

Torsten
former_member543291
Discoverer
0 Kudos
Hi Torsten ,

Thanks for the Valuable information .

We are on BW 7.5 SP11 ,i am trying to debug my first script which uses the Push down functionality .

While using the Debug perspective i am getting the below error window



This window is coming when i try to view the data in the Variables (i.e inTab & outTab) and hit F5/F6 .

Am i missing something here ? or its the fault of the HANA studio i am using . I am using HANA Studio 2.3.27

Also one more question , the tempTab used in your example code ,is it declared in the Public section of the Class and then populated in the Method ?

 

 
Torsten_
Advisor
Advisor
Hi,

I'm not sure but I assume the  the AMDP Debug error you is a front end related to (may be) an old ADT version. But I'm not sure.

I would suggest to update the front end to the newest version and if that not fix the issue create an incident for that topic.

 

Regarding to the tempTab question, I assume you mean the tempTab in Figure 3.11.

In SQLScript it is not necessary to declare a table. The SQLScript runtime creates the table implicit based on the result set from the SELECT statement.

But keep  in mind the SQLScript engine use the "best" kind of data type for a column based on the result set.

I'd provided more information about that topic here:

HANA based BW Transformation – Guidelines and Recommendations

 

Torsten

 
0 Kudos

Hi Torsten,

We are on SAP_BW 750, SP08. I still don’t see the “Script Generation” Tab in the DTP Simulation mode. (See below screenshot)

Please advice what I’m doing wrong.

BTW, I only have the PROCEDURE written for one of the individual info objects in the Transformation Routines. I don’t have any Start / End / Expert Routines.

And I have the AMDP debugger ‘On’ and working for other stuff, for example: Planning Sequences.

 

former_member543291
Discoverer
0 Kudos
Hi Torsten ,

Thanks you for the response . Will try to get my ADT version updated .
Torsten_
Advisor
Advisor
0 Kudos
Hi,

the script generation tab is only available in BW 7.40. For BW 7.50 see paragraph

3.1.3 AMDP Debugger (BW 7.50 and HANA SP09 or higher)


SP09 here is related to the HANA version, not BW 7.50 SP09!

And I see in you screenshot that you are running the transformation editor in a standalone SAP GUI. Please use the embedded SAP GUI in Eclipse.

If you are using the embedded SAP GUI editor you will automatically linked to the ABAP in Eclipse (AIE) Class editor and not in the SAP GUI class editor (SE24). (see Figure 3.9: Prepare AMDP debugger)

 

Torsten

 
0 Kudos
Hi Torsten,

How do I get to the Generated SQL Statement shown in fig 3.1?

I have a simple transformation with AMDP end routine.

I open the DTP and switch to debug option (Serially in the Dialog Process (for Debugging)).  I set the breakpoints in 'Select Statement' and 'Insert Statement' and then click on the Simulate button in the DTP.

I directly get to the results screen of the DTP monitor. I don't know how to get the Generated SQL statement. I tired it in both SAP GUI and embedded GUI in eclipse but the results were the same.

 

Regards,

Jagan

 

 
Torsten_
Advisor
Advisor
0 Kudos
Hi,

what release are you running?

The statement is only generated in case of data within the source. Please check if there are data to process?

Torsten
yoona_kim
Explorer
0 Kudos
Hi Torsten,

Your blog is a bright light for me in the dark.

I am very grateful to you as a follower.as one of your follower.

My problem was issued by Debug Configurations.

We are on SAP_BW 750, SP18.

Could you advise me What I should do next?

yoona_kim
Explorer
0 Kudos
Thank you very much for your quick reply. Torsten.
wounky
Participant
0 Kudos
Hello Torsten,

 

Could you please tell me how to find a mapping between the Technical Name of the transformation and; Analysis Process + Active Routine Class (if exists).

The information can be extracted manually by entering the transformation and opening the Properties/Techincal tab.


When I tried to trace the SQL behind it, the only hints I could get were to use D010SINF, RSDHAMAP, CL_RODPS_HANA_CONTEXT/MODEL,
CL_RSDD_HANA_MODEL.


Kind regards,
Sebastian
Torsten_
Advisor
Advisor
Hi,

the logic is:

concatenate '/BIC/' <<Transformation-ID>>12(20) '_' <<object version>>

 

Means:

First the constanct value for the namespace (/BIC/).

If you are already running the BW accelerator for the DWC the namespace could be different. I assume you are running an earlier release 😉

Than the second part are the last 20 signs from the transformation ID.

 

Followed by the sign for the object version, means A for active version and M for the version which is used durring the development.

 

Torsten

 

 
wounky
Participant
0 Kudos

Thank you, Torsten. It works!
Could you please tell me if there is a way to map the SAP HANA Analysis Process ID starting with 'TR_'?

What I am trying to do:
Create a function to validate all the transformations within the transport, if they are available in version A, if applicable if they have active class/procedure, and if they have an active HANA Analysis Process.

 

paulvatter
Participant
0 Kudos
Hi Torsten

hope you are doing fine!

Can you share some details about the "BW accelerator for the DWC" you are mentioning?

Thanks and best regards

Paul
Torsten_
Advisor
Advisor
Hi,
please check table RSTRAN column TRANPROG.

Torsten
Torsten_
Advisor
Advisor
0 Kudos
Hi Paul,

no I can not, unfortunately ;-(
I am no longer part of the BW development team and therefore no longer up to date with the new projects.

Sorry Torsten
danpaps
Discoverer
0 Kudos
Hi Torsten,

hope you are doing fine!

I have a question regarding the update of the 0RECORDMODE through AMDP.

As you can see from the Screenshot form the Debugger, there are several records with Recordmode = 'X', but in the New Data Table of the ADSO the 0Recordmode Field is empty for all the records...




Can you point me to what might be the cause of the issue? In case you don't have answer, because you are "no longer part of the BW development team", can you please guide us to a responsible person who can answer these issues?

Thank you in advance,

Dan
danpaps
Discoverer
0 Kudos
Hi again,

All Keyfigures might be set to 0 directly in the New Table for the records with 0RECORDMODE = 'X', but this behaviour is not really helpfull when dealing with LIS Extractors containing Before and After Image records.

Cheers,
Dan
sameer_mehta
Participant
0 Kudos

Hi Torsten,

 

Thanks for the very informative blog.

I would like to ask a question here, we have implemented a AMDP using an Info Source in between. While doing the data loads it is giving an error "Max. number of rows per table or partition reached", this error is coming while inserting the records into the Inbound queue of the ADSO but on the other hand if execute the DTP by inserting a breakpoint in the AMDP script, everything is working fine without any error.

 

It seems strange that the same transformation is giving error but not when executed using a breakpoint in the AMDP script.

 

Any insights on this issue would be helpful. We are using BW 7.5 SP22

 

Thanks.