1. Linda Canfield
  2. PowerBuilder
  3. Tuesday, 08 October 2019

Hello,

 

We have an audit request to show the data source on specific datawindows for reports.  We do not modify the code or provide the source code and depend on PowerPlan to make those changes however we still need to provide the data source to our auditors.  We have a specific datawindow dw_tax_rpt_roll_foward that is in the taxreports.pbd however there is not a taxreports.pbl in our source code or workspace.  How can we retrieve the data source for this specific datawindow?  Is there a way to extract the datawindow from the pbd? 

Thanks,

Linda

Chris Pollach Accepted Answer Pending Moderation
1
Votes
Undo

Michael;

  If Roland were in Canada, I could give him this award ...

Image result for Molson Golden

Thanks again Roland for that new PBD tool!

Regards ... Chris

Comment
There are no comments made yet.
  1. Wednesday, 9 October 2019
  2. PowerBuilder
  3. # 1
Roland Smith Accepted Answer Pending Moderation
2
Votes
Undo

I went ahead and created an extract tool and posted it to my website. Look for DWFromPBD on this page:

http://www.topwizprogramming.com/tools.html

 

Comment
Thank you Roland .. .that was very kind of you!
  1. Chris Pollach
  2. Wednesday, 9 October 2019
Roland, you are golden!
  1. Michael Kramer
  2. Wednesday, 9 October 2019
There are no comments made yet.
  1. Wednesday, 9 October 2019
  2. PowerBuilder
  3. # 2
Miguel Leeuwe Accepted Answer Pending Moderation
0
Votes
Undo

In addition to the other answers. If it's only the sql you're interested in:

One thing you can do is 

- assign the dw to a control on a window.

- do a retrieve of that dw (you do have to know the retrieval arguments for that, see the other answers)

- in debug, put a stop in the sqlpreview event of the dw control. It'll show the Select

Comment
There are no comments made yet.
  1. Tuesday, 8 October 2019
  2. PowerBuilder
  3. # 3
Michael Kramer Accepted Answer Pending Moderation
0
Votes
Undo

Hi Linda,
What PowerBuilder version is your app running?

It is fairly straightforward to write a tiny PB app that enables the user to:

  1. Select a specific .PBD file and specific export folder
  2. Show list of DataWindow objects inside that .PBD file
  3. Extracts the syntax of whatever DataWindow objects the user selects from that list
  4. Output
    1. Separate DW-Name.txt for each extracted DataWindow object

ALTERNATIVE

  1. Select specific app folder and specific export folder
  2. Loop through all .PBD files in that folder
  3. Loop through all DataWindow objects for each .PBD file
  4. Extract syntax for each DataWindow
  5. Output:
    1. Separate subfolder for each .PBD file (same DW-name may appear across multiple .PBD files)
    2. Separate file DW-Name.txt for each extracted DataWindow object

HTH /Michael

Sidebar:
If relevant I'd be happy to help as a courtesy (I have fragments of such app already somewhere on disk) ==>
IF relevant THEN reach out to me via LinkedIn messaging.

 

Comment
We are using PowerBuilder 2017
  1. Linda Canfield
  2. Tuesday, 8 October 2019
I have access to PB 2017 and PB 2019 so I could help you if needed.

The "complexity" is that PB function LibraryExport returns empty string for PBD files. I have hardcoded sample running in PB 2019 but it will take a few hours to make into runnable app ready to export from any app.



If someone else reaches out with existing code, my suggestion is accept it upon successful test.

In case you want me to turn my sample into actual app tool, please reach out through LinkedIn (link through MVP pages). This being courtesy code I could publish it through this community afterwards. But I need to know that it is worthwhile before I invest a weekend. /Michael
  1. Michael Kramer
  2. Tuesday, 8 October 2019
There are no comments made yet.
  1. Tuesday, 8 October 2019
  2. PowerBuilder
  3. # 4
