Friday, July 29, 2022

Replacing LOOP statement with ABAP Filter Operator

I tried to compare how ABAP filter operator compete with LOOP statement.

 

1. Classic LOOP statement

On top of itab t_data that is being looped over into a structure a new itab t_data1 is generated from the structure. A condition for the LOOP specified as hardcoded into WHERE part of the LOOP statement.

LOOP AT t_data INTO s_data WHERE ( col_1 = 'AAA' ).

  INSERT s_data INTO TABLE t_data1.

ENDLOOP.

 

2. Filter Operator

A Filter Operator is used to build the itab t_data2 based on th_data itab. Condition is specified as hardcoded one in the filter.

DATA(t_data2) = FILTER #( th_data WHERE col_1 = 'AAA' ).

 

Next, let assume that we have a multiple conditions for the LOOP so they are stored in a special itabs.

3. Classic LOOP statement with WHERE condition as a range

In a case of the class LOOP statement I leveraged range type of itab. The range (t_filter itab) is prepared prior the LOOP. Afterwards the range in used in the WHERE part of the LOOP by IN statement.

t_filter = VALUE #( BASE t_filter ( opt = 'EQ' sign = 'I' low = 'AAA' ) ).
 
LOOP AT th_data INTO s_data WHERE col_1 IN t_filter.
  INSERT s_data INTO TABLE t_data3.
ENDLOOP.

 

4. FILTER Operator with filter as itab

A hash itab (th_filter) is prepared with the condition prior the FILTER operator statement. A new itab (t_data4) is prepared by Filter operator. The Filter operator uses IN statement to specified the itab with the filter.

th_filter = VALUE #( BASE th_filter ( col_1 = 'AAA' ) ).
 
DATA(t_data4) = FILTER #( th_data IN th_filter WHERE col_1 = col_1 ).

 

Conclusion

In my system based on component SAP_ABA 75, SP04 I achieved the fastest the run no 2. Means Filter operator where the condition was hardcoded.



Few more remarks:

To count the no of the itab entries I used REDUCE (Reduction Operator – part of Iteration expression). The statement basically goes over all the entries of the itab and adding 1 into n variable as specified in NEXT statement.

v_count = REDUCE i( INIT n = 0 FOR x_data IN t_data4 NEXT n = n + 1 ).

 

Yes, I’m aware that I could do this by lines (a row function) as seen below. However, I wanted to try more the reduce operator instead.

DATA(v_cnt) = lines( t_data1 )

 

To calculate total of figure that is stored in column col_f in all the itabs I used again Reduction Operator. Just in this case the value of the column col_f is being added up into n variable.

v_count = REDUCE i( INIT n = 0 FOR x_data IN t_data4 NEXT n = n + x_data-col_f ).

Source code available in my Gitgub gist zmm_loop_replacement

Monday, July 25, 2022

How to determine query tech name for BEx variable processing (in user exit/BADI)

While implementing a logic in user exit based BEx/BW variables a requirement of query technical name determination may appear. Thus, I tried to research on this topic a little bit. Fortunately, there is a structure called I_S_RKB1D, which has a description Query Reporting Attribute. The structure has a lot of useful information. Among others (see below) there is an also COMPID information that has the query technical name. The structure is available since a call of standard FM RRS_REPORT_INIT_START.

The structure is still available in memory at the point where the custom logic serving for purposes of specific variable is called.


Columns available in the structure:

COMPUID UUID in compressed form

INFOCUBE InfoCube

GENUNIID Internal display of the report identifier

COMPTYPE Type of a reporting component

COMPID Name (ID) of a reporting component

RFCSUPPORT Report supports access using OLAP API

OBJSTAT Object Status

SMODE Special reports

READMODE Read Mode

NOAGGRFL Flag: Do not use aggregates for this query

IDVERS Dictionary version (internal vers.) of report in RSIX

DVERS Dictionary version (current Release) of report in RSIX

