IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Sorting with a field which are present in different position


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
D Rishi

New User


Joined: 01 Mar 2010
Posts: 21
Location: India

PostPosted: Thu Dec 02, 2010 4:46 pm
Reply with quote

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
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Thu Dec 02, 2010 4:52 pm
Reply with quote

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
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Thu Dec 02, 2010 5:04 pm
Reply with quote

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
View user's profile Send private message
D Rishi

New User


Joined: 01 Mar 2010
Posts: 21
Location: India

PostPosted: Thu Dec 02, 2010 5:22 pm
Reply with quote

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
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Thu Dec 02, 2010 5:35 pm
Reply with quote

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
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Thu Dec 02, 2010 10:28 pm
Reply with quote

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:

Code:

   INREC IFTHEN=(...


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
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Thu Dec 02, 2010 11:29 pm
Reply with quote

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
View user's profile Send private message
D Rishi

New User


Joined: 01 Mar 2010
Posts: 21
Location: India

PostPosted: Fri Dec 03, 2010 3:13 pm
Reply with quote

Its great!! Thanks Kolusu.. The code is working fine..

Also thanks to frank, expat & arun for paying time for this.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts INCLUDE OMIT COND for Multiple values... DFSORT/ICETOOL 5
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
This topic is locked: you cannot edit posts or make replies. Automation need help in sorting the data DFSORT/ICETOOL 38
No new posts Join 2 files according to one key field. JCL & VSAM 3
No new posts How to move the first field of each r... DFSORT/ICETOOL 5
Search our Forums:

Back to Top