Highlighted
Absent Member.
Absent Member.
874 views

[archive] Combo Box Code Question

[Migrated content. Thread originally posted on 17 May 2005]

AcuBench generates this working storage code to hold the contents of a combo box:

01 .
03 SCR-LUSHIPTERM-Cm-1-Container-Item.
05 PIC X(12)
VALUE IS "1 COLLECT".
05 PIC X(12)
VALUE IS "2 PPD & CHG".
05 PIC X(12)
VALUE IS "3 PREPAID".
05 PIC X(12)
VALUE IS "4 WILL CALL".
05 PIC X(12)
VALUE IS "5 COUNTER".
05 PIC X(12)
VALUE IS "6".
05 PIC X(12)
VALUE IS "7".
05 PIC X(12)
VALUE IS "8".
05 PIC X(12)
VALUE IS "9".
78 SCR-LUSHIPTERM-Cm-1-Container-Num VALUE IS 9.
03 SCR-LUSHIPTERM-Cm-1-Container REDEFINES
SCR-LUSHIPTERM-Cm-1-Container-Item PIC X(12)
OCCURS 9 TIMES
INDEXED SCR-LUSHIPTERM-Cm-1-Container-Idx.
77 SCR-LUSHIPTERM-Cm-1-Value PIC X(12).

What is the purpose of the 78 level item? I can see it holds the number of entries in the array but the redefines' occurs handles the number of entries as well. The 78 level item is not referenced anywhere in the generated procedure code. I have deleted the 78 level item without any apparent effect on execution.

Is there some purpose I'm missing? The item's placement in the group hierarchy is also puzzling.

Regards

Vins Nash
0 Likes
3 Replies
Highlighted
Absent Member.
Absent Member.

RE: [archive] Combo Box Code Question

Looks to me like some poorly generated code by acubench. Have you contacted support?
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] Combo Box Code Question

I did ask support. But the reply was that it contains the number of entries in the array which we already know.

Thanks

Vins Nash
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] Combo Box Code Question

What I typically do when I structure things this way is use the constant wherever I need to define the max occurs items, for instance in WS:

78 SCR-LUSHIPTERM-Cm-1-Container-Num VALUE IS 9.
01 .
03 SCR-LUSHIPTERM-Cm-1-Container-Item.
05 PIC X(12)
VALUE IS "1 COLLECT".
05 PIC X(12)
VALUE IS "2 PPD & CHG".
05 PIC X(12)
VALUE IS "3 PREPAID".
05 PIC X(12)
VALUE IS "4 WILL CALL".
05 PIC X(12)
VALUE IS "5 COUNTER".
05 PIC X(12)
VALUE IS "6".
05 PIC X(12)
VALUE IS "7".
05 PIC X(12)
VALUE IS "8".
05 PIC X(12)
VALUE IS "9".
03 SCR-LUSHIPTERM-Cm-1-Container REDEFINES
SCR-LUSHIPTERM-Cm-1-Container-Item PIC X(12)
OCCURS SCR-LUSHIPTERM-Cm-1-Container-Num TIMES
INDEXED BY SCR-LUSHIPTERM-Cm-1-Container-Idx.

And then in my procedure division, when I want to iterate through the SCR-LUSHIPTERM-Cm-1-Container items, I do something like this:
PERFORM VARYING SCR-LUSHIPTERM-Cm-1-Container-Idx
FROM 1 BY 1
UNTIL SCR-LUSHIPTERM-Cm-1-Container-Idx >
SCR-LUSHIPTERM-Cm-1-Container-Num
|do some logic with reference to SCR-LUSHIPTERM-Cm-1-Container(SCR-LUSHIPTERM-Cm-1-Container-Idx)
END-PERFORM.

This way when the max items(occurs) changes later I only have to change it one place in Working storage, and everything remains consistent.
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.