Sample Reform Shortcut Script - Support

Sample Reform Shortcut Script

From Support

Jump to: navigation, search

Listed below is a sample database script for use with Reform and the Shortcut Plugin to allow users to look up information in an ODBC database and return the data to a selected Reform data field.

'---------------------------------------------------------
'-- Set up key value to look for
'---------------------------------------------------------
sLookupCustomer = "839283"
sRtnCustomer = ""
'---------------------------------------------------------
'-- Set up for Client Access/400 ODBC Data Source
'-- Must create an ODBC data source for the AS/400 system
'-- S10571ZM first by running ODBCAD32.EXE from Start/Run
'---------------------------------------------------------
cDBCONN = "DSN=S10571ZM;UID=;PWD=;"
'---------------------------------------------------------
'-- Run SQL Select on Table to select single matching record
'-- from the customer database QCUSTCDT in library QIWS
'---------------------------------------------------------
cSQL = "SELECT * FROM qiws.qcustcdt where CUSNUM =" + Str(sLookupCustomer)
'---------------------------------------------------------
'-- Try to open the database via the selected ODBC data source
'-- or ADO connection string
'---------------------------------------------------------
lDbHand = DBOPEN(cDBCONN)
'---------------------------------------------------------
'-- Now execute the SQL record selection command to find
'-- the record we need from the customer file
'---------------------------------------------------------
IF DBEXECUTE(lDbHand, cSQL) > 0 
    'Record found. Assign the value in the database to the return field
    sRtnCustomer = str(DBGET(lDbHand, "CUSNUM"))
Else 
	  'Record not found
    sRtnCustomer = "Not Found"
ENDIF
'---------------------------------------------------------
'-- Close the ODBC database table
'---------------------------------------------------------
DBCLOSE(lDbHand)


Personal tools