View previous topic :: View next topic
|
Author |
Message |
Learncoholic
New User
Joined: 20 Sep 2007 Posts: 97 Location: India
|
|
|
|
Hi,
I have a I/P file that reads:
Code: |
AAA
AAAAA
123145
SCNCASHCJ
|
I want to have the O/P as:
Code: |
' AAA',
' AAAAA',
' 123145',
' SCNCASHCJ'); |
The No of records in the file may vary on a daily basis.
I did this is 2 SORT Steps. I would prefer to have it in 1 step.
I tried to do it in 1 step by using:
INREC - to provide Sequence Number
SORT - descending based on the Sequence No
OUTFIL IFTHEN - to build ');' in case Sequence No is 1 otherwise build ','.
This arrangement actually flips the records.
Can this be done without flipping using a single SORT Step?
Thanks |
|
Back to top |
|
|
sergeyken
Senior Member
Joined: 29 Apr 2008 Posts: 2019 Location: USA
|
|
|
|
At the first step, no info can be available in advance: what is following next to the current record?
This is fundamental principle; it is not related neither to SORT, nor to anything else.
Any possible trick would simulate the second scan of records, either explicitly, or in hidden manner. |
|
Back to top |
|
|
daveporcelan
Active Member
Joined: 01 Dec 2006 Posts: 792 Location: Pennsylvania
|
|
|
|
Additional information would be helpful.
When the scope of the problem is too narrow, the possible solutions are limited.
The desired output appears to be part of SYSIN DD for some sort of SQL.
Please show the next step of the Job where this is to run.
I have a thought that could be helpful, but can not properly express without additional information. |
|
Back to top |
|
|
RahulG31
Active User
Joined: 20 Dec 2014 Posts: 446 Location: USA
|
|
|
|
As daveporcelan mentioned, if it is indeed a part of SQL query where you are doing something like a 'WHERE values IN' and trying to build the list of values then, you could possibly make use of a 'Dummy' record:
Code: |
OUTFIL BUILD=(1:X'7D',2:1,16,18:X'7D6B',X),
TRAILER1=(1:X'7D',2:C' DUMMY',18:X'7D5D5E')
OPTION COPY |
the output will be:
Code: |
' AAA',
' AAAAA',
' 123145',
' SCNCASHCJ',
' DUMMY'); |
The 'Dummy' value won't make a difference to the output if chose carefully.
. |
|
Back to top |
|
|
Learncoholic
New User
Joined: 20 Sep 2007 Posts: 97 Location: India
|
|
|
|
Hi Rahul & daveporcelan,
Both of you are correct. This O/P of the SORT is an I/P to a SQL Query.
I get what Rahul is suggesting & putting a Dummy record will work perfectly fine in my case.
Thanks |
|
Back to top |
|
|
daveporcelan
Active Member
Joined: 01 Dec 2006 Posts: 792 Location: Pennsylvania
|
|
|
|
That is what I was going to suggest, but was waiting for you to provide more information.
Since you are 'learnaholic', learn this: providing some background information (do not go overboard), would greatly help get solutions to the problem.
Lucky for you, both Rahul and I have enough experience to work with the sparse information provided. |
|
Back to top |
|
|
|