Preserving your changes to the Java XOM when the z/OS data model is updated

You can add code to a generated Java™ XOM and keep the changes when the z/OS® data model (COBOL copybook or PL/I include file) is updated by enclosing that code inside user code tags.

About this task

If you add some user code in a Java XOM that was generated from a z/OS data model, you must update the COBOL XOM or the PL/I XOM and regenerate the Java XOM if the z/OS data model is modified. To preserve the user code that you added in the Java XOM, you can enclose it between specific user code tags in the Java XOM. These tags are created automatically when the Java XOM is generated.
Attention: If the mapping name of a Java class has changed when you update the Java XOM, for example, the Borrower class is renamed to CoBorrower, then the original Java class Borrower is deleted, including your added code.

Procedure

  1. Enclose any classes you added in the generated Java XOM between the tags USER_IMPORT_BEGIN and USER_IMPORT_END. These tags are used to import a user library. For example:
    //@USER_IMPORT_BEGIN
    import java.util.Date;
    //@USER_IMPORT_END
  2. Enclose any methods you added in the generated Java XOM between the tags USER_CODE_BEGIN and USER_CODE_END. For example:
    //@USER_CODE_BEGIN
    public Date parseEffectDate()
    //@USER_CODE_END

Example

The following example is based on a COBOL data model.

In the following Loan class, a new method is added to parse a Date object from a String type attribute "effectDate". This method can then be used to perform the following tasks:

  • Include the required String to Date conversion libraries between user import tags
  • Include a parseEffectDate() method between user code tags to handle the String to Date conversion
package xom;

import ilog.rules.bom.annotations.CustomProperties;
import java.util.List;

//@USER_IMPORT_BEGIN
import java.util.Date;
import java.text.*;
//@USER_IMPORT_END

@CustomProperties(names = {"cobol_type"}, values = {"true"})
public class Loan {

	private long amount;
	private String effectDate;
	private String approved;

	public Loan() {
	}
  ......
  ......
//@USER_CODE_BEGIN
	public Date parseEffectDate() {
      .....  
    	DateFormat format = new SimpleDateFormat("yyyyMMdd");
    	......
      Return format.parse(this.effectDate);
  }
//@USER_CODE_END
}