| By Deanne M. Chance | Article Rating: |
|
| December 26, 2005 01:30 PM EST | Reads: |
19,361 |
Step 5: Connect to your database
In the open event of the application object, connect to your database and open your main window:
SQLCA.DBMS='odb'
SQLCA.DBPARM="ConnectString='DSN=blwmed;UID=dba;PWD=sql'"
CONNECT USING SQLCA;
If SQLCA.SQLCODE <> 0 then
Messagebox("Connect Error", SQLCA.SQLErrText)
Halt Close
End If
Open(w_main)
Step 6: Write code to initialize the bar code scanner
PocketBuilder has native hardware support for the PPT8800 called SymbolBarCodeScanner. Drop one in on your main window and call it bar_code.
Add your initialization code to a ue_postopen event:
bar_code.Open()
bar_code.ScanNoWait()
Step 7: Create a GUI
Note: The information that is retrieved when you scan a bar code is typically the SKU. The title, author, and quantity are retrieved from the database using the SKU as a key. Though not technically necessary (we really only need SKU and quantity to perform the update), it's a nice touch for the user. It is populated in the cb_ok clicked event as part of processing the SKU (See Figure 4).
Step 8: Code for the ScanTriggered event
Notice, we must specifically state what field we want to put the scanned data into. This is not the case with the Y cable scanners you might have seen at POS stations. These typically emulate the keyboard so it is possible to scan into any text field without further coding. This is not the case with the Symbol.
int iRet
string stmp
iRet = This.RetrieveData()
If iRet = 1 Then
stmp = This.ScannedData
sle_sku.Text = stmp
cb_ok.TriggerEvent('clicked')
End If
iRet = This.ScanNoWait()
Step 9: Process the scanned data in the clicked event of CB_OK
Step 10: Cleanup
String ls_text
Integer li_scanned
Datastore lds_Item
Long ll_rowcount
ls_Text = Upper(Trim(sle_sku.text))
li_scanned = Integer(sle_scanned.Text)
lds_Item = CREATE datastore
lds_Item.dataobject = 'd_inventory'
lds_Item.SetTransObject(SQLCA)
ll_RowCount = lds_Item.Retrieve(ls_Text)
If ll_RowCount <= 0 Then
MessageBox(is_ModuleName, 'Item Not Found')
sle_sku.text = ''
Return 1
End If
st_title.text = lds_Item.GetItemString(1, 'in_title')
st_author.text = lds_Item.GetItemString(1, 'in_author')
st_qty.text = String(lds_Item.GetItemNumber
(1, 'in_qty_onhand')+ li_scanned)
UPDATE "group1"."inventory_tb"
SET "in_qty_onhand" = "in_qty_onhand" + :li_scanned
WHERE "group1"."inventory_tb"."in_isbn" = :ls_text;
If SQLCA.SQLCode <> 0 Then
MessageBox(is_ModuleName, SQLCA.SQLErrText)
Return -1
Else
COMMIT;
End If
DESTROY lds_item
Return 1
In the close event of the main window, release the bar code scanner object:
bar_code.Close()
In the close event of the application object, disconnect from your database:
DISCONNECT USING SQLCA;
Simple. We're done.
Wondering how to learn more? Check out the following links. One of particular interest to the SymbolBarcodeObject is the mobility kit. Here you can find just about anything you want to do with bar codes. These would be implemented as external function calls in PocketBuilder. If you are looking for examples, see Reed Shilt's original implementation of the SymbolBarcodeObject on CodeExchange. Note: Most of these require a handle to the bar code object. This can be obtained by using the DeviceHandle() method.
Resources
- PocketBuilder code examples: http://pocketpb.codexchange.sybase.com/
- PocketBuilder newsgroup: www.sybase.com/developer/newsgroups
- Symbol Mobility Developer Kits: http://devzone.symbol.com/
Published December 26, 2005 Reads 19,361
Copyright © 2005 SYS-CON Media, Inc. — All Rights Reserved.
Syndicated stories and blog feeds, all rights reserved by the author.
More Stories By Deanne M. Chance
Ms. Chance graduated in 1996 with a degree in computer science from the University of Illinois. She has been a frequent contributor to the PowerBuilder Developer's Journal and gave a key presentation at Sybase TechWave 2005 entitled "A Real-Time Physical Inventory Solution Using PocketBuilder ASA and a WiFi Connection." She has held several engineering positions, starting a career at Motorola where she focused on mobile I.P. by doing real-time embedded programming for the base radio controller group as part of the iDEN/Nextel project.
![]() |
SYS-CON Australia News Desk 12/26/05 02:44:00 PM EST | |||
Why do a physical inventory? A physical inventory count is necessary to reconcile the quantity on hand stored in a database versus what is really on the shelf. In a retail environment, this process is typically done once a year. In a perfect world, these values would always be in sync. |
||||
![]() |
Chance 11/28/05 11:46:24 AM EST | |||
Pardon me I meant to say PocketBuilder, not Powerbuilder! |
||||
![]() |
Chance 11/28/05 11:44:47 AM EST | |||
One other note, I make a reference to using the DeviceHandle() method to get an instance handle to the barcode object. Although this is valid for version 1.5x in later versions of Powerbuilder it has been changed to the read only property DeviceHandle |
||||
![]() |
Chance 11/28/05 09:00:02 AM EST | |||
Hi this is Chance. I noticed the author of this article is Ch Chance. This is somewhat amusing as I use to suffer from a serious stuttering problem. However, no more. So, I was wondering could you change that to Written by: Chance |
||||
- Why SOA Needs Cloud Computing - Part 1
- Cloud Expo and The End of Tech Recession
- The Transition to Cloud Computing: What Does It Mean For You?
- A Rules Engine Built in PowerBuilder
- Sybase Named “Silver Sponsor” of iPhone Developer Summit
- How PowerBuilder Got Its Groove Back
- The Cloud Has Cross-Border Ambitions
- Ulitzer Named "New Media" Partner of Greatly Anticipated iStrategy Event in Berlin
- Risks and Enterprise Mobility?
- Steps for Success in Enterprise Mobility?
- Are Mobile Luddites Resisting Mobility?
- Hot Event in Santa Clara Becomes Cool with the iPhone
- The Difference Between Web Hosting and Cloud Computing
- Sybase CTO to Speak at 4th International Cloud Computing Expo
- Why SOA Needs Cloud Computing - Part 1
- Cloud Expo and The End of Tech Recession
- The Transition to Cloud Computing: What Does It Mean For You?
- Five Reasons to Choose a Private Cloud
- Seeding The Cloud: The Future of Data Management
- The Threat Behind the Firewall
- Economy Drives Adoption of Virtual Lab Technology
- Tips for Efficient PaaS Application Design
- A Rules Engine Built in PowerBuilder
- Sybase Named “Silver Sponsor” of iPhone Developer Summit
- Where Are RIA Technologies Headed in 2008?
- PowerBuilder History - How Did It Evolve?
- The Top 250 Players in the Cloud Computing Ecosystem
- Custom Common Dialogs Using SetWindowsHookEx
- DDDW Tips and Tricks
- OLE - Extending the Capabilities of PowerBuilder
- DataWindow.NET How To: Data Entry Form
- Book Excerpt: Sybase Adaptive Server Anywhere
- Sybase ASE 12.5 Performance and Tuning
- Working with SOA & Web Services in PowerBuilder
- Office 2003 Toolbar: A New Look For Your Old PowerBuilder App
- Dynamically Creating DataWindow Objects

































