MyPage is a personalized page based on your interests.The page is customized to help you to find content that matters you the most.


I'm not curious

PowerBuilder Foundation Classes - Simple way to Create PowerBuilder Applications using PFC

Published on 28 October 16
2
1
1. We are going to create a simple powerbuilder application using PFC framework

2. Create a powerbuilder workspace and create a target.In my case (PBW is PFC_WorkSpace.pbw and PBT is pfcapp.pbt .the application name I used is pfcapp)

3. All all the PFC PBls to the target the target should look some thing like below . Here (C:\Users\Username\Desktop\PFC_Application) is the workspace path-

C:\Users\Username\Desktop\PFC_Application\pfcapp.pbl; C:\Users\Username\Desktop\PFC_Application\pfeapsrv.pbl; C:\Users\Username\Desktop\PFC_Application\pfedwsrv.pbl; C:\Users\Username\Desktop\PFC_Application\pfemain.pbl; C:\Users\Username\Desktop\PFC_Application\pfeutil.pbl; C:\Users\Username\Desktop\PFC_Application\pfewnsrv.pbl; C:\Users\Username\Desktop\PFC_Application\pfcapsrv.pbl; C:\Users\Username\Desktop\PFC_Application\pfcdwsrv.pbl; C:\Users\Username\Desktop\PFC_Application\pfcmain.pbl; C:\Users\Username\Desktop\PFC_Application\pfcutil.pbl; C:\Users\Username\Desktop\PFC_Application\pfcwnsrv.pbl;

apart form the pfcapp.pbl other are the PFC pbls

4. Now we need to set up the transaction ,sqlda,error,sqlsa,msg objects which our application uses . Double Click on the application object and select "Additional Properties" Under variable types set like below -

SQLCA - n_tr
SQLDA - n_dda
SQLSA - n_dsa
Error - n_err
Message - n_msg

5. If you are using an .ini file to get the login details, you need to setup that in the inherited application manager user object(will be discussed later below ).
Else double click on the n_tr user object under pfemain.pbl and then in of_init function you need to setup the database,server details like below -

// Profile EAS Demo DB V125
SQLCA.DBMS = "ODBC"
SQLCA.AutoCommit = False
SQLCA.DBParm = "ConnectString='DSN=EAS Demo DB V125;UID=dba;PWD=sql'"
return 1

You may use your own code according to the server type and the way how you are connecting to DB

Note : We are not going to write "Connect using SQLCA;" here.

6. Now inherit n_cst_appmanager userobject from pfeapsrv.pbl (as n_cst_pfc_appmanager) and save in the pbl that you created for the application (in my case pfcapp.pbl and i saved as n_cst_pfc_appmanager)

7. Double Click on the n_cst_pfc_appmanager and in the properties set up the inifile,logo,helpfiles,application version (if you are using these things else leave it blank). In my case I have used the above things and it should look like below -

PowerBuilder Foundation Classes - Simple way to Create PowerBuilder Applications using PFC - Image 1
8. Now double click the applicaiton object and create a global variable for the application manger user object like below -
n_cst_pfc_appmanager gnv_app
Under the application objects open event -

gnv_app = create n_cst_pfc_appmanager
gnv_app.Event pfc_open(commandline)

9. Now we are done with the set up of transaction object for our application also with the application manager. Now we are going to create a MDI application with two windows one as MDI window other is sheet which should display the customer details using a datawindow dw_cust(your choice) with a dataobject (d_cust) your choice.

a/ To create a main window inherit w_frame from pfemain.pbl and save(w_frame_window) in the library(pfemain.pbl)
b/ To Create a sheet window inherit w_Sheet from pfemain.pbl and save (w_sheet_customers) in the library(pfemain.pbl)

write the below code under pfc_open event of n_cst_pfc_appmanager to open frame window-

of_splash will display a splash window with the image file and version which you entered at the development of n_cst_pfc_appmanager

The integer will represent the number of seconds that you are going to show the splash window

this.of_splash( 1)
open(w_frame_window)

10. Now you need a menu for the frame window and for the sheet window . For that -

Inherit m_master(A standard menu. we are not going to use m_frame) from the pfewnsrv.pbl save(m_frame_menu) in your library. We are going to use the same menu for both MDI and Sheet windows in this particular application(you may change accordingly)