RNAME ABAP Program Name

AUTHOR Name of author

GENTIME Query Generation Time (Cache Invalidation)

LASTUSER Last Changed By

MODTIME Last Change to Definition

REPTIME Last Change of Query Runtime Object

GEN1TIME Query Gen Time (no cache invalidation needed)

PACKFL Process Key Figure with High Precision

PACKFL_DEF Boolean

NOSPBUF SP Cannot be Permanently Buffered

CACHEMODE Query Cache Mode

CACHEUSAGEMODE Cache Usage Mode

KIDSEL Use Selection of Structure Elements

FAGGR_LATE Calculation of Commutative Formulas After Aggregation

OPT_OCCURS Boolean

OPT_OCCURS_TIME UTC Time Stamp in Short Form (YYYYMMDDhhmmss)

OPT_OCCURS_MODE Optimization Mode

OPT_OCCURS_PER Optimization Periods

SUPPRMESS Suppress Messages

CACHEUSEREXIT Indicator: Cache Use Despite Virtual Characteristics/KF

NOPARALLEL No Parallel Processing

GENPROT Generation Protocol

INPUTABLE Make All Basic Indicators Ready for Input

PARTITIONMODE Type of SP Grouping for Delta Caching

DELTACACHE Update Cache Objects in Delta Process

ACTUALDATA Data Integrity

OLAPSTAT OLAP Statistic Properties of the Query

OLAPSTATDETLEV OLAP Statistics Detail Level

ADDNLS Should the Cold Store storage be read too?

NOHPA Obsolete Field (Do Not Use BWA Index)

READMODE_DEFT Boolean

ACTUALDATA_DEF Boolean

CACHEMODE_DEF Boolean

DELTACACHE_DEF Boolean

PARTITION_DEF Boolean

DIS_MODE Disaggregation on Totals

INFOPROV_SUPPORT Query is used as InfoProvider

NOPARALLEL_DEF Boolean

KIDSEL_DEF Boolean

ADDNLS_DEF Boolean

NOHPA_DEF Boolean

CHUSEREXIT_DEF Boolean

TREXOPS Operations in SAP HANA

TREXOPS_DEF Boolean

MATERIALIZEQUERYLAYER Materialize Intermediate Query Result

MATERIALIZEQUERYLAYER_DEF Boolean

IS_PLANQUERY Boolean

DATA_INTEGRITY_SCENARIO Data Integrity Profile

DI_SCENARIO_DEF Boolean

READ_CHILD_KIDS Also Read the Child Members with Hierarchy Structure Node

READ_CHILD_KIDS_DEF Boolean

OLAPEFFORT OLAP Effort for Query

QMODI Q Mode Implementation (relational browse)

DOCUMENT_SUPPORT Document Support

DEFAULT_DOC_APPL_ID Default Document Application ID

PROPVERS Version of Properties concerning Support Package

MOSTRECENT Read according to newest, possibly not active structure

VARIANT ABAP: Name of variant (without program name)

PMODE Mode in which a query is executed (online, batch)

TMSTMP_ROLLUP UTC Time Stamp in Short Form (YYYYMMDDhhmmss)

TMSTMP_ROLLUP UTC Time Stamp in Short Form (YYYYMMDDhhmmss)

TMSTMP_START TS for Start of RRI_REPORT_IMPORT_AND_CHECK

ODBO Using ODBO to Execute Query

EXPLAIN_QUERY This Is A Explain Query

NO_RTPERSISTENCE Does the query have a runtime persistency

USE_NLS Boolean

ONLY_SIMPLE_CU Boolean

MANDT_DEP Object is client-specific

Tuesday, July 19, 2022

BW transport error: CL_RSTRAN_STEP_ROUT

 Recently my BW transport has crashed while being imported to target system. Error message in the transport log looked like below:


An exception of type CX_SY_OPEN_SQL_DB was raised and terminated the program, Message no. PU108

