Menu

JRecord and Mainframe Assembler DSECTs

Greg Senia
2017-04-05
2017-04-16
  • Greg Senia

    Greg Senia - 2017-04-05

    Bruce,
    Not sure if this is an option but is it possible to use something like JRecord to convert PDS that are stored as Assembler DSECTs vs Cobol Copybooks?

     
  • Bruce Martin

    Bruce Martin - 2017-04-06

    There is nothing builtin for handling DSECT's. Options

    • If only one or two; manually coding The file definitions; this should be easy enough
    • Use a scripting language (rexx / Python to convert the DSEC to an Xml copybook / description.
    • JRecord does support writing your own parser. So in theory a DSECT parser is possible

    The Scripting option might be the easiest.

     
  • Bruce Martin

    Bruce Martin - 2017-04-06

    You can define records in java like:

             AbstractLineReader reader = JRecordInterface1.FIXED_WIDTH.newIOBuilder()
                                     .defineFieldsByLength()
                                         .addFieldByLength("Sku"  , Type.ftChar,   8, 017                                         .addFieldByLength("Store", Type.ftNumRightJustified, 3, 0)
                                         .addFieldByLength("Date" , Type.ftNumRightstified, 6, 0)
                                         .addFieldByLength("Dept" , Type.ftNumRightJustified, 3, 0)
                                         .addFieldByLength("Qty"  , Type.ftNumRightJustified, 2, 0)
                                         .addFieldByLength("Price", Type.ftNumRightJustified, 6, 2)
                                     .endOfRecord()
                                     .newReader(this.getClass().getResource("DTAR020_tst1.bin.txt").getFile());
             AbstractLine saleRecord;
    
             while ((saleRecord = reader.read()) != null) {
                 System.out.println(
                                  saleRecord.getFieldValue("Sku").asString()
                         + "\t" + saleRecord.getFieldValue("Store").asString()
                         + "\t" + saleRecord.getFieldValue("Date").asString()
                         + "\t" + saleRecord.getFieldValue("Dept").asString()
                         + "\t" + saleRecord.getFieldValue("Qty").asString()
                         + "\t" + saleRecord.getFieldValue("Price").asString());
    
             }
             reader.close();
    
     
  • Bruce Martin

    Bruce Martin - 2017-04-06

    You can define a Record in xml. You could try converting your DSECT to Xml using Rexx / Python etc:

    <RECORD RECORDNAME="DTAR020" COPYBOOK="DTAR020" DELIMITER="&lt;Tab&gt;" 
             FONTNAME="CP037" FILESTRUCTURE="Default" STYLE="0" RECORDTYPE="RecordLayout"
             LIST="Y" QUOTE="" RecSep="default">
             <FIELDS>
                     <FIELD NAME="KEYCODE-NO" POSITION="1"  LENGTH="8" TYPE="Char" />
                     <FIELD NAME="STORE-NO"   POSITION="9"  LENGTH="2" TYPE="Mainframe Packed Decimal (comp-3)" />
                     <FIELD NAME="DATE"       POSITION="11" LENGTH="4" TYPE="Mainframe Packed Decimal (comp-3)" />
                     <FIELD NAME="DEPT-NO"    POSITION="15" LENGTH="2" TYPE="Mainframe Packed Decimal (comp-3)" />
                     <FIELD NAME="QTY-SOLD"   POSITION="17" LENGTH="5" TYPE="Mainframe Packed Decimal (comp-3)" />
                     <FIELD NAME="SALE-PRICE" POSITION="22" LENGTH="6" DECIMAL="2" TYPE="Mainframe Packed Decimal (comp-3)" />
             </FIELDS>
    </RECORD>
    
     
  • Greg Senia

    Greg Senia - 2017-04-13

    This was very insightful. I think what we have to do now is attempt to convert these Variable Block DSECTs into cobol copyrecords. An example of one:

             MACRO                                                          00000100
             INFO                                                           00000200
    INFO     DSECT                                                          00000300
    *********************************************************************** 00000400
    *                                                                     * 00000500
    * FUNCTIONAL AREA         :                                           * 00000600
    * MODULES AFFECTING MACRO :                                           * 00000700
    * TRANSACTION ENGINE      :  YES                                      * 00000800
    * TE DISPLAY NAME         :  INFO                                     * 00000900
    * DISBURSEMENT CODES      :  GC                                       * 00001000
    * TRANSACTION CODES       :  GC                                       * 00001100
    *                                                                     * 00001200
    *********************************************************************** 00001300
    RCLG     DS    XL4      # RECORD LENGTH                                 00001400
    PLNO     DS    PL5      # POLICY NUMBER                                 00001500
    SCDT     DS    XL28     # SCHEDULE DATE                                 00001600
    EFFECTCG DS    PL4      # EFFECTIVE DATE OF LAST TRANSACTION CHANGE     00001700
    TRANSDT  DS    PL4      # CYCLE DATE - TRANSACTION CHANGE DATE          00001800
    FIRST    DS    CL66     # 1ST                                         00001900
    SECND    DS    CL66     # SECOND                                   00002000
    THIRD    DS    CL68     # 3RD                                           00002100
    OWNRD    DS    CL31     # OWNER                                   00002200
             MEND                                                           00002300
    

    Bruce let me know your thoughts. I guess my question would be what would be used to determine record type like in cobol?

     
  • Greg Senia

    Greg Senia - 2017-04-14

    Also Bruce does this give the entire length of the line including the RDW or does it ignore the RDW piece?
    Integer copyRecLength = copyRecord.getData().length;

    byte[] net.sf.JRecord.Details.AbstractLine.getData().length

    get The dat in the line as an Array of Bytes

    Returns:
    Returns the record.

     
  • Bruce Martin

    Bruce Martin - 2017-04-16

    With JRecord you do not specify a Record-Length Field. When definiing the RecordLayout you set the FileStructure / FileOrganisation IO_VB.

    int copyRecLength = copyRecord.getData().length;

    will give the length with-out the record-length field.

     

Log in to post a comment.