Avatar of Theo Kouwenhoven
Theo Kouwenhoven
Flag for Netherlands asked on

Fill Field in Displayfile with variable name

Hi Experts,

I have to fill a field in a displayfile, by fieldname
When I put the cursor on a field and press one Function key, I have to store some data from that field.
When I put the cursor on a field and press another Function key, I have to put some data into that field.

After pressing the Fxx key I know the fieldname and screenposition, but I need at least the position in the screenbuffer.


Thanks
IBM System iMainframe Languages

Avatar of undefined
Last Comment
Theo Kouwenhoven

8/22/2022 - Mon
Gary Patterson, CISSP

What programming language are you using?  In RPG, you shouldn't need to worry about the buffer position - the fields in your display file will get declared automatically when you declare the display file in your "F" specs.

Can you provide the DDS source for the display file?
Theo Kouwenhoven

ASKER
Hello Gary,

Yes RPG, I know how to program that, F Specs are not enough to solve this.

What I need is to fill one of 30+ fields with a previously stored value:
I know howto get the fieldname where my cursor is in (from DDS),
But I need to change the contents.
.

I like to change the field by name, by pointer or bij substring the DDS record.
What i Don't want to do is:

Select;
When cursorfield = 'NAME';
NAME = 'hello'
When cursorfield = 'ADDRES'
ADDRES = 'hello'

etc. etc for 36 fields.
ASKER CERTIFIED SOLUTION
Gary Patterson, CISSP

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Member_2_276102

I pretty much agree with Gary. If the fields had unpredictable names, etc., I would have no problem going with offsets and lengths; and a lengthy SELECT-block would be fine.

I've used various file APIs to work with variable fields for cases like journal entries, but those cases don't have externally-described, formatted record structures that are always known at compile time. There aren't always good choices.

Use the structures provided by the compiler whenever possible.
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
Theo Kouwenhoven

ASKER
Hi Gary, Tom,

I know the people that I have to work with, select block will create problems in the futur by extending the screen by ne fields and not testing. I go for the ofsett and length

Thanks,
Member_2_276102

You can certainly create a very nice encapsulated proc that accepts a field name and a value (and a return value or pointer) and that hides all of the work of calculating lengths/offsets. It could be well insulated from nearly all future DSPF changes by adjusting automatically to everything from format changes to field name changes, including adding new fields and dropping old ones.

Just be sure to test extensively.
Theo Kouwenhoven

ASKER
Yes Tom,

What I tried to say, is that a SELECT-block will not work in this case.
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.