|
View previous topic :: View next topic
|
| Author |
Message |
D Rishi
New User
Joined: 01 Mar 2010 Posts: 21 Location: India
|
|
|
|
Hi All,
I have a flat file with fixed length of 778 byte. And there are certain types of records like 'A1', 'F1', 'C1', 'G1', 'M1', 'M2' etc. starting with 1st byte; with 2 variants like '20' & '30' ( from 5th byte say ).
But I need to sort the file with certain keys among which one of the keys(with 9 bytes) position is different in different types of record.
Here I tried but the code doesn't work out..i am trying to Push the field's value from different position in the last byte & trying to sort afterwards.
INREC IFOUTLEN=778,
IFTHEN=(WHEN=(5,2,CH,EQ,C'20',AND,(1,2,CH,EQ,C'C1',OR,
1,2,CH,EQ,C'G1')),PUSH=(779:168,9)),
IFTHEN=(WHEN=(5,2,CH,EQ,C'30',AND,(1,2,CH,EQ,C'C1',OR,
1,2,CH,EQ,C'G1')),PUSH=(779:83,9)),
IFTHEN=(WHEN=(1,2,CH,NE,C'C1',OR,1,2,CH,NE,C'G1'),
PUSH=(779:28,9))
SORT FIELDS=(16,3,CH,A,1,2,CH,A,779,9,CH,A,19,8,CH,A,5,2,CH,A) --
Probably it is having some syntax error also.. But please provide some workable solution..
Thnaks
Rishi |
|
| Back to top |
|
 |
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2482 Location: @my desk
|
|
|
|
D Rishi,
Welcome to the forums.
You need to use OVERLAY instead of PUSH. PUSH is not applicable in this context. PUSH is used when you need to GROUP a set of records using WHEN=GROUP.
If it does n't work, post your Syntax error and SYSOUT messages here using "Code" tags. |
|
| Back to top |
|
 |
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2482 Location: @my desk
|
|
|
|
| Also you need to omit the IFOUTLEN parameter as well. If you don't need the additional 9 bytes at pos-779 to be written in output, you can choose not to select it in the OUTREC pass. |
|
| Back to top |
|
 |
D Rishi
New User
Joined: 01 Mar 2010 Posts: 21 Location: India
|
|
|
|
Hi Arun,
i)I tried with using Overlay instead of PUSH with IFOUTLEN parameter..
The error was..
RECORD TYPE IS F - DATA STARTS IN POSITION 1
END OF FIELD BEYOND MAXIMUM RECORD LENGTH
ii)Then I removed the IFOUTLEN The error coes as below:
IFTHEN=(WHEN=(5,2,CH,EQ,C'20',AND,(1,2,CH,EQ,C'C1',OR,
$
STATEMENT DEFINER ERROR
iii) Then I used When=Group but sytax error was comming.. |
|
| Back to top |
|
 |
expat
Global Moderator

Joined: 14 Mar 2007 Posts: 8798 Location: Welsh Wales
|
|
|
|
Can you also show the error message codes as well as the content.
Also which release level you are using may also affect the solution given. |
|
| Back to top |
|
 |
Frank Yaeger
DFSORT Developer

Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
| Quote: |
ii)Then I removed the IFOUTLEN The error coes as below:
IFTHEN=(WHEN=(5,2,CH,EQ,C'20',AND,(1,2,CH,EQ,C'C1',OR,
$
STATEMENT DEFINER ERROR
|
Well, along with IFOUTLEN, you removed INREC, so you don't have a valid control statement. You need INREC:
If you want more help on this, you need to explain in more detail what it is exactly you're trying to do. Show an example of the records in your input file (relevant fields only) and what you expect for output. Explain the "rules" for getting from input to output. Give the starting position, length and format of each relevant field. Give the RECFM and LRECL of the input file. If the input file can have duplicates within it, show that in your example. |
|
| Back to top |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
D rishi,
Based on your description you can use the following control cards
| Code: |
//SYSIN DD *
INREC IFTHEN=(WHEN=INIT,OVERLAY=(779:28,9)),
IFTHEN=(WHEN=(1,2,SS,EQ,C'C1,G1',AND,5,2,ZD,EQ,20),
OVERLAY=(779:168,9)),
IFTHEN=(WHEN=(1,2,SS,EQ,C'C1,G1',AND,5,2,ZD,EQ,30),
OVERLAY=(779:83,9))
SORT FIELDS=(016,3,CH,A, $ KEY-1
001,2,CH,A, $ KEY-2
779,9,CH,A, $ KEY-3
019,8,CH,A, $ KEY-4
005,2,CH,A),EQUALS $ KEY-5
OUTREC BUILD=(1,778)
//* |
|
|
| Back to top |
|
 |
D Rishi
New User
Joined: 01 Mar 2010 Posts: 21 Location: India
|
|
|
|
Its great!! Thanks Kolusu.. The code is working fine..
Also thanks to frank, expat & arun for paying time for this. |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|