title: Dataset (Sysout) read error after COBOL program execution
body: <p>In a rexx program, a COBOL program is invoked and it's SYSOUT is 
  captured using a temporary dataset allocation (TSO alloc) and then using an EXECIO read. It works usually without any issues.</p>
  
  <p>One of our users (using a different machine) reported an issue at the 
  EXECIO read.</p>
  
  <pre><code> IRX0562E Abnormal completion of the GET Data Management macro.   
   IRX0565E SG0     ,$LOGON  ,3420,D,SYSOUT  ,GET    ,WRNG.LEN.RECORD,0000003500000 0,QSAM.     
   IEC020I      001-4,SG0,$LOGON,SYSOUT,3420,BWS858,     
   IEC020I      SYS15089.T170858.RA000.SG0.R0278041     
   IEC020I DCB EROPT=ABE OR AN      INVALID CODE, AND/OR NO SYNAD EXIT  SPECIFIED   
   IRX0250E System abend code 001, reason code 00000004.     
   IRX0255E Abend in host command EXECIO or address environment routine MVS.
  </code></pre>
  
  <p>I found that this issue occured specifically when COBOL program has some 
  outputs on SYSOUT.
  I could recreate similar situation in my z/OS system by specifying 'VB' attribute in TSO allocation. In this case, the allocated dataset is not viewable in ISPF. Following error message is shown, when trying to view it in ISPF.</p>
  
  <pre><code>'I/O error occurred reading the edit data'
  </code></pre>
  
  <p>If this corrupted data is allocated using SHARED/OLD mode then the 
  problem is resolved. So this kind of issue occurs with New allocation and during the COBOL program execution.</p>
  
  <p>After the COBOL program execution, further SHR/OLD mode allocation 
  corrected this issue. Any ideas on what exactly went wrong here? </p>
  
  <p>for the test version, I use the catalogued file as follows. The following allocation of SYSOUT, just before the COBOL program execution is as follows.  See that the issue occurs only when I change the record format as 'VB'(which is a re-creation of same error reported by a user in another zos machine).</p>
  
  <pre>
  
       if  (existsDSN(tmpDS)) then do  
           ADDRESS TSO,                        /* Here it works */
           "ALLOC DS('"tmpDS"') F(SYSOUT) SHR REUSE"  
       end  
       else do  
           ADDRESS TSO                        /* ds creation error here */   
           "ALLOC DS('"tmpDS"') F(SYSOUT) NEW DSORG(PS)",  
           "BLKSIZE(121) SPACE(5,15) TRACKS RECFM(F B A) DIR(0)"  
       end
  
  </pre>
  
  <p>please note that the catalogued SYSOUT dataset is not even readable in ISPF browse mode.  </p>
  
  <hr>
  
  <p>Following is the output of COBOL program mentioned by bill, however the first record appears twice(i.e, total 4 message lines) in SYSOUT.</p>
  
  <pre><code> 0000000121
  4FFFFFFFFFF
  00000000121
     '   ` expected message text
  4070007004
  00D0009000
  </code></pre>