Wanting to execute pui.download api call without showing a window. RPG program would call record format with a hidden output field with the path/file name to be used by pui.download. I'm thinking this would be in the windows onload. The screen then would just return back to the RPG program. I tried this with pui.click() but get the error "Unable to reach server..." and does not return back to program.
Current script.
pui.download({ "id": getElementValue("OutputField1") });
pui.click();
pui.download
-
- Profound User
- Posts: 61
- Joined: Tue Jun 28, 2016 12:53 pm
- First Name: James
- Last Name: Sherwood
- Company Name: Brunswick Boat Group
- City: Knoxville
- State / Province: Tennessee
- Contact:
-
- 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: pui.download
James,
pui.download() is a JavaScript routine. In order to run it, you must have a page running in a web browser, as that is where it runs.
Please do not call pui.click() immediately after calling pui.download(). pui.download() needs some time to run, it creates a connection to IBM i and negotiates a download with a program that runs on the server. This occurs in the background while your screen continues to run. If you run pui.click() while pui.download() is still running in the background (which is almost certainly the case here) you will cut it off in the middle of it's processing.
Instead of sending a screen that runs pui.download() and pui.click() in the onload event, I would suggest running pui.download() directly from the prior screen. Then there should be no reason to bring up a new/separate screen with this running in the onload event. If RPG processing needs to be done, do it in the exit program thats called by pui.download() instead of doing it in your "main" RPG program.
Good luck
pui.download() is a JavaScript routine. In order to run it, you must have a page running in a web browser, as that is where it runs.
Please do not call pui.click() immediately after calling pui.download(). pui.download() needs some time to run, it creates a connection to IBM i and negotiates a download with a program that runs on the server. This occurs in the background while your screen continues to run. If you run pui.click() while pui.download() is still running in the background (which is almost certainly the case here) you will cut it off in the middle of it's processing.
Instead of sending a screen that runs pui.download() and pui.click() in the onload event, I would suggest running pui.download() directly from the prior screen. Then there should be no reason to bring up a new/separate screen with this running in the onload event. If RPG processing needs to be done, do it in the exit program thats called by pui.download() instead of doing it in your "main" RPG program.
Good luck
-
- Profound User
- Posts: 61
- Joined: Tue Jun 28, 2016 12:53 pm
- First Name: James
- Last Name: Sherwood
- Company Name: Brunswick Boat Group
- City: Knoxville
- State / Province: Tennessee
- Contact:
Re: pui.download
Thanks Scott. The challenge is from the RPG program to generate a print out, generate a PDF and then execute pui.download() in sequence. The information you supplied will be helpful.
-
- 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: pui.download
James,
Yes, in my experience the best way to do that is for the exit program to that. The exit program for a download is called PUIDNLEXIT, and this program will be passed various pieces of info, including the "id" from your pui.download() call. Although this ID defaults to being the same as the IFS path, it doesn't have to be the path. Think of it as a "key" to tell the program what to generate.
So you can send an id of "MakeReport" (or whatever you like) and the PUIDNLEXIT program can see that, call a routine to generate a report and convert it to PDF, and then it can specify the IFS path name of the PDF. It can also delete the PDF when the download is complete, which is nice way to keep things neat and tidy.
Hope that helps
Yes, in my experience the best way to do that is for the exit program to that. The exit program for a download is called PUIDNLEXIT, and this program will be passed various pieces of info, including the "id" from your pui.download() call. Although this ID defaults to being the same as the IFS path, it doesn't have to be the path. Think of it as a "key" to tell the program what to generate.
So you can send an id of "MakeReport" (or whatever you like) and the PUIDNLEXIT program can see that, call a routine to generate a report and convert it to PDF, and then it can specify the IFS path name of the PDF. It can also delete the PDF when the download is complete, which is nice way to keep things neat and tidy.
Hope that helps
Who is online
Users browsing this forum: No registered users and 3 guests