Previous Topic: Closedown ProgramNext Topic: Error Routine


CHGOBJ to Alter Key Values

If you have a model originally implemented in RPG that you want to generate in COBOL, review use of the Change Object (CHGOBJ) function type, described here, and proceed to the steps for converting from RPG to COBOL in this chapter.

A CHGOBJ function implemented in RPG can include code to update key values. However, an equivalent COBOL implementation cannot, since the COBOL REWRITE statement does not allow key value changes.

If you need to change the value of one or more keys using a COBOL program, do not use a CHGOBJ function. Instead, when you define the function that specifies the COBOL function, use separate Delete Object (DLTOBJ) and Create Object (CRTOBJ) functions.

If necessary, you can use an Execute Internal Function (EXTINTFUN) function to provide a dummy CHGOBJ function.

For example, a function that changes the value of a key field in the database has different implementations:

For more information on how to change key values using a COBOL program, see Building Applications.