View previous topic :: View next topic
|
Author |
Message |
tilak_arani
New User
Joined: 07 Sep 2006 Posts: 6 Location: chennai
|
|
|
|
Hi,
I am reading each record and writing to file by using DO.. END loop. Records are written in output record succesfully. next thing is concerned about ADDING HEADER to the written records. How can i do that in the program
Thank you |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8797 Location: Welsh Wales
|
|
|
|
Please explain exactly what you want to do.
You read the records, and by definition, a header record should be the first redord in the file.
Is it a standard header or does its contents depend on the file data.
Unless you start to give some detail about what you want / need to do, you will not receive any great help if any at all. |
|
Back to top |
|
|
tilak_arani
New User
Joined: 07 Sep 2006 Posts: 6 Location: chennai
|
|
|
|
i just need a standard header expat...
tried giving push but didnt worked out
the code :
Code: |
/*********REXX*********/
"EXECIO * DISKR INDD (STEM INPUT. FINIS"
SAY 'INDD FILE IS OPEN....'
PUSH 'EMPNO DEPTNO NAME'
"EXECIO 1 DISKW OUTDD "
COUNT = 1
DO WHILE COUNT <= INPUT.0
LINE1 = INPUT.COUNT
PARSE VAR LINE1 1 EMPNO 7 7 DEPTNO 10 10 NAME
OUTLINE.COUNT = EMPNO DEPTNO NAME
"EXECIO * DISKW OUTDD (STEM OUTLINE. FINIS"
IF RC = 0 THEN
SAY 'ALL RECS ARE WRITTEN IN PS'
ELSE SAY 'NOT COMPLETED...'
COUNT = COUNT + 1
END
EXIT
|
|
|
Back to top |
|
|
superk
Global Moderator
Joined: 26 Apr 2004 Posts: 4652 Location: Raleigh, NC, USA
|
|
|
|
Don't do this, since you are essentially overwriting your previous write:
"EXECIO * DISKW OUTDD (STEM OUTLINE. FINIS"
Queue the output records instead:
Code: |
/*********REXX*********/
...
"EXECIO * DISKR INDD (STEM INPUT. FINIS"
SAY 'INDD FILE IS OPEN....'
QUEUE 'EMPNO DEPTNO NAME'
DO COUNT = 1 TO INPUT.0
PARSE VAR INPUT.COUNT 1 EMPNO 7 7 DEPTNO 10 10 NAME
QUEUE EMPNO DEPTNO NAME
END
"EXECIO "QUEUED()" DISKW OUTDD (FINIS"
EXIT
|
If you really MUST use the stem variables, i.e.:
"EXECIO * DISKW OUTDD (STEM OUTLINE. FINIS"
then you should've made the first stem OUTLINE.1 your header:
Code: |
/*********REXX*********/
"EXECIO * DISKR INDD (STEM INPUT. FINIS"
SAY 'INDD FILE IS OPEN....'
OUTLINE.1 = 'EMPNO DEPTNO NAME'
COUNT = 1
DO WHILE COUNT <= INPUT.0
LINE1 = INPUT.COUNT
PARSE VAR LINE1 1 EMPNO 7 7 DEPTNO 10 10 NAME
INDEX = COUNT + 1
OUTLINE.INDEX = EMPNO DEPTNO NAME
COUNT = COUNT + 1
END
"EXECIO * DISKW OUTDD (STEM OUTLINE. FINIS"
IF RC = 0 THEN
SAY 'ALL RECS ARE WRITTEN IN PS'
ELSE SAY 'NOT COMPLETED...'
EXIT
|
|
|
Back to top |
|
|
tilak_arani
New User
Joined: 07 Sep 2006 Posts: 6 Location: chennai
|
|
|
|
thank you SuperK.... |
|
Back to top |
|
|
superk
Global Moderator
Joined: 26 Apr 2004 Posts: 4652 Location: Raleigh, NC, USA
|
|
|
|
Also ...
Code: |
DO WHILE COUNT <= INPUT.0
LINE1 = INPUT.COUNT
PARSE VAR LINE1 1 EMPNO 7 7 DEPTNO 10 10 NAME
OUTLINE.COUNT = EMPNO DEPTNO NAME
"EXECIO * DISKW OUTDD (STEM OUTLINE. FINIS" <===
IF RC = 0 THEN
SAY 'ALL RECS ARE WRITTEN IN PS'
ELSE SAY 'NOT COMPLETED...'
COUNT = COUNT + 1
END
|
why did you want to completely write every stem variable (OUTLINE.) each time you made an iteration through the loop? |
|
Back to top |
|
|
Pedro
Global Moderator
Joined: 01 Sep 2006 Posts: 2547 Location: Silicon Valley
|
|
|
|
Quote: |
next thing is concerned about ADDING HEADER to the written records. How can i do that in the program |
Not sure if your question was answered. In any case, it was not stated clearly enough so I know what you are asking. |
|
Back to top |
|
|
tilak_arani
New User
Joined: 07 Sep 2006 Posts: 6 Location: chennai
|
|
|
|
superk,
actually i was just started working on rexx. so i iterated as we do in cobol.
your reply with code is very clear. thank you very much
Pedro,
thanks for the concern |
|
Back to top |
|
|
superk
Global Moderator
Joined: 26 Apr 2004 Posts: 4652 Location: Raleigh, NC, USA
|
|
|
|
This is a tip. I don't know how REXX is being taught, but I think that beginners needs to stay away from the stem variables until they have a better grasp of how to properly use the data stacks. I realize that what you did is just an exercise, since there are obviously better ways to accomplish what you wanted. However, honestly, I'd write my own code like this, especially if I don't know the amount of the potential input data:
Code: |
/* REXX */
FIRST = 1
DO FOREVER
"EXECIO 1 DISKR INDD"
IF RC <> 0 THEN LEAVE
PARSE PULL RECORD
IF FIRST THEN
DO
PUSH 'EMPNO DEPTNO NAME'
"EXECIO 1 DISKW OUTDD"
FIRST = 0
END
PARSE VAR RECORD 1 EMPNO 7 DEPTNO 10 NAME
PUSH EMPNO DEPTNO NAME
"EXECIO 1 DISKW OUTDD"
END
"EXECIO 0 DISKR INDD (FINIS"
"EXECIO 0 DISKW OUTDD (FINIS"
EXIT 0
|
|
|
Back to top |
|
|
|