0% found this document useful (0 votes)
158 views

Working With SAP Business One Script: All Countries

Uploaded by

Agustin Rudas
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
158 views

Working With SAP Business One Script: All Countries

Uploaded by

Agustin Rudas
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 24

How To Guide PUBLIC

SAP Business One Cloud SP02


Document Version: 1.1 – 2013-05-20

Working with SAP Business One Script


All Countries
Typographic Conventions

Type Style Description

Example Words or characters quoted from the screen. These include field names, screen titles,
pushbuttons labels, menu names, menu paths, and menu options.
Textual cross-references to other documents.

Example Emphasized words or expressions.

EXAMPLE Technical names of system objects. These include report names, program names,
transaction codes, table names, and key concepts of a programming language when they
are surrounded by body text, for example, SELECT and INCLUDE.

Example Output on the screen. This includes file and directory names and their paths, messages,
names of variables and parameters, source text, and names of installation, upgrade and
database tools.

Example Exact user entry. These are words or characters that you enter in the system exactly as they
appear in the documentation.

<Example> Variable user entry. Angle brackets indicate that you replace these words and characters
with appropriate entries to make entries in the system.

EXAMPLE Keys on the keyboard, for example, F 2 or E N T E R .

PUBLIC Working with SAP Business One Script


2 © 2013 SAP AG. All rights reserved. Typographic Conventions
Document History

Version Date Change

1.0 2012-10-29 First version.

1.1 2013-05-20 Replace on-demand terminology with cloud.

Working with SAP Business One Script PUBLIC


Document History © 2013 SAP AG. All rights reserved. 3
Table of Contents

1 Introduction .................................................................................................................................................... 5
1.1 Prerequisites ............................................................................................................................................................ 5
1.2 Glossary .................................................................................................................................................................... 5

2 Enabling SAP Business One Script .............................................................................................................. 7

3 Configuring SAP Business One Script......................................................................................................... 9

4 Managing Scripts .......................................................................................................................................... 11


4.1 Importing Scripts .................................................................................................................................................... 11
4.2 Creating Scripts ..................................................................................................................................................... 12
4.3 Running Scripts ..................................................................................................................................................... 13
4.4 Editing Scripts ........................................................................................................................................................ 14
4.5 Debugging Scripts ................................................................................................................................................. 15
4.6 Removing Scripts .................................................................................................................................................. 16

5 Sample Scripts ............................................................................................................................................. 18


5.1 Simple Callback ..................................................................................................................................................... 18
5.2 Simple Form ........................................................................................................................................................... 18

PUBLIC Working with SAP Business One Script


4 © 2013 SAP AG. All rights reserved. Table of Contents
1 Introduction

SAP Business One Script is a lightweight, JavaScript-based extension system that you can use to quickly adapt
SAP Business One to business-specific processes in cloud environments.
Unlike traditional SAP Business One add-ons, these extensions are "sandboxed", with managed access to system
functionality. SAP Business One Script enables you to quickly and cheaply develop solutions that address last-
mile extensibility, without the need for certification.

1.1 Prerequisites

• For information on hardware and software requirements, see the following:


o SAP Business One System Requirements, which you can find in the SAP Business One documentation
resource center in SAP Channel Partner Portal at http://channel.sap.com/sbo/documentation.
o Platform requirements, which you can find at http://channel.sap.com/sbo/platforms.
o Compatibility with the SAP Business One client application, which you can find in SAP Note 1756002.
• You have installed and configured a cloud environment, with SAP Business One Cloud W1 PL04, or later. For
more information, see SAP Business One Cloud Administrator's Guide.
• You have verified that SAP Business One Script is deployed to the required service units, and assigned it to
the tenants of those service units for which you want to enable scripting functionality. For more information
about deploying and assigning extensions using the Cloud Control Center, see SAP Business One Cloud
Administrator’s Guide.
• You have installed Google Chrome or Mozilla Firefox, or another Web browser that offers JavaScript
debugging functionality.

1.2 Glossary

Field Description

SAP Business One Cloud SAP Business One Cloud is the SAP cloud solution for small businesses
and subsidiaries of large enterprises. SAP Business One is centrally
hosted by partners in data centers. Providers license the application to
customers for use as a service when they need it, that is, “on demand.”
It eliminates the need for on-site IT resources to manage infrastructure
and thereby reduces operational expenses.

Script A small program that automates the execution of simple tasks in SAP
Business One. The application executes scripts on-the-fly.

JavaScript The scripting language you use to create SAP Business One scripts.

Working with SAP Business One Script PUBLIC