Program CL_RSTRAN_STEP_ROUT===========CP, include CL_RSTRAN_STEP_ROUT===========CM003, line 24

Errors occurred during post-handling RS_AFTER_IMPORT for * L, Message no. PU133

RS_AFTER_IMPORT belongs to package RSO_TLOGO

The errors affect the following components: Message no. PU136

   BW4-ME (Metadata (Design time)), Message no. PU137



My transport contained few
BW transformations but from the error log, it wasn’t obvious which TRFN the error is related to. From a keyword “CL_RSTRAN_STEP_ROUT” that popped up in the error log, I concluded that it had something to do with a routine in the TRFN. That just did not help as most of my TRFN in the transport had routines. I tried to google the keyword as well. I just ran into an old question on SAP Community network forum. It happened that I replied on that question back in 2011 – more than eleven years ago – “huh” :) In my reply to that forum question, I suggested to “try to delete whole field routine, activate transformation and create routine again”. Therefore, I did this – right, there was nothing to lose. Just this time I focused only on TRFN which had field routines not a start/end/expert ones. I just recreated a field routines by simply deleting and recreating them.

Moreover, it worked like a charm, on next import to target system I just got a warnings not an errors.

Monday, July 18, 2022

How often a Process Chains are being killed in your BW?

In BW systems if a particular process in a Process Chain (PC) runs into a problem in most cases a whole chain is stopped. Such process chain gets a red status that means that it did not finished properly. A corrective action is needed to be done by BW administrator. An issue that caused the process to be terminated must be removed and process can be restarted afterwards.

However sometime a situation can be different. The chain's run need to be stopped for some reason. There are few options of how to abort currently running process chain.

One can go to respective basis job of the current process that is executed by the PC. Once the job is found from SAP Basis t-code like SM37 the job can be canceled. This can be achieved by displaying a pop-up window of the PC's process within PC related t-codes like RSPC1, etc. There under Bckg tab it is possible to jump to the SM37 via Batch Monitor button.

Once you arrive, there just use Stop icon (Stop active job) available on a toolbar. Afterwards the job status turn to a red, (Canceled) you can return back to level of the chain and particular process will be set to Aborted. This is indicated in table RSPCPROCESSLOG - column STATE = X = Aborted or R = Error.

Other option can be found directly with a monitor part of PC related t-codes like RSPC1. There is a button called "Stop current run as soon as possible" on the toolbar. 


If during the PC run a button "Stop current run as soon as possible" is pressed a flag TO_BE_KILLED is set in table RSPCKILL. The PC is terminated at the step during which execution a button was pressed. The respective step has followign monitor entry in its pop window:

The table RSPCKILL stores such a “killed” runs of the PC. It has a very simple layout there are only following columns in the table:

 

LOG_ID - Log-ID of a Process Chain Run

TSTPNM - Last Changed By

TSTPDAT - Changed On

TSTPTIM - Changed at

TO_BE_KILLED – Boolean, X if the PC was killed like described above

 

Based on number of the entries in this table one can get a rough idea how many time a process chain was stopped/killed during its run in the BW system. Technically the entry in the table is created by a call of a method REMOVE_FROM_BATCH of ABAL class CL_RSPC_FRONTEND. Respective entry in table RSPCPROCESSLOG - column STATE = F = Done.





Friday, July 1, 2022

Working with navigational attributes in Composite Providers

While working with Composite Providers (HCPR) a navigation attributes of InfoObjects that are present in objects contained in the HCPR are not shown by default. Below picture illustrates how it looks like when the navigation attributes are not shown.

In BW Modelling Tools  of SAP HANA Studio there is an option how to enable it. In the HCPR maintenance screen under a right click there is an option called “Show Unassigned Navigation Attributes”.


Once the above option is activated then the navigation attributes are present and can be freely assigned. Here’s how does it look like when the navigation attributes are available.