Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Exporting Infomaker 9 report in Powerbuilder 9 app

78 views
Skip to first unread message

dpinion

unread,
Jan 7, 2009, 10:59:31 AM1/7/09
to
Greetings,

I have a need to export a window to PDF that displays a report created
in Infomaker. I have looked through the help files and internet until
my eyes are shot, but can't find what I am looking for. I will not be
able to have a print/export/etc... button on the report window itself,
so it will have to reference the report window from another one.
Hopefully this will make things clearer:

Report window name: w_rpt_moreinfo
The report name: rpt_order_sheet

I need to somehow in powerscript export this report out to a PDF. At
some point I would also like to give the PDF a name based on values
from another window, but that is a different email for a different
time.

Thanks for any help.

Roland Smith [TeamSybase]

unread,
Jan 7, 2009, 3:17:16 PM1/7/09
to
The SaveAs function has an option to create PDF.

"dpinion" <dpi...@gmail.com> wrote in message
news:6a43fada-5b5c-4dcc...@z27g2000prd.googlegroups.com...

dpinion

unread,
Jan 7, 2009, 3:41:38 PM1/7/09
to
On Jan 7, 3:17 pm, "Roland Smith [TeamSybase]" <rsm...@trusthss.com>
wrote:

> The SaveAs function has an option to create PDF.
>

Agreed, and I have been trying to use it. However I don't know how to
tell the saveAs function to save the report window mentioned above. I
don't know the conventions to get at the report to export it.

Thanks

Jerry Siegel [TeamSybase]

unread,
Jan 7, 2009, 7:46:34 PM1/7/09
to
Take a look at the SaveAs datawindow method. Sounds like you need a button
or menu item to call SaveAs for the datawindow.
You should also look at the Application Techniques manual in the HTML books
for details on setting up GhostScript, which converts a PostScript print
file to PDF. It can't be included in PB due to licensing issues.

"dpinion" <dpi...@gmail.com> wrote in message

news:ef51603e-f302-442b...@h41g2000yqn.googlegroups.com...

dpinion

unread,
Jan 12, 2009, 9:16:04 AM1/12/09
to
On Jan 7, 7:46 pm, "Jerry Siegel [TeamSybase]"

<jNOsSPAMsiegel@yahoo!.com> wrote:
> Take a look at the SaveAs datawindow method. Sounds like you need a button
> or menu item to call SaveAs for the datawindow.
> You should also look at the Application Techniques manual in the HTML books
> for details on setting up GhostScript, which converts a PostScript print
> file to PDF. It can't be included in PB due to licensing issues.
>
> "dpinion" <dpin...@gmail.com> wrote in message

>
> news:ef51603e-f302-442b...@h41g2000yqn.googlegroups.com...
> On Jan 7, 3:17 pm, "Roland Smith [TeamSybase]" <rsm...@trusthss.com>
> wrote:
>
> > The SaveAs function has an option to create PDF.
>
> Agreed, and I have been trying to use it. However I don't know how to
> tell the saveAs function to save the report window mentioned above. I
> don't know the conventions to get at the report to export it.
>
> Thanks

I have used the saveas command for other situations. The difference
here is that I cannot place the command button on the window that
contains the report. I need to be able to reference that window (and
more specifically the report it contains) from another window, but I
cannot seem to find syntax to allow me to do so.

Jerry Siegel [TeamSybase]

unread,
Jan 12, 2009, 9:50:58 AM1/12/09
to
PB creates a global variable with same name as the window. It's good OO to
put the method that handles the data owned by the window within that window.
Your code would look like
IF IsValid (w_reportwindow) THEN
w_reportwindow.wf_makepdf ('c:\reports\mypdf.pdf')
END IF

If for some reason you can't say "please" and must reach across the table
and grab the data, I would expect w_reportwindow.dw_report.SaveAs(PDF!,
'c:\reports\mypdf.pdf') to work - of course *I* have never tried to do it
that way <G>

