To Read Hash File in A Loop

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
thirupri
Premium Member
Premium Member
Posts: 40
Joined: Wed Sep 17, 2003 3:41 am
Location: Saudi Arabia
Contact:

To Read Hash File in A Loop

Post by thirupri »

I created a Job for to conversion of a flat file. But the file name is not fixed. So I created another Job to get the file names in the directory and moved to the Hash file. Now, how to read the hash file in a loop and call the Job and pass the value for all the file name in the Hash file. I Hashkey as a unique in the Hash file and filename column.

Platform: Window2000
DS Version : 6.0.1

Thanks,

Best Regards,
Thiruma Valavan
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

Why read from a hash file when you can do a directory listing and loop from that?

Try this from a DS Batch job, and correct the html formatting that happens around the < > characters:


NTcmd="dir ":YourDirectoryPathParameter:"*.dat /b"
Call DSExecute("NT", NTcmd, ScreenOutput, ReturnCode)
Results = ""
If INDEX(ScreenOutput, "File Not Found", 1) Then
Results = "No files to process"
End Else
LinesInScreenOutput=DCOUNT(ScreenOutput, @AM)
For FileNamePtr=1 to LinesInScreenOutput
FileName = ScreenOutput< FileNamePtr > ***Remove spaces by the < >
Call DSLogInfo("Processing filename [":FileName:"]", "Msg")
Results< -1 > = FileName ***Remove spaces by the < >

*
* Put your job control logic here
*
Next FileNamePtr
End
Call DSLogInfo("The following files were processed: ":Results, "Msg")


Kenneth Bland
thirupri
Premium Member
Premium Member
Posts: 40
Joined: Wed Sep 17, 2003 3:41 am
Location: Saudi Arabia
Contact:

Post by thirupri »

Kenneth,
This command line ' NTcmd="dir ":YourDirectoryPathParameter:"*.dat /b" ' is the ":YourDirectoryPathParameter:" is a Parameter. For eg. My Path is "D:OFDMWingsDaily" and the file names doesn't have any extension like "DAT". How will you hard code this value.



Best Regards,
Thiruma Valavan
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

You're hardcoding paths in programs? Unless you have extensions, you're going to get a full directory listing with *.*.

NTcmd="dir D:OFDMWingsDaily*.* /b"



Kenneth Bland
thirupri
Premium Member
Premium Member
Posts: 40
Joined: Wed Sep 17, 2003 3:41 am
Location: Saudi Arabia
Contact:

Post by thirupri »

Kenneth,
Thanks again. I used the Parameter itself. It's working fine. Thank for your guidance.


Best Regards,
Thiruma Valavan
Post Reply