PB dynamic report format free definition implementation

xiaoxiao2021-03-06  74

In the usual server / client method MIS development, there is always an endless report that requires production, and the time to debug report is also the most, and it is often not able to meet the customer's requirements. If you can adjust the format and content of the report yourself, then save it, how good it automatically calls saved report formats when you start it. I finally realized the requirements by the following methods. PB (PowerBuilder) has a specially saved report format (referred to as a PSR file) with a special preservation report ending at PSR. According to the data window, you can directly read the principle of the PSR file generation report, and the program is saved by generating a PSR file to implement a dynamic report format. I. Realization Principle: The report in the PB is actually equivalent to the data window. The first step, the implementation of dynamic reports. By setting the data window object (DataObject) in the Data Window Object (Data Summary ", the object location is realized, and the object value is changed (including addition and deletion) through the MODIFY function of the data window. The second step, the preservation of the report format. In an application, the name of the data window object is always unique, and each data window object is converted into a PSR file in the database table. When the window is open, the program is presented before the report format is present. If there is, first read the report format in a temporary file, then set the data object (DataWindow) of the data object (DataObject) for this report file, then extract the data; if you do not exist, directly extract the data directly. Second, the implementation process: 1. Create a database table to save the report format file.

Table Name: DYN_REPORT DWOBJECTVARCHAR2 (20) Data Window Object Name Primary Key RptitleVarchar2 (80) Title Name Memolong Raw Report Format

2. Create a window W_TEMP. Define instance variables as follows: string is_dwtype, is_dwobject // Save the type and name of the object in the report

Control Name Control Meaning DW_PRINT Data Window Object CB_EXIT Exit button CB_SAVEREPORT Report Format Save button

3. Add the following code in the OPEN event of the window, and the check report format exists if there is a read definition report format to the data window.

blob emp_pic long ll_handle string ls_dwobject, ls_reportfile, ls_path ls_dwobject = dw_print.dataobject // report format select count is determined whether the data window is present (*) into: ll_count from dyn_report where dwobject =: ls_dwobject; if ll_count> 0 then // read take the report format files to large text variable selectblob memo into: emp_pic from dyn_report where dwobject =: ls_dwobject; // create temporary files to the hard disk psr ls_reportfile = '/temp7089.psr' ll_handle = FileOpen (is_reportfile, StreamMode, write, LockWrite!! !, Replace!) FileWrite (ll_handle, emp_pic) FileClose (ll_handle) dw_print.dataobject = ls_reportfile dw_print.settransobject (sqlca) else Dw_print.settransobject (sqlca) End if Dw_print.retrieve () 4, the report format to save. The Clicked implementation via the CB_SAVEREPORT button. string ls_filename long ll_count blob Emp_id_pic ls_filename = "temp70201.psr" // save the report format to your hard disk temporary files dw_print.saveas (ls_filename, PSReport, false!) sqlca.autocommit = true select count (*) into: ll_count from dyn_report where dwobject =: is_dwobject; if ll_count = 0 then insert into dyn_report (dwobject, rptitle) values ​​(: is_dwobject,: ls_filename,: ls_path); end if // read the data stored in the database table in the temporary file from the hard disk emp_id_pic = of_readbmpfile (ls_filename ) // This function reads the contents of the binary file to the big text object // updates the database UpdateBlob Dyn_Report Set Memo =: EMP_ID_PIC WHERE DWOBJECT =: is_dwObject; Sqlca.autocommit = false5, dynamic report implementation. Capture the object in the data window through the CLICKED event of Data Window DW_PRINT, and store the object name in the implementation variable is_dwobject, and prepare for the next step by step.

string ls_type, ls_dwoname // get object type and name ls_type = trim (upper (dwo.type)) ls_dwoname = trim (dwo.name) is_dwtype = ls_type choose case ls_type case "TEXT", "CommandButton", "GROUPBOX" is_dwobject = Ls_dwoname // is set to drag and change the size, other classes with this.modify (ls_dwoname ". resizeable = '" "1') this.modify (ls_dwoname ". Moveable = " " 1 ") case" line "// linear object can not be provided by Resizeable and moveable to adjust properties, must is_dwobject = ls_dwoname case through other paths" RECTANGLE "," ELLIPSE "," GRAPH "," BITMAP "is_dwobject = ls_dwoname this.modify (ls_dwoname ". Resizeable = '" " 1' "this.modify (ls_dwoname ". Moveable = '" " "color", "compute" is_dwobject = ls_dwoname this.modify (ls_dwoname ". Resizeable ='" "1 '") This.Modify (Ls_dwoname ") End Choose then can achieve basic dynamic report operations through the modify () function, there are many articles in this class, there is also a lot of PB Examples can be used directly, this is no longer described. 6. Add: Close (PARENT) in the CLICKED () event of the CB_EXIT button. 7. Add: Open (w_temp) in the OPEN event applied. Then save and run, big success! 8, this program is debugged at PB7.0 plus Oracle8.05.

转载请注明原文地址:https://www.9cbs.com/read-120704.html

New Post(0)