1. Preetish Agarkhed
  2. PowerBuilder
  3. Wednesday, 28 February 2024 12:56 PM UTC

Hi,

 

I am trying use PDFDocument object to import datawindow to print. It seems that if the datawindow datasource is a Stored Procedure then ImportDatawindow is returning -1.

 

PDFDocument lpdf_doc

Long ll_return

 

dw_1.SetTransObject(SQLCA)

dw_1.Retrieve()

lpdf_doc = CREATE PDFDocument

ll_return = lpdf_doc.ImportDatawindow(dw_1)

 

ll_return is -1, because datasource is SP for dw_1. In case of datasource being a normal select(Quick Select/SQL Select) then ImportDatawindow is returning 1.

 

Has anybody come across this issue?

Accepted Answer
Andreas Mykonios Accepted Answer Pending Moderation
  1. Thursday, 29 February 2024 14:00 PM UTC
  2. PowerBuilder
  3. # Permalink

Hi.

Just checked the same thing with a datastore which datasource is a stored procedure.

 

pdfdocument lvn_pdfdoc 
datastore lds_test

lds_test = CREATE datastore
lds_test.dataobject = "d_test"
li_err = lds_test.of_settransobject(sqlca) 

IF fileexists( "C:\2Check\aaa.pdf") THEN filedelete( "C:\2Check\aaa.pdf") 
IF fileexists( "C:\2Check\bbb.pdf") THEN filedelete( "C:\2Check\bbb.pdf") 

IF lds_test.retrieve(ad_attempt_pid, ad_question_pid, li_group_id) > 0 THEN 
	lds_test.saveas( "C:\2Check\aaa.pdf", pdf!, true) 

	lvn_pdfdoc = CREATE pdfdocument 

	lvn_pdfdoc.ImportDataWindow(lds_test) 
	lvn_pdfdoc.ImportDataWindow(lds_test) 
	lvn_pdfdoc.ImportDataWindow(lds_test) 
	lvn_pdfdoc.ImportDataWindow(lds_test) 
	lvn_pdfdoc.ImportDataWindow(lds_test) 
	lvn_pdfdoc.ImportDataWindow(lds_test) 

	lvn_pdfdoc.save( "C:\2Check\bbb.pdf") 

	IF isvalid(lvn_pdfdoc) THEN DESTROY lvn_pdfdoc 
END IF 

if isvalid(lds_test) then destroy lds_test​

Both files are successfully saved.

Andreas.

Comment
  1. Chris Pollach @Appeon
  2. Thursday, 29 February 2024 16:25 PM UTC
Hi Andreas;

The problem is caused because the DWO's source is *not* migrated to PB 2022 Rx from PB 2019 R3 and thus that old syntax is not processed properly when performing the ImportDatawindow() command.

The fix would be to edit the PB 2019Rx DWO's source in PB 2022 R3 and change the 1st lin3 from "release=19;" to "release=22;" & then save the DWO source back to its PBL to have the DWO properly migrated to the 2022 R3 standard . Then the ImportDatawindow() command should now work OK.

Regards .. Chris
  1. Helpful
  1. Andreas Mykonios
  2. Friday, 1 March 2024 07:20 AM UTC
Hi Chris.

Actually, what I say is that I don't have a problem even when using a datawindow created with older PB release (in this case 2019 R3). It also works with a datawindow created from PB 2022 R3 using a stored procedure as datasource.

Andreas.
  1. Helpful
There are no comments made yet.
Dale Burts Accepted Answer Pending Moderation
  1. Tuesday, 29 October 2024 19:41 PM UTC
  2. PowerBuilder
  3. # 1

Moved to new question : importdatawindow-using-pdfdocument-is-returning-1-for-composite-report

 

PDFdocument lpdf_doc
lpdf_doc = create PDFdocument
.....
.......


dw_1.settransobject( sqlca )
dw_1.retrieve( report_number )
dw_1.object.DataWindow.Export.PDF.Method = NativePDF! 
dw_1.Object.DataWindow.Export.PDF.NativePDF.PDFStandard ='1'
dw_1.Object.DataWindow.Export.PDF.NativePDF.CustomSize = '5'

ll_return = lpdf_doc.importdatawindow( dw_1 )

[THIS IS THE CALL THAT THROWS THE ERROR]

We have had a user experiencing this issue for some time now.

The previous code used a simple dw_1.SaveAs ( ls_network_path, PDF!, TRUE) with no issues.

Prior to switching over to using PDFDocument, I had published a question regarding if GhostScript was still required if we were switching over to using PDFDocment.  I believe the response was that one didn't necessarily have anything to do with the other.

 

So we have moved forward with the 2022R3 migration, using the PDFDocument to build the PDF and save to a network location.

However, we are not using a stored procedure as datasource, but we are building a composite report (comprised of 15 separate datawindows)

However, most of the headers say "release 12.5;"  and a couple say "release 19;"

Another thing that is peculiar in diagnosing this bug, from my development machine, while running the executable, I have no issues completing the process which calls IMPORTDATAWINDOW (which is triggering the error message above for one of our users), followed by calling SAVE using PDFDocument.  Not sure if other users are also experiencing the same issue, but clearly it is has been an issue for this one user.

 

Last thing, the error is fired the first time through the code, the next time the user runs it saves without issue.

 

 

 

Comment
There are no comments made yet.
Preetish Agarkhed Accepted Answer Pending Moderation
  1. Thursday, 29 February 2024 11:47 AM UTC
  2. PowerBuilder
  3. # 2

It seems that SaveAs() function of datawindow also does not export PDF if datasource is stored procedure. If I pass parameter as Text! in SaveAs() function for the same datawindow it exports fine. Hence it seems to be the issue with PDF export only for stored procedure. Mentioning this because ImportDatawindow uses internally SaveAs() function only.

 

Comment
  1. Preetish Agarkhed
  2. Thursday, 29 February 2024 13:53 PM UTC
Thanks Andreas for the response. I will try again. Is the datawindow built in the new PB version?
  1. Helpful
  1. Andreas Mykonios
  2. Thursday, 29 February 2024 15:25 PM UTC
No. This application was originally built in PB 2019 R3. Then it was migrated to 2022, 2022 R2 and 2022 R3.

Andreas.
  1. Helpful
  1. Andreas Mykonios
  2. Friday, 1 March 2024 07:22 AM UTC
I also tried with a datawindow created in PB 2022 R3. Datasource is from a stored procedure. It works fine. What version of powerbuilder you are using?

Andreas.
  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.