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 

reading a file

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


Joined: 31 Jan 2007
Posts: 20
Topics: 6

PostPosted: Thu Sep 06, 2007 2:38 pm    Post subject: reading a file Reply with quote

I have the below requirement.

input file
Line 1 - !PROGRAM !COBOL PROGRAMES,
Line 2 - JCL, VSAM !REXX

output file
line 1 - !PROGRAM
line 2 - !COBOL PROGRAMES, JCL, VSAM
line 3 - !REXX

how do i achieve the output. Please advise.
Back to top
View user's profile Send private message
CICS Guy
Intermediate


Joined: 30 Apr 2007
Posts: 292
Topics: 3

PostPosted: Thu Sep 06, 2007 2:50 pm    Post subject: Reply with quote

Simple, just read all the records and save the data, then write it out how-ever you need.....
Back to top
View user's profile Send private message
anaik
Beginner


Joined: 31 Jan 2007
Posts: 20
Topics: 6

PostPosted: Thu Sep 06, 2007 2:53 pm    Post subject: Reply with quote

do you mean i should save it in memory..
it is a big file
Back to top
View user's profile Send private message
CICS Guy
Intermediate


Joined: 30 Apr 2007
Posts: 292
Topics: 3

PostPosted: Thu Sep 06, 2007 3:31 pm    Post subject: Reply with quote

Well, maybe a better defination of your requirements is in order....Line 1 & line 2 translated to line 1, line 2 & line 3 does not seem to qualify as "a big file"... Confused
Back to top
View user's profile Send private message
anaik
Beginner


Joined: 31 Jan 2007
Posts: 20
Topics: 6

PostPosted: Thu Sep 06, 2007 3:33 pm    Post subject: Reply with quote

i am giving an example of my requirement.
Back to top
View user's profile Send private message
CICS Guy
Intermediate


Joined: 30 Apr 2007
Posts: 292
Topics: 3

PostPosted: Thu Sep 06, 2007 4:03 pm    Post subject: Reply with quote

anaik wrote:
i am giving an example of my requirement.
OK...
Back to top
View user's profile Send private message
Bill Dennis
Advanced


Joined: 03 Dec 2002
Posts: 579
Topics: 1
Location: Iowa, USA

PostPosted: Thu Sep 06, 2007 4:23 pm    Post subject: Reply with quote

What language or Utility?
What ideas to you have already?
We could help you choose the best one!
_________________
Regards,
Bill Dennis

Disclaimer: My comments on this foorum are my own and do not represent the opinions or suggestions of any other person or business entity.
Back to top
View user's profile Send private message
vkphani
Intermediate


Joined: 05 Sep 2003
Posts: 483
Topics: 48

PostPosted: Fri Sep 07, 2007 12:36 am    Post subject: Reply with quote

anaik,

I guess you want to copy the record till ! mark and copy the rest of the data to the next record. Using seqnum you can achieve the desired output.
Check the below link for some examples.
http://www.mvsforums.com/helpboards/viewtopic.php?t=7838&highlight=seqnum
Back to top
View user's profile Send private message Send e-mail
blitz2
Beginner


Joined: 23 Jan 2007
Posts: 84
Topics: 14

PostPosted: Fri Sep 07, 2007 1:28 am    Post subject: Reply with quote

anaik,

Can you please post the details of the input file? .. like VB or FB? record length? flat file? Approximately how many records are we looking at?
________
Medical Marijuana Strains


Last edited by blitz2 on Thu Mar 10, 2011 5:35 pm; edited 1 time in total
Back to top
View user's profile Send private message
jsharon1248
Intermediate


Joined: 08 Aug 2007
Posts: 291
Topics: 2
Location: Chicago

PostPosted: Fri Sep 07, 2007 9:17 am    Post subject: Reply with quote

