How can integrate .w program into mfg/pro?

sphipp

Member
If you have a .w program that you need to integrate into QAD, the easiest way to do it is:
1. Compile the program into the relevant QAD Directory.
2. Either add the program into a menu using 36.4.4 or run it directly from the menu by typing in the program name.

That's it, really.

In QAD Character, the compiled code is stored in a directory under the language directory that is the first 2 characters of the program. So, if you use English (us) and your program is myprogram.w then you would compile it into us/my/ giving you a program us/my/myprogram.r.

Desktop and GUI will be different, of course.

You have to make sure that the program you are using does not have the same name as an existing QAD program and that it compiles properly. It's also best to use the QAD includes, if you have them, so that it looks like a QAD program.

Of course, if you wanted to really reflect QAD's Programming Style, you'd have to have one program that calls 20 others do do a single task. :)
 
Hi sphipp,

The first I compile my program (.w) with QAD character and then I added into QAD with menu 36.4.4 But when I run NetUi I dont see my program(just add before). Do you know why?

thank in advance!
 
Hi sphipp,

When I run .w program on Desktop the error issue "Unable to set com-handle property. (5677)", How to fix this error? Plz help me

Thank in advance!
 

sphipp

Member
It sounds as though you have written a program using Appbuilder that you want to run against the MFG/PRO database.

You don't seem to need this on a menu as part of the standard MFG/PRO system.

This is fairly straightforward.

If you compile the program you have written then you should be able to run it from a shortcut on the Desktop. Don't forget you have to connect to the database using -N -H -S parameters and this may have licensing ramifications.

As for the problem with the com-handle, it could be for various reasons. What com-handle are you using? Is it in the PROPATH? Sometimes you have to set the Startup Directory in your shortcut to be the source-code/compiled-code directory.

What are you trying to do? An error message of "Unable to set com-handle property. (5677)" is about as useful as the old "Syntax Error". If you can post some code samples, that might help.
 
Hi Sphipp, Happy New Year!
If you compile the program you have written then you should be able to run it from a shortcut on the Desktop. Don't forget you have to connect to the database using -N -H -S parameters and this may have licensing ramifications.
Your mean i have to create ODBC connection? this is my code
/* KSV Editor Copyright: (C) 2000-2006 Serguey Klimoff (bulklodd) Filename: TEST.P Comment: Parameters: Uses: Used by: Created: 01.03.2007 12:19 ADMINIST Modified: 01.03.2007 12:19 ADMINIST */ &ANALYZE-SUSPEND _VERSION-NUMBER AB_v10r12 GUI ADM2 &ANALYZE-RESUME &Scoped-define WINDOW-NAME wWin {adecomm/appserv.i} &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS wWin /*------------------------------------------------------------------------ File: Description: from cntnrwin.w - ADM SmartWindow Template Input Parameters: Output Parameters: History: New V9 Version - January 15, 1998 ------------------------------------------------------------------------*/ /* This .W file was created with the Progress AB. */ /*----------------------------------------------------------------------*/ /* Create an unnamed pool to store all the widgets created by this procedure. This is a good default which assures that this procedure's triggers and internal procedures will execute in this procedure's storage, and that proper cleanup will occur on deletion of the procedure. */ CREATE WIDGET-POOL. /* *************************** Definitions ************************** */ /* Parameters Definitions --- */ /* Local Variable Definitions --- */ {src/adm2/widgetprto.i} /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME &ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK /* ******************** Preprocessor Definitions ******************** */ &Scoped-define PROCEDURE-TYPE SmartWindow &Scoped-define DB-AWARE no &Scoped-define ADM-CONTAINER WINDOW &Scoped-define ADM-SUPPORTED-LINKS Data-Target,Data-Source,Page-Target,Update-Source,Update-Target,Filter-target,Filter-Source /* Name of designated FRAME-NAME and/or first browse and/or first query */ &Scoped-define FRAME-NAME fMain /* Custom List Definitions */ /* List-1,List-2,List-3,List-4,List-5,List-6 */ /* _UIB-PREPROCESSOR-BLOCK-END */ &ANALYZE-RESUME /* *********************** Control Definitions ********************** */ /* Define the widget handle for the window */ DEFINE VAR wWin AS WIDGET-HANDLE NO-UNDO. /* Definitions of handles for OCX Containers */ DEFINE VARIABLE CtrlFrame AS WIDGET-HANDLE NO-UNDO. DEFINE VARIABLE chCtrlFrame AS COMPONENT-HANDLE NO-UNDO. /* ************************ Frame Definitions *********************** */ DEFINE FRAME fMain WITH 1 DOWN NO-BOX KEEP-TAB-ORDER OVERLAY SIDE-LABELS NO-UNDERLINE THREE-D AT COL 1 ROW 1 SIZE 176.6 BY 28.62 WIDGET-ID 100. /* *********************** Procedure Settings ************************ */ &ANALYZE-SUSPEND _PROCEDURE-SETTINGS /* Settings for THIS-PROCEDURE Type: SmartWindow Allow: Basic,Browse,DB-Fields,Query,Smart,Window Container Links: Data-Target,Data-Source,Page-Target,Update-Source,Update-Target,Filter-target,Filter-Source Other Settings: APPSERVER */ &ANALYZE-RESUME _END-PROCEDURE-SETTINGS /* ************************* Create Window ************************** */ &ANALYZE-SUSPEND _CREATE-WINDOW IF SESSION:DISPLAY-TYPE = "GUI":U THEN CREATE WINDOW wWin ASSIGN HIDDEN = YES TITLE = "Report Preview" HEIGHT = 28.62 WIDTH = 176.6 MAX-HEIGHT = 28.81 MAX-WIDTH = 178.2 VIRTUAL-HEIGHT = 28.81 VIRTUAL-WIDTH = 178.2 RESIZE = no SCROLL-BARS = no STATUS-AREA = no BGCOLOR = ? FGCOLOR = ? THREE-D = yes MESSAGE-AREA = no SENSITIVE = yes. ELSE {&WINDOW-NAME} = CURRENT-WINDOW. /* END WINDOW DEFINITION */ &ANALYZE-RESUME &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _INCLUDED-LIB wWin /* ************************* Included-Libraries *********************** */ {src/adm2/containr.i} /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME /* *********** Runtime Attributes and AppBuilder Settings *********** */ &ANALYZE-SUSPEND _RUN-TIME-ATTRIBUTES /* SETTINGS FOR WINDOW wWin VISIBLE,,RUN-PERSISTENT */ /* SETTINGS FOR FRAME fMain FRAME-NAME */ IF SESSION:DISPLAY-TYPE = "GUI":U AND VALID-HANDLE(wWin) THEN wWin:HIDDEN = yes. /* _RUN-TIME-ATTRIBUTES-END */ &ANALYZE-RESUME /* ********************** Create OCX Containers ********************** */ &ANALYZE-SUSPEND _CREATE-DYNAMIC &IF "{&OPSYS}" = "WIN32":U AND "{&WINDOW-SYSTEM}" NE "TTY":U &THEN CREATE CONTROL-FRAME CtrlFrame ASSIGN FRAME = FRAME fMain:HANDLE ROW = 1.24 COLUMN = 2 HEIGHT = 28.33 WIDTH = 174 WIDGET-ID = 2 HIDDEN = no SENSITIVE = yes. PROCEDURE adm-create-controls: CtrlFrame:NAME = "CtrlFrame":U . /* CtrlFrame OCXINFO:CREATE-CONTROL from: {460324E8-CFB4-4357-85EF-CE3EBFE23A62} type: CrystalActiveXReportViewer */ END PROCEDURE. &ENDIF &ANALYZE-RESUME /* End of _CREATE-DYNAMIC */ /* ************************ Control Triggers ************************ */ &Scoped-define SELF-NAME wWin &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL wWin wWin ON END-ERROR OF wWin /* Report Preview */ OR ENDKEY OF {&WINDOW-NAME} ANYWHERE DO: /* This case occurs when the user presses the "Esc" key. In a persistently run window, just ignore this. If we did not, the application would exit. */ IF THIS-PROCEDURE:pERSISTENT THEN RETURN NO-APPLY. END. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL wWin wWin ON WINDOW-CLOSE OF wWin /* Report Preview */ DO: /* This ADM code must be left here in order for the SmartWindow and its descendents to terminate properly on exit. */ APPLY "CLOSE":U TO THIS-PROCEDURE. RETURN NO-APPLY. END. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME &UNDEFINE SELF-NAME &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK wWin /* *************************** Main Block *************************** */ /* Include custom Main Block code for SmartWindows. */ {src/adm2/windowmn.i} run viewreport. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME /* ********************** Internal Procedures *********************** */ &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE adm-create-objects wWin _ADM-CREATE-OBJECTS PROCEDURE adm-create-objects : /*------------------------------------------------------------------------------ Purpose: Create handles for all SmartObjects used in this procedure. After SmartObjects are initialized, then SmartLinks are added. Parameters: ------------------------------------------------------------------------------*/ END PROCEDURE. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE control_load wWin _CONTROL-LOAD PROCEDURE control_load : /*------------------------------------------------------------------------------ Purpose: Load the OCXs Parameters: Notes: Here we load, initialize and make visible the OCXs in the interface. ------------------------------------------------------------------------------*/ &IF "{&OPSYS}" = "WIN32":U AND "{&WINDOW-SYSTEM}" NE "TTY":U &THEN DEFINE VARIABLE UIB_S AS LOGICAL NO-UNDO. DEFINE VARIABLE OCXFile AS CHARACTER NO-UNDO. OCXFile = SEARCH( "wwin.wrx":U ). IF OCXFile = ? THEN OCXFile = SEARCH(SUBSTRING(THIS-PROCEDURE:FILE-NAME, 1, R-INDEX(THIS-PROCEDURE:FILE-NAME, ".":U), "CHARACTER":U) + "wrx":U). IF OCXFile ? THEN DO: ASSIGN chCtrlFrame = CtrlFrame:COM-HANDLE UIB_S = chCtrlFrame:LoadControls( OCXFile, "CtrlFrame":U) . RUN initialize-controls IN THIS-PROCEDURE NO-ERROR. END. ELSE MESSAGE "wwin.wrx":U SKIP(1) "The binary control file could not be found. The controls cannot be loaded." VIEW-AS ALERT-BOX TITLE "Controls Not Loaded". &ENDIF END PROCEDURE. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE disable_UI wWin _DEFAULT-DISABLE PROCEDURE disable_UI : /*------------------------------------------------------------------------------ Purpose: DISABLE the User Interface Parameters: Notes: Here we clean-up the user-interface by deleting dynamic widgets we have created and/or hide frames. This procedure is usually called when we are ready to "clean-up" after running. ------------------------------------------------------------------------------*/ /* Delete the WINDOW we created */ IF SESSION:DISPLAY-TYPE = "GUI":U AND VALID-HANDLE(wWin) THEN DELETE WIDGET wWin. IF THIS-PROCEDURE:pERSISTENT THEN DELETE PROCEDURE THIS-PROCEDURE. END PROCEDURE. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE enable_UI wWin _DEFAULT-ENABLE PROCEDURE enable_UI : /*------------------------------------------------------------------------------ Purpose: ENABLE the User Interface Parameters: Notes: Here we display/view/enable the widgets in the user-interface. In addition, OPEN all queries associated with each FRAME and BROWSE. These statements here are based on the "Other Settings" section of the widget Property Sheets. ------------------------------------------------------------------------------*/ VIEW FRAME fMain IN WINDOW wWin. {&OPEN-BROWSERS-IN-QUERY-fMain} VIEW wWin. END PROCEDURE. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE exitObject wWin PROCEDURE exitObject : /*------------------------------------------------------------------------------ Purpose: Window-specific override of this procedure which destroys its contents and itself. Notes: ------------------------------------------------------------------------------*/ APPLY "CLOSE":U TO THIS-PROCEDURE. RETURN. END PROCEDURE. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE viewreport wWin PROCEDURE viewreport : /*------------------------------------------------------------------------------ Purpose: Parameters: Notes: ------------------------------------------------------------------------------*/ DEFINE VARIABLE chApplication AS COM-HANDLE NO-UNDO. DEFINE VARIABLE chReport AS COM-HANDLE NO-UNDO. DEFINE VARIABLE chConnProps AS COM-HANDLE NO-UNDO. CREATE 'CrystalRuntime.Application' chApplication. CREATE 'CrystalRuntime.Report' chReport. /* Insert full path to the Crystal report */ chReport = chApplication:OpenReport("e:\test\Test.rpt"). /* Set the Connection Info to Connection Properties of the table object */ chConnProps = chReport:Database:Tables(1):ConnectionProperties. /* Clear the ConnectionProperties collection */ chConnProps:DeleteAll. Add the ODBC DSN chConnProps:ADD("DSN", "fov"). /* Add the database level User ID if required */ chConnProps:ADD("sysprogress", "fov"). /* Add the database level password if required */ chConnProps:ADD("fov", "fov"). /* Use either of the following statements to override the Catalog name if the report has been created using OpenEdge 10.1B or later - see P122620 for more information*/ /* chReport:Database:Tables(1):Location = "". */ /* chReport:Database:Tables(1):SetTableLocation("","",""). */ /* Example of some adjustable parameters */ chCtrlFrame:CrystalActiveXReportViewer:EnableNavigationControls = TRUE. /* Enables the CRViewer's Navigation Controls */ chCtrlFrame:CrystalActiveXReportViewer:EnableExportButton = TRUE. /* Enables the CRViewer's Export button */ chCtrlFrame:CrystalActiveXReportViewer:EnableSearchControl = FALSE. /* Disables the CRViewer's Search control */ /* Set the report source */ chCtrlFrame:CrystalActiveXReportViewer:ReportSource = chReport. /* View the report */ chCtrlFrame:CrystalActiveXReportViewer:ViewReport(). RELEASE OBJECT chConnProps. RELEASE OBJECT chReport. RELEASE OBJECT chApplication. ASSIGN chConnProps = ? chReport = ? chApplication = ?. END PROCEDURE. /* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME
thank you in advance!
 

sphipp

Member
Oh, how I hate AppBuilder code ......

You are using Crystal Reports and that is what is causing the COM-HANDLE error.

What I would do, to start off with, is identify exactly where in your code the error happens.

I do not use Crystal Reports, so I have no experience with that particularly, but generally when using COM-HANDLEs that are playing up I do the following.

Before each place where you refer to a COM-HANDLE put in a simple debug message. If you want, put this in a procedure to make the code easier, but it doesn't really matter.

So, define a procedure p_debug as below, then in your code before each and every use of the com-handle, put in a line calling p_debug.

Code:
DEFINE VARIABLE chApplication AS COM-HANDLE NO-UNDO. 
DEFINE VARIABLE chReport AS COM-HANDLE NO-UNDO. 
DEFINE VARIABLE chConnProps AS COM-HANDLE NO-UNDO. 
run p_debug ("Create Application").
CREATE 'CrystalRuntime.Application' chApplication. 
run p_debug ("Create Report").
CREATE 'CrystalRuntime.Report' chReport. /* Insert full path to the Crystal report */ 
run p_debug ("Open Report").
chReport = chApplication:OpenReport("e:\test\Test.rpt"). 
/* Set the Connection Info to Connection Properties of the table object */ 
run p_debug ("Connection Properties").
chConnProps = chReportatabase:Tables(1):ConnectionProperties. 
/* Clear the ConnectionProperties collection */ 
chConnPropseleteAll. Add the ODBC DSN 
 
