Get Max Key From Hashfile

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
martin
Participant
Posts: 67
Joined: Fri Jul 30, 2004 7:19 am
Location: NewJersy

Get Max Key From Hashfile

Post by martin »

Hi Guys,

I have a design, which pulls Max SUK from Hashfile, and passes to Transformation stage to generate Next Key. Now I want to get rid of these extra stages and processing time, and replace with ROUTINE which can read Max SUK from Hashfile created out Project Area.

If any can help me with Routine code, I would really appreciate.

Thanks
Martin
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Code: Select all

Trans("hashedfilename", "keyvalue", 1, "X")
Read about this function in DataStage BASIC manual. You may need to add Trans() to DSParams file if you don't like the red colour.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
martin
Participant
Posts: 67
Joined: Fri Jul 30, 2004 7:19 am
Location: NewJersy

Post by martin »

Hi Ray,

Thanks for the reply,I will try and let you know.

Rg
Martin
martin
Participant
Posts: 67
Joined: Fri Jul 30, 2004 7:19 am
Location: NewJersy

Post by martin »

Hi Ray,

I tried your code

Code: Select all

TRANS("/Ascential/Datastage/DEV/Ha_RequestDim', "REQ_ID", 1, "X")
I got error
DataStage Job 85 Phantom 31381
Program "JOB.1638071665.DT.1386332505.TRANS1": Line 51, Unable to open "/Ascential/Datastage/DEV/Ha_RequestDim" file.
DataStage Phantom Finished


Any Idea

Thanks
Martin
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

Your hashed file is externally pathed. Consider writing a quick function that utilizes the OPENPATH statement to open the hashed file, then a READ statement to read the appropriate row from the hashed file.

Consider also changing the hashed file to a sequential file. I'm sure you are more comfortable reading a line from a text file using a grep statement.
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

It must be the name of the hashed file in a Trans() function, not its pathname. You need to create a VOC pointer using SETFILE before the Trans() function will work. You would have determined this had you read the entry for Trans() in the manual.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
martin
Participant
Posts: 67
Joined: Fri Jul 30, 2004 7:19 am
Location: NewJersy

Post by martin »

As per Kcbalnd I am writing to Seq File and capturing Max Key value using Transformation Routine......Its working the way it has to work.

I also tried Ray method and bit confused using .

Code: Select all

TRANS ( [DICT] filename, record.ID, field#, control.code)
1. I defined SETFILE <Full Path> in before-Job Subroutine with ExecTCL.
2. Then I used TRANS function in Transformation Derivation

first step gave me error, I know I am doing mistake, Ray i would really appreciate if can help me to understand This Function.

Thanks
Martin[/code]
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Code: Select all

SETFILE pathname VOCname OVERWRITING
creates an entry called VOCname in the VOC file as a pointer to the hashed file whose pathname is specified by pathname - it is the name in the VOC file that you must use in the TRANS function.

TRANS(VOCname, keyvalue, field#, code) opens the hashed file referred to by VOCname, reads the record specified by keyvalue and returns the field whose number is given as field#. The code argument is a single letter that specifies what to do if the record can't be found.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply