This feature requires Velixo v6.1.2 or higher with Excel for Windows

Description

The WRITEBACK function sends one or more lines of values to the ERP.

The function uses the fields specified in a pre-defined Import Scenario for a specific screen in the ERP.

Syntax

WRITEBACK(Connection, ScreenID, ImportScenarioName, DataColumnNames, 
RangeOrDataItem, RangeOrDataItem1,RangeOrDataItem2, ..., RangeOrDataItem250)

Parameters

The WRITEBACK function uses the following parameters:

Parameter

Required/Optional

Description

Connection

Required

The name of the connection as configured in the Connection Manager

ScreenID

Required

The ScreenID of the ERP screen containing the data that is being sent to the ERP.

ImportScenarioName

Required

The name of the pre-defined Import Scenario that is being used to send data to the ERP.

DataColumnNames

Required

The names of the fields to which data is being written. These names must all exist in a single row on the worksheet.

OutputRange

Optional

An Excel range reference to a cell (or range of cells) for output parameters. If multiple records are expected, the range should include a row for each record.

RangeOrDataItem

Required

The first set of data to be sent to the ERP. The values to be written must be specified in the same order as the column/field names specified in the DataColumnNames parameter

RangeOrDataItem1

Optional (depending on the amount of data being written to the ERP)

An additional set of data to be sent to the ERP

...

RangeOrDataItem250

Optional (depending on the amount of data being written to the ERP)

An additional set of data to be sent to the ERP


Example

Given this configuration:

We could create this function:

=WRITEBACK("Demo", "AR303000", "ACU Import Customers", B1:O1, B2:O2, B3:O3,
B4:O4, B5:O5)

Description

As a basic example, will be writing data to the screen with the ID "AR303000".

That ERP contains an active, pre-defined Import Scenario named ACU Import Customers:

To help us create our worksheet, we can use the WRITEBACKARGUMENTS function to list the name of the fields associated with that specific Import Scenario:

and then fill in the data we want to send to the specified ScreenID:

(note:  Empty values cannot be omitted if column names are specified for them in
that WRITEBACK formula. The number of values must be equal to the number of
column names. Otherwise, an error message will be shown:

Our WRITEBACK function...

=WRITEBACK("Demo", "AR303000", "ACU Import Customers", B1:O1, B2:O2, B3:O3, 
B4:O4, B5:O5)

... can then reference the data we have filled in.

  • B1:O1 references the names of the fields to which we will be sending data

  • B2:O2 references the first line of data we are sending

  • B3:O3 references the second line of data we are sending.

  • etc.

note: The WRITEBACK function does not require us to use cell references; we could
also type information directly into the function.

e.g.,
=WRITEBACK("Demo", "AR30300, "ACU Import Customers",{"TESTDEL1","First",
"[email protected]","79169224455","1-st Ave","23 bul.2","New York","US","NY",,
"LOCAL","","",""})

The WRITEBACK function also supports importing multiple entries with a single function call. Expanding on the above example, we could send two records to the ERP like this:

=WRITEBACK("Demo", "AR303000", "ACU Import Customers",{"Customer ID","Customer Name","Email","Phone 1","Address Line 1","Address Line 2","City","Country Code","State","Postal Code","Customer Class"},{"TESTDEL1","First","[email protected]","79169224455","1-st Ave","23 bul.2","New York","US", "NY",,"LOCAL","","",""},{"TESTDEL2","First","[email protected]","79169224455","1-st Ave","23 bul.2","New York","US","NY","","LOCAL"})

Note that we are sending data for both TESTDEL1 and TESTDEL2 with a single WRITEBACK function with each set of data contained within its own set of braces { }

πŸ” See below for additional ways to compose writeback data.


Result

Before the data is sent to the ERP...

...the status of the function is Pending:

Once we select Import Current Worksheet, the process will start:

Once the process is complete...

... the status of the WRITEBACK function will change to Line range uploaded...

... and, within our ERP, we can visit screen AR303000 and see that the data has been imported:

πŸ” Ways to build writeback data lines

In this section, let's explore all the different ways how you can compose data for the WRITEBACK function. For your convenience, we made the function very powerful and flexible in that regard.

We will be using a hypothetical example where you write back data lines containing an account number, employee ID, a monetary amount, and a date. We'll be using a fictional screen id EX123456 and scenario names "EX Import Lines".

As separate lines - multiple WRITEBACK functions

The first way to write back such a block of data would be to just specify every data line as separate RangeOrDataItem arguments of the WRITEBACK function:

This works great if the number of lines doesn't change over time, or changes relatively infrequently.

The downside is that you need to keep track when the number of lines changes, and not forget to copy down the formula every now and then.

As separate lines - single WRITEBACK function

A slight variation of the above approach is if you want to use just one WRITEBACK function and display the status just once on your worksheet. To specify data items as separate lines in such a case, you can use multiple RangeOrDataItem arguments representing writeback lines:

The downside here, again, is when the number of items changes over time, you will need to manually modify your formula.

As a block of data - single WRITEBACK function

Alternatively, you can just put the whole Excel range into the first RangeOrDataItem argument of the WRITEBACK function:

❗With hard-coded range references, it might be an OK choice when the shape of data and the number of lines stays the same over time. If the shape of data changes, however, there is a risk that you might forget to modify the formula to include the additional data lines.

It is a great choice, though, when the whole block of data is a spilling range:

πŸ‘‹ Hint: You can use such functions as COLLATE, HSTACK and VSTACK to compose such a dynamic block.

From separate columns of data - single WRITEBACK function

Let's suppose that the employee's name in our example stays the same, no matter what, and the date is the same for every line.

Also, let's suppose that the Account and Amount are Excel spill ranges coming from two different functions or data sources.

Can we compose our writeback data in a more dynamic way without using HSTACK / COLLATE, and also avoid repeating JOHNDOE over every line?

Yes, we can!

Note how we reference the Account / Amount using the spilling range syntax with "#", and also specify "EmployeeName" and "Date" as a single-cell-reference.

Velixo will be smart enough to internally compose data lines that look like this, where constant single-cell references are internally "copied down" for every row (in bold below):

81000, JOHNDOE, 100, 01/01/2022,

81010, JOHNDOE, 200, 01/01/2022,

81020, JOHNDOE, 300, 01/01/2022 etc.

This saves space on the worksheet, gets rid of unnecessary duplication, and is also completely robust if the spilling ranges of accounts/amounts resize in the future.

❗ Note, how in that last example, we still need to specify all relevant data column names in the WRITEBACK function call.

Happy power-using of the WRITEBACK function with Velixo! πŸ’ͺ

Did this answer your question?