Introduction © 2013 SAP AG. All rights reserved. 5
Field Description

Debug The process of locating and removing defects in scripts. While


developing SAP Business One scripts, you may be required to debug
the script.

Debugger An application that enables you to test and debug scripts. Debuggers
typically allow you to run a script step-by-step, and stop a script at a
specific point or when certain defined conditions are satisfied.

Form (Window) Displays the details of a record or page and provides a means of data
entry for users. In SAP Business One, each form has a unique
identification number, which you can use to bind scripts to specific
forms.

Debug Port Facilitates communication between the SAP Business One Script
debugging service and the debugger, which is typically a Web browser.
To debug scripts, you must first start the debug port in SAP Business
One.

Add-On Program that offers additional functionality for SAP Business One. All
add-ons are technically dependent on and can be installed on top of
SAP Business One.

System Landscape Directory (SLD) A central directory of all SAP Business One components in a cloud
Database landscape.

Service Unit A collection of the software components, servers, and storage required
to provide access to a full SAP Business One installation. All SAP
Business One components in a single service unit have the same
version. A single service unit can contain multiple tenants with similar
requirements.

Tenant A company database, storage, and licenses allocated to a customer to


provide business functionality. A customer may have multiple tenants
across different service units, with each tenant having a different
application version or purpose, such as productive, demonstration, or
testing instances.

PUBLIC Working with SAP Business One Script


6 © 2013 SAP AG. All rights reserved. Introduction
2 Enabling SAP Business One Script

Procedure

To enable SAP Business One Script, do the following:

Caution
To enable SAP Business One Script, you must have superuser permissions in SAP Business One.
1. From the SAP Business One Main Menu, choose Administration → Add-Ons → Add-On Manager.
The Add-On Manager window appears.

2. On the Installed Add-Ons tab, select SBOScript, and then choose the Start button.
3. To save your changes, choose the OK button.

Result

The following windows are available from the SAP Business One Main Menu:
• Administration → Extension Management → Script Settings

Working with SAP Business One Script PUBLIC


Enabling SAP Business One Script © 2013 SAP AG. All rights reserved. 7
Use this window to configure the required settings for working with SAP Business One Script. For more
information, see Configuring SAP Business One Script.
• Administration → Extension Management → Script Manager
Use this window to import, create, edit, and debug scripts. For more information, see Managing Scripts.

PUBLIC Working with SAP Business One Script


8 © 2013 SAP AG. All rights reserved. Enabling SAP Business One Script
3 Configuring SAP Business One Script

Prerequisite

You have enables SAP Business One Script. For more information, see Enabling SAP Business One Script.

Procedure

To configure the required settings for SAP Business One script, do the following:
1. From the SAP Business One Main Menu, choose Administration → Extension Management → Script Settings.
The Script Settings window appears.

2. On the Script Name tab, configure an external script editor as follows:


o To edit scripts using Notepad or Eclipse, select the corresponding checkbox.

Note
Notepad is installed by default with Microsoft Windows; however, to use Eclipse, you must manually
install the application.
o To edit scripts using another editor, select the Other Editor checkbox, and then enter the path to the
application executable on your computer.
3. On the Debugger tab, do either of the following:
o To debug scripts using the built-in debugger of Google Chrome or Mozilla Firefox, select the
corresponding checkbox.

Note
To debug scripts using Google Chrome or Mozilla Firefox, you must manually install either application.

Working with SAP Business One Script PUBLIC


Configuring SAP Business One Script © 2013 SAP AG. All rights reserved. 9
o To debug scripts using another Web browser, select the Other Browser checkbox, and then enter the path
to the application executable on your computer.

4. To save the settings, choose the OK button.

PUBLIC Working with SAP Business One Script


10 © 2013 SAP AG. All rights reserved. Configuring SAP Business One Script
4 Managing Scripts

4.1 Importing Scripts

Procedure

To import an existing SAP Business One script, do the following:


1. From the SAP Business One Main Menu, choose Administration → Extension Management → Script Manager.
The Script Manager window appears.

2. Right-click anywhere in the header row, and then from the context menu, choose Import Script.
The Select Scripts window appears.
3. Select a valid JavaScript file, and then choose the Open button.
4. In the Script Manager window, enter the following information:
o Partner Name – The author of the script.
o Script Name – The name of the script.
o Binding Form – The SAP Business One form on which the script acts.

Working with SAP Business One Script PUBLIC


Managing Scripts © 2013 SAP AG. All rights reserved. 11
o Version – The version of the script.

Result