"dpinion" <dpi...@gmail.com> wrote in message

news:732e1d0e-9340-456a...@m16g2000vbp.googlegroups.com...

dpinion

unread,
Jan 12, 2009, 10:22:52 AM1/12/09
to
On Jan 12, 9:50 am, "Jerry Siegel [TeamSybase]"

<jNOsSPAMsiegel@yahoo!.com> wrote:
> PB creates a global variable with same name as the window. It's good OO to
> put the method that handles the data owned by the window within that window.
> Your code would look like
> IF IsValid (w_reportwindow) THEN
>     w_reportwindow.wf_makepdf ('c:\reports\mypdf.pdf')
> END IF
>
> If for some reason you can't say "please" and must reach across the table
> and grab the data, I would expect w_reportwindow.dw_report.SaveAs(PDF!,
> 'c:\reports\mypdf.pdf') to work - of course *I* have never tried to do it
> that way <G>

Thanks Jerry,
I will give those a try. A bit more information. The program itself is
not mine, but a CRM package my company bought that was created with
powerbuilder. They have given us the ability to create our own scripts
and add features, but any scripts are only available using their pre-
defined functions. For example:

gf_buttonprocessuser: Allows us to use the TAG property of a command
button to run script within this function (uses CASE statements that
match the TAG property you set for the button). However, I don't have
access to windows, only datawindows. So I place a button on a
datawindow, give it a TAG, and then add a CASE statement for that TAG
in the function and add my code.

I hope this makes sense. I must say I really like powerbuilder and
have used it for creating apps for my company since we started using
it for the CRM development. I am still pretty new to the world of
coding, but since I had VBA experience they thought I was good
enough.. ;0)


dpinion

unread,
Jan 12, 2009, 11:11:25 AM1/12/09
to
Hey Jerry,
Please see below

On Jan 12, 9:50 am, "Jerry Siegel [TeamSybase]"


<jNOsSPAMsiegel@yahoo!.com> wrote:
> PB creates a global variable with same name as the window. It's good OO to
> put the method that handles the data owned by the window within that window.
> Your code would look like
> IF IsValid (w_reportwindow) THEN
>     w_reportwindow.wf_makepdf ('c:\reports\mypdf.pdf')
> END IF

***
Here is the code I came up with. When ran it does not find the window:
window w_rpt_moreinfo
datawindow dw_report

IF IsValid (w_rpt_moreinfo) = True THEN
Messagebox("It's there!", "I see your window, w_rpt_moreinfo!")
else
messagebox("Nope", "don't see it")
END IF

Also I could not find anything on wf_makepdf. Is that an actual
function?
***


>
> If for some reason you can't say "please" and must reach across the table
> and grab the data, I would expect w_reportwindow.dw_report.SaveAs(PDF!,
> 'c:\reports\mypdf.pdf') to work - of course *I* have never tried to do it
> that way <G>

***
and I tried this:
w_rpt_moreinfo.dw_report.SaveAs(PDF!,'c:\reports\mypdf.pdf')
but got an error:
"Incompatible property dw_report for type Window"
***
>

Jerry Siegel [TeamSybase]

unread,
Jan 12, 2009, 11:45:00 AM1/12/09
to
Do not declare w_rpt_moreinfo, it will be local to your script and hide the
global variable that PB created.
wf_makepdf is a function you would have added to the window if you could
have.
Likewise with dw_report - you will need to know what the DW control in
w_rpt_moreinfo is called and refer to it directly. Very easy if you have the
source, otherwise try the PB object browser.

"dpinion" <dpi...@gmail.com> wrote in message

news:9725077a-9cf9-41d4...@a12g2000pro.googlegroups.com...

dpinion

unread,
Jan 12, 2009, 12:05:55 PM1/12/09
to
Hi Jerry,
See below:

On Jan 12, 11:45 am, "Jerry Siegel [TeamSybase]"


