Sorting non uniform structured sequential file

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
mtechnocrat
Participant
Posts: 38
Joined: Sat Feb 28, 2004 12:11 pm

Sorting non uniform structured sequential file

Post by mtechnocrat »

Hi All

I have 4 jobs , my target is sequential file.
In First job , I have 16 columns and loading Customer Info into a sequential file .
In Second Job , I have 20 columns and loading product data in to the same sequential file.
In third job I have 4 columns and aarget is same sequential file.

My requirement is I need to sort this output data , so that I need to get the information for customer,Product ..etc for same order no .

ex :
output file : this is pipe seperated file .


Customer 1000 NY USA 701 DIRECT REGULAR 15000.00
Customer 2000 NJ USA 801 CARTRIER DAILY 25000.00
Product 1000 AAA Elec device
Product 2000 BBB Cell Device
Addr 1000 Anto
Addr 2000 Lenin

After sorting the data should be :

Addr 1000 Anto
Customer 1000 NY USA 701 DIRECT REGULAR 15000.00
Product 1000 AAA Elec device

Addr 2000 Lenin
Customer 2000 NJ USA 801 CARTRIER DAILY 25000.00
Product 2000 BBB Cell Device

I tried with sorter , but b'coz of non uniform structure I was unable to open the sequential file ..Is it possible to sort the data for this FIle ? Please suggest me.


Thanks in Advance
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

if you just want to sort it by second column, then in the after job subroutine, choose execsh
and paste the bottom command there

Code: Select all

sort +1 -n #file# > #sortedFile#
file is the full path and file name of the file to be sorted
sortedFile is the full path and file name of the sorted file.
:wink:
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
mtechnocrat
Participant
Posts: 38
Joined: Sat Feb 28, 2004 12:11 pm

Post by mtechnocrat »

DSguru2B wrote:if you just want to sort it by second column, then in the after job subroutine, choose execsh
and paste the bottom command there

Code: Select all

sort +1 -n #file# > #sortedFile#
file is the full path and file name of the file to be sorted
sortedFile is the full path and file name of the sorted file.
:wink:
Hi
I need to sort based on first column , second columns and one more column is there . Can u help me to sort out this issue.

thanks
Rishi
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Sure. Please specify the columns you want it sorted by.
Your input data.
Your final output data.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
mtechnocrat
Participant
Posts: 38
Joined: Sat Feb 28, 2004 12:11 pm

Post by mtechnocrat »

DSguru2B wrote:Sure. Please specify the columns you want it sorted by.
Your input data.
Your final output data.
Hi Guru
As u said in previous reply I have executed the script after subroutine by select ExecSh ..But its not creating file in that particular path.
Here I used some dummy job , in the job I am not using the file , b'coz of column structure I am unable to import/open this file , thats why I have executed this script with some dummy job , let me know ur comments.Pls correct me if I am going in wrong way.

thanks
Rishi
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

go to the director log and see what message are you getting for the EXECSH in the after job subroutine.
Are you sure you gave the right path. Does all the folders exist. There has to be a spelling mistake.
Also, if the job log is not much of a help, then go to the directory where the file to be sorted is present.
and in the command prompt run the sort command i sent you earlier.
and then do a cat on the sorted file and see if thats what you need.
Try these things and let me know.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
mtechnocrat
Participant
Posts: 38
Joined: Sat Feb 28, 2004 12:11 pm

Post by mtechnocrat »

DSguru2B wrote:go to the director log and see what message are you getting for the EXECSH in the after job subroutine.
Are you sure you gave the right path. Does all the folders exist. There has to be a spelling mistake.
Also, if the job log is not much of a help, then go to the directory where the file to be sorted is present.
and in the command prompt run the sort command i sent you earlier.
and then do a cat on the sorted file and see if thats what you need.
Try these things and let me know.
I have checked in the Director , this showing 'NO Output form commnd lIne "

Message :
Sorttest..AfterJob (ExecSH): Executed command: sort +1 -n #/data/datastage/Data/CAST/SOURCE.txt# >#/data/datastage/Data/CAST/SORT.txt#
*** No output from command ***

I have checked in that particular location , there is no file .I have given th CorrectPath ..
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Ok. If you are giving the full path, please remove the begining and ending hash signs.
The hash sign was if you are passing the path as a job parameter.
Just remove the hash signs and you will be fine.
So now your command will look like this

Code: Select all

sort +1 -n /data/datastage/Data/CAST/SOURCE.txt > /data/datastage/Data/CAST/SORT.txt 

Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
mtechnocrat
Participant
Posts: 38
Joined: Sat Feb 28, 2004 12:11 pm

Post by mtechnocrat »

DSguru2B wrote:Ok. If you are giving the full path, please remove the begining and ending hash signs.
The hash sign was if you are passing the path as a job parameter.
Just remove the hash signs and you will be fine.
So now your command will look like this

Code: Select all

sort +1 -n /data/datastage/Data/CAST/SOURCE.txt > /data/datastage/Data/CAST/SORT.txt 

Hi Guru

I have got he expected out put , Thank very much.

Thanks a lot

Rishi
Post Reply