View previous topic :: View next topic |
Author |
Message |
anaik Beginner
Joined: 31 Jan 2007 Posts: 20 Topics: 6
|
Posted: Thu Sep 06, 2007 2:38 pm Post subject: reading a file |
|
|
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 |
|
 |
CICS Guy Intermediate
Joined: 30 Apr 2007 Posts: 292 Topics: 3
|
Posted: Thu Sep 06, 2007 2:50 pm Post subject: |
|
|
Simple, just read all the records and save the data, then write it out how-ever you need..... |
|
Back to top |
|
 |
anaik Beginner
Joined: 31 Jan 2007 Posts: 20 Topics: 6
|
Posted: Thu Sep 06, 2007 2:53 pm Post subject: |
|
|
do you mean i should save it in memory..
it is a big file |
|
Back to top |
|
 |
CICS Guy Intermediate
Joined: 30 Apr 2007 Posts: 292 Topics: 3
|
Posted: Thu Sep 06, 2007 3:31 pm Post subject: |
|
|
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"...  |
|
Back to top |
|
 |
anaik Beginner
Joined: 31 Jan 2007 Posts: 20 Topics: 6
|
Posted: Thu Sep 06, 2007 3:33 pm Post subject: |
|
|
i am giving an example of my requirement. |
|
Back to top |
|
 |
CICS Guy Intermediate
Joined: 30 Apr 2007 Posts: 292 Topics: 3
|
Posted: Thu Sep 06, 2007 4:03 pm Post subject: |
|
|
anaik wrote: | i am giving an example of my requirement. | OK... |
|
Back to top |
|
 |
Bill Dennis Advanced

Joined: 03 Dec 2002 Posts: 579 Topics: 1 Location: Iowa, USA
|
Posted: Thu Sep 06, 2007 4:23 pm Post subject: |
|
|
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 |
|
 |
vkphani Intermediate

Joined: 05 Sep 2003 Posts: 483 Topics: 48
|
|
Back to top |
|
 |
blitz2 Beginner

Joined: 23 Jan 2007 Posts: 84 Topics: 14
|
Posted: Fri Sep 07, 2007 1:28 am Post subject: |
|
|
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 |
|
 |
jsharon1248 Intermediate
Joined: 08 Aug 2007 Posts: 291 Topics: 2 Location: Chicago
|
Posted: Fri Sep 07, 2007 9:17 am Post subject: |
|
|
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 |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
|
Posted: Fri Sep 07, 2007 9:49 am Post subject: |
|
|
jsharon1248,
I guess you overlooked that the input starts with a delimiter
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
 |
jsharon1248 Intermediate
Joined: 08 Aug 2007 Posts: 291 Topics: 2 Location: Chicago
|
Posted: Fri Sep 07, 2007 10:05 am Post subject: |
|
|
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 |
|
 |
|
|