MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Extract data from flat flie based on condition using SORT

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
koolspark
Beginner


Joined: 27 May 2010
Posts: 29
Topics: 13

PostPosted: Tue Apr 26, 2011 5:54 am    Post subject: Extract data from flat flie based on condition using SORT Reply with quote

I've a file with LRECL=1200, which has client addresses starting from position 326 to 505 (total 180 bytes).
This address is split into 6 fields, each of 30bytes lenth.
address-line-1 from 326 to 355
address-line-2 from 356 to 385
address-line-3 from 386 to 415
address-line-4 from 416 to 445
address-line-5 from 446 to 475
address-line-6 from 476 to 505

But, currently we are storing the address in three contiguous fileds only(90bytes). so, the address can be
address-line-1 thru address-line-3 (position 326 to 415) or
address-line-2 thru address-line-4 (position 356 to 445) or
address-line-3 thru address-line-5 (position 386 to 475) or
address-line-4 thru address-line-6 (position 416 to 505)

I've a 3bytes numberic field in position 323 of this file which tells me from which position the address is starting.
Now, I need to extract the 90 bytes address from this file to another file based on the value in position 323.

If position 323 has 31 then i need to extract the address from address-line-1 thru address-line-3 (position 326 to 415)
If position 323 has 61 then i need to extract the address from address-line-2 thru address-line-4 (position 356 to 445)
If position 323 has 91 then i need to extract the address from address-line-3 thru address-line-5 (position 386 to 475)
If position 323 has 121 then i need to extract the address from address-line-4 thru address-line-6 (position 416 to 505)

Appreciate any help.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12375
Topics: 75
Location: San Jose

PostPosted: Tue Apr 26, 2011 10:26 am    Post subject: Reply with quote

koolspark,


Unless I am missing something isn't it a simple request of using IFTHEN statements to check the contents at position 323 and build the output?

Use the following DFSORT JCL which will give you the desired results. If the contents at pos 323 is 31,61,91 or 121 it will create a 90 byte padded with spaces. ( Last when=none statement)

Code:

//STEP0100 EXEC PGM=SORT                         
//SYSOUT   DD SYSOUT=*                           
//SORTIN   DD DSN=Your Input FB 1200 byte file,DISP=SHR                   
//SORTOUT  DD SYSOUT=*                           
//SYSIN    DD *                                   
  SORT FIELDS=COPY                               
  INREC IFOUTLEN=90,                             
  IFTHEN=(WHEN=(323,3,ZD,EQ,031),BUILD=(326,90)),
  IFTHEN=(WHEN=(323,3,ZD,EQ,061),BUILD=(356,90)),
  IFTHEN=(WHEN=(323,3,ZD,EQ,091),BUILD=(386,90)),
  IFTHEN=(WHEN=(323,3,ZD,EQ,121),BUILD=(416,90)),
  IFTHEN=(WHEN=NONE,BUILD=(90X))                 
//*

_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group