Fill Field in Displayfile with variable name

Theo Kouwenhoven
Theo Kouwenhoven used Ask the Experts™
on
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
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Gary PattersonVP Technology / Senior Consultant

Commented:
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 KouwenhovenApplication Consultant

Author

Commented:
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.
VP Technology / Senior Consultant
Commented:
From my perspective, the Select block that you've described is the best, simplest, and most maintainable way to do this, and it just works.

That said, the List Fields QUSLFLD API can provide the input/output buffer position for each field in each record format.  It has a fairly complex structure

https://www-01.ibm.com/support/knowledgecenter/ssw_ibm_i_72/apis/quslfld.htm

In searching for the manual page, I also found this discussion here on EE:

http://www.experts-exchange.com/Programming/System/AS_-_400/Q_22746596.html

- Gary
Angular Fundamentals

Learn the fundamentals of Angular 2, a JavaScript framework for developing dynamic single page applications.

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.
Theo KouwenhovenApplication Consultant

Author

Commented:
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,
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 KouwenhovenApplication Consultant

Author

Commented:
Yes Tom,

What I tried to say, is that a SELECT-block will not work in this case.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial