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
MurpheyAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
Gary PattersonConnect With a Mentor 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
0
 
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?
0
 
MurpheyAuthor 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.
0
Take Control of Web Hosting For Your Clients

As a web developer or IT admin, successfully managing multiple client accounts can be challenging. In this webinar we will look at the tools provided by Media Temple and Plesk to make managing your clients’ hosting easier.

 
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.
0
 
MurpheyAuthor 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,
0
 
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.
0
 
MurpheyAuthor Commented:
Yes Tom,

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

From novice to tech pro — start learning today.