Roland Smith Accepted Answer Pending Moderation
0
Votes
Undo

Chris's explanation is basically a more detailed version of my response.

What you need to do is create a new target adding taxreports.pbd to the library list. The new target just needs a simple window with a DataWindow control on it. No need to connect to the database.

In the window open event add this line:

dw_1.DataObject = "d_objectname"

Then add a button that extracts the source and writes it to a file using the method from my first response.

Comment
There are no comments made yet.
  1. Tuesday, 8 October 2019
  2. PowerBuilder
  3. # 5
Linda Canfield Accepted Answer Pending Moderation
0
Votes
Undo

Do you happen to have the code to write the syntax to the file?  We don't normally modify the code and I do not want to create any issues with our source code that may impact future builds.

 

Thanks so much!!

Comment
Once you have the DWO Source after the Describe() command .. just use the FileOpen(), FileWriteEx() and FileClose() commands to write the source to disk. Note that you *cannot* save the DWO Source back into a PBD. Its a read only library. So your "Audit" utility App would be also good from the EDP Auditor's perspective for keeping your Production App's integrity.
  1. Chris Pollach
  2. Tuesday, 8 October 2019
You can however save it to a PBL file with the LibraryImport function.
  1. Roland Smith
  2. Tuesday, 8 October 2019
There are no comments made yet.
  1. Tuesday, 8 October 2019
  2. PowerBuilder
  3. # 6
Chris Pollach Accepted Answer Pending Moderation
1
Votes
Undo

Hi Linda;

  Yes & No

No ... 

   When you build a PBD or DLL from a PB library - only the machine (executable) code remains the PB manuals tell you their is no DWO source - only compiled code.

   If you attach the PBD to your PB IDE, you can see the DWO's and introspect them in the "System Tree". However, the IDE will not let you open the DW Painter or edit the Source Code. You can try and trick the IDE by renaming the PBD => PBL but the IDE knows its still really a PBD and will not let you look at it.

Yes ... 

  When you compile your PB Application that contains PBD's, you can still see the DWO source code. For example, in my framework when you are in "Audit Mode" from an Executable App ...

  So what you can do is ...

1) Write a small PB "Audit" application.

2) Let the User pick any number of PBD files.

3) Add these to the Audit App's library list (use AddToLibraryList command).

4) Use the LibraryDirectory command to get the names of the DWO's in any PBD

5) In the Audit App, load the DWO into a DW Control (or DataStore)

    DC/DS.DataObject = "DWOName" // from PBD list

6) Use the Describe("DataWindow.Syntax") command to get the DWO source. It will locate it in the PBD!

7) Now you can write this DWO source to an Audit file or into an Audit DB for further analysis.

Tip: For a working example of these type of processing commands in use ... check out my SQLExtract utility ...

http://chrispollach.blogspot.com/2017/11/sqlx.html

HTH

Regards .... Chris

Comment
There are no comments made yet.
  1. Tuesday, 8 October 2019
  2. PowerBuilder
  3. # 7
Roland Smith Accepted Answer Pending Moderation
1
Votes
Undo

Assign the DataWindow object to a DW control and then do this:

ls_source = dw_1.Describe("DataWindow.Syntax")

Then add code to write the syntax to a .srd file.

The first line of the file will look like this:

$PBExportHeader$d_objectname.srd

Then write the contents of ls_source.

 

 

Comment
You could extract all the DataWindow objects if you wanted, using the LibraryDirectory function.



ls_entries = LibraryDirectory("taxreports.pbd", DirDataWindow!)



Then import ls_entries into a datastore that uses an external DW object with the columns:



objectname string(50)

modified datetime

comments string(500)



Loop through the rows and use object name to set the DataObject property of a control as well as for the file name of the output file.
  1. Roland Smith
  2. Tuesday, 8 October 2019
There are no comments made yet.
  1. Tuesday, 8 October 2019
  2. PowerBuilder
  3. # 8
  • Page :
  • 1


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