The application copies the JavaScript code to the SLD database and displays the selected script in the Script
Manager window. For more information, see Running Scripts.

4.2 Creating Scripts

Procedure

To create a new SAP Business One script, do the following;


1. From the SAP Business One Main Menu, choose Administration → Extension Management → Script Manager.
The Script Manager window appears.
2. Right-click anywhere in the window, and then from the context menu, choose Add Row.
3. Enter the following information for the script:
o Partner Name – The author of the script.
o Script Name – The name of the script.
o Binding Form – The SAP Business One form on which the script acts.
o Version – The version of the script.

PUBLIC Working with SAP Business One Script


12 © 2013 SAP AG. All rights reserved. Managing Scripts
4. You can enter the script content using the built-in editor of SAP Business One or an external editor. For more
information, see Editing Scripts.

4.3 Running Scripts

Prerequisite

You have imported an SAP Business One script, or created a new script, and the script is bound to an SAP
Business One form.

Procedure

To run an SAP Business One script, do the following:


1. From the SAP Business One Main Menu, choose Administration → Extension Management → Script Manager.
The Script Manager window appears.
2. In the Status column of the row that corresponds to the script that you want to run, change the status to
Enabled.
3. Open the window that corresponds to the form to which the script is bound.

Working with SAP Business One Script PUBLIC


Managing Scripts © 2013 SAP AG. All rights reserved. 13
Example
If the binding form is 139, this corresponds to the Sales Order window.

Result

After opening the window, the application automatically runs the script.

4.4 Editing Scripts

You can edit scripts using the built-in editor of SAP Business One or an external editor.

Prerequisite

To edit scripts in an external editor, you have installed the application on your computer and entered the file path
in the Script Settings window. For more information, see Configuring SAP Business One Script.

Procedure

To edit an SAP Business One script, do the following:


1. From the SAP Business One Main Menu, choose Administration → Extension Management → Script Manager.
The Script Manager window appears.
2. Right-click the row that corresponds to the script that you want to remove, and then from the context menu,
choose either of the following:
o Edit – Opens the built-in script editor.
o Edit Script in Editor – Opens an external editor, according to the settings in the Script Settings window.
3. Depending on your choice in the previous step, do either of the following:
o If you selected Edit in the previous step, the Script Editor window appears.
Modify the code accordingly, and then choose the Update button to save your changes.

PUBLIC Working with SAP Business One Script


14 © 2013 SAP AG. All rights reserved. Managing Scripts
o If you selected Edit Script in Editor in the previous step, an external application window appears
containing the JavaScript code.
Modify the code accordingly, save the file, and then choose the Update button in the Script Manager
window.

Result

The application updates the JavaScript code belonging to the script in the SLD database and removes any
temporary files created in external editing processes.

4.5 Debugging Scripts

Prerequisites

• You have installed and configured Node-Inspector on your computer.


• You have configured a debugger in the Script Settings window. For more information, see Configuring SAP
Business One Script.

Procedure

To debug an SAP Business One script, do the following:


1. From the SAP Business One Main Menu, choose Administration → Extension Management → Script Manager.
The Script Manager window appears.

Working with SAP Business One Script PUBLIC


Managing Scripts © 2013 SAP AG. All rights reserved. 15
2. Choose the Start Debug Port button.
3. Right-click the row that corresponds to the script that you want to debug, and then from the context menu,
choose Debug Script.

4.6 Removing Scripts

Procedure

To remove an SAP Business One script, do the following:


1. From the SAP Business One Main Menu, choose Administration → Extension Management → Script Manager.
The Script Manager window appears.
2. Right-click the row that corresponds to the script that you want to remove, and then from the context menu,
choose Delete Row.

PUBLIC Working with SAP Business One Script


16 © 2013 SAP AG. All rights reserved. Managing Scripts
3. To save the changes, choose the Update button.

Working with SAP Business One Script PUBLIC


Managing Scripts © 2013 SAP AG. All rights reserved. 17
5 Sample Scripts

5.1 Simple Callback

The following example script is bound to form 134, which corresponds to the Business Partner Master Data
window in SAP Business One. After opening the Business Partner Master Data window, the script performs a
check on the E-Mail field for the presence of the "@" symbol. If the symbol is present, the script sets the
background color of the field to green; otherwise, the script sets the background color to red.

Example
var LostFocusCallBack = function(itemEvent)
{
var oEditText = this.Specific;
var text = oEditText.String;
if(text.indexOf("@") == -1)
{
this.BackColor = 141490;
}
else
{
this.BackColor = 3329330;
}
return true;
}
application.formTypes('134').items('60').on('After_LOST_FOCUS',
LostFocusCallBack);

