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 

Construct a new file with selected first line column value

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


Joined: 08 Dec 2005
Posts: 17
Topics: 6
Location: India

PostPosted: Tue Jul 14, 2009 6:23 am    Post subject: Construct a new file with selected first line column value Reply with quote

Hi All,

I have searched many topics to find out any examples related to my requirement, but do not find any. Please help me on this. Thanks in advance.

Requirement ...
If my second record is "90000000000000000000000000" (Pls check my input file, line # 2) then create a single line output file - output file format #1 (conditions are mentioned below), else don't change anything, just copy all the lines to output file (Output file format #2).

P.S.: Only one output file, if the above condition matches then create format #1, else format #2.

Conditions (to create OUTPUT FILE FORMAT #1)...
1) First field - cycle date (extract it from line one, last column of i/p file. Field starts @ 18, length is 8 ).
2) Following that fill up with no '9'

Code:

INPUT FILE: (LRECL=25)

101 XXXXXXXXXXXX 06212009
90000000000000000000000000
99999999999999999999999999
...
...

OUTPUT FILE FORMAT #1:(LRECL=25)

06212009999999999999999999999999999999999999999999999999

OUTPUT FILE FORMAT #2:(LRECL=25)

101 XXXXXXXXXXXX 06212009
90000000000000000000000000
99999999999999999999999999
...
...

Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Tue Jul 14, 2009 9:50 am    Post subject: Reply with quote

bala,

The following DFSORT JCL will give you the desired results

Code:

//STEP0100 EXEC PGM=SORT     
//SYSOUT   DD SYSOUT=*       
//SORTIN   DD DSN=Your 25 byte input file,
//            DISP=SHR
//SORTOUT  DD SYSOUT=*                                               
//SYSIN    DD *                                                     
  SORT FIELDS=COPY                                                   
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(51:C'NN',SEQNUM,8,ZD)),           
  IFTHEN=(WHEN=GROUP,BEGIN=(53,8,ZD,EQ,1),PUSH=(26:1,25,51,1),       
  RECORDS=2),                                                       
  IFTHEN=(WHEN=(53,8,ZD,EQ,2,AND,1,1,ZD,EQ,9,AND,2,24,ZD,EQ,0),     
  OVERLAY=(51:C'YY'))                                               
  OUTREC IFTHEN=(WHEN=GROUP,BEGIN=(51,1,CH,EQ,C'Y'),PUSH=(52:52,1)) 
  OUTFIL IFOUTLEN=25,                                               
  INCLUDE=(53,8,ZD,GT,1,AND,51,2,SS,EQ,C'YY,NN'),                   
  IFTHEN=(WHEN=(51,2,CH,EQ,C'YY',AND,53,8,ZD,EQ,2),                 
  BUILD=(43,8,17C'9')),                                             
  IFTHEN=(WHEN=(51,2,CH,EQ,C'NN',AND,53,8,ZD,EQ,2),                 
  BUILD=(26,25,/,C'9',24C'0'))                       
/*

_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
bala
Beginner


Joined: 08 Dec 2005
Posts: 17
Topics: 6
Location: India

PostPosted: Wed Jul 15, 2009 2:23 am    Post subject: Reply with quote

It shows your excellence. Thanks a lot Kolusu.
Back to top
View user's profile Send private message
bala
Beginner


Joined: 08 Dec 2005
Posts: 17
Topics: 6
Location: India

PostPosted: Mon Jul 20, 2009 9:52 am    Post subject: Reply with quote

Kolusu,
Sorry to ask question again in the same topic. Small change in the requirement. Constantly I will not get the following value as my second record (previously it was not the case, this is the only change right now).

Code:
90000000000000000000000000  <<== 1,1,ZD,EQ,9,AND,2,24,ZD,EQ,0

Current logic push the value "Y" once it finds the char "Y" @ 51st column. So that all "NN" rows (next to "YY") will become as "NY". The include cond will omit these "NY" rows. In this case, I will have only "YY" selected row. You gave this based on my requirement.

Suppose, my input file has the cond value "90000000000000000000000000" at line 5 (it may vary), then I don't know how to omit first 4 lines/What logic to use it here ? I tried out many ways, but not able to traverse back and set any values (here, first 4 lines). Kindly help me on this. Thanks.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Mon Jul 20, 2009 10:30 am    Post subject: Reply with quote

bala,

The job can be modified but the question is do you want to retain the header records? Lets say you found the record "90000000000000000000000000" at line 200 what do you want to do with the first 199 lines? Do you need them?
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
bala
Beginner


Joined: 08 Dec 2005
Posts: 17
Topics: 6
Location: India

PostPosted: Tue Jul 21, 2009 3:56 am    Post subject: Reply with quote

Thanks for your response.

Quote:
Lets say you found the record "90000000000000000000000000" at line 200 what do you want to do with the first 199 lines? Do you need them?


Say for example, my input file has 300 lines, and 200th line has "90000000000000000000000000" then I want 1 line output file ("90000000000000000000000000" should be replaced by cycle date & 9s - please refer my OUTPUT FILE FORMAT #1 & it's conditions). So, in our case, the first 199 and last 100 records should be ignored. Else (if there is no "90000000000000000000000000" record in my input file,) print all 300 records into output file (i.e. both input and output files should have same content).
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Tue Jul 21, 2009 11:17 am    Post subject: Reply with quote

bala,

Use the following Control cards. I still assumed that your first record in your input file has the DATE which you need in pos 18. This job looks for the record with "90000000000000000000000000" and if found will only write the record modifying it or else it will copy the input as is

Code:

//SYSIN    DD *                                                   
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(26:SEQNUM,8,ZD,8X,C'1NN')),   
  IFTHEN=(WHEN=GROUP,BEGIN=(26,8,ZD,EQ,1),PUSH=(34:18,8)),       
  IFTHEN=(WHEN=(1,1,ZD,EQ,9,AND,2,24,ZD,EQ,0),OVERLAY=(42:C'0YY'))
  SORT FIELDS=(42,1,CH,A),EQUALS         
                               
  OUTREC IFTHEN=(WHEN=INIT,OVERLAY=(26:SEQNUM,8,ZD)),             
  IFTHEN=(WHEN=GROUP,BEGIN=(26,8,ZD,EQ,1,AND,42,1,ZD,EQ,0),       
  PUSH=(44:43,1))                                                 

  OUTFIL IFOUTLEN=25,INCLUDE=(43,2,SS,EQ,C'YY,NN'),               
  IFTHEN=(WHEN=(43,2,CH,EQ,C'YY'),BUILD=(34,8,17C'9'))           
/*

_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
bala
Beginner


Joined: 08 Dec 2005
Posts: 17
Topics: 6
Location: India

PostPosted: Wed Jul 22, 2009 11:07 pm    Post subject: Reply with quote

It works well. Thanks a lot Kolusu.
Back to top
View user's profile Send private message
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