<jNOsSPAMsiegel@yahoo!.com> wrote:
> Do not declare w_rpt_moreinfo, it will be local to your script and hide the
> global variable that PB created.

***
If I do not declare it, I get a "Undefined variable" error in
Powerbuilder, and it will not compile/save.
***

> wf_makepdf is a function you would have added to the window if you could
> have.

I see.. :)

> Likewise with dw_report - you will need to know what the DW control in
> w_rpt_moreinfo is called and refer to it directly. Very easy if you have the
> source, otherwise try the PB object browser.
>

***
I believe the control is dw_report in this case. We have the ability
to click on a portion of the window, and it will tell us the window
name, the datawindow name it contains, what library it is from as well
as the window's ancestor. And I still don't know how I might be able
to refer to it directly from another window, as I cannot seem to
include the window name in the dot notation.(?)


Jerry Siegel [TeamSybase]

unread,
Jan 12, 2009, 12:44:04 PM1/12/09
to
Are you writing this code in a separate application? If so it would not know
about a window in the CRM application. You may need to use that feature the
vendor supplied to add code through the Tag. Or you might to ask them to add
a save as PDF feature ;-)

"dpinion" <dpi...@gmail.com> wrote in message

news:aa35e3f3-a1f7-4943...@f33g2000vbf.googlegroups.com...

dpinion

unread,
Jan 12, 2009, 12:55:22 PM1/12/09
to
On Jan 12, 12:44 pm, "Jerry Siegel [TeamSybase]"

<jNOsSPAMsiegel@yahoo!.com> wrote:
> Are you writing this code in a separate application? If so it would not know
> about a window in the CRM application. You may need to use that feature the
> vendor supplied to add code through the Tag. Or you might to ask them to add
> a save as PDF feature ;-)


I am adding the code through their supplied function and calling it
using the button's Tag. I can make my own app and place everything on
the same window and have it work fine. I just cannot seem to use a
button on a datawindow on a window within their app to reference the
report's window (where the is no option to place a button) and have it
save the PDF.

Unfortunately the application is a bit older and they have now went to
a .net framework. So no upgrade support (to the existing CRM) or an
expensive CRM upgrade.

Jerry Siegel [TeamSybase]

unread,
Jan 12, 2009, 3:00:49 PM1/12/09
to
Barf.
Where does that supplied function exist? The name gf_buttonprocessuser
suggests that it is a global function, declared independently of any
specific window. Can you post the code? And show me the buttonclicked code
in the datawindow (more likely an ancestor datawindow control) that is
calling it?
Maybe I can hack a way to get the PDF directly, or maybe it will take less
Excedrin to use a your separate application.

"dpinion" <dpi...@gmail.com> wrote in message

news:6ff2d89c-888d-4af8...@i24g2000prf.googlegroups.com...

dpinion

unread,
Jan 13, 2009, 8:37:37 AM1/13/09
to
On Jan 12, 3:00 pm, "Jerry Siegel [TeamSybase]"

<jNOsSPAMsiegel@yahoo!.com> wrote:
> Barf.
> Where does that supplied function exist? The name gf_buttonprocessuser
> suggests that it is a global function, declared independently of any
> specific window. Can you post the code? And show me the buttonclicked code
> in the datawindow (more likely an ancestor datawindow control) that is
> calling it?
> Maybe I can hack a way to get the PDF directly, or maybe it will take less
> Excedrin to use a your separate application.
>

Hey Jerry,
Thanks for your willingness to help me! I don't know if this will
help, but below is example code showing how the gf_buttonprocessuser
function works, and what variables are passed to it. (hopefully the
formatting will keep here)


gf_dwbuttonprocess_user()

Description:
Called when a user clicks a button placed on a datawindow. (See
PowerBuilder event ButtonClicked in the next appendix.) When placing a
custom button on a datawindow, have the related code execute.

Syntax: gf_dwbuttonprocess_user(adw, astng)
Argument Description

adw Datawindow by reference; the datawindow containing
the button.
astag String by value; tag value from calling datawindow
button.

Return Value
None

Example
This gf_dwprocessbutton_user function calls another report from a
report in More Information.

[Start Code]

string lsType
integer liCount
string lsWindow, lsDetailDW

if adw.AcceptText() = -1 then return

string lsaParms[]

// get number of arguments
liCount = gf_dwbuttonparsetag(astag,lsaParms)

if liCount <= 0 then return

lsType = lsaParms[1]

choose case Upper(lsType) <-- This is where the TAG for the button
comes into play in order to execute the code below


case 'MOREINFO'
// mc 12/8/00 Caveat: the retrieval argument for the more info
datawindow
// will be the first column in the SQL
// in the *calling* datawindow, where the button is.
// 1 2 3 4
// e.g. moreinfo:w_rpt_moreinfo:tr_cust_snapshot:row
// Arguments:
// 1 - moreinfo
// 2 - window name (w_rpt_moreinfo)
// 3 - datawindow name (e.g. tr_cust_snapshot)
// 5 - row (auto-appended)

if liCount < 4 then return // valid number of arguments?

lsWindow = lsaParms[2]
lsDetailDW = lsaParms[3]

if not w_desktop.wf_security_chk(lsWindow, 'init') then return

gstrmoreinfo.dwname = lsDetailDW
lstrView.datawindow = adw
w_desktop.wf_RequestOpen(lsWindow, string(Now(), 'h:mm:ss:ffffff'))
end choose

[End Code]

I don't know if this helps, and I may be fighting a lost cause on this
one, but I do appreciate your help.

Jerry Siegel [TeamSybase]

unread,
Jan 13, 2009, 9:29:06 AM1/13/09
to
The clue I'm seeing here is

adw Datawindow by reference; the datawindow containing the
button.
So you can call a method in the DW without caring what window it's in. I
think you could pass the file name for the PDF in the tag, but I would
probably omit it from the SaveAs call and have the function ask for a file
name so that the user could keep different versions. The tag would just be
SavePDF, then

CASE 'SavePDF'
adw.SaveAs ('',PDF!)

Give that a try and let me know if it works

"dpinion" <dpi...@gmail.com> wrote in message

news:a55cede8-1197-4e6e...@20g2000yqt.googlegroups.com...

dpinion

unread,
Jan 13, 2009, 10:45:54 AM1/13/09
to
On Jan 13, 9:29 am, "Jerry Siegel [TeamSybase]"

<jNOsSPAMsiegel@yahoo!.com> wrote:
> The clue I'm seeing here is
> adw              Datawindow by reference; the datawindow containing the
> button.
> So you can call a method in the DW without caring what window it's in. I
> think you could pass the file name for the PDF in the tag, but I would
> probably omit it from the SaveAs call and have the function ask for a file
> name so that the user could keep different versions. The tag would just be
> SavePDF, then
>
> CASE 'SavePDF'
>     adw.SaveAs ('',PDF!)
>
> Give that a try and let me know if  it works
>

Hey Jerry,
For some reason I can't save it using PDF!, but text and Excel work
fine. It isn't quite what I need though, as that will save the values
in the *current* datawindow, where I need to be able to save a
different window from the command button event. Looking over the code
above again, I got to wondering. See my questions below in the code:

// Arguments:
// 1 - moreinfo

// 2 - window name (w_rpt_moreinfo) ******* Is it possible to use
this? This is the name of the window I need, however it is currently
brought in as a string

// 3 - datawindow name (e.g. rpt_order_sheet) *******Same with this,
except it is the name of the actual report I need.


// 5 - row (auto-appended)

if liCount < 4 then return // valid number of arguments?

lsWindow = lsaParms[2]
lsDetailDW = lsaParms[3]

if not w_desktop.wf_security_chk(lsWindow, 'init') then return

gstrmoreinfo.dwname = lsDetailDW
lstrView.datawindow = adw
w_desktop.wf_RequestOpen(lsWindow, string(Now(), 'h:mm:ss:ffffff'))

******* So instead of opening the window (it will already be open),
could I use "lsWindow" and "lsDetailDW" to plug the values for the
window and report into the saveas function?

end choose

dpinion

unread,
Jan 14, 2009, 9:46:45 AM1/14/09
to
Looks like I may have stumped the panel.. :) I had a thought, but I
don't know if it will work. I have the window and datawindow placed
into the code as strings. Is there a way to convert strings into
powerbuilder objects? So then instead of the string I would have a
reference to the object?

On Jan 13, 10:45 am, dpinion <dpin...@gmail.com> wrote:
> On Jan 13, 9:29 am, "Jerry Siegel [TeamSybase]"
>
> <jNOsSPAMsiegel@yahoo!.com> wrote:
> > The clue I'm seeing here is
> > adw              Datawindow by reference; the datawindow containing the
> > button.

> > So you can call a method in the DW without caring whatwindowit's in. I


> > think you could pass the file name for the PDF in the tag, but I would
> > probably omit it from the SaveAs call and have the function ask for a file
> > name so that the user could keep different versions. The tag would just be
> > SavePDF, then
>
> > CASE 'SavePDF'
> >     adw.SaveAs ('',PDF!)
>
> > Give that a try and let me know if  it works
>
> Hey Jerry,
> For some reason I can't save it using PDF!, but text and Excel work
> fine. It isn't quite what I need though, as that will save the values
> in the *current* datawindow, where I need to be able to save a

> differentwindowfrom the command button event. Looking over the code


> above again, I got to wondering. See my questions below in the code:
>
> // Arguments:
> // 1 - moreinfo

> // 2 -windowname (w_rpt_moreinfo) ******* Is it possible to use
> this? This is the name of thewindowI need, however it is currently


> brought in as a string
>
> // 3 - datawindow name (e.g. rpt_order_sheet) *******Same with this,
> except it is the name of the actual report I need.
> // 5 - row (auto-appended)
>
> if liCount < 4 then return // valid number of arguments?
>
> lsWindow = lsaParms[2]
> lsDetailDW = lsaParms[3]
>
> if not w_desktop.wf_security_chk(lsWindow, 'init') then return
>
> gstrmoreinfo.dwname = lsDetailDW
> lstrView.datawindow = adw
> w_desktop.wf_RequestOpen(lsWindow, string(Now(), 'h:mm:ss:ffffff'))

> ******* So instead of opening thewindow(it will already be open),
> could I use "lsWindow" and "lsDetailDW" to plug the values for thewindowand report into the saveas function?
>
> end choose

Jerry Siegel [TeamSybase]

unread,
Jan 14, 2009, 10:33:22 AM1/14/09
to
You can create a user object or open an instance of a window given the name,
but I don't know of a native way to get a reference to an existing window.
You might look at http://www.rgagnon.com/pbdetails/pb-0255.html for a method
finding the title and class of every open window using Windows API calls.
Having found the window you could step through its control [ ] array to find
the datawindow.

"dpinion" <dpi...@gmail.com> wrote in message

news:0207d1cd-b798-48e0...@13g2000yql.googlegroups.com...

M. Searer

unread,
Jan 15, 2009, 11:17:09 AM1/15/09
to
If you are trying to call a function/event on the window then you should be able to:
You say that you have a reference to the datawindow control.
Get its parent (may need to loop if you have the dw on an object that is on the widnow):

window lw_parent
powerobject lpo_parent
lpo_parent = adw.getparent()
if lpo_parent.TypeOf() = window! then lw_parent = lpo_parent

then use dynamic to call the function or event on the descendent window.

lw_parent.dynamic <yourwindowfunctioncall>


"dpinion" <dpi...@gmail.com> wrote in message news:0207d1cd-b798-48e0...@13g2000yql.googlegroups.com...

0 new messages