run p_debug ("Add DSN FOV").
chConnProps:ADD("DSN", "fov"). 
/* Add the database level User ID if required */ 
run p_debug ("ADD sysprogress FOV").
chConnProps:ADD("sysprogress", "fov"). 
/* Add the database level password if required */ 
run p_debug ("ADD fov fov").
chConnProps:ADD("fov", "fov"). /* Use either of the following statements to override the Catalog name if the report has been created using OpenEdge 10.1B or later - see P122620 for more information*/ 
/* chReportatabase:Tables(1):Location = "". */ 
/* chReportatabase:Tables(1):SetTableLocation("","",""). */ 
/* Example of some adjustable parameters */ 
run p_debug ("Enable Navigation Controls").
chCtrlFrame:CrystalActiveXReportViewer:EnableNavigationControls = TRUE. 
/* Enables the CRViewer's Navigation Controls */ 
run p_debug ("Enable Export Button").
chCtrlFrame:CrystalActiveXReportViewer:EnableExportButton = TRUE. 
/* Enables the CRViewer's Export button */ 
run p_debug ("Enable Search Control").
chCtrlFrame:CrystalActiveXReportViewer:EnableSearchControl = FALSE. 
/* Disables the CRViewer's Search control */ /* Set the report source */ 
run p_debug ("Report Source").
chCtrlFrame:CrystalActiveXReportViewer:ReportSource = chReport. 
/* View the report */ 
run p_debug ("View Report").
chCtrlFrame:CrystalActiveXReportViewer:ViewReport(). 
run p_debug ("Release Objects").
RELEASE OBJECT chConnProps. 
RELEASE OBJECT chReport. 
RELEASE OBJECT chApplication. 
ASSIGN 
chConnProps = ? 
chReport = ? 
chApplication = ?. 
END PROCEDURE. 
/* _UIB-CODE-BLOCK-END */ &ANALYZE-RESUME 
 
