Professional Documents
Culture Documents
SAP Business One Customization Tools
SAP Business One Customization Tools
DATABASE
MANAGEMENT SYSTEM
using SAP Business One
CONTENTS:
UNIT I: SAP BUSINESS ONE QUERY GENERATOR
UNIT II: CUSTOMIZATION TOOLS - USER-DEFINED FIELDS, TABLES, VALUES AND OBJECTS
Many users of SAP Business One (SBO) are unaware that there is a powerful and simple query generator
available within the standard product. The query generator is a tool that makes it easy for authorized users to
extract information from the company databases.
There are many reasons why companies would want to query the database but generally the requirement
is to produce a view of the data that does not exist in one of the standard reports offered by SAP or to present the
data in a customized format.
Take for example the common requirement to extract a business partner listing. This is a simple task using
the query generator. Let’s take a look how SAP supports this requirement.
The first thing to do is identify the names of the database fields that we want to extract in our query. This
is made simple by asking the SAP client to show ‘System Information’. To do this, drop down the ‘View’ menu from
within the SBO client and select the ‘System Information’ option so that it shows a tick as indicated in the
screenshot below:
The status bar, which extends along the entire lower edge of the SAP Business One Main Window, contains various
text fields.
The left side is designated to display important, pertinent status and debug information about any window that is
opened. By selecting System Information from the View menu, you can view detailed information of any given field
when the cursor passes over it. The information is displayed on the left side of the status bar.
The system Information contains the field description used in the table, and the name of the table where the field
is located.
SQL DATABASE TABLE IN SAP BUSINESS ONE
The foundation of every Relational Database Management System is a database object called table. Every database
consists of one or more tables, which store the database’s data/information. Each table has its own unique name
and consists of columns and rows.
The database table columns (called also table fields) have their own unique names and have a pre-defined data
types. Table columns can have various attributes defining the column functionality (the column is a primary key,
there is an index defined on the column, the column has certain default value, etc.).
While table columns describe the data types, the table rows contain the actual data for the columns.
WHO CAN BENEFIT FROM USING SQL QUERIES IN SAP BUSINESS ONE?
It may not be easy to deduce the ideal reader of this book. In fact, there are many different groups of SAP
Business One users who may need this tool.
To my knowledge, there is no standard organization chart for Small and Midsized enterprises. Most of
them are different. You may often find one person that handles more than one role. In this sense all users,
especially end users, may need this
book as long as they can use SQL query with the basic knowledge required. You may check the following list to
see if anything applies to you:
Do you need to check specific sales results over certain time periods, for certain areas or certain
customers?
Do you want to know who the top vendors from certain locations for certain materials are?
Do you have dynamic updated version of your sales force performance in real time?
Do you often check if approval procedures are exactly matching your expectations?
Have you tried to start building your SQL query but could not get it done properly?
Have you experienced writing SQL query but the results are not always correct or up to your
expectations?
If the answer to any of the questions mentioned earlier is "yes", then you can certainly benefit from
reading this book. It will answer each and every question mentioned earlier and give you the power to solve
complicated problems.
Consultant
If you are an SAP Business One consultant, you have probably mastered SQL query already. However, if that is not
the case, this book would be a great help to extend your consulting power. It will probably become a mandatory
skill in the future that any SAP Business One consultant should be able to use SQL query.
Developer
If you are an SAP Business One add-on developer, these skills will be good additions to your capabilities. You may
find this book useful even in some other development work like coding or programming. Very often you need to
embed SQL query to your codes to complete your Software Development Kit (SDK) project
(Note: SDK , TB1300, is another program and is not covered in this course)
No matter what your background is, you will find this book useful whenever you need to get certain data
quickly and accurately.
Source: (Mastering SQL Queries for SAP Business One by Gordon Du)
Before going into the details of SQL query, I would like to briefly introduce some basic database concepts because
SQL is a database language for managing data in Relational Database Management Systems (RDBMS).
Table
Table is a key component within a database. One table or a group of tables represent one kind of data. For
example, table OSLP within SAP Business One holds all Sales Employee Data. Tables are two-dimensional data
storage place holders. You need to be familiar with their usage and their relationships with each other. If you are
familiar with Microsoft Excel, the worksheet in Excel is a kind of two-dimensional table.
Table is also one of the most often used concepts in the book. Relationships between each table may be more
important than tables themselves because without relation, nothing could be of any value. One important function
within SAP Business One is allowing User Defined Table (UDT). All UDTs start with "@".
Field
A field is the lowest unit holding data within a table. A table can have many fields. It is also called a column. Field
and column are interchangeable. A table is comprised of records, and all records have the same structure with
specific fields. One
important concept in SAP Business One is User Defined Field (UDF). All UDFs start with U_.
SQL
SQL is often referred to as Structured Query Language. It is pronounced as S-Q-L or as the word "Sequel". There
are many different revisions and extensions of SQL. The current revision is SQL: 2008, and the first major revision is
SQL-92. Most of SQL extensions are built on top of SQL-92.
Query
Query is the most common operation in SQL. It could refer to all three SQL subsets. In this book, however, you will
only learn the read-only part of the query. No Add, Delete, or Update SQL statement in DML will be discussed in
the book since it is prohibited from SAP support policy for SAP Business One database integrity. All DCL or DDL SQL
will also not be included because we neither control access to data in a database, nor define data structure for a
database. You will find SELECT leading query only within the book. Read-only query SELECT has powerful
functionality for finding useful information to meet your specific needs.
NOTE: You have to understand the risks of running any Add, Delete, or Update queries that could potentially
alter system tables even if they are User Defined Fields. Using Add, Delete or Update will your SAP license. Only
SELECT query is legitimate for SAP Business One system table.
Naming convention of tables for SAP Business One
To help you understand the previous mentioned data dictionary quickly, we will be going through the naming
conventions for the table in SAP Business One.
"A" tables
Most tables starting with "A" may mean historical log tables. A here represents
Archive. For example:
AITM: Items—History
ACRD: Business Partners—History
AUSR: Archive Users—History
Document header tables
These are special O tables with the exact same structure. They can be tables related to Sales or Purchase. These
are called Marketing Documents. These also include most Inventory transaction tables. Some examples are:
OJDT-Journal Entry: This table includes all financial journal entries no matter whether they are
automatically posted or manually posted.
OINM-Warehouse Journal: This table includes all inventory-related transactions. It is a single point
to check everything in relation to your inventory (or stock). It becomes a view in the new version. This view must
be queried very carefully.
ADOC-Document History: This table includes all document history.
However, it is wrongly named in the documentation, "Invoice History" table
in the help file.
Write down the Master Table names of the following documents or forms in SAP Business One:
FORM/DOCUMENT MASTER TABLE
1 Purchase Quotation
2 Purchase Order
3 Goods Receipts PO
4 Goods Return
5 A/P Invoice
6 A/P Credit Memo
7 Sales Quotation
8 Sales Order
9 Delivery
10 Return
11 A/R Invoice
12 A/R Credit Memo
13 Item Master Data
14 Business Partner Master Data
15 Chart of Accounts
SOLUTION: (Log in SAB Business One using SBODemoGB (OEC Computers UK) Database)
1. Purchase Quotation : The Master table name is OPQT
Activate the viewing of system information in the task bar.
To activate, On the menu bar, go to View > System Information (if System Information has a check mark, it is
already activated.)
Open the Purchase Quotation document under Purchasing A/P > Purchase Order
Mouse over to any fields on the header portion (e.g Vendor, Customer , Name, Posting Date, etc.) and check the
Master Table name on the status bar found at the bottom of SAP Window. The Four Capital Letters which starts
with "O" is the master table (Remember that master tables start with "O').
ANSWERS:
FORM/DOCUMENT MASTER TABLE
1 Purchase Quotation OPQT
2 Purchase Order OPOR
3 Goods Receipts PO OPDN
4 Goods Return ORPD
5 A/P Invoice OPCH
6 A/P Credit Memo ORPC
7 Sales Quotation OQUT
8 Sales Order ORDR
9 Delivery ODLN
10 Return ORDN
11 A/R Invoice OINV
12 A/R Credit Memo ORIN
13 Item Master Data OITM
14 Business Partner Master Data OCRD
15 Chart of Accounts OACT
Write down the Document Line / Document Row Table names of the following documents or forms in SAP
Business One:
Document Row Document Line Table Name
1 Contents Tab of A/R Invoice Document
2 Addresses Tab of the Business Partner Master Data
3 Contents Tab of Purchase Order Document
SOLUTIONS:
1. Contnets Tab of A/R Invoice Document - Document Line Table Name: INV1
Open Sales A/R > A/R Invoice
Mouse Over to any fields under the contents tab and check the system information.
ANSWERS:
Document Row Document Line Table Name
1 Contents Tab of A/R Invoice Document INV1
2 Addresses Tab of the Business Partner Master Data CRD1
3 Contents Tab of Purchase Order Document POR1
SQL SELECT
The SQL SELECT statement is used to select data from a SQL database table. This is usually the very first SQL
command every SQL newbie learns and this is because the SELECT SQL statement is one of the most used SQL
commands.
Note: There are other SQL syntax other than SQL Select such as SQL CREATE, SQL INSERT SQL DELETE, ETC..
However, as mentioned earlier, only SQL SELECT query is legitimate for SAP Business One system table. Using other
SQL. Other SQL Syntax will void the warranty of the SAP license as other syntax may cause error on the
functionalities of SAP Business One tables. But you may use other syntax for User-defined tables and user-defined
objects. For this material, we will focus only on SQL SELECT.
SELECT Statement
Main parts of a SELECT statement
SELECT column_list
FROM table_list
WHERE search_condition
GROUP BY group_expression
ORDER BY order_expression [ASC | DESC]
The list of column names after the SQL SELECT command determines which columns you want to be returned in
your result set. If you want to select all columns from a database table, you can use the following SQL statement:
SELECT * FROM Table1
OCRD is the Master Table name for Business Partners. The Query above will extract all columns from the table
Business Partner Master Data.
OPTION 1: (For those who are not familiar with SQL Queries)
To view result, on the Menu Bar, go to Tools > Queries > Query Generator
Type OCRD on the upper left field, then press Tab on the keyboard > Click Execute
RESULT: All Columns from OCRD (Business Partner Master Data) is displayed.
OPTION 2: (For those who are already familiar with SQL Queries)
To view result, on the Menu Bar, go to Tools > Queries > Query Generator
Click Execute (ignore the warning message) > Click Edit Mode icon (Pencil icon)
Type the query SELECT * FROM OCRD (not case sensitive) > click Execute
When the list of columns following the SELECT SQL command is replaced with asterix (*) all table columns are
returned. Word of caution here, it’s always better to explicitly specify the columns in the SELECT list, as this will
improve your query performance significantly.
The table name following the SQL FROM keyword (in our case OCRD) tells the SQL interpreter which table to use to
retrieve the data.
Note: Fields in the marketing documents have the same column names.
SOLUTIONS
1. Using Option 1 will not display the column name.
The Total Before Discount (Total Document) field is composed of Currenty + Amount. Hence, two columns a
involved here. The Column for Currency and the Column for Values. In this case, we have to use OPTION 2.
ANSWERS:
Module Document Field Column Name
1 Purchasing A/P Purchase Order Document Total DocTotal
2 Purchasing A/P Purchase Order Vendor CardCode
3 Purchasing A/P Purchase Order Name CardName
4 Purchasing A/P Purchase Order Posting Date DocDate
5 Banking Outgoing Payment Name CardName
6 Sales A/R A/R Invoice Name CardName
7 Sales A/R Sales Order Posting Date DocDate
8 Financials Chart of Accounts G/L Account AcctCode
9 Financials Chart of Accounts Name AcctName
10 Financials Journal Entry Posting Date RefDate
Generate a report showing a list of Business Partners stored in SAP. The report should reflect the Business Partner
Code, Name and Contact Person.
When you check the Master Table name, it is OCRD.
Upon Checking the Column Names of the Partner Code, Name and Contact Person, the Column Names are
CardCode, Cardname and CntctPrsn respectively
OPTION 2: (For those who are already familiar with SQL Queries)
Go to Tools > Queries > Query Generator
Click Execute (ignore the warning message) > Click Edit Mode icon (Pencil icon)
Type the query SELECT CardCode, CardName, CntctPrsn FROM OCRD
(not case sensitive) > click Execute
The SQL WHERE clause is used to select data conditionally, by adding it to already existing SQL SELECT query. The
WHERE caluse is used to provide limits to a set of data.
Options for WHERE search_condition
Restricts the rows returned from the SELECT.
a) AND operator: Both conditions must be true.
WHERE CardType = ‘C’ and Country = ‘Germany’
b) OR operator: Either one of the conditions must be true.
WHERE Country = ‘Italy’ OR Country = ‘Germany’
c) Using different operators:
Equal: =
Not Equal: <>, !=
Greater, Smaller than: >, <, >=, <=
Not Greater, Smaller than: !>, !<
d) LIKE: Compares if a string matches a certain pattern.
CustomerName LIKE ‘Mic%’
CustomerName LIKE ‘%roc%’
CustomerName NOT LIKE ‘A%’
CustomerName LIKE ‘M[ae]ier’
CustomerName LIKE ‘M_ier’
e) BETWEEN: Specifies a range.
WHERE Age BETWEEN 10 AND 20
WHERE Age NOT BETWEEN 10 AND 20
f) NULL: Specifies a search for null values.
WHERE ContactName IS NULL
WHERE ContactName IS NOT NULL
EXAMPLE 1:
Generate a report showing a list of Customers stored in SAP. The report should reflect the Customer Code, Name
and Contact Person.
When you check the Master Table name, it is OCRD.
Upon Checking the Column Names of the Partner Code, Name and Contact Person, the Column Names are
CardCode, Cardname and CntctPrsn respectively.
Based on the condition that only customers are reflected (and will exclude Vendors), we will use the CardType
Column.
*Note: You have to enclose C with Single Quotations. All data other than amounts/ numeric values should be
enclosed with single quotations. (For numeric values, there is no need to enclose in a single quotation but you
have to remove commas since comma in SQL is used to separate data.)
OPTION 1: (For those who are not familiar with SQL Queries)
On the Menu Bar, go to Tools > Queries > Query Generator
Type OCRD on the upper left field, then press Tab on the keyboard
Put you mouse cursor in the Select field.
Double Click CardCode, Cardname and CntctPrsn respectively.
You should only see list of Customers upon executing the query.
EXAMPLE 2:
We will be querying the code for all items in the Item Master Data , their Item Names, in-stock quantity,
committed quantity and ordered quantity
The code
SELECT ItemCode, ItemName, OnHand, IsCommited, OnOrder FROM OITM
OPTION1:
OPTION 2:
The above SQL Statment will return the same result as option 1.
SELECT ItemCode, ItemName, OnHand, IsCommited, OnOrder FROM OITM where OnHand = 500
In this simple SQL query we used the "=" (Equal) operator in our WHERE criteria:
OnHand = 500
But we can use any of the following comparison operators in conjunction with the SQL WHERE clause:
SQL DISTINCT
The SQL DISTINCT clause is used together with the SQL SELECT keyword, to return a dataset with unique entries
for certain database table column.
We will use our Business Partners table (CRD1) to illustrate the usage of SQL DISTINCT. The name of the field is
Country. Look at the figure below.
SELECT Country FROM CRD1 SELECT DISTINCT Country FROM CRD1
*The number of results is the same as the *The results are only the countries linked to the Business
number of Business Partners recorded. Partners on record, without repeating an entry.
SQL LIKE
The SQL LIKE clause is very useful when you want to specify a search condition within your SQL WHERE clause,
based on a part of a column contents. For example if you want to select all customers having FirstName starting
with 'M' you need to use the following SQL statement:
SELECT CardCode, CardName, Address, MailAddres FROM OCRD where CardName like 'M%'
The '%' is a so called wildcard character and represents any string in our pattern.
You can put the wildcard anywhere in the string following the SQL LIKE clause and you can put as many wildcards
as you like too.
Note that different databases use different characters as wildcard characters, for example '%' is a wildcard
character for MS SQL Server representing any string, and '*' is the corresponding wildcard character used in MS
Access.
1. Generate a list of Business Partners having an Account Balance (Receivable or Payable) of more than 20,000 and
less than 40,000. Show The Business Partner's Code, Name and Account Balance.
3. Generate a list of unpaid A/P Invoices. Show the Vendor Code, Name, Invoice Number, Due Date and the
Document Total
*Remember that an Invoice with a Status Open is not yet paid and an Invoice with a Status Closed is already Paid.
SQL AS
'AS' is a command to set an alias to the selected column. The Alias will be reflected in the Query Preview. To
illustrate, consider the following:
EXAMPLE:
Generate a list of unpaid A/P Invoices. The Column Headers should be as follow:
Vendor Code, Vendor Name, Invoice Number, Invoice Due Date and Invoice Amount respectively.
SOLUTION:
The query statement and the query preview should be:
Note: You have to enclose the characters after the command AS in single quotations.
Do not close the query preview yet. We are going to save queries by category by following the succeeding
proccedures
For queries that are executed on a recurring basis such as reports that are needed daily, weekly or
monthly, saving the SQL query statement will save time in reconstructing the statement. The results are updated
immediately as soon as changes to the database/transactions were made.
Assuming an updated Query Preview showing the details above is needed every week. Save the Query so that you
can go back to it anytime you need to generate the list of all Unpaid A/P Invoices.
Category: Weekly Reports
Query Name: Unpaid A/P Invoices
In the Query Preview, A/P Invoice Number 238 is not yet paid as refleccted in the report.
After recording the payment, this invoice should not be reflected in the Query Preview anymore.
Record an the Payment (Use Bank Transfer, use G/L Account 161000 - Bank Account)
Banking > Outgoing Payments > Outgoing Payments
Process the Payment to V23000 Anthony Smith for Invoice Number 238.
SQL ORDER BY
The SQL ORDER BY clause comes in handy when you want to sort your SQL result sets by some column(s).
However, this is more useful when you need to sort two columns. If you only intend to sort one column, you may
disregard the ORDER BY clause - just generate the needed data then double click your preferred column for
sorting.
If you do not whether the sorting should be Ascending or Descending, the default is in Ascending Order.
If I doubleclick Document Total column header, the result will be sorted based on Document Total
The data above were sorted alphabetically by Customer Name, then Numerically by Document Total
SQL GROUP BY
The SQL GROUP BY statement is used along with the SQL aggregate functions like SUM, COUNT, AVG (average),
etc. to provide means of grouping the result dataset by certain database table column(s).
Options for GROUP BY group_expression
Specifies the groups for output rows. Calculates an aggregate value for each column from the SELECT.
SELECT country, city, SUM(revenue) FROM…GROUP BY country, city
All columns from the select clause must have an aggregate function or be in the GROUP BY statement. It is
recommended that these be used together with an ORDER BY for ordering the output of the columns.
Examples for aggregate functions:
AVG – Returns the average of the values in the expression
SUM – Returns the total of the values
MAX – Returns the highest value in the expression
MIN – Returns the lowest value in the expression
COUNT – Returns the number of rows
The best way to explain how and when to use the SQL GROUP BY statement is by example.
EXAMPLE 1:
Create a Query that will show how many Customers, Leads and Vendors are there in the system.
The result should show the following:
CardType Number of Business Partners
(C, S or L for Customer, Supplier of Lead) (Count of Business Partners per CardType)
SOLUTION:
EXAMPLE 2:
Create a Query that will show the total A/R Invoice amount issued per customer.
The result should show the following:
Customer Name Total A/R Invoice Amount
SOLUTION:
EXAMPLE 2:
Create a Query that will show the Average Purchases from each vendor for the year 2009 based on the recorded
A/P Invoices. The result should show the following:
Vendor Name Average Purchases
Note: Whether you SAP date is formatted as MM/DD/YYYY or DD/MM/YYY, the date format to be used in SAP will
always follow MM/DD/YYY, since this is the date format of its server - Microsoft SQL.
SOLUTION: The basis for the date should be the posting date.
In case you also like to se the total of the averages, click CTRL on the keyboard then double click the header.
SQL HAVING
The SQL HAVING clause is used to restrict conditionally the output of a SQL statement, by a SQL aggregate function
used in your SELECT list of columns.
You can't specify criteria in SQL WHERE clause against a column in the SELECT list for which SQL aggregate function
is used.
EXAMPLE: Create a Query that will show a list of customers whose total purchases from the company, based on
A/R Invoices issued, is greater than or equal to 300,000.
You might be thinking to use the the following SQL statement. The following will generate an error:
Again, you cannot use an aggreagte function such as SUM in the WHERE clause. To generate the needed report, we
will use the HAVING clause.
SQL TOP
SQL TOP is used together with SQL SELECT to extract a list of entries ranked on a defined confition/parameter. This
should be followed by an ORDER BY ASC or DESC statement so that SAP can determine which among the column is
the basis in determining the rank and to determine how to rank the data - lowest to highest or highest to lowest.
EXAMPLE:
Generate a list of TOP 5 A/R Invoices for the year 2009.
The Query Preview should show the following:
Customer Name Invoice Number Invoice Total
SOLUTION:
SQL JOIN
The SQL JOIN clause is used whenever we have to select data from 2 or more tables.
To be able to use SQL JOIN clause to extract data from 2 (or more) tables, we need a relationship between certain
columns in these tables.
EXAMPLE:
To illustrate, consider the following requirements: Generate the list of Top 3 Sales Employees based on delivered
goods to customer.
The SQL Query Preview should show the following:
Sales Employee Name Total Sales
SOUTIONS:
Based ont he requirement above, we are goinng to use the Delivery Document (ODLN) and the Sales Emplpyee
Column name is SlpCode
You might be thinking of Executing the following statement:
The problem with the above SQL Statement is that, it only returns the Sales Employee Code and not the names.
To resolve the concern, we are going to use SQL JOIN. To determine from where table can we get the Sales
Employee Names, open a Delivery Document.
Go to Sales A/R > Delivery > Last Data Record
Choose the Dorpdown list button on the Sales Employee field > Choose Define New
Mouse over to any fiel in the resulting window - Sales Employees/Buyers Setup window
Note the Master table Name found on the status bar: OSLP
To generate the report,
OPTION 1:
RESULT:
OPTION 2: (For those who are already familiar with SQL Query)
You may also type the following SQL Query directly it the Query Preview window. Before constructing the query,
what we need to know is what column is found in both tables,Table 1 (OSLP) and Table 2 (ODLN).
The answer is SlpCode. Both tables has the column for SlpCode. This will be used in generating the needed data as
follow:
NOTE: When saving SQL Statements involving the need to extract the date today, it is safe to use the
following to exctract the date only.
DATEADD(day, DATEDIFF(day, 0, GETDATE()),0)
DATEDIFF is a function used to add or subtract dates, which will result to a whole number.
DATEDIFF(datepart, startdate, enddate)
Datepart specifies on which part of the date to calculate the difference (for example year, month, or day).
Startdate is subtracted from enddate. If startdate is later than enddate, a negative value is returned.
The syntax is as follow:
DATEDIFF (day, Date1, Date2) Get the difference between Date1 and Date2, in number of days
DATEDIFF (month, Date1, Date2) Get the difference between Date1 and Date2, in number of months
DATEDIFF (year, Date1, Date2) Get the difference between Date1 and Date2, in number of years
EXAMPLE: Take a look at the following SQL Query Statement and Preview:
DocDate - DocDueDate (DocDate - DocDueDate): Since the two values are dates, it also returned a Date Format
as the result.
To extract the diference in number of days, we are going too use the syntax DATEDIFF.
EXAMPLE: Generate a list of A/P Invoices that are due for payment between today and 7 days from today. All A/P
Invoice with a passed Due Date should not be part of the report. Show the Vendor Name, Invoice Number, Invoice
Amount and the Due Date.
Since the database which we are using has not been used for the current year, no data will be displayed for the
requirement above. Hence, post at least 2 A/P Invoices with the following Details:
Go to Purchasing A/P > A/P Invoic > Enter the needed data > Add the Invoice
Take a look at the following SQL Statement:
Third invoice which we have created is not reflected in the Query Preview. This is because GETDATE() alone is used
for the condition. Again, GEDATE() consists of date today plu time today. Hence, since the thirs invoice is created a
few seconds or minutes ago, it does not meet the criteria.
The following is the correct SQL Statement and Preview (the result should show the three invoices we have just
created unless, you posted more invoices that will fit the requirements)
You can also use the BETWEEN clause:
SOLUTIONS:
*DATEDIFF(day, DocDueDate, GETDATE()) - the syntax calculates for the difference between Document Due Date
and the Date today in terms of Number of days - the consideration is the number of days, ignoring now the time
portion. Hence, although GETDATE() is composed of Date + Time, the syntax is still correct.
You may also do the following which will provide the same result:
Save the Query - Category: Weekly Reports
Query Name: Uncollected A/R Invoices
Since the needed report is not part of the default reports which can be generated in SAP Business One, use SQL to
generate a report as required:
Open Tools>Queries>Query Generator >Click Execute
Ignore the error message. Click the Pencil Icon to go to Edit Mode and enter the following:
SELECT cardcode as 'Customer Code', cardname as 'Customer Name', creditline, creditline - balance as
'Deviation from Credit Limit'
from OCRD where cardtype = 'c'
* Save the Query - Query Name: Uncollected A/R more than 5K Category: Other Reports
UNIT IV: CUSTOMIZATION TOOLS - USER-DEFINED FIELDS, TABLES, VALUES AND OBJECTS
User-defined fields, as described enable you to add fields to existing tables to keep track of additional information.
For example, you can add a field called CarNumber to the Employee Master Data table to keep track of the license
plate number for each employee. User-defined tables, can be used in one of the
following ways:
• To represent business objects, such as vehicle master data, or to group logical sets of userdefined
fields
• To hold valid values for other user-defined fields. You can link user tables to user-defined fields,
and require users to select from the values in the tables.
2. Select the category to which you want to add a field, and choose Add . The Field Data window appears.
3. Specify the name and type of field by entering the following fields in the Field Data form:
Title: The field name. The Title value cannot contain spaces or special characters.
Description: The field display name.
Length: The size of the field.
Type: If the field type is Alphanumeric, the length is the maximum number of characters.
If the field is Numeric, the length is one more than the maximum number of digits.
For example, specify 10 to allow up to 10 digits to be entered.
Type and Structure: Describes the type of data to be contained in the field.
The type and structure determines the type of data that can be entered into each field,
and how it is displayed. For more information about how different types of fields are
displayed to the user, see Entering Values in User-Defined Fields.
The following table describes the Type field options, and the Structure field options for each type:
a. Alphanumeric - A series of characters. The following are the structure options for this type:
• Regular: Lets you enter up to 254 characters.
• Address: For future use.
• Telephone No.: If automatic dialing is set up, this will let you dial the number by clicking it (not available in the
demo database).
• Text: will let you enter:
o 2 GB of text in header fields
o 255 KB of text in row fields
b. Numeric - Integers up to 10 digits long. There are no structure options for this type.
c. Date/Time - The display format for dates and time is determined by system initialization settings, located in
Administration → System Initialization → General Settings → Display tab.
Type Description / Structure Options
d. Units and Totals - Integer and decimal numbers. The following are the structure options for this type:
• Rate • Quantity
• Amount • Percents
• Price • Measure
The structures are identical except for the display format. The formats are determined by system initialization
settings located in Administration → System Initialization → General Settings → Display tab.
Type Description / Structure Options
e. General - Links and images. The following are the structure options for this type:
• Link: allow you to enter a link to a file or to a Web address
• Image: allow you to enter a link to a picture
When you add a link to a file/picture, the file/picture is copied to folders specified in the initialization settings. You
must specify these folders in Administration → System Initialization → General Settings → Path tab. Specify a
folder for files (attachments) and another for pictures.
4. Specify the valid values for the field. This step is optional. Select one or more of the following checkboxes in the
Field Data form:
Field Name Description
a. Set Valid Values for Field - Specifies that there is a predefined list of valid values for this field. For this field,
users must pick from a dropdown list of valid values. To enter a valid value, choose the New button and enter a
value and a description.
b. Set Default Value for Field - Specifies that there is a default value for the field in cases where the user does not
select one. Choose a default value from the list (if you provided a list of valid values) or enter a default value. This
setting is mandatory when the field is defined as mandatory.
c. Mandatory Field - Requires that you enter a value for this field in every document or form. If you select this
checkbox, you must specify a default value for the field.
d. Set Linked Table- Specifies that the valid values for this field are the keys (values for the Code field) in a specific
user-defined table. For more information, see Linking a User Table to a User-Defined Field. If you select this
checkbox, Set Valid Values for Field, Set Default Value for Field, and Mandatory Field are disabled.
Note
The following message is displayed:
Result
The following occurs when you add a user-defined field:
• Information about the new field (such as its name, its size, and the table to which it was added) is stored in the
CUFD table (user field definition table).
• The field is added to the relevant table. The prefix U_ is added to the name of the field in the database table,
indicating that it is a user-defined field.
SOLUTION:
Go to Tools > Customization Tools > User-Defined Fields - Management
Expand Marketing Documents, then click Rows > Click Add.
RESULT:
NOTE: The values in the dropdown list are fixed and a user can only add more values by updating the User-Defined
Fields Management Setup window.
NOTE: The UDF for Truck will also be visible in all marketing documents such as Sales Order, A/R Invoice and even
to Purchase Order, Goods Receipts PO and A/P Invoice Documents if you choose View → User-Defined Fields after
opening the mentioned windows. To limit the UDF to be available only in the Delivery document, we have to
assign a Category for the UDF.
Modifying the Display of User-Defined Fields in the Title Level
You can modify the way user-defined fields are displayed. For example, you can choose which fields are to be
displayed and in what order. User-defined field settings are saved separately for each user and for each form.
You have many user-defined fields and you would like to display different sets each time you need to display user-
defined fields. You can create a couple of categories for different user-defined fields and change the displayed
category when necessary.
Prerequisite
A form is open with the user-defined fields panel displayed. For more information, see Displaying
Header User-Defined Fields.
EXAMPLE:
Assign a Category for the UDF Truck. Set that the UDF Truck is only active and visible in the Delivery document
and not in other documents.
SOLUTION:
A. ASSIGN A CATEGORY AND SET THE UDF AS ACTIVE AND VISIBLE IN THE DELIVERY DOCUMENT:
1. Open the Delivery Document under Sales A/R → Delivery.
2. In the menu bar, choose View → User-Defined Fields. Assigning a Category is not possible if the UDF is not
visible.
3. Go to Tools → Customization Tools → Settings
4. Choose the Visible and Active columns (put a checkmark on the boxes). The following are the information in
relation to the column headers:
Field - The display name of the field.
Visible - Specifies whether the field is to be displayed or hidden.
Active - Specifies whether a user can edit the field.
Order - Specifies the display order of the fields. 1 for First, 2 for second, 3 for third, etc. This is useful if
you have 2 or more UDFs in a form. The number must be an integer. The field with the lowest
number is displayed first; the one with the highest number is displayed last.
Category - Assigns the field to a category. You can filter the user-defined fields so only fields in a specific
category are displayed using the dropdown list at the top of the user-defined fields panel:
5. In the Category column, choose Defined New. Input Delivery Document or any category name as you see fit
then click Update.
6. Then click Cancel to close the Interest - Setup window. You will go back to the Settings -Fields - Setup windows.
In the Category column, choose Delivery Document then click OK.
7. You will return to the Delivery Document. Notice that the UDF for Truck is not anymore visible. This is because
the default category for the form is General. Change it to Delivery Document. The UDF for Truck should is now
visible.
B. SET THE UDF AS NOT VISIBLE AND NOT ACTIVE IN OTHER MARKETING DOCUMENTS.
B.1. Sales Order
1. Open the Delivery Document under Sales A/R → Sales Order.
2. In the menu bar, choose View → User-Defined Fields. Assigning a Category is not possible if the UDF is not
visible.
3. Go to Tools → Customization Tools → Settings
4. Uncheck the Visible and Active columns in the Truck row then click OK. The UDF for Truck is not anymore
visible.
DO THE SAME FOR A/R INVOICE, PURCHASE ORDER, GOODS RECEIPTS PO AND A/P INVOICE DOCUMENT.
Prerequisite
NOTE: You can link a field to a user-defined table only.
• The field type is Alphanumeric and its structure is Regular.
• The Set Valid Values for Field and Set Default Value for Field checkboxes are not selected.
Procedure
A. Create a User-Defined Table.
Create a User-Defined Table (UDT) for "DRIVER".
1. In the menu bar, choose Tools → Customization Tools → User-Defined Tables - Setup.
The User-Defined Tables - Setup window opens. Enter a Table Name and Description:
Table Name Description
DRIVER Driver
Click Update then OK.
B. Create a User-Defined Field and Link the User-Defined Table to the User - Defined Field
In the Delivery Document, add a UDF with the following details:
Title DRIVER
Description Driver
Length 20
OPTION 1: Tools > User Defined Windows > Choose DRIVER and type the following codes and names:
Code Name
John John Dela Cruz Click Update
Peter Peter Picas Click Update, then click OK to close the window.
OPTION 2: Additional Values can be entered by choosing Define New in the User-Defined Field linked to a table.
Open the Delivery Document. Go to Sales A/R > Delivery
If the UDF for Driver is not yet displayed, choose View > User Defined Fields on the Menu bar then choose General
on the UDF Category.
Click the Dropdown List icon on the Driver field then choose Define New. Enter the following data:
Code Name
Chris Chris Basillio Click Update
Aron Aron Seagull Click Update, then click OK to close the window.
RESULT:
4. Choose the Update button then choose Yes on the system message.
RESULT:
Close all windows then go back to Delivery Document to check the changes.
Recommendation
NOTE: Do not remover the UDF for Truck. The following procedures are for illustration purposes only and are not
intended to remove the UDF for Truck.
If you are sure you want to delete the UDF, Choose again Yes if you see the following system message:
4.3 CONSTRUCTING SAP BUSINESS ONE FORM SYSTEM VARIABLES AND CREATING USER-DEFINED VALUES
(UDV)* *Formerly FMS - Formatted Search
A powerful skill to learn when digging into SQL query and writing formatted search (FMS) is learning how to
construct SAP Business One system variables. You may have seen them in examples on the Internet but not
quite understood how they are constructed. We're going to show you how to find the building blocks of a
variable and construct one. Once you get to understand them it is easy to apply it in everyday situations.
The $ sign system variables will work in conjunction with the SQL query generator within the SAP client. When
writing formatted searches to customize the behavior of SAP Business One they are extremely powerful,
especially on the marketing document level.
Constructing System Variables
The item designates which form data matrix you are working with in the SAP client. Column stands for the
field in the table and type is a special designator related to which data type we are working with.
It is very easy to find these values to construct the variable in most cases. You simply turn on System
Information on the SAP Business One view menu. A keyboard shortcut will also turn these fields on by hitting
CTRL+Shift+I.
Once you have enabled this, hover / m o u s e over any field or label in the Business One client. You will see
something like this across the bottom status bar of the client:
System Information
Using the system variable syntax you know that the variable can be constructed as: $[$38.1.0]
System Variable Data Types: The last number in the variable stands for data type. The data type part has
a set of available options:
0 = string
1 = number
2 = currency
3 = date
When the system information does not give a column value, use 0 (zero). Instead of using the numbers for
data type, y o u m a y a l s o use their name such as $[$22.0.number]
You may also utilize database table names and field names when constructing form variables. In these
variables you would leave off the one dollar sign ($) and t h e data type. They are constructed like this:
$[ORDR.CardCode]
One last thing to know about constructing $ system variables is that sometimes the "Item" in the syntax will
need a negative sign in front of it.
What $[$-4.0.0] is telling your code is that the system variable relates to a user defined field on the header
of your document. The main form will be positive and the UDF form will be negative.
A practical example is seeing how these form variables can be used is in a formatted search. When
customizing SAP Business One to make it work for your company you will be employing many of these
examples. This code snip is a SQL formatted search query that will return the value being held in the business
partner card code attached to a sales order.
SELECT $[$4.0.0]
Open up the query generator and paste the code into a query. Save the query.
EXAMPLES:
Provide the Form System Variable for the following fields:
1. Vendor field in the Purchase Order Document
2. Posting Date field of the A/R Invoice Document
3. No. field (or Document Number) of the A/R Invoice Document
4. Posting Date field of the Outgoing Payment Document
5. Preferred Vendor field of the Business Partner Master Data (under Purchasing Data tab).
SOLUTIONS:
Make sure that viewing System Information is Activated: View > System Information
Mouse Over to the needed fields to see the Item No., and the Column No. In case there is no column no.,
use Zero - 0.
ANSWERS:
1. $[$4.0.0]
2. $[$10.0.3]
3. $[$8.0.1]
4. $[$10.0.3]
5. $[$16.0.0]
• Deselect the box Auto Refresh, to activate the query linked to the field only when placing the cursor in
the field and selecting from the menu bar Tools → Search Function → Search (or using the key combination
Shift+F2).
• Select the box Auto Refresh to display an additional field on the right.
Two elements must be selected to conduct an Auto Refresh for a Table type field:
• The first element is the field type used for the refresh operation: by Header field or by Table field.
• The second element is the field name.
Option User action and values Comments
When Field Changes Select to refresh the field when a Header field Any change or update of the selected field
changes. will cause the search field to be refreshed.
Select the required field from the list of Header For example, a change in the selected
fields found in the drop down list located below the Header field will refresh all the rows in the
Auto Refresh box. table.
When Exiting Altered Select to refresh the field when a Table type field Any change or update in the selected field
Column changes. will cause the search field to be refreshed.
Select the required field from the list of Table type
fields found in the drop down list located below the
Auto Refresh box.
Field User action and values Comments
Refresh Regularly Select to refresh the search field each time you open or Avoid using the Refresh Regularly
browse to the document or window containing the option under this type of query since
User-Defined Values. it might affect documents you did not
intend to affect.
If the field is linked to a query that opens a multi- row
'List of' window, the first value appearing on the list will Use the Refresh Regularly option in
be selected. specific cases only, since each time
you browse to an existing document,
all the User-Defined Valueses defined
in the document are activated. This
might cause the document to be
displayed
very slowly.
Display Saved Values Select to display the value saved in the field during the The field will be refreshed only if you
addition/update of the document. That is, the value replace the field linked to the query.
saved in the database.
Auto Refresh is not implemented in fields that cannot be updated. For example, the G/L Account
Code field in an existing journal entry, the Item Number in an existing Delivery and so on.
Auto Refresh + Refresh Regularly is similar to Auto Refresh + Display Saved Values, apart
from the fact that the last one does not refresh the value when browsing or finding a document.
Limitation: When browsing through editable documents (such as Sales Orders), Header fields
with Auto Refresh are refreshed, however the document status does not change from OK to
Update.
Example 1 - SEARCH IN EXISTING USER-DEFINED VALUES (NO QUERIES LINKED)
Create a User-Defined Value for you Business Partners' Type of Business/Category. The UDV shall be placed in
the Remarks field of the Business Partner Master Data's General tab. The list of values shall be:
Merchandising
Manufacturing
Service
GOCC
Government
Others
SOLUTIONS:
Open Business Partners > Business Partner Master Data
Put your mouse cursor in the Remarks field > Press Alt + Shift + F2
Choose Search in Existing User-Defined Values then Press the Button next to it.
The Field Values-Setup window will appear. Type the needed data:
Click Update every time a data is typed. Click OK to close the window.
Click Update on the User-Defined Values - Setup window:
OUTPUT:
You should see a magnifying glass in the Remarks field of the Business Partner Master Data (under General Tab).
Click on the magnifying glass to choose the Business Partner's Business Type/Category.
Example 2 - SEARCH IN EXISTING USER-DEFINED VALUES ACCORDING TO SAVED QUERIES
Add a User-Defined Field to Show the Business Partner Balance
The company‘s sales staff needs to see the customer’s existing balance when they are on the phone taking a new
order.
1. Add a user-defined field to the title of marketing documents to show the account balance.
Choose the relevant type and structure for amounts.
Click Add. Choose Yes on the system Message and click OK to close the window.
2. Create a query to fetch the business partner balance from the database
SELECT T0.[Balance] FROM OCRD T0 WHERE T0.[CardCode] = $[$4.0.0]
Save this query.
Go to Tools>Queries>Query Generator
Since we do not see any column number in the status bar, we will use zero (0).
Data Type = 0 for String
1 for Number
2 for Currency
3 for Date
Go to Tools > Queries > Query Generator > Execute
Click OK.
Test the user-defined field
Make sure that there is a customer with a non-zero balance. If necessary, create an invoice for a customer.
In the open sales order, select a customer with balance.
The query will run and the account balance will appear in the field.
Note: To see the account balance on other marketing documents, you need to add user-defined values to each document
type. You can use the same query with these user-defined fields.
EXERCISE 1. Retrieve items from the Item Master Data window in which the Preferred Vendor is identical to the
Vendor
Code selected in a purchasing document. Thus, when creating Purchase Orders, you shall only see the items in
which the chosen Vendor is the assigned as the preferred vendor the Item Master Data window.
SOLUTION
A. Create and save the query as follows:
SELECT ItemCode from OITM Where CardCode = $[$4.0.0]
B. Link the query to the Item No. field in the required purchasing document.
Data migration involves selecting, extracting, and importing business data from the client’s legacy
system to SAP Business One.
Note: Often the client will use data migration as an opportunity to cleanse their legacy data,
especially their customer and vendor data. This is the client’s responsibility, but you should be aware
that this could cause delays to the implementation project. Experienced partners mention that this
point is very often under-estimated and can have a serious impact on the success of the project.
There are two main ways to import legacy data into SAP Business One – from within SAP Business
One you can use the Data Import from Excel utility, and from outside of SAP Business One you can
use the Data Transfer Workbench (DTW).
Using the Data Import from Excel utility, you can import business partner data and item data. You
cannot import G/L accounts or transactional data.
Using the Data Transfer Workbench, you can import a wide variety of objects, including business
partner and item data, the chart of accounts, and transactions such as journal entries and invoices.
You can also export transactions (documents) from an existing SAP Business One company database
and import them into another SAP Business One company, using the Import Transactions from SAP
Business One window.
Import From Excel Utility
Business
Items
Partners
Microsoft Excel
.txt file .txt file
Using the Import From Excel utility, you can import data for business partners, items, and price lists
to a company in SAP Business One. In addition to creating new master records, you can also update
existing master records.
You prepare the data in Microsoft Excel with the data in columns and then save the spreadsheet as
text (tab delimited).
Then, in the utility, you select either BP or Items, and you see a complete list of all master data fields
for BP or item master data. You then select the fields to match to the columns in the Excel
spreadsheet. As you select each data field, it is removed from the selection list so you cannot assign
the same field twice.
The following fields are mandatory in a Microsoft Excel spreadsheet to be imported:
Business Partner: Code, name, and type (customer, vendor, or lead). If no entry exists for
the type of business partner, the system automatically selects type C for customer.
Item: Only the item number is required for importing new item master records and updating
existing master records. SAP recommends that you import the expense and revenue
accounts for the item to prevent errors. You can also upload price lists. Specify the item
code, and for every price you want to upload, specify the price list code, price, and price list
currency.
Choose Administration Data Import/Export Data Import Import from Excel to start the
import from Microsoft Excel.
After a successful upload, create a query on the table OCRD (business partners), OITM (items), or
ITM1 (price lists) to check if the data was imported correctly.
Note that, even thought the templates contain every field for the object, you do not have to enter
every field. Leaving them blank in the import file will simply result in them being blank or defaulted
in SAP Business One.
Data Transfer Workbench Templates
Example:
OCRD - BusinessPartners.xlt
DTW provides Microsoft Excel templates that correspond to the tables in SAP Business One. Each
template is a Microsoft .xlt file and corresponds to an SAP Business One database table. Each
template name starts with the 4 character table name, for example, the main business partner
master data table is OCRD.
The template contains a title row and comments regarding the type of data that is required for each
column. Refer to the How To Guide for DTW in the SAP Business One documentation for additional
information.
Do not delete the first two rows in the templates. Start entering your data on row 3.
Add one additional column for every user-defined field that you want to import.
After you have entered or pasted your data, save the template as a text file that is tab-delimited or
comma delimited (file type .txt or .csv).
Note: To import an object, you must have with full authorization to create the object in the SAP
Business One general authorizations. Therefore you must login to DTW as a user with these
authorizations.
Field Types in the Template
Type: int
Type: string Type: enum
Specific
values
In row 1 of the template there are tooltips that provide information of the type of data required in a
field, for example:
Integer
String and length
Enum
The tooltip for an enum type field provides the list of accepted values, for example:
cCustomer or cSupplier
tYES
tNO
bop_None
bom_Buy
Parent and Child Templates
If a business
object is represented by only one table in SAP Business One (such as G/L accounts), only one
template is necessary. If a business object is represented by more than one table (for example,
business partner master data where multiple tables are used for addresses and contact persons),
one template for each table is provided.
The templates are related in a parent and child relationship through Column A.
There can be multiple rows in a child spreadsheet for a single row in the parent spreadsheet. For
example, there may be multiple contact employees for a business partner.
The LineNum column in child templates is used only during Update mode. LineNum must be an
integer so if you want to update the first line/record you assign the value 0 to the LineNum field in
the data file. If you wish to update the second line/record, you assign the value 1 to LineNum and so
on.
DTW provides a step-by-step wizard for importing the prepared data in the .txt or .csv file. This uses the Data
Interface API to ensure data consistency.
You choose the business object that you want to import or update. You can only import or update
one object at a time.
You choose the data files that you want to import and link them to the object. Depending on the
business object there may be several data files for different tables of the same business object.
Once you have linked the files to the object, you should verify that all source fields are mapped to
the correct target field. If you have not made any changes to columns in the template files, the
mapping should be correct. In the mapping rules you determine which column in the data file
(source fields) belongs to which field in the system (target fields). The target fields include user-
defined fields and you will need to map them to source fields. You can choose to skip the import of
certain columns by choosing Leave it Blank. You can save and reuse mapping rules.
You can also let the system check the mapping. It returns error messages if:
You mapped two different target fields to one source field or two different source fields to
one target field
You did not map a source field to a mandatory target field
Tips for Data Transfer Workbench
Follow the same order as you would for manually creating data, for example, create or import the
chart of accounts, currencies, business partner groups, banks, payment terms, item groups and
warehouses first before you import business partners, items, and transactions.
If you do not need a field, leave it blank. Many fields are set to a default value. If you only use a few
fields, create a customized template.
If you encounter an error during the import, try creating the same data manually in SAP Business
One
Leave the LineNum column blank for import. This is only used for update runs.
Format each cell in the spreadsheet as text. This prevents Excel from formatting or truncating
numeric values.
Some fields require the internal code from SAP Business One instead of the name, for example:
Item group codes are internally numbered starting at 100, 101, 102, etc.
Chart of accounts drawers are internally numbered as 100000000000000,
100000000000000, 100000000000000, etc.
Enter all dates as yyyymmdd, regardless of localization (for example, 20101215). Make sure you
format the cell as text.
Enter decimal places as used in the localization, for example, 10,50 or 10.50
If you import text fields, such as Remarks, make sure the text does not contain the delimiter
character that you are using in the import files, for example, if you are using comma deleted files,
then the Remarks text should not contain any commas.
To import a journal entry for a business partner, use the Journal Entry templates and leave the
AccountCode field empty and enter the BP code in the ShortName field
Before starting the following exercises, make sure that the posting period is updated.
Exercise 1
Using DTW, import the following business partner groups to SAP Business One:
Vendor Customer
Groups Groups
V Special C Retail
V Corporate C Wholesale
V Sole C Manufacturing
V Media C Middle Men
V Partner C Special
Exercise 2
Using DTW, import the following Business Partners to SAP Business One:
VENDORS
Seq. Vendor Code Vendor Name Vendor Group Payment Terms
1 SN100 Vendor 1 V Special 3 Installments
2 SN200 Vendor 2 V Special 3 Installments
3 SN300 Vendor 3 V Special 3 Installments
4 SN400 Vendor 4 V Special 3 Installments
5 SN500 Vendor 5 V Special 3 Installments
6 SN600 Vendor 6 V Special 3 Installments
CUSTOMERS
Seq. Customer Code Customer Name Customer Group Payment Terms
1 CN100 Customer 1 C Retail Cash
2 CN200 Customer 2 C Retail Cash
3 CN300 Customer 3 C Retail Cash
4 CN400 Customer 4 C Retail Cash
5 CN500 Customer 5 C Retail Cash
6 CN600 Customer 6 C Retail Cash
7 CN700 Customer 7 C Retail Cash
8 CN800 Customer 8 C Retail Cash
9 CN900 Customer 9 C Retail Cash
10 CN1000 Customer 10 C Retail Cash
11 CN1100 Customer 11 C Wholesale 2P10Net30
12 CN1200 Customer 12 C Wholesale 2P10Net30
13 CN1300 Customer 13 C Wholesale 2P10Net30
14 CN1400 Customer 14 C Wholesale 2P10Net30
15 CN1500 Customer 15 C Wholesale 2P10Net30
16 CN1600 Customer 16 C Wholesale 2P10Net30
17 CN1700 Customer 17 C Wholesale 2P10Net30
18 CN1800 Customer 18 C Wholesale 2P10Net30
19 CN1900 Customer 19 C Wholesale 2P10Net30
20 CN2000 Customer 20 C Wholesale 2P10Net30
21 CN2100 Customer 21 C Manufacturing 2P10Net30
22 CN2200 Customer 22 C Manufacturing 2P10Net30
23 CN2300 Customer 23 C Manufacturing 2P10Net30
24 CN2400 Customer 24 C Manufacturing 2P10Net30
25 CN2500 Customer 25 C Manufacturing 2P10Net30
26 CN2600 Customer 26 C Manufacturing 2P10Net30
27 CN2700 Customer 27 C Manufacturing 2P10Net30
28 CN2800 Customer 28 C Manufacturing 2P10Net30
29 CN2900 Customer 29 C Manufacturing 2P10Net30
30 CN3000 Customer 30 C Manufacturing 2P10Net30
31 CN3100 Customer 31 C Middle Men 2P10Net30
32 CN3200 Customer 32 C Middle Men 2P10Net30
33 CN3300 Customer 33 C Middle Men 2P10Net30
34 CN3400 Customer 34 C Middle Men 2P10Net30
35 CN3500 Customer 35 C Middle Men 2P10Net30
36 CN3600 Customer 36 C Middle Men 2P10Net30
37 CN3700 Customer 37 C Middle Men 2P10Net30
38 CN3800 Customer 38 C Middle Men 2P10Net30
39 CN3900 Customer 39 C Middle Men 2P10Net30
40 CN4000 Customer 40 C Middle Men 2P10Net30
41 CN4100 Customer 41 C Special 3 Installments
42 CN4200 Customer 42 C Special 3 Installments
43 CN4300 Customer 43 C Special 3 Installments
44 CN4400 Customer 44 C Special 3 Installments
45 CN4500 Customer 45 C Special 3 Installments
46 CN4600 Customer 46 C Special 3 Installments
47 CN4700 Customer 47 C Special 3 Installments
48 CN4800 Customer 48 C Special 3 Installments
49 CN4900 Customer 49 C Special 3 Installments
50 CN5000 Customer 50 C Special 3 Installments
Exercise 3
Item Code Item Name Item Group Preferred Vendor Unit Price
M100 New Item 1 Items SN300 100
M200 New Item 2 Items SN800 200
M300 New Item 3 Items SN1600 100
M400 New Item 4 Items SN1600 50
M500 New Item 5 Items SN1600 150
M600 New Item 6 Items SN1600 120
M700 New Item 7 Items SN1600 80
M800 New Item 8 Items SN1600 70
M900 New Item 9 Items SN1600 65
M1000 New Item 10 Accessories SN1600 65
M1100 New Item 11 Accessories SN1600 65
M1200 New Item 12 Accessories SN1600 65
M1300 New Item 13 Accessories SN1600 65
M1400 New Item 14 Accessories SN1600 65
M1500 New Item 15 Accessories SN1600 300
Exercise 3
Exercise 4
Notes:
For do not encode comma (,) on files saved as .csv
For fields whose valid values are tNO and tYES, use N for tNO and Y for tYES if you encounter this
error: "Data is too large".
When importing chart of accounts, you may also use the following you encounter the error "Data is
too large."
I (for Income) instead of at_Revenues
E (for Expenses) instead of at_Expenses
N (for Not applicable) instead of at_Other
If you still encounter the same error even after changing the valid values, check the spelling of the
valid values you used in the DTW template. (e.g. you may have typed CCustomer instead of
cCustomer, or n instead of N)
SOLUTIONS:
Exercise 1
Using DTW, import the following business partner groups to SAP Business One:
Vendor Customer
Groups Groups
V Special C Retail
V Corporate C Wholesale
V Sole C Manufacturing
V Media C Middle Men
V Partner C Special
2. On the Templates folder, open Administration > Setup > Business Partners > Business Partner Group
Open the Microsoft Excel Template OCRG - BusinessPartnerGroups. (OCRG is the table name for Vendor
Groups and Customer groups in SAP Business One)
3. Enter the required information.
GroupCode: Since we are just adding data, we can use 1,2,3,...etc. However, If we will update a Vendor
Group, we will use the exact group code in SAP Business One. We can check the group code through the
query generator.
GroupType: Vendor or Customer Group - bbpgt_VendorGroup for Vendor and bbpgt_CustomerGroup for
Customer. (Mouse Over to the Column Headers/Titles to have a hint on how to input the required data)
Output:
4. Save the file as Comma delimited (.csv) with file name OCRG - BusinessPartnerGroups_UL (You can choose
a different file name)
Exercise 2
Using DTW, import the following Business Partners to SAP Business One:
VENDORS
Seq. Vendor Code Vendor Name Vendor Group Payment Terms
1 SN100 Vendor 1 V Special 3 Installments
2 SN200 Vendor 2 V Special 3 Installments
3 SN300 Vendor 3 V Special 3 Installments
4 SN400 Vendor 4 V Special 3 Installments
5 SN500 Vendor 5 V Special 3 Installments
6 SN600 Vendor 6 V Special 3 Installments
7 SN700 Vendor 7 V Special 3 Installments
8 SN800 Vendor 8 V Special 3 Installments
9 SN900 Vendor 9 V Special 3 Installments
10 SN1000 Vendor 10 V Special 3 Installments
11 SN1100 Vendor 11 V Corporate Net 30
12 SN1200 Vendor 12 V Corporate Net 30
13 SN1300 Vendor 13 V Corporate Net 30
14 SN1400 Vendor 14 V Corporate Net 30
15 SN1500 Vendor 15 V Corporate Net 30
16 SN1600 Vendor 16 V Corporate Net 30
17 SN1700 Vendor 17 V Corporate Net 30
18 SN1800 Vendor 18 V Corporate Net 30
19 SN1900 Vendor 19 V Corporate Net 30
20 SN2000 Vendor 20 V Corporate Net 30
21 SN2100 Vendor 21 V Sole Net 30
22 SN2200 Vendor 22 V Sole Net 30
23 SN2300 Vendor 23 V Sole Net 30
24 SN2400 Vendor 24 V Sole Net 30
25 SN2500 Vendor 25 V Sole Net 30
26 SN2600 Vendor 26 V Sole Net 30
27 SN2700 Vendor 27 V Sole Net 30
28 SN2800 Vendor 28 V Sole Net 30
29 SN2900 Vendor 29 V Sole Net 30
30 SN3000 Vendor 30 V Sole Net 30
31 SN3100 Vendor 31 V Media 2P10Net30
32 SN3200 Vendor 32 V Media 2P10Net30
33 SN3300 Vendor 33 V Media 2P10Net30
34 SN3400 Vendor 34 V Media 2P10Net30
35 SN3500 Vendor 35 V Media 2P10Net30
36 SN3600 Vendor 36 V Media 2P10Net30
37 SN3700 Vendor 37 V Media 2P10Net30
38 SN3800 Vendor 38 V Media 2P10Net30
39 SN3900 Vendor 39 V Media 2P10Net30
40 SN4000 Vendor 40 V Media 2P10Net30
41 SN4100 Vendor 41 V Partner 2P10Net30
42 SN4200 Vendor 42 V Partner 2P10Net30
43 SN4300 Vendor 43 V Partner 2P10Net30
44 SN4400 Vendor 44 V Partner 2P10Net30
45 SN4500 Vendor 45 V Partner 2P10Net30
46 SN4600 Vendor 46 V Partner 2P10Net30
47 SN4700 Vendor 47 V Partner 2P10Net30
48 SN4800 Vendor 48 V Partner 2P10Net30
49 SN4900 Vendor 49 V Partner 2P10Net30
50 SN5000 Vendor 50 V Partner 2P10Net30
CUSTOMERS
Seq. Customer Code Customer Name Customer Group Payment Terms
1 CN100 Customer 1 C Retail Cash
2 CN200 Customer 2 C Retail Cash
3 CN300 Customer 3 C Retail Cash
4 CN400 Customer 4 C Retail Cash
5 CN500 Customer 5 C Retail Cash
6 CN600 Customer 6 C Retail Cash
7 CN700 Customer 7 C Retail Cash
8 CN800 Customer 8 C Retail Cash
9 CN900 Customer 9 C Retail Cash
10 CN1000 Customer 10 C Retail Cash
11 CN1100 Customer 11 C Wholesale 2P10Net30
12 CN1200 Customer 12 C Wholesale 2P10Net30
13 CN1300 Customer 13 C Wholesale 2P10Net30
14 CN1400 Customer 14 C Wholesale 2P10Net30
15 CN1500 Customer 15 C Wholesale 2P10Net30
16 CN1600 Customer 16 C Wholesale 2P10Net30
17 CN1700 Customer 17 C Wholesale 2P10Net30
18 CN1800 Customer 18 C Wholesale 2P10Net30
19 CN1900 Customer 19 C Wholesale 2P10Net30
20 CN2000 Customer 20 C Wholesale 2P10Net30
21 CN2100 Customer 21 C Manufacturing 2P10Net30
22 CN2200 Customer 22 C Manufacturing 2P10Net30
23 CN2300 Customer 23 C Manufacturing 2P10Net30
24 CN2400 Customer 24 C Manufacturing 2P10Net30
25 CN2500 Customer 25 C Manufacturing 2P10Net30
26 CN2600 Customer 26 C Manufacturing 2P10Net30
27 CN2700 Customer 27 C Manufacturing 2P10Net30
28 CN2800 Customer 28 C Manufacturing 2P10Net30
29 CN2900 Customer 29 C Manufacturing 2P10Net30
30 CN3000 Customer 30 C Manufacturing 2P10Net30
31 CN3100 Customer 31 C Middle Men 2P10Net30
32 CN3200 Customer 32 C Middle Men 2P10Net30
33 CN3300 Customer 33 C Middle Men 2P10Net30
34 CN3400 Customer 34 C Middle Men 2P10Net30
35 CN3500 Customer 35 C Middle Men 2P10Net30
36 CN3600 Customer 36 C Middle Men 2P10Net30
37 CN3700 Customer 37 C Middle Men 2P10Net30
38 CN3800 Customer 38 C Middle Men 2P10Net30
39 CN3900 Customer 39 C Middle Men 2P10Net30
40 CN4000 Customer 40 C Middle Men 2P10Net30
41 CN4100 Customer 41 C Special 3 Installments
42 CN4200 Customer 42 C Special 3 Installments
43 CN4300 Customer 43 C Special 3 Installments
44 CN4400 Customer 44 C Special 3 Installments
45 CN4500 Customer 45 C Special 3 Installments
46 CN4600 Customer 46 C Special 3 Installments
47 CN4700 Customer 47 C Special 3 Installments
48 CN4800 Customer 48 C Special 3 Installments
49 CN4900 Customer 49 C Special 3 Installments
50 CN5000 Customer 50 C Special 3 Installments
OPTIONAL: You may delete unnecessary columns and leave only the five columns listed above.
On the CardType column (mouse over to the column header/title to view valid values), the following are the
valid values:
cCustomer (for Customer)
cSupplier (for Vendor)
cLid (for Lead)
On the GroupCode Column, enter the actual group code assigned in SAP Business One.
To view the actual GroupCode, go to Tools> Queries> Query Generator> Click Execute> Activate the Edit
Mode by clicking this icon:
Type select * from ocrg > click Execute
On the PayTermsGrpCode, enter the Payment Terms code set in SAP Business One. You can check the
Payment Terms codes using query generator.
OCTG is the table name for the Payment Terms table in SAP Business One:
To check the table name, go to Administration> Setup> Business Partners> Payment Terms
(click Ctrl + Shift + I or go to View> System Information then mouse over to any field in the Payment
Terms window to view the table name)
Since you already have the required date, fill out the needed columns in the Microsoft Excel template file
OCRD - BusinessPartners:
Save the file as Comma delimited (.csv). Name it as OCRD - BusinessPartners_UL (or any file name of your
preference)
2. Import the file to SAP Business One using Data Transfer Workbench
On the DTW window, Click Import > Next
On Step 1: Choose Master Data > Next
On Step 2: Choose Add New Data > Next
On Step 3: Choose Business Partners > Business Partner Master Data > Next
On Step 4: Browse for the csv file prepared to add the new business partners > Next
The system message shall state "100 Business Objects were imported successfully"
Log in to SAP Business One, and view the new Business Partners added:
Exercise 3
Using DTW, add the following items to the Item Master Data in SAP Business One
Item Code Item Name Item Group Preferred Vendor Unit Price
M100 New Item 1 Items SN300 100
M200 New Item 2 Items SN800 200
M300 New Item 3 Items SN1600 100
M400 New Item 4 Items SN1600 50
M500 New Item 5 Items SN1600 150
M600 New Item 6 Items SN1600 120
M700 New Item 7 Items SN1600 80
M800 New Item 8 Items SN1600 70
M900 New Item 9 Items SN1600 65
M1000 New Item 10 Items SN1600 65
M1100 New Item 11 Accessories SN1600 65
M1200 New Item 12 Accessories SN1600 65
M1300 New Item 13 Accessories SN1600 65
M1400 New Item 14 Accessories SN1600 65
M1500 New Item 15 Accessories SN1600 300
The Microsoft Excel template file consists of complete columns found in the Item Master Data table.
Based on the needed data above, we will only need the following columns:
ItemCode
Item Name
Items Group Code (use the Query Generator to view the Items Group Code)
Mainsupplier (for Preferred Vendor)
(Notice the there is no column for the Unit Price. This is because, the unit price is entered in a separate
Microsoft Excel template file ITM1 - Items_Prices.)
The Table name for Items Group can be viewed in Administration> Setup> Inventory> Item Groups
(Click Ctrl + Shift + I and mouse over to the Item Group Name field)
3. Enter the required date in the template file OITM - Items. The output should be:
4. Save the file as Comma delimited (.csv). Name it as OITM - Items_UL (you may choose a different file
name)
5. Encode the prices in Miscrosoft Office Excel template file OITM - Items_Prices
Start>All Programs>SAP Business One > Data Migration> Templates> Templates> Inventory> Item Master
Data> ITM1 - Items_Prices).
Put the integer "1" under the price list column, indicating that the price entered will be the item's Base Price.
The integer "1" for Base Price is determined through the use of the Query Generator:
The output should be:
Keep the LineNum Column Empty when saving the file/ when importing the file. You may also input the
currency GBP. This is already the currency setup in the OEC Computers Database, hence, you may leave this
column blank.
Save the file as Comma delimited (.csv). Name it as OITM - Items_Prices (or any other file name as you see
fit).
6. Using DTW, import the two csv files (OITM - Items and ITM1 -Items_Prices) to SAP Business One.
Click Import > Next
On Step 1: Choose Master Data > Next
On Step 2: Choose Add New Data > Next
On Step 3: Choose Inventory > Item Master Data> Next
On Step 4: Browse for the OITM - Items_UL in the Parent Object Items
Browse for the ITM1 - Items_Prices_UL in the Child Object for Items_Prices
On Step 5: Click Next
On Step 6: Click Next
On Step 7: Click Import
Click Finish
Log in to SAP Business One and view the Items added to the Items Master Data
Inventory> Item Master Data
Type * in the Item number field and press enter. Scroll down to view the items added
Exercise 4
Using DTW, create A/P invoices using the following information:
AP Invoice 1 AP Invoice 2 AP Invoice 3
Vendor SN100 Vendor SN1000 Vendor SN2000
Posting Date 25-Aug-13 Posting Date 1-Jul-14 Posting Date 13-Feb-15
Due Date 25-Aug-13 Due Date 1-Jul-14 Due Date 13-Feb-15
Document Date 25-Aug-13 Document Date 1-Jul-14 Document Date 13-Feb-15
The Microsoft Excel template file consists of complete columns found in the AP Invoice table.
Based on the needed data above, we will only need the following columns:
DocNum (1 for the first AP Invoice, 2 for the Second AP Invoice, 3 for the Third AP Invoice, etc...)
DocType (dDocuments_Items for Purchased Items and dDocuments_Service for Purchased Services)
DocDate (Document Date: format should be YYYYMMDD)
DocDueDate (Due Date: format should be YYYYMMDD)
CardCode (Vendor Code)
TaxDate (Posting Date: format should be YYYYMMDD)
The output should be:
2. The items and quantities in the contents tab of the AP Invoice are encoded in a separate Microsoft Office
Excel template file PCH1 - Document_Lines
(Start>All Programs>SAP Business One > Data Migration> Templates> Templates> Purchasing> AP Invoice>
PCH1 - Document_Lines)
PCH1 is the table name for the contents tab of the AP Invoice Document.
The Microsoft Excel template file consists of complete columns found in the AP Invoice document.
Based on the needed data above, we will only need the following columns:
ParentKey (the DocNum based on OPCH - Documents_UL)
LineNum (Row number under the contents tab of AP invoice Document)
ItemCode
Quantity
* If the purchase price of the items are not the same with the unit price entered in the Item Master
Data, you will input the purchase price in the Price column. In this exercise, since the purchase price
is not given, we assume that the purchase price would be the base price set in the Item Master Data.
The output should be:
3. Save the file as Comma delimited (.csv). Name the file as OPCH - Documents_UL (or any file name of your
preferrence)
4. Import to the Parent Object (OPCH - Documents_UL) and the Child Object (PCH1 - Document_Lines_UL) to
SAP Business One using DTW
Open Data Transfer Workbench and log-in to the database you used in the previous exercises
Click Import > Next
On Step 1: Choose Transactional Data > Next
On Step 2: Choose Add New Data > Next
On Step 3: Choose Purchasing > AP Invoice> Next
On Step 4: Browse for the OPCH - Documents_UL in the Parent Object Documents
Browse for the PCH1 - Document_Lines_UL in the Child Object for Document_Lines
> Next
On Step 5: Click Next
On Step 6: Click Next
On Step 7: Click Import. Click Finish
Log in to SAP Business One and view the AP Invoice created.
Purchasing AP> AP Invoice. Click the Last Data Record on the tool bar:
d. Save the excel file as Text (Tab Delimited) or paste the encoded data in note pad.
Use any file name as you see fit.
e. Import the text file to SAP Business One (Make sure to close the excel file when importing):
f. Go back to SAP Business One and Check the imported data in Inventory>Item Master Data
UNIT VI: PRINT LAYOUT DESIGN
5. Design the Print Layout for OEC Computer UK's A/R Invoices. It should show the following:
1. Prepared by: (who created the A/R Invoice)
2. Printed by: (who printed the invoice)
3. Printed on: (Date and Time of printing)
You may position the new fields to any part of the document as you see fit.
6. Close the print preview window of the A/R Invoice and start designing the print layout repot for A/R
Invoice.
A. Create a user defined field in marketing documents that shows who is the current user (you will
use this for the Printed by field of your Print Layout).
a. Choose Tools Customization Tools User-Defined Fields – Management.
b. Select Marketing Documents > Title
Choose Add and enter the following details:
Field Name or Data Type Values
Title (no spaces) User
Description User Name
Type Alphanumeric
Length 20
Structure Regular
c. Click Add. Choose Yes on the system message. Close all other windows.
Click Update.
f. Design the Print Layout (Do not close the A/R Invoice window)
Click the Layout Designer icon on the tool bar (pencil icon).
Choose AR Invoice (System) then click Manage Layout, then Edit.
SAP Business One is an ERP system that sits on a number of database systems which includes Microsoft SQL Server,
IBM DB2 and Sybase.
For the purpose of this material, the emphasis is on Microsoft SQL Server. It is worth mentioning that SAP Business
One has a traditional backup utility called the SBO Backup Service. Microsoft SQL Server also has its own backup
tool resident in the enterprise manager.
Source: http://it.toolbox.com/blogs/sap-library/difference-between-sap-business-one-backup-and-microsoft-sql-
server-backup-9533
HOW TO BACKUP A DATABASE:
Backup the database which you are currently using (either SBODemoGB1, SBODemoGB2, SBODemoGB3, etc.)
1. Minimize SAP Business One. Go to Start > All Programs > Microsoft SQL Server 2005 (or 2008 if your Microsoft
SQL Server is 2008)> SQL Server Management Studio Express
2. In the Authentication field, choose "SQL Server Authentication" and Enter the following then click Connect
Username: sa Password: B1Admin
6. Click Remove (to remove the default path) then click Add to choose where to save the backup file.
7. Select a destination for the backup file
8. Choose a path. Save the file as ".bak". Click OK.
10. You shall see the message below. Click OK then close the SQL Server.
10. Open your chosen backup file destination to view the backup file. We will be using the backup file in the
succeeding activities.
SOLUTION:
NOTE: Do not delete anything from the SQL Server, otherwise you might delete your own database or other
databases being utilized by other classes.
STEP 1. Go to Start > All Programs > Microsoft SQL Server 2005 > SQL Server Management Studio
Express
STEP 2. In the Authentication field choose "SQL Server Authentication", enter the following:
Username: sa
Password: B1Admin
Click Connect
STEP 3. Right click on the Databases folder and choose Restore Database
STEP 4. Enter a Database Name on the To Database field (type your name, please note that
spaces are not allowed)
Under Source for restore, Choose From Device and click the browse button beside the From Device
field
Choose Add on the Specify Backup window
STEP 5. Locate the backup file StudentName.bak - remember that you were asked to save the file
with your name as the filename. (In this illustration, it is located in my PCs Drive D.).
Click Add, then click the backup file. Click OK, then OK again
STEP 6. Click OK
STEP 7. Select the file to be restored by clicking the check box under the Restore column and click OK.
NOTE: If the error bellow occur, Click on Options on the upper left of the window. If no errors were
encountered, proceed to STEP 8 in the succeeding pages.
The error above occurs either because the path is incorrect or because StudentName.bak already exist in
SAP Business One Databases or both.
if your OS is 64-bit, the path should start with Program Files (x86). For 32-bit, the path should start
with Program Files.
Edit the original file's database name. In this illustration, the backup file was originally taken from
SBODemoGB2. It was updated as SBODemoGB(Restored).
Click OK
STEP 8. The system should confirm successful restoration of database.
Close MSSQL.