Abinitio Interview Question 7


The Input DataSet is as follws:

Acc_No, Acc_holder, Credit_month,Credit_Amount      month_no
001, xxxx, JAN, 1000 1
001, xxxx, FEB, 500 2
002, yyyy, JAN, 800             ===> 1
002, yyyy, AUG, 2300 8
002, yyyy, DEC, 500 12
003,    zzzz, May, 200 5

Problem Statement:
For each acc holder the credit month and the 
corresponding credit amount will be stored. 
It's not necessary to have the amount for all the 12 
months and in case of missing ,
value '0' needs to be populated. 

We need one record per acc_holder in the output with 
12 months data along with the total. 

Steps for Approach:


1. Generic the missing #s -> Normalize (12) 
2. Aggregate the records -> Rollup


Expected O/p: 

Acc_No |Acc_holder      | monthly_amt_summary           |    Total 
001 | xxxx | 1000 ,500,0,0,0,0,0,0,0,0,0,0|    1500
002 | yyyy  | 800 ,0,0,0,0,0,0,2300,0,0,0,500|    3600
003 |   zzzz |  0,0,0,0,200,0,0,0,0,0,0,0|            200



Design:
                            Key(Acct No)
                      --->sort->dedupsort--Normalize----->
                      |                                                           |
Input:Replciate                                                          JOIN; Key(AcctNo+MonthNo)-->Rollup-->Output
                      |                                                           |
                      ---Reformat----------------------------->



type temporary_type=
record
decimal("") cnt;
string("") amt_summary;
end;

temp::initialize(in)=
begin
temp.cnt::1;
temp.amt_summary::'';
end;

out::rollup(temp,in)=
begin
temp.amt_summary::if(temp.cnt==1) in.Credit_Amount else string_concat(temp.amt_summary,',',in.Credit_Amount);
temp.cnt::temp.cnt+1;
end;

out::finalize(temp,in)=
begin
out.*::in.*;
out.monthly_amt_summary::temp.amt_summary;
end;


Expected O/p: 

Acc_No | Acc_holder | monthly_amt_summary|     Total 
001 | xxxx | 1000 ,500,0,0,0,0,0,0,0,0,0,0| 1500
002 | yyyy  | 800 ,0,0,0,0,0,0,2300,0,0,0,500|         3600
003 |    zzzz         |    0,0,0,0,200,0,0,0,0,0,0,0|                   200


outputDML;
record
string("|") Acc_No;
string("|") Acc_holder;
string("|") yearly_amt_summary;
decimal("\n") Total;
end;


For other Abinitio Youtube video please visit my channel ->  DataPundit

For other peace and meditation videos please visit my channel -> @paradisetracks



Comments

Popular posts from this blog

Abinitio Interview Question # 1 - Write Multiple Files in Abinitio

Next In Sequence in ABinitio | How next_in_sequence() works in MFS