Page 1 of 1

Exchange from form to function and back

Posted: Tue Apr 18, 2017 4:01 am
by trossiter
I have a form that calls a function to manipulate some input data. The function does its thing and exchanges back the same fields that were used for input as well as some other fields. This was working before. Since then, I have added a custom error return code field that is exchanged from the function back to the form.

Depending on the outcome of the function processing, my custom field is given a value of either OK, NA, NG, NP or ER. The idea is then my form can use that value to decide what to do next. However, when control returns to my form, my custom field is blank, along with any other fields that I should be expecting some kind of value, as if the exchange command in my function right before returning control to the form is not posting the fields to the exchange list.

I'm wondering if somehow the exchange list is getting full. It shouldn't be since the total number of characters of all the fields I'm exchanging back to my function is only about 330. If it is getting full, is there a way to clear the exchange list without affecting the values of the fields I am exchanging back to my form?

Re: Exchange from form to function and back

Posted: Tue Apr 18, 2017 6:00 am
by trossiter
I've decided to use a work file to temporarily store the values I'm trying to pass back, keyed by username. When the function returns control to the form, I'll just perform a fetch to get the values I need and delete the record in the file.

Re: Exchange from form to function and back

Posted: Tue Apr 18, 2017 6:43 am
by trossiter
After changing the Exchange command at the end of my function to insert a record to my work file, I've come to the conclusion that my function is having some kind of issue performing I/O operations. There is no record in my file when there should be one. When I copy the code from my function and place it in my form, the record in my work file is inserted correctly. I have no idea why using the function will not perform I/O when called, but it's code will work just fine if used in the form.

Re: Exchange from form to function and back

Posted: Tue Apr 18, 2017 8:31 am
by MarkD
The attached import file contains a process (Forum_001), a function (Forum_002) and a form (Forum_003).
The form exchanges fields into the function which exchanges back modified values which are then displayed.
Does it work for you?

Re: Exchange from form to function and back

Posted: Tue Apr 18, 2017 9:44 am
by MarkD
Also - when you say that it used to work .... do you mean that it still works for the original fields, just not for the mew field(s) you have added to is?

Re: Exchange from form to function and back

Posted: Wed Apr 19, 2017 12:50 am
by trossiter
Not quite. The function originally would take some address fields as input and call a SOAP service I created in Integrator to validate and correct the address information. My client wanted a few other fields added to collect additional information from the service, so I created those and mapped them. I then created a field for handling any type of error that could happen, and I set it myself in the function's code. I did this instead of using something like RET_CODE because it was always being set to OK after the function returns. My error code field is being returned as a blank value even though it should be being set to something other than blank.

After I created my work file, I commented out the exchange command and instead insert all the fields I am trying to exchange into my work file (which contains the same fields) right before the return. Immediately after the function call in my form, I fetch the record that should have just been created in the file. I put a break point on that fetch command when debugging, and when I step to the next line, I am checking to see if a record is there in Lansa Client. The file is still empty, so my function is not inserting the fields to the file.

Re: Exchange from form to function and back

Posted: Wed Apr 19, 2017 1:05 am
by billcross
Are there a lot of fields in the function itself ? I have encountered an issue where a function with the total length of all fields is > 10000 that it causes and index error when trying to read the exchange list. All fields are in the exchange list whether exchanged or not and the index is only a 4 digit field.

Re: Exchange from form to function and back

Posted: Wed Apr 19, 2017 7:55 am
by MarkD
The 9999 bytes limit would only ever have applied to RDML functions generated as RPG I think.
For RDMLX, generated to C/C++, I don't think that would be an issue.

Re: Exchange from form to function and back

Posted: Fri Apr 21, 2017 5:46 am
by trossiter
I found out what was going on.

Since this function can be called from both RDML functions and RDMLX functions, I thought I should use Menu Msgtxt() to display messages. Using Menu causes the function to end prematurely and return to its menu screen when used on an AS400 session. This would occur before getting to my Exchange. I have changed all of the Menu calls to Message, and it is working as it should now.