S) Reformat and normalize example -- Input : 1,2,3-7,8,9

 Input : 1,2,3-7,8,9

Output :

1

2

3

4

5

6

7

8

Solution 

let decimal(4)val1 =0; 

let decimal(4)val2 =0; 

let decimal(4)diff =0; 

 

out::reformat(in)= 

begin 

if(string_index(in.id,"-")) 

        begin 

        val1 =string_substring(string_replace(string_substring(in.id,1,string_index(in.id,"-")-1),","," "),1,1); 

        val2=string_substring(string_replace(string_substring(in.id,string_index(in.id,"-")+1,string_length(in.id)),",",""),3,1); 

        diff =(val2-val1)+1; 

        end 

 else diff =1; 

 out.id :: if (string_index(in.id,"-")> 0) valelse in.id; 

 out.diff :: diff; 

 end; 

Normalize 

out::length(in)= 

begin 

out:: (decimal("|"))in.diff; 

end; 

 

/*Do computation*/ 

out::normalize(in,index)= 

begin 

out.id::if(index ==0) (decimal("")) in.id else string_lrtrim((decimal("")) in.id+index); 

end; 

O/p DML 

Record 

String(“\n”)id; 

End  

 

Refomat 

 

Comments

Popular posts from this blog

T) For data parallelism, we can use partition components. For component parallelism, we can use replicate component. Like this which component(s) can we use for pipeline parallelism?

T) When to use sort within groups ?

T) Explain about on .abi-unc files in abinitio ?