A lot of former mainframe people will tell you that it was a pretty rough transition from the good ole' days of COBOL and VMS to the modern paradigm of Object-Oriented C++/Java/.NET development. Some have stuck around, fighting over the handful of jobs maintaining the remaining systems. Others are still in denial, believing that "minicomputers" are just a fad and that we will soon return to the heyday of mainframes.

A few have actually snuck into our world, trying to undermine and transform it into a world of flat files, and fixed-length strings. Be on the look out for these developers. Fortunately, their M.O. is easy to spot: who can miss UPPR_CSE_EVRYTHNG? But the sure-fire way of telling is to look for a single underlying string for all data storage, such as this code from James Watson's JavaBOL-based system:

  public void setCUSTOMER_NBR(String value)
  {
    final int paddingType = P_RIGHT_SPACE_FILL;
    final int offset = 16;
    final int length = 6;

    String s = padString(value, length, paddingType);

    setValue(offset, length, s);
  }

  public String getCUSTOMER_NBR()
  {
    final int paddingType = P_RIGHT_SPACE_FILL;
    final int offset = 16;
    final int length = 6;

    String s = getValue(offset, length);
    return unpadString(s, paddingType);
  }

  private String getRawCUSTOMER_NBR()
  {
    final int offset = 16;
    final int length = 6;

    return getValue(offset, length);
  }

  private String getValue(int offset, int length)
  {
    return data.substring(offset, offset + length);
  }

  //ED: and the technique for repeating records ...

 public int getLINE_NBR(int index1) throws IndexOutOfBoundsException
 {
  final int paddingType = P_LEFT_ZERO_FILL;
  final int offset = 294;
  final int length = 3;
  int[] indexes = new int[1];
  indexes[0] = index1;
  ArrayDimensions[] ad = new ArrayDimensions[1];
  ad[0] = new ArrayDimensions(75, 96);
  String s = getValue(calculateOccursOffset(offset, indexes, ad), length);
  return unpadInt(s, paddingType);
 }

  public static int calculateOccursOffset(int baseOffset, int[] arguments, ArrayDimensions[] ad )
  {
    int calculatedOffset = baseOffset;
    for(int i=0; i<ad.length; i++)
    {
      calculatedOffset += (((ArrayDimensions)ad[i]).occursLength * arguments[i]);
    }
    return calculatedOffset;
  }
[Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!