Logo DWBI.org Login / Sign Up
Sign Up
Have Login?
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.
Login
New Account?
Recovery
Go to Login
By continuing you indicate that you agree to Terms of Service and Privacy Policy of the site.
SAP Data Services

Data Services Scenario Questions Part 7

Updated on Oct 02, 2020

In this tutorial we will discuss some scenario based questions and their solutions using SAP Data Services. This article is meant mainly for Data Services beginners.

This article is one of the series of articles written to showcase the solutions of different business scenarios in SAP Data Services. You may browse all the scenarios from the below list.

  1. Cumulative Sum of salaries, department wise
  2. Getting the value from the previous row in the current row
  3. Getting the value from the next row in the current row
  4. Getting total Sum of a value in every row
  5. Cumulative String Concatenation (Aggregation of string)
  6. Cumulative String Aggregation partition by other column
  7. String Aggregation

Scenario 7: With reference to the previous department-employee source file, lets try to load the target table data as below:

DEPTNOENAME_LIST
10A,B,C,D
20E,F,G,H

Solution:

The approach to this Scenario will be exactly the same as that of Scenario 6, discussed in the previous section. First take a look at the Data flow below:

Data flow
Data flow

The difference lies in the last three Query transforms namely- QRY_FORMAT, QRY_REV_SORT and QRY_FILTER. Apart from that the Data flow is an exact replica of the previous scenario solution.

In Query transform QRY_FORMAT we define a New Output Column, say SEQ_NUM_GRP with data type int and specify the Mapping as gen_row_num_by_group( QRY_CONCAT_NAME.DEPTNO ).

Query- Sequence By Group
Query- Sequence By Group

Using the Data Services function gen_row_num_by_group we generate sequence numbers starting from 1 for every departments.

Next in the Query transform, QRY_REV_SORT, select the columns DEPTNO and ENAME_LIST from the Schema In of the Query transform and Map to Output. Specify the ORDER BY on DEPTNO Ascending and SEQ_NUM_GRP in Descending type.

Query- Reverse Sort
Query- Reverse Sort

Finally in the Query transform, QRY_FILTER, we will filter only the first row of each department records coming from the previous transform. Select DEPTNO and ENAME_LIST from the Schema In of the Query transform and Map to Output. Specify the WHERE clause as is_group_changed( QRY_REV_SORT.DEPTNO ) = 1.

Query- Filter
Query- Filter

Using the Data Services function is_group_changed we will capture only the first record of each set of departments.

Finally we place a Template Table as Target in the Target Datastore.

Data Preview
Data Preview