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
LVL 17
MurpheyApplication ConsultantAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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?
MurpheyApplication ConsultantAuthor 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.
Gary PattersonVP 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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Why Diversity in Tech Matters

Kesha Williams, certified professional and software developer, explores the imbalance of diversity in the world of technology -- especially when it comes to hiring women. She showcases ways she's making a difference through the Colors of STEM program.

tliottaCommented:
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.
MurpheyApplication ConsultantAuthor 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,
tliottaCommented:
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.
MurpheyApplication ConsultantAuthor Commented:
Yes Tom,

What I tried to say, is that a SELECT-block will not work in this case.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
IBM System i

From novice to tech pro — start learning today.