I make frequent use of the RPG *LIKE DEFN operation, as I enjoy the increased security of defining work fields properly. There is, however, a very subtle consideration with *LIKE that caused me quite a bit of debugging time.
For a recent project, I had defined fields as shown in 3. Note that the field OFFSET is defined as a binary field, length four (which allows up to nine digits). I also wanted field PMOFST to be defined as a binary field, length four. By using *LIKE DEFN as shown in the figure, however, PMOFST is defined as a packed field, length nine.
For a recent project, I had defined fields as shown in Figure 3. Note that the field OFFSET is defined as a binary field, length four (which allows up to nine digits). I also wanted field PMOFST to be defined as a binary field, length four. By using *LIKE DEFN as shown in the figure, however, PMOFST is defined as a packed field, length nine.
In most circumstances, this probably would not cause any problems. But in my usage, I specifically needed a binary field, as I was using it as a parameter to an openness API. Many of the APIs require binary fields as parameters. In my case, the unforeseen conversion to packed is what caused erroneous processing.
Gotcha! Likewise, My Friend
Figure 3 RPG source for *LIKE DEFN
Figure 3: RPG Source for *LIKE DEFN I DS I B 1 40OFFSET C *LIKE DEFN OFFSET PMOFST
LATEST COMMENTS
MC Press Online