Context-Sensitive Problems

In RPG III, there are occasions when it is impossible to determine the type of specifications in a /COPY member without the context of the surrounding specifications of the primary source member. There are two instances of this problem:
  • In data structure subfields or program-described file fields
    Figure 1. RPG III /COPY file with input fields only
         I* If the RPG III source member contains only the source
         I* statements describing fields FIELD1 and FIELD2 below, the
         I* Conversion Aid is unsure how to convert them.  These
         I* statements may be data structure fields (which are converted
         I* to definition specifications) or program-described file
         I* fields (which are converted to input specifications).
         I                                        1   3 FIELD1
         I                                        4   6 FIELD2
  • In renaming an externally described data structure field or an externally described file field
    Figure 2. RPG III Source with a renamed field
         I* If the RPG III source member contains only the source
         I* statement describing field CHAR below, the Conversion
         I* Aid is unsure how to convert it.  This statement may be
         I* a rename of an externally described data structure field
         I* which is converted to a definition specification) or
         I* a rename of an externally described file field)
         I* (which is converted to an input specification).
         I              CHARACTER                       CHAR

In the above two instances, a data structure is assumed and definition specifications are produced. A block of comments containing the input specification code is also produced. For example, the Conversion Aid will convert the source in Figure 1 to the code shown in Figure 3. If Input specification code is required, delete the definition specifications and blank out the asterisks from the corresponding Input specifications.

Figure 3. RPG IV source after converting source with input fields only
     D* If the RPG III source member contains only the source
     D* statements describing fields FIELD1 and FIELD2 below, the
     D* Conversion Aid is unsure how to convert them.  These
     D* statements may be data structure fields (which are converted
     D* to definition specifications) or program-described file
     D* fields (which are converted to input specifications).
     D FIELD1                  1      3
     D FIELD2                  4      6
     I*                                 1    3  FIELD1
     I*                                 4    6  FIELD2

Remember that you have two ways of correcting these types of problems. Either use the EXPCPY(*YES) option of the CVTRPGSRC command, or manually correct the code after conversion.