Add this menu to the m_frame_window

11/ In the frame window (w_frame_window) write the below codes for the events mentioned below -


pfc_open -

w_sheet ref_sheet
OpenSheet(ref_sheet, "w_sheet_customers", this, 0, Original!)

pfc_preopen -

this.of_SetSheetManager(true)
this.of_SetStatusBar(true)
this.inv_statusbar.of_SetTimer(true)

pfc_postopen -

// Here you will understand why we wrote code in the of_init in the n_tr

integer return_value
string my_ini
my_ini = gnv_app.of_GetAppIniFile()
if SQLCA.of_Init(my_ini, "Database") = -1 then
messagebox("Connecting to database"," Database initialization error" +my_ini)
halt close
end if
if SQLCA.of_Connect() = -1 then
messagebox("Connecting to database"," Cannot connect to database" +my_ini)
halt close
else
this.SetMicroHelp("Successfully connected to database")
end if

12/ Attach same menu fro the sheet window (w_sheet_customers)
13/ Create a dataobject of your own type (d_cust)

14/ Now we need a datawindow . For this -

a/ Insert --> Control --> UserObject and select u_dw under pfemain.pbl and place it on the sheet window
b/ add the dataobject to it (d_cust)

15/ write the below code in the constructor event of the datawindow
This.of_SetRowSelect(true)
This.of_SetRowManager(true)
This.of_SetSort(true)
This.of_SetProperty(true)
This.of_SetTransObject(SQLCA)
this.inv_rowselect.of_SetStyle(dw_1.inv_rowselect.EXTENDED)
this.inv_sort.of_SetStyle(dw_1.inv_sort.DRAGDROP)
this.inv_sort.of_SetColumnHeader(true)
if this.of_Retrieve() = -1 then
SQLCA.of_Rollback()
messagebox("Error", "Cannot retrieve records")
else
SQLCA.of_Commit()
this.SetFocus()
end if
16/ Fine. But where we are retrieving the datawindow ? Write the below code under the of_retrieve() function of the u_dw user object
Return this.retrieve()
Thats all . You should be able to run the application with out any issues.
You may change the menu option name to customers for m_frame_menu-->File-->Open like below -

PowerBuilder Foundation Classes - Simple way to Create PowerBuilder Applications using PFC - Image 2
// When I ran my application the output was like below -
PowerBuilder Foundation Classes - Simple way to Create PowerBuilder Applications using PFC - Image 3
//File-->Customers in Framewindow
PowerBuilder Foundation Classes - Simple way to Create PowerBuilder Applications using PFC - Image 4
PowerBuilder Foundation Classes - Simple way to Create PowerBuilder Applications using PFC - Image 5
This blog is listed under Development & Implementations Community

View Comments (2)
Post a Comment

Please notify me the replies via email.

Important:
  • We hope the conversations that take place on MyTechLogy.com will be constructive and thought-provoking.
  • To ensure the quality of the discussion, our moderators may review/edit the comments for clarity and relevance.
  • Comments that are promotional, mean-spirited, or off-topic may be deleted per the moderators' judgment.
  1. 09 December 20
    0

    you need to inherit the datawindow from u_dw..for more information check the below link - https://stackoverflow.com/questions/4715130/powerbuilder-how-do-i-keyword-search-a-drop-down-list

  2. 08 December 20
    0

    Hi, I am new to PFC. I added all PFC related PBLs into the library list. However I get the following error when i try to script dw_1.of_SetDropDownSearch(TRUE) - 'unknown function name - of_setdropdownsearch'. I have done all the steps until 'gnv_app.Event pfc_open(commandline)' that is mentioned in this article. Any suggestions would be appreciated. Regards

You may also be interested in
 
Awards & Accolades for MyTechLogy
Winner of
REDHERRING
Top 100 Asia
Finalist at SiTF Awards 2014 under the category Best Social & Community Product
Finalist at HR Vendor of the Year 2015 Awards under the category Best Learning Management System
Finalist at HR Vendor of the Year 2015 Awards under the category Best Talent Management Software
Hidden Image Url

Back to Top