1

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

wwkudu
  • 2,778
  • 3
  • 28
  • 41
lili -
  • 11
  • 2
  • 1
    What are you trying to do ???. Also I suggest checking your listed code, either you have miss copied it or there are some major errors. You realise that `EXECIO * dISKW outfile (STEM lineo. FINIS` writes the whole stem to the file. I do not understand why you are writing the whole file in the loop. The code will read and then write the file multiple times. – Bruce Martin May 29 '20 at 11:01
  • Hi Bruce, I tried to simplifz the explanation. In fact, I need to read all files in PDS, line by line, and in some cases to make modification and write each modified file in another PDS. – lili - May 29 '20 at 11:52
  • Because I am new in REXX, I was thinking that the ADDRESS TSO "EXECIO * dISKW outfile (STEM lineo. FINIS" is writing in the output file the current line and the ADDRESS TSO "FREE FI(outfile)" closes the current file. Please, If I am wrong , help me to find the command to use to be able to write line by line in the output file and in the end to close the current file. – lili - May 29 '20 at 11:55
  • Resolved! After every input file, I used DROP STEM. I used EXECIO * dISKW outfile (STEM lineo. FINIS only 1 time after each input file. – lili - May 29 '20 at 14:29

1 Answers1

1

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