Unable to update rich DSPF subfile from RPG

Use this board to ask questions or have discussions with other Rich Displays users.
Theju112
Profound User
Posts: 48
Joined: Fri Jul 10, 2020 8:35 am
First Name: Thej
Last Name: Pav
Company Name: Confidential
Phone: 00918310800134
Address 1: Chennai
Address 2: India
City: Chennai
State / Province: Outside Canada/USA
Zip / Postal Code: 673592
Country: India
Contact:

Unable to update rich DSPF subfile from RPG

Post by Theju112 »

Dear Scott and Team,

I have a green screen subfile for which I am attempting to create an equivalent rich DSPF using the "grid" widget.

The first field of each subfile record is an option input field where the user can take an option '1' to select a record and flag it for deletion.

There is a "select all" option which will update the option field of all records to '1'. The intention of this option is to reduce the users efforts to key in the option value for all records.

In the rich DSPF, the option field is a select box widget. I am trying to chain the subfile records based on rrn and update option field value. This works fine in green screen, but in the web screen it just wont update.

RPG CODE
begsr selectAll;                   
                                   
  dow *inkl = *off;                
    exfmt selectW;                 
    if *inke;                      
      rrn# = 1;                    
      dou not %found;              
        Chain rrn# s01;            
        if %found;                 
          option = '1=Select';     
          update s01;              
        endif;                     
        rrn# += 1;                 
      enddo;                       
      *in88 = *on;                 
      leave;                       
    endif;                         
  enddo;                           
  *inkl = *off;                    
endsr;                             
I have defined the choices property value to have one value "1=Select". This is the same value I am using in the RPG. So I am not sure why this isnt updating.

Any help please?
Scott Klement
Experienced User
Posts: 2711
Joined: Wed Aug 01, 2012 8:58 am
First Name: Scott
Last Name: Klement
Company Name: Profound Logic
City: Milwaukee
State / Province: Wisconsin

Re: Unable to update rich DSPF subfile from RPG

Post by Scott Klement »

I don't see anything obvious wrong, here. It should work fine. I suggest debugging your code to see what is failing.
Theju112
Profound User
Posts: 48
Joined: Fri Jul 10, 2020 8:35 am
First Name: Thej
Last Name: Pav
Company Name: Confidential
Phone: 00918310800134
Address 1: Chennai
Address 2: India
City: Chennai
State / Province: Outside Canada/USA
Zip / Postal Code: 673592
Country: India
Contact:

Re: Unable to update rich DSPF subfile from RPG

Post by Theju112 »

Hi Scott,

I am not sure what the issue is. When the select box is replaced with a combo box/ text box, the value is populated as expected. But the select box is failing which confirms that there is some issue on the front-end side. I am not sure if it is an issue with the select widget or if some HTML/JavaScript intricacy that is causing the behavior. Any further suggestions?
Scott Klement
Experienced User
Posts: 2711
Joined: Wed Aug 01, 2012 8:58 am
First Name: Scott
Last Name: Klement
Company Name: Profound Logic
City: Milwaukee
State / Province: Wisconsin

Re: Unable to update rich DSPF subfile from RPG

Post by Scott Klement »

I don't feel like I know enough about your screen to tell you what's wrong with it. All I really know is that you're using a select box.

Run the program, and press Ctrl-F9 when the failing screen is on the display. This will create a dump of the JSON that was sent to the Profound UI framework -- if you post that JSON here, I can try to re-run your screen.
Theju112
Profound User
Posts: 48
Joined: Fri Jul 10, 2020 8:35 am
First Name: Thej
Last Name: Pav
Company Name: Confidential
Phone: 00918310800134
Address 1: Chennai
Address 2: India
City: Chennai
State / Province: Outside Canada/USA
Zip / Postal Code: 673592
Country: India
Contact:

Re: Unable to update rich DSPF subfile from RPG

Post by Theju112 »

Dear Scott,

Attached is the json.
Attachments
json.txt
(59.49 KiB) Downloaded 634 times
Scott Klement
Experienced User
Posts: 2711
Joined: Wed Aug 01, 2012 8:58 am
First Name: Scott
Last Name: Klement
Company Name: Profound Logic
City: Milwaukee
State / Province: Wisconsin

Re: Unable to update rich DSPF subfile from RPG

Post by Scott Klement »

Theju112,

1) I looked at the data in your JSON dump, and the option field in the grid is not '1=Select'. Since we agreed that you would reproduce the problem and press Ctrl-F9 to make the dump, I assumed that you had actually run the RPG code that sets 1=Select. However, this was not sent from the RPG program.

2) Then I wrote my own RPG program that would send 1=Select to make sure there wasn't a problem with the Open Access handler. I quickly discovered that the RPG code that you posted to these forums can never run because it checks for *INKE = *ON, and there isn't anything on your screen that turns on that indicator. The "Select All / Clear All" icon on your screen actually works using JavaScript code, it never sets on an indicator and returns control back to RPG.

The JavaScript code in the "Select All / Clear All" option works correctly.

It is very hard to tell you what is wrong with code if I can't see the failing code! I can't read minds.

3) I added a new button that turns on *INKE -- this is only a guess at the problem, because you didn't have this on your screen. After doing this, I was able to make a new Ctrl-F9 dump that shows that the RPG program is, indeed, sending the 1=Select as expected. However, the screen didn't display it.

Looking at the screen, I found the following in the onload event:

Code: Select all

let recordCount = getObj("S01").grid.getRecordCount();
sessionStorage.clear();
getObj("S01").grid.setNumberOfRows(recordCount + 1);
for(let recordIndex=0;recordIndex<=recordCount;)
{
      getObj("S01").grid.setDataValue(recordIndex, "OPTION"," ");
      recordIndex++;
}
getObj("S01").grid.setNumberOfRows(13);
I recommend that you change the sessionStorage.clear() to sessionStorage.removeItem("selected"); Clearing everything in session storage is not a good idea, because other code (including Profound UI itself) may use session storage, and you will wipe out its data.

Also I don't understand why you are changing the number of rows to 13.

Also, you are deliberately wiping out all values in the OPTION field. So, of course, any updates that were made within the RPG program aren't going to work... you're erasing them!

4) To find out if the setDataValue, above, was the only cause of the problem, I commented out all of the code in the onload event. I discovered that the RPG program is sending '1=SELECT' and the choices property is set to '1=Select'. Since these don't match (due to the different upper/lower case) the option was still not selected.

The reason why the RPG code is '1=SELECT' is because you have "Text Transform: Uppercase" in the binding dialog for the OPTION field.
transformUpper.png
transformUpper.png (22.09 KiB) Viewed 5200 times
I change this to "None", and the UPDATEs from the RPG code worked as expected.
Theju112
Profound User
Posts: 48
Joined: Fri Jul 10, 2020 8:35 am
First Name: Thej
Last Name: Pav
Company Name: Confidential
Phone: 00918310800134
Address 1: Chennai
Address 2: India
City: Chennai
State / Province: Outside Canada/USA
Zip / Postal Code: 673592
Country: India
Contact:

Re: Unable to update rich DSPF subfile from RPG

Post by Theju112 »

Hi Scott,

Since the update was happening successfully when I used a text box instead of a select box, I assumed the issue must be with how I had set up the
select box widget and you would be interested to see only the "front end" code associated to the select widget. Apologies.

Since the back end RPG was not updating the values as required, I came up with a front end "work around" to populate the select boxes with "1=SELECT".

The onload and onclick events are part of this work around.

The work around uses the script below to set the values. This script would fire on an onClick event of the "Select All" button.

Code: Select all

let recordCount = getObj("S01").grid.getRecordCount();
let isSelected = sessionStorage.getItem('selected');

console.log(isSelected);

getObj("S01").grid.setNumberOfRows(recordCount + 1);

if ((isSelected === 'off') || (isSelected === null))
{
  for(let recordIndex=0;recordIndex<=recordCount;)
  {
      getObj("S01").grid.setDataValue(recordIndex, "OPTION","1=Select");
      recordIndex++;
  }
  sessionStorage.setItem('selected','on');
}
else{
  for(let recordIndex=0;recordIndex<=recordCount;)
  {
      getObj("S01").grid.setDataValue(recordIndex, "OPTION"," ");
      recordIndex++;
  }
  sessionStorage.setItem('selected','off');
}
  getObj("S01").grid.setNumberOfRows(13);
The OnLoad script which you saw is to clear the values the above script populates. This solution works as required by me.

To replicate the exact issue I was facing earlier, I have re-created the attached dump after removing the onload and onclick scripts I had added.

Now when the user clicks the select all button, its response is tied to indicator *in11. When *in11 is on, the selectAll subroutine is executed from where exfmt selectW is done which displays a confirmation screen. If the user confirms by pressing F5 (*inke), the records should be updated.

But it still doesn't work even after setting text transform to "None" as you suggested.

The RPG is now assigning a value of '1=Select'. This matches the value I have set in the choices property of the select box. I believe this should
rule out the possibility that the RPG is passing an invalid value.

As was observed earlier, if I use a text box instead of a select box, the value gets updated successfully.

I have confirmed in debug mode that the code that assigns the value to the select box and updates the subfile is indeed executed.

Now to answer your question "Also I don't understand why you are changing the number of rows to 13" - as I found out while trying to implement my
work around in the onclick event, the grid.setDataValue sets the values of only those records which are visible on the screen. When it is srolled down,
the select boxes are blank. In order to solve this, I display all the records in the grid using "getObj("S01").grid.setNumberOfRows(recordCount + 1);"
Then I reset it back to display 13 rows using getObj("S01").grid.setNumberOfRows(13) as the grid should initially display only 13 records to fit on the screen.

Hope I am clear and have not confused you further. Please do let me know if you need further details.
Attachments
json_after update from RPG.txt
(67.26 KiB) Downloaded 544 times
Scott Klement
Experienced User
Posts: 2711
Joined: Wed Aug 01, 2012 8:58 am
First Name: Scott
Last Name: Klement
Company Name: Profound Logic
City: Milwaukee
State / Province: Wisconsin

Re: Unable to update rich DSPF subfile from RPG

Post by Scott Klement »

Theju112 wrote: Thu Jul 29, 2021 2:26 am Hope I am clear and have not confused you further. Please do let me know if you need further details.
To the best of my knowledge, I've already given you the solutions? Is there more that you're having trouble with?
Theju112
Profound User
Posts: 48
Joined: Fri Jul 10, 2020 8:35 am
First Name: Thej
Last Name: Pav
Company Name: Confidential
Phone: 00918310800134
Address 1: Chennai
Address 2: India
City: Chennai
State / Province: Outside Canada/USA
Zip / Postal Code: 673592
Country: India
Contact:

Re: Unable to update rich DSPF subfile from RPG

Post by Theju112 »

Hi Scott,

Yes, I am still facing the same issue. The RPG is not updating the select box values as expected. The dump attached in my previous reply was created after the update operation was completed by the RPG.

As you have suggested, I have tried setting Text transform = "none" but it still doesn't work.
Theju112
Profound User
Posts: 48
Joined: Fri Jul 10, 2020 8:35 am
First Name: Thej
Last Name: Pav
Company Name: Confidential
Phone: 00918310800134
Address 1: Chennai
Address 2: India
City: Chennai
State / Province: Outside Canada/USA
Zip / Postal Code: 673592
Country: India
Contact:

Re: Unable to update rich DSPF subfile from RPG

Post by Theju112 »

Hi Scott,

Please let me know if you got a chance to look at the JSON I had attached in my previous post.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest