lili -
lili -

Reputation: 11

REXX - length of output files in PDS

Can you, please help me with an idea: I am writing a REXX program in TSO that reads all the files in PDS1 and let's say writes line by line all the files into PDS2. My problem is:

  1. I read a file1 of 1500 lines ; I write a file1 of 1500 lines in PDS2
  2. I read a file2 of 200 lines ; I write a file2 of 1500 lines in PDS2 . The extra lines are from the file1 !
  3. I read a file3 of 2500 lines ; I write a file3 of 2500 lines in PDS2

I'm not able to see where my problem is. The code is as follows:

ADDRESS TSO "ALLOC DA("newDS") FI(infile4) SHR"
ADDRESS TSO "ALLOC DA("newDSO") FI(outfile)"   
................
 S= RES.0                
 DO q = 7 TO S           
    RES.q = STRIP(RES.q) 
  ...........
    ADDRESS TSO "EXECIO * DISKR infile4 (STEM LINE. FINIS" 
    do until i > line.0   
      ADDRESS TSO "EXECIO * DISKR infile4 (STEM LINE. FINIS" 
    ......
      ADDRESS TSO "EXECIO * dISKW outfile (STEM lineo. FINIS"
    ...... 
      i = i + 1 
    end
    ADDRESS TSO "FREE FI(infile4)" 
    ADDRESS TSO "FREE FI(outfile)" 
END

Thanks in advance

Upvotes: 1

Views: 484

Answers (1)

Robert Schreiber
Robert Schreiber

Reputation: 61

Another approach would be to do something like this pseudo-code that does not use stem variables at all. This also has the advantage of not soaking up memory when processing huge files...

do forever
    "execio 1 diskr indd"  /* Read 1 record */
    if (rc <> 0) or some other conditions -- look it up in the book )
    then do while queued()>0 /* Make sure the queue is empty b4 we leave */
            pull .
         end
         leave
    end
    parse pull data_record  /* Mixed-case data */

    new_data_record = somemod(old_data_record)

    queue new_data_record
    "execio 1 diskw outdd" /* write 1 record */
    if (rc<>0) then I have an I/O error writing (full disk?)    
end
"execio 0 diskw outdd (finis"   /* Close the output dataset */

IBM/zOS V2R4 Manuals/ikja300_v2r4.pdf

Upvotes: 1

Related Questions