Working with Data Sources in the SAP Business One UI API

Similar documents
Duet Enterprise: Tracing Reports in SAP, SCL, and SharePoint

Using JournalEntries and JournalVouchers Objects in SAP Business One 6.5

Single Sign-on For SAP NetWeaver Mobile PDA Client

Visual Composer Modeling: Data Validation in the UI

SAP AddOn Quantity Distribution. by Oliver Köhler, SAP Germany

SAP NetWeaver Identity Management Identity Center Minimum System Requirements

Configuring relay server in Sybase Control Center

Duplicate Check and Fuzzy Search for Accounts and Contacts. Configuration with SAP NetWeaver Search and Classification (TREX) in SAP CRM WebClient UI

Enterprise Search Extension for SAP Master Data Governance

EWM125. Labor Management in SAP EWM COURSE OUTLINE. Course Version: 16 Course Duration: 4 Hours

BIT460. SAP Process Integration Message Mapping COURSE OUTLINE. Course Version: 15 Course Duration: 3 Day(s)

PLM210. Master Data Configuration in SAP Project System COURSE OUTLINE. Course Version: 15 Course Duration: 2 Day(s)

How to Enable Single Sign-On for Mobile Devices?

Quick View Insider Microblog: Why Is There No Inbox?

How to Find Suitable Enhancements in SAP Standard Applications

How to Handle the System Message in SAP NetWeaver Mobile 7.1

Visual Composer Modeling: Migrating Models from 7.1.X to 7.2.0

Visual Composer for SAP NetWeaver Composition Environment - Connectors

BC100. Introduction to Programming with ABAP COURSE OUTLINE. Course Version: 15 Course Duration: 2 Day(s)

SAP BusinessObjects Predictive Analysis 1.0 Supported Platforms

ADM950. Secure SAP System Management COURSE OUTLINE. Course Version: 10 Course Duration: 2 Day(s)

AC507. Additional Functions of Product Cost Planning COURSE OUTLINE. Course Version: 15 Course Duration: 2 Day(s)

DS50. Managing Data Quality with SAP Information Steward COURSE OUTLINE. Course Version: 10 Course Duration: 2 Day(s)

Crystal Reports 2008 FixPack 2.4 Known Issues and Limitations

MDG100 Master Data Governance

DEV523 Customizing and Extending PowerDesigner

Installing SAP NetWeaver Mobile Client (eswt) on a Storage Card

Quick View Insider: Understanding Quick View Configuration

BOCE20. SAP Crystal Reports for Enterprise: Advanced Report Design COURSE OUTLINE. Course Version: 15 Course Duration: 3 Day(s)

BC410. Programming User Dialogs with Classical Screens (Dynpros) COURSE OUTLINE. Course Version: 10 Course Duration: 3 Day(s)

BOC320. SAP Crystal Reports - Business Reporting and Report Processing Strategies COURSE OUTLINE. Course Version: 15 Course Duration: 3 Day(s)

NET311. Advanced Web Dynpro for ABAP COURSE OUTLINE. Course Version: 10 Course Duration: 4 Day(s)

BC430 ABAP Dictionary

How to reuse BRFplus Functions Similar to R/3 Function Modules using BRF+ Expression Type Function Call

BOC310. SAP Crystal Reports: Fundamentals of Report Design COURSE OUTLINE. Course Version: 15 Course Duration: 2 Day(s)

HA150 SQL Basics for SAP HANA

ADM900 SAP System Security Fundamentals

How to Download Software and Address Directories in SAP Service Marketplace

BC480 PDF-Based Print Forms

ADM950. Secure SAP System Management COURSE OUTLINE. Course Version: 15 Course Duration: 2 Day(s)

Visual Composer s Control Types

How to Set Up Data Sources for Crystal Reports Layouts in SAP Business One, Version for SAP HANA

Quick View Insider: How Can I Change the Colors? (SNC 7.0)

EDB358. System and Database Administration: Adaptive Server Enterprise COURSE OUTLINE. Course Version: 10 Course Duration: 5 Day(s)

Testing Your New Generated SAP NetWeaver Gateway Service

BC405 Programming ABAP Reports

BW Text Variables of Type Replacement Path

Message Alerting for SAP NetWeaver PI Advanced Adapter Engine Extended

EDB367. Powering Up with SAP Adaptative Server Enterprise 15.7 COURSE OUTLINE. Course Version: 10 Course Duration: 2 Day(s)

