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!

Display File Field Error?

Status
Not open for further replies.

loonybin

Programmer
Dec 12, 2002
38
0
0
US
I have a numeric field(18N 0 Dec) which is needed on the selection screen. I am doing a REFFLD, clearly defining it as 18N 0. When I run a debug on my CL and I display the field, it's showing as 10 Char! Could someone please explain this to me. It works if it's only 10N 0.
Does it mean there's length restriction on certain types? If so, is there a way I could handle this a different way?

Thank you in advance.
 
When you say "18N 0", that's not how you've actually defined it is it?

In RPG the 'N' field type is an indicator field type. This is a Boolean definition, to contain '1' or '0' only. You cannot specify a length of 18,0 for this. In DDS you cannot specify an 'N' type.

You say it's a screen field. If you were to edit the screen in SDA, what definition would you see? 18 long or 10 long, alpha or numeric?
 
The field is 18S 0. N for numeric, sorry for the confusion. I could compile the screen and it looks fine when I run the screen driver. But when I enter for ex. 2, it comes back in display as 0000000000OUTQXXX. The CL debug when I display the screen field is saying that it's 10A, not 18S 0 but the DDS defines and displays it as 18S 0.

Please help. I've never encountered this.

Thank you.
 
hi loonybin!

You've mentioned that you've used REFFLD in your screen.Maybe you could try checking the field of the file you've used in your REFFLD if it's really 18S,0

 
Type Length Dec
P 18 0

Yes I've checked it over and over again because it doesn't make sense to me. I tried to give it a length of -8 using the reffld and it works perfectly fine. It's not possible also that I am declaring a different DSPF because this is an enhancement. So my guess there's a restriction that I don't know. Please help.

Thank you.
 
Look at your compile listing for the screen file and make sure you are pulling the correct version of the reference file. Maybe your compile library list is hitting the wrong object for the reference file.


"When once you have tasted flight, you will forever walk the Earth with your eyes turned skyward, for here you have been, and there you will always long to return."

--Leonardo da Vinci

 
Hang on...

I'm not sure I'm 100% with the problem here, but I see you mention that you "tried to give it a length of -8 using the reffld".

So if the field being referenced is 18 and you've overridden that by specifying -8 then you'll end up with a field 10 long.

???
 
Type Length Dec
P 18 0

Yes I've checked it over and over again because it doesn't make sense to me. I tried to give it a length of -8 using the reffld and it works perfectly fine. It's not possible also that I am declaring a different DSPF because this is an enhancement. So my guess there's a restriction that I don't know. Please help.

Thank you.
 
loonybin

The field being referenced is a Packed Decimal (according to what you wrote in a previous post). Then, your doing a REFFLD AND you're defining it as 18 S 0 (zoned decimal). If this is what you're doing, that's the problem. If you're referencing a field, you don't need to define it's length, since that's being done via the REFFLD keyword. Check your DDS for the screen, and if you're defining the length of the field, remove the length and data type and recompile the screen.



RedMage1967
IBM Certifed - RPG IV Progammer
 
Type Length Dec
GWFIELD P 18 0
---------------------------------

A #FIELD R -8 B 6 28REFFLD(GWFIELD)
When I define the field like this, my program runs with no problem -- JUST FOR TESTING.

---------------------------------
A #FIELD R B 6 28REFFLD(GWFIELD)

When I take out the length, compile and run it. It comes back in display as 0000000000OUTQXXX.
The CL debug when I display the screen field is saying that it's 10A, not 18S 0 but the DDS defines and displays it as 18S 0.


 
How are you getting the data from GWFIELD to #FIELD?

RedMage1967
IBM Certifed - RPG IV Progammer
 
This is a display file.
#Field is the selection field.
GWFIELD is coming from REF(FILE).

The file is in my library only because it is new. My library is set to *CURLIB. That should eliminate the possibility that I am referencing a different object.
And like I said, it works the way I wanted it to work when it is defined as -8.

Thanks.
 
You're using a CL to run this screen right?
If you're using #Field to display the contents of GWFIELD, you need to do
Code:
ChgVar  Var(&#Field) Value(&GwField)
If #Field is being used to receive data typed in by the user, initialize the field with zeros
Code:
ChgVar  Var(&#Field) Value(0)
Do one of these before you display the screen. See if that helps. It almost sounds to me like you're getting some junk data in the field.

RedMage1967
IBM Certifed - RPG IV Progammer
 

Select Field ......: _________________

This is the only field that gets displayed when I run the program. Debug says the field is empty but it defines it as 10 Char??? which is the problem.

I put 2, then hit enter.
Debug says the field is
'0000000000'. I need 000000000000000002.

I have no idea why it's defining it as 10 Char.
 
OK. Let me back up.
What language is the program written in? RPG or CL?


RedMage1967
IBM Certifed - RPG IV Progammer
 
The screen driver is written in CL. It's supposed to just get the entry and submit a job.

I just converted it to RPG and it's working fine. I've used both RPG and CL as screen drivers in the past and I've never encountered any problems like this. I thought the screen would work well with either language on the AS400.

Well, I apologise for wasting your time.
Thank you very much.

If anyone knows why the CL is not taking it, please let me know still.

Thanks again REDMAGE1967.
 
loonybin

Sorry for being so dense. I don't do that many screens anymore. If I need a screen or other interactive type of application, I write it in Visual RPG instead.

I'm assuming that you compiled the program. Check to see how the compiler has you're fields defined. (Both the #Field and the GWFIELD). They should be defined the same.

RedMage1967
IBM Certifed - RPG IV Progammer
 
Packed fields are not even an option for screen fields are they? If you prompt on an 'a' spec & then hit f1 on data type P is not a valid type.
 
Data type "P" is valid only for PF's, not DSPF's.
So, what's the compiler doing when the REFFLD is packed?

RedMage1967
IBM Certifed - RPG IV Progammer
 
Oh no don't apologize. Thank you. You gave me an idea to try it in RPG.

The compiler defines #FIELD as 10 Char. I'll post anything that I could find about this.

Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top