Not knowing what language you wanted, I looked at this in COBOL. You could try UNSTRING but you'd have to use the POINTER option and UNSTRING moves the delimiter to a separate field from the receiving fields, so you'd get stuck putting the pieces back together in the output record. I think this is easiest just looping through the input record moving it character by character into the output record until you hit your delimiter. Here's some untested code that should get you close to what you're looking for. Perform the 100-GEN-OUT-REC paragraph for every record on the input file.

Code:

01  IN-REC.                                       
  03  IN-REC-CHAR    OCCURS 100 TIMES             
                     INDEXED BY INREC-NDX         
                     PIC X(01).                   
01  OUT-REC.                                       
  03  OUT-REC-CHAR   OCCURS 100 TIMES             
                     INDEXED BY OUTREC-NDX         
                     PIC X(01).                   
01  WS-VARS.                                       
  03  WS-DELIMITER  PIC X(01) VALUE '!'.           
  03  WS-REC-LEN    PIC S9(04) COMP-3 VALUE +100. 


100-GEN-OUT-REC.                                                   
 ***                                                           
 ***  > INREC-NDX KEEPS TRACK OF THE POSITION IN THE INPUT     
 ***    RECORD                                                 
 ***  > OUTREC-NDX KEEPS TRACK OF NEXT AVAILABLE POSITION IN   
 ***    OUTPUT RECORD                                         
 ***                                                           
                                                             
 ***  INITIALIZE POINTERS AND MOVE FIRST DELIMITER TO OUT-REC 
      MOVE SPACES TO OUT-REC                                   
      SET INREC-NDX  TO +1                                     
      SET OUTREC-NDX TO +1                                     
      MORE IN-REC-CHAR(INREC-NDX) TO OUT-REC-CHAR(OUTREC-NDX)   
                                                             
 ***  POSITION OUT-REC INDEX TO NEXT AVAILABLE POSITION       
      SET OUTREC-NDX TO +2         
                           
 ***  LOOP THROUGH EACH CHARACTER SEARCHING FOR  DELIMITER         
      PERFORM VARYING INREC-NDX                                   
                 FROM +2 BY +1                                     
                UNTIL INREC-NDX > WS-REC-LEN                       
                                                                 
 ***  WHEN YOU FIND A DELIMITER, WRITE THE OUTPUT RECORD;  THEN     
 ***  SET THE OUT-REC INDEX BACK TO 1 AND INITIALIZE OUT-REC       
        IF IN-REC-CHAR(INREC-NDX) = WS-DELIMITER                   
          WRITE OUT-FILE FROM OUT-REC                             
          SET OUTREC-NDX TO +1                                     
          MOVE SPACES TO OUT-REC                                   
        END-IF                                                     
                                                                 
 ***  MOVE THE IN-REC CHARACTER TO THE OUPUT RECORD  AND           
 ***  INCREMENT THE OUT-REC INDEX                                 
        MOVE IN-REC-CHAR(INREC-NDX) TO OUT-REC-CHAR(OUTREC-NDX)   
        SET OUTREC-NDX UP BY +1                                   
                                                                 
     END-PERFORM                                                 
     WRITE OUT-FILE FROM OUT-REC 
    .
100-EXIT. EXIT.

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: Fri Sep 07, 2007 9:49 am    Post subject: Reply with quote

jsharon1248,

I guess you overlooked that the input starts with a delimiter

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


Joined: 08 Aug 2007
Posts: 291
Topics: 2
Location: Chicago

PostPosted: Fri Sep 07, 2007 10:05 am    Post subject: Reply with quote

Actually, I assumed a delimiter as the first position of every input record and handled that with the MOVE (which I typed as 'MORE') prior to the PERFORM.


Quote:

Code:

***  INITIALIZE POINTERS AND MOVE FIRST DELIMITER TO OUT-REC 
      MOVE SPACES TO OUT-REC                                   
      SET INREC-NDX  TO +1                                     
      SET OUTREC-NDX TO +1                                     
      MORE IN-REC-CHAR(INREC-NDX) TO OUT-REC-CHAR(OUTREC-NDX)   

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 -> Application Programming 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