Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

variables as part of field names

Status
Not open for further replies.

Ju5

Programmer
May 25, 2007
85
0
0
PH
Does anyone know if it is possible to use a variable as part of a field name in RPG?

For example:

z-add 1 to Fn
read file1

dou eof
move field1 to detailFn
read file1
add 1 to Fn
enddo

z-add 1 to Fx
dou Fx > Fn
write detailFx
enddo

o-specs
detail1
detail2
detail3
detail4

Is this possible?

 
To clarify:

I'm working on a report where I need to add a description to an entry. The entry is part of a list located at the middle of the report but the description needs to be grouped and placed at the end of the report. For example:


list
item1
item2
item3
.
.
.
details
.
.
.
descriptions
item1 description
item2 description
.
.
.

The O-specs for this report is stored separately in a PRTF file in QDDSSRC. Descriptions are 5 lines of 80 characters.

My problem is that the number of items that can appear on the list is not fixed so there can be anywhere from 1 to, theoretically, 100. Since the O-spec is fixed I will need to add 500 lines(5 lines * max of 100 items).
 
You probably want to do something like this, if I understand you correctly. You only need to output one line for the description, as it will loop Fn times


z-add 1 to Fn
read file1

dou eof
move field1 to arrdet(Fn)
read file1
add 1 to Fn
enddo

z-add 1 to Fx
dou Fx > Fn
eval printline = arrdet(Fx)
write detailRF
enddo

o-specs (actually your detail format in PRTF)
printline
 
It works!
thanks for the suggestions!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top