PeopleSoft - Record Field Properties - Value

After being involved in PeopleSoft development for so many years, I got an interesting question from  one of my friend. In PeopleSoft, what is the significance of the "Value" property for a field object. There are some special cases where we use the Value property and some cases where we do not.

Well, this is very basic but needs to be carefully understood. Enterprise PeopleTools Peoplebooks defines this property as the one that contains the current value of the field, converted to an appropriate PeopleCode data type. To really understand the difference between Record.Field and Record.Field.Value, let us do some case study here.

I have a basic page setup, which contains a text field and a submit button.

We are going to play around to understand this record field property of the Field Class. On the Test Button, the following PeopleCode is executed

TEST_REC.FIELD1.Value = "value123";
Error (TEST_REC.FIELD1);

Now, when Test Button is clicked, the value of Test Field is set to 'value123' and the following Error message pops out

---------------------------
Message from webpage
---------------------------
value123

The PeopleCode program executed an Error statement, which has produced this message.
---------------------------
OK   
---------------------------


All as expected. Now, let us change it a little.

TEST_REC.FIELD1 = "value123";
Error (TEST_REC.FIELD1.Value);

Identical outputs. So, what exactly is the difference between Record.Field and Record.Field.Value?

The search record of my component is Installation. INSTALLATION is a PeopleSoft delivered record object. There are some special constraints when using this record in PeopleCode. As an example, when I tried this piece of code

If INSTALLATION.SAT.Value = "N" Then
   Error (INSTALLATION.SAT.Value);
End-If;

But, PeopleSoft recommends not using .value for INSTALLATION or OPTIONS table, as per the rules given in PeopleBooks. Also, if you are referring the record field through a field object, .value is more appropriate.

Local Field &Fl = GetField(TEST_REC.FIELD1);
&Fl.Value = "123";

Anyway,you cannot assign the value '123' directly to the object here. Application designer would not allow such an activity. It would throw the following error

Assignment left hand side of type Field is not compatible with right hand side of type String. (2,47)

Also, if you try to 'Error' the object in the code using "Error (&Fl);" , you get a different run time error.

---------------------------
Message from webpage
---------------------------
Internal error. Unknown type for return value. (180,135)

The PeopleCode program executed an Error statement, which has produced this message.
---------------------------
OK   
---------------------------


Note:

1) If the string contains spaces only, .Value would return an empty string. i.e. Len() would return 0.

2) If the string contains trailing spaces, then value simply ignores it.

3) If the field contains leading spaces, value ignores that as well.

Easter Egg:

When analysing this part, when I tried, Error (Len(TEST_REC.FIELD1.Value));, in PT8.46, PeopleSoft gave weird error messages when the string length is 1, 2 and 3.

Example:

1) Length: 1; Example: a

---------------------------
Message from webpage
---------------------------
1Out of available memory (180,1)

Out of available memory
---------------------------
OK   
---------------------------

Cannot understand, how "Out of Available Memory" came from.

2) Length: 2; Example: ab

---------------------------
Message from webpage
---------------------------
2PeopleCode (180,2)


---------------------------
OK   
---------------------------

From where does this came from? (PeopleCode)

3) Length: 3; example: abc

---------------------------
Message from webpage
---------------------------
3today (180,3)


---------------------------
OK   
---------------------------

From where does this came from? (today)


4 comments:

  1. Hi..

    These errors came from Message Catalogue..

    The error function treat the no as message set number's

    Thanks
    Srinivas
    Srinivasreddy18.blogspot.com

    ReplyDelete
  2. These messages came from message catalog (where Peoplesoft define the error/warning/informative meessage)

    The error fn treat these no's as message no's

    ReplyDelete
  3. Yeah, can guess that these are picked up from the message catalog..but the behavior is strange..

    ReplyDelete