Show TOC

Background documentationUsing the BarCodeReader Locate this document in the navigation structure

 

The BarCodeReader is used for mobile data entry using a Pocket PC that is able to read barcodes using special equipment. For example, it can be used to read the barcode with an EAN product ID on a product's packaging.

If you insert this UI element into a view of a Web Dynpro application, the Pocket PC is then ready to scan when the application is called, and the read data can be passed to the SAP NetWeaver Application Server.

Prerequisites

  • The SAP NetWeaver Developer Studio is installed on your computer, and you can use it to create your mobile Web Dynpro application

  • You have access to a SAP NetWeaver Application Server, where you are running the Web Dynpro application

  • You are using a Pocket PC with special scanning equipment manufactured by Intermec Technologies or Symbol Technologies

  • You have created a Web Dynpro project including component, window and view

Procedure

Defining a View
  1. Navigate to the view where you want to insert the BarCodeReader.

  2. Double-click the view or choose Edit from the context menu.

  3. Insert the mobile UI element BarCodeReader.

    Note Note

    This interface element is not visible on the user interface and activates the scanning function of the mobile device when the mobile application is called. When the mobile device reads a barcode - that is, the onRead event is triggered - the data is passed to the server and can be stored in the context. The event parameter must be mapped to the parameter of the action.

    End of the note.
  4. Insert a TextViewelement - for example, ShowData.

Defining an Action
  1. In the View Designer, define an action called Scan and specify a parameter called ScanData for this action.

Specifying a Context Structure
  1. Choose the Context tab, select the context root node and choose   New   Value Attribute   in the context menu.

  2. Specify an attribute called Data of type string.

Specifying UI Element Properties
  1. Assign one of the following two values to the type property of the BarCodeReader:

    • intermec, if you are using a mobile device manufactured by Intermec Technologies

    • symbol, if you are using a mobile device manufactured by Symbol Technologies

  2. Assign action Scan to event onRead of the BarCodeReader.

  3. Assign the context path to context attribute data to property text of UI element TextView. Since context attribute data is a root node attribute, you must only assign the data string. To select the context attribute, press the button on the right of the line.

Implementation of the View Controller
  1. Add the following source code to the implementation of the view controller.

  2. To do this, switch to the Implementation tab. The read data is passed to the context by the event handler of the Scan action and the relevant context attribute is set.

public void onActionScan(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent, java.lang.String scanData )

{

//@@begin onActionScan(ServerEvent) wdThis.wdGetContext().currentContextElement().setData(scanData);

//@@end

You also need to define a parameter mapping in the wdDoModifyView method.

public static void wdDoModifyView(IPrivateBarCodeTestView wdThis, IPrivateBarCodeTestView.IContextNode wdContext, com.sap.tc.webdynpro.progmodel.api.IWDView view, boolean firstTime)

{

//@@begin wdDoModifyView

if (firstTime) {

IWDBarCodeReader barCodeReader = (IWDBarCodeReader) view.getElement("BarCodeReader");

barCodeReader.mappingOfOnRead().addSourceMapping ("data","scanData");

}

//@@end

}

Result

If you call this Web Dynpro application on a Pocket PC equipped with a barcode scanner, the Pocket PC is ready to scan. When a barcode is read by the scanner, the data is passed to the server and stored in the context of the view.

Since the text property of the TextView is bound to the corresponding context attribute Data, the data stored in this barcode can be displayed in the TextView.