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.
Preetish Agarkhed Accepted Answer Pending Moderation
  1. Thursday, 29 February 2024 11:47 AM UTC
  2. PowerBuilder
  3. # 1

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.