IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

help needed in writing header for records


IBM Mainframe Forums -> CLIST & REXX
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
tilak_arani

New User


Joined: 07 Sep 2006
Posts: 6
Location: chennai

PostPosted: Thu Jan 07, 2010 4:34 pm
Reply with quote

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
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Thu Jan 07, 2010 5:08 pm
Reply with quote

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
View user's profile Send private message
tilak_arani

New User


Joined: 07 Sep 2006
Posts: 6
Location: chennai

PostPosted: Thu Jan 07, 2010 5:56 pm
Reply with quote

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
View user's profile Send private message
superk

Global Moderator


Joined: 26 Apr 2004
Posts: 4652
Location: Raleigh, NC, USA

PostPosted: Thu Jan 07, 2010 7:05 pm
Reply with quote

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
View user's profile Send private message
tilak_arani

New User


Joined: 07 Sep 2006
Posts: 6
Location: chennai

PostPosted: Thu Jan 07, 2010 7:22 pm
Reply with quote

thank you SuperK.... icon_smile.gif
Back to top
View user's profile Send private message
superk

Global Moderator


Joined: 26 Apr 2004
Posts: 4652
Location: Raleigh, NC, USA

PostPosted: Thu Jan 07, 2010 7:28 pm
Reply with quote

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
View user's profile Send private message
Pedro

Global Moderator


Joined: 01 Sep 2006
Posts: 2547
Location: Silicon Valley

PostPosted: Thu Jan 07, 2010 10:14 pm
Reply with quote

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
View user's profile Send private message
tilak_arani

New User


Joined: 07 Sep 2006
Posts: 6
Location: chennai

PostPosted: Fri Jan 08, 2010 6:51 pm
Reply with quote

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
View user's profile Send private message
superk

Global Moderator


Joined: 26 Apr 2004
Posts: 4652
Location: Raleigh, NC, USA

PostPosted: Fri Jan 08, 2010 7:42 pm
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> CLIST & REXX

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 2
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Pulling a fixed number of records fro... DB2 2
No new posts Two input files & writing counter... DFSORT/ICETOOL 12
Search our Forums:

Back to Top