title: How to FTP a variable length file from linux to mainframe z/OS
body: <p>I could not FTP a variable length file to mainframe; the operation was success, but the dataset generated on mainframe is not correct; can anyone help me.</p>
  
  <p>procedures.</p>
  
  <ol>
  <li><p>I have created a variable length dataset on mainframe.</p>
  
  <pre>
  DSN=.TEST.DATA1
  LRECL=16
  </pre>
  
  <p>Its content have 5 records, each has 12 characters:
  <code>
  000001 11AAAA000001
  000002 11AAAA000002
  000003 11AAAA000003
  000004 11AAAA000004
  000005 11AAAA000005
  </code></p></li>
  <li><p>download the dataset to linux using FTP client on a linux platform
  <code>
  ftp -v -n&lt;
  user  
  prompt
  binary
  quote site rdw
  get TEST.DATA1
  close
  bye
  EOF
  </code></p></li>
  <li>the file was downloaded successfully.</li>
  <li>upload the file back to mainframe
  <code>
  ftp -v -n&lt;
  user  
  prompt
  binary
  quote site rdw recfm=v lrecl=16
  put TEST.DATA1 TEST.DATA2
  close
  bye
  EOF
  </code></li>
  <li><p>the new generated dataset TEST.DATA2 on mainframe is not correct.
   <pre>
   000001     11AAAA00
   000002 0001    11AA
   000003 AA000002<br>
   000004 11AAAA000003
   000005     11AAAA00
   000006 0004    11AA
   000007 AA000005<br>
   </pre></p>
  
  <p>It seems the RDW field was treated as data field, this is not I expected; I wish the TEST.DATA2 has same as TEST.DATA1.</p></li>
  </ol>
  
  <p>Thanks.</p>