procedure p_debug:
def input param inp_message as char no-undo.
message inp_message view-as alert-box.
end procedure.

When you run the program, you should get a load of really annoying pop-up alert-boxes. Don't rush through them, instead slowly click OK, making note of which ones you have encountered. Sooner or later, you will get a COM-HANDLE error after one message. This will tell you where the error has occured.

Once you know where the error is happening, you can try and find out why the error is happening. Try commenting out the line that causes the error and see if this generates another error. Try checking the syntax against a working example and seeing if there are any differences.

It's a bit vague, I know, but it should help you find out where the error is.

MESSAGE VIEW-AS ALERT-BOX is the programmer's friend. It's the best debugging tool I know.
 
Hi Sphipp,

Thank you for your advance,

My program run Okie with .p or .r file (not integrate QAD system) but when I integrate into QAD system the old error "Unable to set com-handle property. (5677)" still occur (I run my program with QAD Desktop), Do you have any way to help me this problem (My customer require run into QAD system :eek:)

Thank inadvance!
 

sphipp

Member
Did you try putting the debug messages in?

Crystal Reports uses COM-HANDLES to connect to databases and run reports.

Your problem is with the Crystal Reports calls.

You need to identify where the problems are happening.

Once you know where the problem is happening, you can then try and solve it.
 
