Sybase NNTP forums - End Of Life (EOL)

The NNTP forums from Sybase - forums.sybase.com - are now closed.

All new questions should be directed to the appropriate forum at the SAP Community Network (SCN).

Individual products have links to the respective forums on SCN, or you can go to SCN and search for your product in the search box (upper right corner) to find your specific developer center.

Can't set PrinterName when there's no DataObject

3 posts in DataWindow Last posting was on 2009-01-05 13:41:36.0Z
Dan Cooperstock Posted on 2009-01-03 13:52:15.0Z
Newsgroups: sybase.public.powerbuilder.datawindow
Subject: Can't set PrinterName when there's no DataObject
From: Dan Cooperstock <info@Software4NonProfits.com>
Organization: Software4NonProfits.com
Message-ID: <Xns9B885A3CCBDCEinfoSoftwareNonProfi@192.138.151.106>
User-Agent: Xnews/5.04.25
NNTP-Posting-Host: vip152.sybase.com
X-Original-NNTP-Posting-Host: vip152.sybase.com
Date: 3 Jan 2009 05:52:15 -0800
X-Trace: forums-1-dub 1230990735 10.22.241.152 (3 Jan 2009 05:52:15 -0800)
X-Original-Trace: 3 Jan 2009 05:52:15 -0800, vip152.sybase.com
Lines: 25
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub sybase.public.powerbuilder.datawindow:88485
Article PK: 417739

I'm trying to print to a PDF printer by setting
dw_report.Object.DataWindow.Print.PrinterName. It works for my standard
reports, where the DataWindow control (dw_report in this case) has a
DataObject set to a real DataWindow object from my PBL.

But sometimes I am creating custom reports from user-specified SQL, so
there is no DataObject - I have the data in a DataStore, I get its syntax,
create the DW from its syntax, then copy the rows from the DataStore to the
DW. The code (omitting error checking for brevity) is as follows:

ls_syntax = lds_data.Object.DataWindow.Syntax // lds_data is my DataStore
dw_report.Create(ls_syntax, ls_err) // this works with no error
lds_data.RowsCopy(1, lds_data.RowCount(), Primary!, dw_report, 1, Primary!)

In this case, when I set dw_report.Object.DataWindow.Print.PrinterName it
doesn't take any value, and it thus doesn't print to the PDF printer.

Can anyone explain this or suggest a work-around? Thanks.

---------------------------
Dan Cooperstock
DONATION web site: http://www.Software4Nonprofits.com
DONATION Support forums: http://forums.Software4Nonprofits.com
Email: mailto:info@Software4Nonprofits.com
Phone: 416-423-7722


Dan Cooperstock Posted on 2009-01-03 15:22:09.0Z
Newsgroups: sybase.public.powerbuilder.datawindow
Subject: Re: Can't set PrinterName when there's no DataObject
From: Dan Cooperstock <info@Software4NonProfits.com>
References: <Xns9B885A3CCBDCEinfoSoftwareNonProfi@192.138.151.106>
Organization: Software4NonProfits.com
Message-ID: <Xns9B88697B3829DinfoSoftwareNonProfi@192.138.151.106>
User-Agent: Xnews/5.04.25
NNTP-Posting-Host: vip152.sybase.com
X-Original-NNTP-Posting-Host: vip152.sybase.com
Date: 3 Jan 2009 07:22:09 -0800
X-Trace: forums-1-dub 1230996129 10.22.241.152 (3 Jan 2009 07:22:09 -0800)
X-Original-Trace: 3 Jan 2009 07:22:09 -0800, vip152.sybase.com
Lines: 45
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub sybase.public.powerbuilder.datawindow:88486
Article PK: 417743

Dan Cooperstock <info@Software4NonProfits.com> wrote in
news:Xns9B885A3CCBDCEinfoSoftwareNonProfi@192.138.151.106:

> I'm trying to print to a PDF printer by setting
> dw_report.Object.DataWindow.Print.PrinterName. It works for my
> standard reports, where the DataWindow control (dw_report in this
> case) has a DataObject set to a real DataWindow object from my PBL.
>
> But sometimes I am creating custom reports from user-specified SQL, so
> there is no DataObject - I have the data in a DataStore, I get its
> syntax, create the DW from its syntax, then copy the rows from the
> DataStore to the DW. The code (omitting error checking for brevity) is
> as follows:

[snip]

OK, I figured this out. It's not because there's no DataObject, it's
because the syntax I'm setting on the DW comes from a DataStore, which
isn't intended to be printed. To fix this, I hack the syntax before doing
the dw_report.Create(ls_syntax, ls_err) call, to add in the printer
properties that I observed are in a DW's normal syntax but missing from a
DataStore's normal syntax, as follows:

ll_pos = Pos(ls_syntax, "datawindow")
if ll_pos > 0 then
ll_pos = Pos(ls_syntax, "(", ll_pos)
if ll_pos > 0 then
ls_syntax = Left(ls_syntax, ll_pos) + &
' print.printername="" print.documentname=""
print.canusedefaultprinter=yes ' + &
'print.prompt=no print.buttons=no print.preview.buttons=no
print.cliptext=no ' + &
'print.overrideprintjob=no print.collate=yes ' + &
Mid(ls_syntax, ll_pos + 1)
end if
end if

With this change, setting dw_report.Object.DataWindow.Print.PrinterName
now works, and thus the printing to the PDF printer works.

---------------------------
Dan Cooperstock
DONATION web site: http://www.Software4Nonprofits.com
DONATION Support forums: http://forums.Software4Nonprofits.com
Email: mailto:info@Software4Nonprofits.com
Phone: 416-423-7722


Scott Morris Posted on 2009-01-05 13:41:36.0Z
From: "Scott Morris" <bogus@bogus.com>
Newsgroups: sybase.public.powerbuilder.datawindow
References: <Xns9B885A3CCBDCEinfoSoftwareNonProfi@192.138.151.106> <Xns9B88697B3829DinfoSoftwareNonProfi@192.138.151.106>
Subject: Re: Can't set PrinterName when there's no DataObject
Lines: 44
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.5512
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579
X-RFC2646: Format=Flowed; Original
NNTP-Posting-Host: vip152.sybase.com
X-Original-NNTP-Posting-Host: vip152.sybase.com
Message-ID: <49620e10$1@forums-1-dub>
Date: 5 Jan 2009 05:41:36 -0800
X-Trace: forums-1-dub 1231162896 10.22.241.152 (5 Jan 2009 05:41:36 -0800)
X-Original-Trace: 5 Jan 2009 05:41:36 -0800, vip152.sybase.com
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub sybase.public.powerbuilder.datawindow:88489
Article PK: 417742


> OK, I figured this out. It's not because there's no DataObject, it's
> because the syntax I'm setting on the DW comes from a DataStore, which
> isn't intended to be printed. To fix this, I hack the syntax before doing

I don't really follow this but I can assure you that a datastore provides
the same print functionality that a datawindow control does.

> the dw_report.Create(ls_syntax, ls_err) call, to add in the printer
> properties that I observed are in a DW's normal syntax but missing from a
> DataStore's normal syntax, as follows:
>
> ll_pos = Pos(ls_syntax, "datawindow")
> if ll_pos > 0 then
> ll_pos = Pos(ls_syntax, "(", ll_pos)
> if ll_pos > 0 then
> ls_syntax = Left(ls_syntax, ll_pos) + &
> ' print.printername="" print.documentname=""
> print.canusedefaultprinter=yes ' + &
> 'print.prompt=no print.buttons=no print.preview.buttons=no
> print.cliptext=no ' + &
> 'print.overrideprintjob=no print.collate=yes ' + &
> Mid(ls_syntax, ll_pos + 1)
> end if
> end if
>
> With this change, setting dw_report.Object.DataWindow.Print.PrinterName
> now works, and thus the printing to the PDF printer works.

Rule Number 1 when discussing anything related to PB is to include the
version and build you are using. Usually it helps to include the backend
database information and the type of connection (oledb, odbc, etc.) you are
using.

If the version you are using is sufficiently old, then the problem may be
that printername is a read-only attribute (changed to modifiable in PB8?).

Another suggestion is that you consider getfullstate / setfullstate (as
opposed to creating from syntax). This might be faster and more efficient -
and it includes the data which your current method won't.

Last suggestion - if you're generating PDFs you might want to use the
built-in saveas functionality and avoid this printer business entirely.