5.2 Simple Form

The following example script is bound to form 140, which corresponds to the Delivery window in SAP Business
One. After opening the Delivery window, the script automatically opens another window, which contains the
following UI controls:
• Text field and label
• Dropdown list and label
• OK and Cancel buttons

PUBLIC Working with SAP Business One Script


18 © 2013 SAP AG. All rights reserved. Sample Scripts
Example
debugger;
// add a new form
var oCreationParams = application.CreateObject(1) ;

oCreationParams.BorderStyle = 4;
oCreationParams.UniqueID = "MySimpleForm";

var oForm = application.Forms.AddEx( oCreationParams );

// add a User Data Source to the form


oForm.DataSources.UserDataSources.Add( "EditSource", 9, 20 );
oForm.DataSources.UserDataSources.Add( "CombSource", 9, 20 );

// set the form properties


oForm.Title = "Simple Form";
oForm.Left = 400;
oForm.Top = 100;
oForm.ClientHeight = 80;
oForm.ClientWidth = 350;

//*****************************************
// Add items to the form
// and set their properties
//*****************************************

//**********************
// Add an OK button
//*********************

// We get automatic event handling for


// the Ok and Cancel Buttons by setting
// their UIDs to 1 and 2 respectively

var oItem = oForm.Items.Add( "1", 4 );


oItem.Left = 6;
oItem.Width = 65;
oItem.Top = 51;
oItem.Height = 19;

Working with SAP Business One Script PUBLIC


Sample Scripts © 2013 SAP AG. All rights reserved. 19
var oButton = oItem.Specific;

oButton.Caption = "Ok";

//************************
// Add a Cancel button
//***********************

oItem = oForm.Items.Add( "2", 4);


oItem.Left = 75;
oItem.Width = 65;
oItem.Top = 51;
oItem.Height = 19;

oButton = oItem.Specific;

oButton.Caption = "Cancel";

//************************
// Add a Rectangle
//***********************

oItem = oForm.Items.Add( "Rect1", 100 );


oItem.Left = 0;
oItem.Width = 344;
oItem.Top = 1;
oItem.Height = 49;

//***************************
// Add a Static Text item
//***************************

oItem = oForm.Items.Add( "StaticTxt1", 8 );


oItem.Left = 7;
oItem.Width = 148;
oItem.Top = 8;
oItem.Height = 14;

oItem.LinkTo = "EditText1";

PUBLIC Working with SAP Business One Script


20 © 2013 SAP AG. All rights reserved. Sample Scripts
oStaticText = oItem.Specific;

oStaticText.Caption = "Static Text 1";

//**********************************
// Add another Static Text item
//**********************************

oItem = oForm.Items.Add( "StaticTxt2", 8 );


oItem.Left = 7;
oItem.Width = 148;
oItem.Top = 24;
oItem.Height = 14;

oItem.LinkTo = "ComboBox1";

oStaticText = oItem.Specific;

oStaticText.Caption = "Static Text 2";

//*************************
// Add a Text Edit item
//*************************

oItem = oForm.Items.Add( "EditText1", 16 );


oItem.Left = 157;
oItem.Width = 163;
oItem.Top = 8;
oItem.Height = 14;

oEditText = oItem.Specific;

// bind the text edit item to the defined used data source
var dBind = oEditText.DataBind;
dBind.SetBound( true, "", "EditSource" );

oEditText.String = "Edit Text 1";

//*************************
// Add a Combo Box item
//*************************

Working with SAP Business One Script PUBLIC


Sample Scripts © 2013 SAP AG. All rights reserved. 21
oItem = oForm.Items.Add( "ComboBox1", 113 );
oItem.Left = 157;
oItem.Width = 163;
oItem.Top = 24;
oItem.Height = 14;

oItem.DisplayDesc = false;

oComboBox = oItem.Specific;

// bind the Combo Box item to the defined used data source
dBind = oComboBox.DataBind;
dBind.SetBound( true, "", "CombSource" );

oComboBox.ValidValues.Add( "1", "Combo Value 1" );


oComboBox.ValidValues.Add( "2", "Combo Value 2" );
oComboBox.ValidValues.Add( "3", "Combo Value 3" );

oForm.Visible = true;

PUBLIC Working with SAP Business One Script


22 © 2013 SAP AG. All rights reserved. Sample Scripts
www.sap.com/contactsap

© 2013 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 ads, 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, xApps, xApp, 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 in
several other countries all over the world. 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.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy