Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Sorting with a field which are present in different position

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: Sorting with a field which are present in different position
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: 2239
Location: @my desk

PostPosted: Thu Dec 02, 2010 4:52 pm    Post subject:
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: 2239
Location: @my desk

PostPosted: Thu Dec 02, 2010 5:04 pm    Post subject:
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    Post subject:
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: 8593
Location: Back in jolly old England

PostPosted: Thu Dec 02, 2010 5:35 pm    Post subject:
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 Moderator


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

PostPosted: Thu Dec 02, 2010 10:28 pm    Post subject:
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    Post subject:
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    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Record Not found in AlX but record re... mukun264 COBOL Programming 7 Fri Mar 24, 2017 9:28 am
No new posts SORT VSAM file with each field one by... maxsubrat DFSORT/ICETOOL 6 Tue Mar 14, 2017 1:07 pm
No new posts IMS DB-How to update a record (a sing... Nic Clouston IMS DB/DC 9 Thu Mar 09, 2017 4:38 pm
No new posts outrec field outside range Danielle.Filteau SYNCSORT 10 Sat Mar 04, 2017 2:37 am
No new posts 2 byte YEAR from Y'DATE2' field tecnokrat DFSORT/ICETOOL 2 Tue Feb 07, 2017 12:05 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us