Hi Sphipp,

I putted the debug message, The report runs till "Enable Navigation Controls" and then issue that error, but I dont know how to find out the reason and fix it :(, do you have any ideas?

thank you in advance!
 

sphipp

Member
I've never used Crystal Reports - all my reporting has been Progress-coded.

Why don't you post the code on the API sub-forum, say you've identified where the error is occuring but don't know how to solve it.

I don't know how many of the API/Crystal Reports experts read the MFG/PRO forum - I know I didn't until I started working with MFG/PRO.
 

sphipp

Member
As a matter of interest, have you checked that the Control Frame is being set properly?

It might be worth putting in another couple of alert-boxes to check that.

MESSAGE VALID-HANDLE (chCtrlFrame) VIEW-AS ALERT-BOX might work. Also, put in an alert-box just before you set chCtrlFrame and just after it. That way, you can tell if you set the com-handle at all.

It may be that the logic of your program doesn't actually set chCtrlFrame as a com-handle, in which case when chCtrlFrame is being used you would get the error message described.
 
Hi Sphipp,
" MESSAGE VALID-HANDLE (chCtrlFrame) VIEW-AS ALERT-BOX" return yes when I run .p file but i compile into mfg/pro it returns no and issue error, what do you think about this?

Thank you for your help!
 

lord_icon

Member
I used to use a UIB created .w when working with MFG/PRO.
You require to goto menu option 36.4.4 and point an entry to your appbuilder .w file. However you require a simple line of code in your GUI created .w,
{mfdtitle.i}
You require the MFG/PRO declerations. A .w requires a seperate session. MFG/PRO has focus, controling win32, this is a work around I used.
 
Hi lord_icon,

I added {mfdtitle.i} before my code but nothing to change :(, do you have any experience to share with me plz, iam facing with this problem. Can you share some code about .w program and apply into MFG/PRO? What environment you use in MFG/PRO NetUI, Desktop or Character?
I add a function into mfg/pro by menu 36.4.4 and set website option with type is Desktop (default is Terminal) by menu 36.3.21.1.

I add debug procedure in my program and there is the difference between run .p file and compile function in mfg/pro
This is a message when i run .p file (press F2)
hdl1.jpg


and this is a message when i compile program in mfg/pro(QAD character)

hdl2.jpg


error.jpg

Thank in advance!
 

sphipp

Member
I see you've posted the question in the API section as well. Maybe that will help.

Have you tried looking where the chCtrlFrame is set up?

I'd check when you call the following section:

OCXFile = SEARCH( "wwin.wrx":U ).
IF OCXFile = ? THEN
OCXFile = SEARCH(SUBSTRING(THIS-PROCEDURE:FILE-NAME, 1, R-INDEX(THIS-PROCEDURE:FILE-NAME, ".":U), "CHARACTER":U) + "wrx":U).
IF OCXFile <> ? THEN DO:
ASSIGN chCtrlFrame = CtrlFrame:COM-HANDLE
UIB_S = chCtrlFrame:LoadControls( OCXFile, "CtrlFrame":U) .
RUN initialize-controls IN THIS-PROCEDURE NO-ERROR.
END.
ELSE MESSAGE
"wwin.wrx":U SKIP(1)
"The binary control file could not be found. The controls cannot be loaded."
VIEW-AS ALERT-BOX TITLE "Controls Not Loaded".

Put some debug messages so that you know that the OCXFile is valid, that the chCtrlFrame is valid and that it is called in the right place, ie before the other Crystal Reports calls.

What you really want to see is that the program initialises chCtrlFrame first then makes the other calls.

It;s worth looking at the following section of code as well:
&IF "{&OPSYS}" = "WIN32":U AND "{&WINDOW-SYSTEM}" NE "TTY":U

You are only setting up the chCtrlFrame when you are not running a Character session. Put in a MESSAGE "{&WINDOW-SYSTEM}" VIEW-AS ALERT-BOX somewhere to check.

It looks now that the reason the program works in GUI but not in Character is that you are specifically telling it to set the chCtrlFrame in GUI but not in Character. The code should work in Windows Character without a problem so perhaps you should be checking for the Operating System rather than the window-system.
 
Top