SAP Afaria Post- Installation Part 1

EDB116. Fast Track to SAP Adaptive Server Enterprise COURSE OUTLINE. Course Version: 15 Course Duration: 5 Day(s)

TBIT44 PI Mapping and ccbpm

BC490 ABAP Performance Tuning

Manual Activities of SAP Note Globalization Services, 2012/06/05

GRC100. GRC Principles and Harmonization COURSE OUTLINE. Course Version: 10 Course Duration: 2 Day(s)

EDB785 SAP IQ Administration

ADM100 AS ABAP - Administration

BC400 Introduction to the ABAP Workbench

How to Guide to create Sample Application in IOS using SUP ODP 2.2

AFA461 SAP Afaria 7.0 System Administration (SP03)

Using Default Values in Backend Adapter

BC404. ABAP Programming in Eclipse COURSE OUTLINE. Course Version: 15 Course Duration: 3 Day(s)

Quick View Insider: How Do I Set Quick View as SNC s Entry Screen?

BW310. BW - Enterprise Data Warehousing COURSE OUTLINE. Course Version: 10 Course Duration: 5 Day(s)

BC400. ABAP Workbench Foundations COURSE OUTLINE. Course Version: 15 Course Duration: 5 Day(s)

EP350. Innovated Content Management and Collaboration COURSE OUTLINE. Course Version: 10 Course Duration: 5 Day(s)

LO Extraction - Part 6 Implementation Methodology

SAP BusinessObjects Dashboards 4.0 SAP Crystal Dashboard Design 2011 SAP Crystal Presentation Design 2011

TBW30 SAP BW Modeling & Implementation

ADM960. SAP NetWeaver Application Server Security COURSE OUTLINE. Course Version: 10 Course Duration: 5 Day(s)

How to Check or Derive an Attribute Value in MDG using BRFPlus

SMP521. SAP Mobile Platform - Native and Hybrid Application Development COURSE OUTLINE. Course Version: 10 Course Duration: 5 Day(s)

ADM920 SAP Identity Management

ADM960. SAP NetWeaver Application Server Security COURSE OUTLINE. Course Version: 15 Course Duration: 5 Day

Building a Real-time Dashboard using Xcelsius and Data Integrator

SMP541. SAP Mobile Platform 3.0 Native and Hybrid Application Development COURSE OUTLINE. Course Version: 15 Course Duration: 5 Day(s)

Personalizing SAP BusinessObjects Explorer Information Spaces

How to Integrate Google Maps into a Web Dynpro ABAP Application Using the Page Builder

How to Work with Analytical Portal

Remote Monitoring User for IBM DB2 for LUW

Web Dynpro: Column Coloring in ALV

Business Objects Integration Scenario 2

Overview of Caffeine ABAP to Go

BC401. ABAP Objects COURSE OUTLINE. Course Version: 15 Course Duration: 5 Day(s)

EDB377. Fast Track to SAP Replication Server Administration COURSE OUTLINE. Course Version: 15 Course Duration: 5 Day(s)

How to Integrate Microsoft Bing Maps into SAP EHS Management

NET312. UI Development with Web Dynpro for ABAP COURSE OUTLINE. Course Version: 10 Course Duration: 4 Day(s)

Upgrade MS SQL 2005 to MS SQL 2008 (R2) for Non-High-Availability NW Mobile ABAP System

What s New / Release Notes SAP Strategy Management 10.1

EP200. SAP NetWeaver Portal: System Administration COURSE OUTLINE. Course Version: 10 Course Duration: 5 Day(s)

Extending DME Transfer Files According to Spanish Banking Control Council to Support Non- Euro Payments

What are Specifics Concerning the Creation of New Master Data?

SAP Plant Connectivity 2.2

TBW60. BW: Operations and Performance COURSE OUTLINE. Course Version: 10 Course Duration: 5 Day(s)

How to Access Images of SAP Netweaver Demo Model JAVA

Architecture of the SAP NetWeaver Application Server

How to do a Manual Kernel Upgrade of an SAP Server

The Dbmlsync API. A whitepaper from Sybase ianywhere Author: Joshua Savill, Product Manager Date: October 30 th, 2008

SAP ME Build Tool 6.1

Upgrading to CR 2008 V1 / SP1

Transcription:

Working with Data Sources in the SAP Business One UI API Applies to: Business One For more information, visit the Business One homepage. Summary Data sources provide a means of managing values that are displayed on a form when working with the SAP Business One User Interface API. Author: James Kofalt Company: SAP Created on: 13 May 2009 Author Bio As Program Manager for SAP Business One Software Solution Partners, Jim Kofalt is responsible for the industry solutions program and other initiatives that drive new business for SAP and its channel partners. Jim has 20 years experience in the software industry, including roles in product management and strategy, business development, and systems implementation. 2009 SAP AG 1

Table of Contents Introduction...3 DBDataSources...3 UserDataSources...4 Related Contents...6 Copyright...7 2009 SAP AG 2

Introduction You use data sources when working with the SAP Business One User Interface API because they serve several purposes: Data sources provide a means of working with data in a form without updating user interface elements every time data changes. In this respect, they improve performance because they allow you to manipulate data without constantly refreshing the UI. Data sources allow you to query SAP Business One data and quickly and easily populate a matrix (grid) item with data. Data sources are required for some items, such as for checkbox items. There are two types of data sources in SAP Business One: DBDataSources and UserDataSources. DBDataSources DBDataSources contain tabular data that has been queried from a system table or user table in the SAP Business One company database. They are always associated with matrix objects, because they represent "two-dimensional" recordset data. In other words, DBDataSources contain data that is organized into columns and rows. DBDataSources serve these purposes: Allow you to work with data without necessarily refreshing the user interface with every change. DBDataSources are like a recordset object variable that has scope within the form that contains the DBDataSource. Allow you to query SAP Business One data and populate a matrix with the data Required in a matrix object To add a DBDataSource to a form, use the Add method of the DBDataSources collection: Dim odbds as SAPbouiCOM.DBDataSource Set odbds = oform.datasources.dbdatasources.add ("OCRD") odbds.query The parameter value "OCRD" passed with the Add method specifies the database table associated with the data source. OCRD contains Business Partner master data. You may filter the records returned to the data source by creating a Conditions object and passing it with the Query method. For example, if you wanted to limit the records returned to Customers and Leads, you could modify the code to read as follows: Dim odbds as SAPbouiCOM.DBDataSource Set odbds = oform.datasources.dbdatasources.add ("OCRD") Dim oconditions As SAPbouiCOM.Conditions Dim ocondition As SAPbouiCOM.Condition Set oconditions = New SAPbouiCOM.Conditions Set ocondition = oconditions.add ocondition.bracketopennum = 2 ocondition.alias = "CardType" ocondition.operation = co_equal ocondition.condval = "C" ocondition.bracketclosenum = 1 ocondition.relationship = cr_or Set ocondition = oconditions.add ocondition.bracketopennum = 1 ocondition.alias = "CardType" ocondition.operation = co_equal ocondition.condval = "L" 2009 SAP AG 3

ocondition.bracketclosenum = 2 odbds.query (oconditions) Next, you can bind the data source to a matrix item: Set ocolumns = omatrix.columns Set ocolumn = ocolumns.item("cardcode") ocolumn.databind.setbound True, "OCRD", "CardCode" Set ocolumn = ocolumns.item("name") ocolumn.databind.setbound True, "OCRD", "CardName" Finally, populate the matrix with data from the data source: omatrix.clear Dim i As Integer For i = 0 To odbdatasource.size - 1 odbds.offset = i omatrix.addrow Next i It is very important to note that DBDataSources do not write back to the database. When you create a DBDataSource, you are querying the database. However, to insert new records, update existing records, or delete records from the database, you need to use the business objects that are available through the Data Interface API (DI-API). This will ensure that referential integrity is maintained, and that business rules are applied properly. UserDataSources A UserDataSource holds a single data value. In this respect, it acts like a simple, form-level variable. It cannot behave like a recordset or array, although it can be bound to a matrix column, which will be discussed below. Keep in mind, however, that it can only hold one value at a time. UserDataSources hold values that are assigned by a user; that is, they are not associated with a table, and they do not query data directly from the SAP Business One database. A simple example of when you would use a UserDataSource is for checkbox items. A checkbox cannot hold a value until it is bound to a data source of the type "short text". If you add a checkbox to a form in SAP Business One without binding it to a UserDataSource, you will not be able to set its Check property to True. Dim itm As SAPbouiCOM.Item Dim chkcheck As SAPbouiCOM.checkbox Dim uds As UserDataSource Set itm = frm.items.add("chk1", it_check_box) Set chkcheck = itm.specific chkcheck.caption = "On Hold?" Set uds = frm.datasources.userdatasources.add("ds1", dt_short_text, 1) chkcheck.databind.setbound True, "", "ds1" chkcheck.checked = True Using a UserDataSource in a matrix is somewhat more difficult to understand, because a UserDataSource it not designed to hold tabular data or arrays. A UserDataSource only holds one value at a time. The key to understanding its usage in a matrix lies in the GetLineData and SetLineData methods. 2009 SAP AG 4

You can add a UserDataSource to a form, then to a column in a matrix item: Dim ouds as SAPbouiCOM.UserDataSource Set ouds = _ ofrm.datasources.userdatasources.add "Remarks", dt_long_text, 30 Set ocolumn = ocolumns.item("comments") ocolumn.databind.setbound True, "", " Remarks" Now I can set the value of the data source: ouds.value = "Always pays on time." Use the GetLineData method to populate your UserDataSources with values from a particular row in the matrix. For example, the following code would update row 3 of the matrix with the values of the bound data sources for each column in the row (including all DBDataSources and all UserDataSources that are bound to columns in the matrix.) omatrix.setlinedata(3) 2009 SAP AG 5

Related Contents For more information, visit the Business One homepage. 2009 SAP AG 6

Copyright Copyright 2009 SAP AG. All rights reserved. No part of this publication may be reproduced or transmitted in any form or for any purpose without the express permission of SAP AG. The information contained herein may be changed without prior notice. Some software products marketed by SAP AG and its distributors contain proprietary software components of other software vendors. Microsoft, Windows, Excel, Outlook, and PowerPoint are registered trademarks of Microsoft Corporation. IBM, DB2, DB2 Universal Database, System i, System i5, System p, System p5, System x, System z, System z10, System z9, z10, z9, iseries, pseries, xseries, zseries, eserver, z/vm, z/os, i5/os, S/390, OS/390, OS/400, AS/400, S/390 Parallel Enterprise Server, PowerVM, Power Architecture, POWER6+, POWER6, POWER5+, POWER5, POWER, OpenPower, PowerPC, BatchPipes, BladeCenter, System Storage, GPFS, HACMP, RETAIN, DB2 Connect, RACF, Redbooks, OS/2, Parallel Sysplex, MVS/ESA, AIX, Intelligent Miner, WebSphere, Netfinity, Tivoli and Informix are trademarks or registered trademarks of IBM Corporation. Linux is the registered trademark of Linus Torvalds in the U.S. and other countries. Adobe, the Adobe logo, Acrobat, PostScript, and Reader are either trademarks or registered trademarks of Adobe Systems Incorporated in the United States and/or other countries. Oracle is a registered trademark of Oracle Corporation. UNIX, X/Open, OSF/1, and Motif are registered trademarks of the Open Group. Citrix, ICA, Program Neighborhood, MetaFrame, WinFrame, VideoFrame, and MultiWin are trademarks or registered trademarks of Citrix Systems, Inc. HTML, XML, XHTML and W3C are trademarks or registered trademarks of W3C, World Wide Web Consortium, Massachusetts Institute of Technology. Java is a registered trademark of Sun Microsystems, Inc. JavaScript is a registered trademark of Sun Microsystems, Inc., used under license for technology invented and implemented by Netscape. SAP, R/3, SAP NetWeaver, Duet, PartnerEdge, ByDesign, SAP Business ByDesign, and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of SAP AG in Germany and other countries. Business Objects and the Business Objects logo, BusinessObjects, Crystal Reports, Crystal Decisions, Web Intelligence, Xcelsius, and other Business Objects products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of Business Objects S.A. in the United States and in other countries. Business Objects is an SAP company. All other product and service names mentioned are the trademarks of their respective companies. Data contained in this document serves informational purposes only. National product specifications may vary. These materials are subject to change without notice. These materials are provided by SAP AG and its affiliated companies ("SAP Group") for informational purposes only, without representation or warranty of any kind, and SAP Group shall not be liable for errors or omissions with respect to the materials. The only warranties for SAP Group products and services are those that are set forth in the express warranty statements accompanying such products and services, if any. Nothing herein should be construed as constituting an additional warranty. 2009 SAP AG 7