You are on page 1of 22

Integration Framework 2.

0 for SAP Business One


Example – How to Send Attachments
Nicolas Fuchs, SAP
May 2019

PUBLIC
Scenario Description: HTTP/RESTful Call from SAP Business One

Electronic document HTTP Call


transmission

HTTA call to Multipart/mixed;


Create B1 purchase order requests
target system
order w/o including
attachment(s) attachment(s)

SAP Business One For example,


company database SAP Ariba Network
for Buyers

© 2019 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 2


Integration Framework 2.0 – New Web-Based IDE

Multiple Tabs
Error Handling

Navigation Tree
Design Elements

Design Area

Notification Area Details Area with Zoom

© 2019 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 3


Definition of Scenario Packages, Scenarios and Scenario Steps

▪ The scenario package is the software logistics unit.


The package handles a specific business integration case
that belongs to a specific namespace and owner.

▪ Scenarios help to structure the business integration


case, for example, master data synchronization, or order
processing.

▪ A scenario step is the technical unit that performs the


message processing.
At runtime, one step is one transaction. Scenario steps
are processing independent of each other.

© 2019 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 4


Scenario Flow Description/Processing Tasks

1. Subscription of inbound to an SAP Business One event for Purchase Order provided by the event
sender and handed over to the integration framework
2. Definition of data retrieval for the concrete SAP Business One event
3. If attachments exist: Definition of an SQL statement to look up the file path and file details of the
attachments in the ACT1 table in relation to the value in the object “AttachmentEntry”
4. Running of the SQL Statement as defined by using the JDBC adapter
5. If attachments exist: Definition of the upload process for attachments, otherwise skip task
6. Definition of the outgoing message based on the previous results using XSL or JavaScript
7. Hand over the message to the HTTA adapter for sending
8. Usage of the HTTP call response to update SAP Business One with the call status information by using
the SAP Business One call atom.

© 2019 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 5


Creating a New Scenario Step: HTTPOutgoing

1 right click
2

3 right-click
4

4 Result: sap.SendPurchaseOrder

© 2019 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 6


Adding an Inbound Atom to Define B1 Inbound

1. Select atom: Ip / Inbound


2. Double click the atom
3. You can change the name of the
1
atom, for example, to “B1Inbound”;
Give the atom a description, for
example, “[B1Inbound]” to be used
for the payload id attribute within the 3
smart message 4
4. Select Adapter Type from the list
”B1EV” 2 5
5. Select the BusinessObject and the
way how to retrieve the data:
BusinessObject: 22
DataRetrieval: Data Retrieval - Smart
Messaging
RetrievalType: DI API - Object Call -
All with Public Properties
(NodesAsProperties)
6. Close all configuration screens

© 2019 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 7


Defining an Additional Path in the Flow if Attachment Exists

1. Add a Branch and Unbranch atom to the flow


2. Draw a line for another/second path with
condition
3. To set the path condition, double click on the
line to enter the condition to the Branch Path
1
4. Set the condition of the second path to
”otherwise” and activate “Always Trigger”

3 XPath Expression:
/*[number(/vpf:Msg/vpf:Body/vpf:Payload[./@Role='S']/BOM/BO/Documents/row/AttachmentEntry)>0]

© 2019 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 8


Adding an XSL to Define an SQL Statement for Retrieving Attachment Details

1. Select xForm atom for XSL/JavaScript


Transformation and add it to the flow
2. Add also an Adapter Call atom to flow
3. Double click the Transformation atom
4. You can change the name of the atom, for
example, to “PrepSQL”;
Give the atom a description written in [ ],
for example “[PrepSQL]” to use for the 3
payload id attribute within the smart
message 1
5. Define the name of the source incl. file
8
extension such as ‘xsl’ for XSL or ‘js’ for a
JavaScript, for example, “PrepSQL.xsl”
6. Close the configuration screen
4
7. Right click the transformation atom to open
2
source in a new tab.
Opening the source physically creates the
file in the BizStore.
7
8. All sources are also available and 5
accessible in the menu “Sources” of the
navigation tree

© 2019 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 9


Defining the SQL Statement to Retrieve File Information of Attachments

1. Open the source to edit the code


2. Add the SQL statement for looking up the details of
the attachments within the template ”transform”
3. The schema of the SQL statements can look like as
shown below.

You can also use the variable “$msg” which refers


to the inbound payload of the incoming message

Please refer to the schema documentation of the


JDBC adapter for further information about SQL
statements representation in the integration
framework.

<xsl:variable name="AttachEntry" select="$msg/BOM/BO/Documents/row/AttachmentEntry" />


<jdbc:SqlStatement>
SELECT "AbsEntry", "Line", "srcPath", "trgtPath", "FileName", "FileExt", "Date", "FreeText" FROM "ATC1“
WHERE "AbsEntry" =<xsl:value-of select="$AttachEntry"/>
</jdbc:SqlStatement>

© 2019 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 10


Setting Parameters for the JDBC Adapter Call to Execute the SQL Statement

1. Double click the Adapter Call atom


2. You can now change the name of the atom: for example,
“CallSQL”;
Give the atom a description, for example “[CallSQL]” to use
for the payload id attribute in the smart message
3. Select the adapter type you want to use.
In our example it is JDBC 2
4. Enter the XPath expression referring to the payload in the 4
XSL transformation atom we have defined in the previous 3
slide (see also below) 1
5. Defining the Outbound Configuration:

To make use of Smart Messaging ”adjustToSmartMsg”


needs to be set to true. 5
If the connection parameter SLD is selected, you can select
the database system during the deployment process.
Otherwise it is possible to select a fixed sysid, pick up the
values via an XPath statement from the message or take the
sender system.
6. Close the configuration screen 4 /vpf:Msg/vpf:Body/vpf:Payload[./@id='PrepSQL']/jdbc:SqlStatement

© 2019 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 11


Split and Join („for-each“) Atoms for Reading Multiple Attachments (1)

1. Add a Split and Join atom to the flow


2. Add a XSL/JavaScript Transformation atom to the
flow
3. Add an Adapter Call to the flow.
4. Double click the Split atom to open the screen to set
the XPath for the iteration

1
4

Split XPath:
/vpf:Msg/vpf:Body/vpf:Payload[./@id='SQLCall']/jdbc:ResultSet/jdbc:Row
© 2019 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 12
Split and Join („for-each“) Atoms for Reading All Attachments (2)

1. Double click the XSL/JavaScript Transformation


atom.
2. You can change the name of the atom: for example,
“prepFilePath”;
Give the atom a description written in [ ], for
example “[prepFilePath]” to use for the payload id
attribute within the smart message
3. Define the name of the source file incl. file extension
such as ‘xsl’ for XSL or ‘js’ for a JavaScript such, for
example, “prepFilePath.xsl”
4. Right click the XSL/JavaScript Transformation atom
1
to open the source in a new tab.
Opening the source physically creates the file in the
BizStore.
5. You can add your code in the section ‘Template’.
4 2
6. All sources are also available and accessible in the
menu “Sources” in the navigation tree.

5
© 2019 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 13
Code Snippet of the XSL/JavaScript Transformation “prepFilePath.xsl”

© 2019 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 14


Setting All Parameters for the FILP (Get File from File System) Adapter Call

1. Double click Adapter Call atom


2. You can change the name of the atom: for example, “ReadFile”;
Give the atom a description, for example “[ReadFile]” to be used
for the payload id attribute in the smart message
3. Select the adapter type FILP – Get File from File System (Polling)
4. Define the Outbound Configuration parameters: 1
pltype xml
sysid empty
adjustToSmartMsg true
filePattern //FileName
(switch Value Source from “Fixed” to
XPath) 2
ftp.throwexeption true or false

© 2019 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 15


Finalizing the Mapping for the „Multipart Message“

1. Add an XSL/JavaScript Transformation atom to the


flow and double click it
2. You can change the name of the atom: for example,
“FinalMessage”;
Give the atom a description written in [ ], for
example “[FinalMessage]” to be used for the
payload id attribute in the smart message
3. Define the name of the source file incl. file extension
such as ‘xsl’ for XSL or ‘js’ for a JavaScript such, for
example, “FinalMessage.xsl” 1
4. Right click the XSL/JavaScript Transformation atom
to open the source in a new tab.
Opening the source physically creates the file in the
BizStore.
5. You can add your code in the section ‘Template’
6. All sources are also available and accessible in the 2
menu “Sources” in the navigation tree

© 2019 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 16


Example of the Multipart Message – Purchase Order with Attachments

Message Envelope

Message Part 1
containing the XML data

Message Part for Attachment(s)


incl. attribute describing the
attachment file(s)

© 2019 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 17


Adding an HTTA Call to Send the MultiPart Message

1. Select Adapter Call atom to add a new adapter call to


the flow
2. Double click the Adapter call atom
3. Change the Identifier and Description to, for example,
HTTAoutgoing and [HTTA]
4. Set the XPath to the message payload. Here, it points to
the previous atom with the Identifier “FinalMessage”: 3
/vpf:Msg/vpf:Body/vpf:Payload[./@id='FinalMessage']/io
4
5. Define the necessary parameters for the Outbound
Configuration, for example, as shown in the screen shot

© 2019 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 18


Changing the XML Processor for MultiPart Messages

Because of constrains of the default JREXML processor to


handle this kind of message types is recommended to use the
SAPXML processor. Also see SAP Note 2331485 - JRE XML
Processor Becomes Default XML Processor
1
1. Right click on the package -> go to Definitions -> XML
Processor Exclusion
2
2. Add a new definition for the XSL/JavaScript atom of the
scenario step which shall use the SAPXML processor
instead of JREXML processor

© 2019 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 19


Deploying the Package in the Deployment Panel

1. Add a new Deployment


2. Select the scenario you want to deploy
3. Assign the Systems to run the scenario
4. For detailed debugging activate detailed 1
debugging
5. Activate the package

4
3
2

© 2019 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 20


Thank you.
Nicolas Fuchs
Global SME Integration
SAP SE

Dietmar-Hopp-Allee 16
69190 Walldorf/Baden
Germany

nicolas.fuchs@sap.com

P +49 6227 7 67177


M +49 172 6279281
Follow us

www.sap.com/contactsap

© 2019 SAP SE or an SAP affiliate company. 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 SE or an SAP affiliate company.
The information contained herein may be changed without prior notice. Some software products marketed by SAP SE and its
distributors contain proprietary software components of other software vendors. National product specifications may vary.
These materials are provided by SAP SE or an SAP affiliate company for informational purposes only, without representation or
warranty of any kind, and SAP or its affiliated companies shall not be liable for errors or omissions with respect to the materials.
The only warranties for SAP or SAP affiliate company 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.
In particular, SAP SE or its affiliated companies have no obligation to pursue any course of business outlined in this document or
any related presentation, or to develop or release any functionality mentioned therein. This document, or any related presentation,
and SAP SE’s or its affiliated companies’ strategy and possible future developments, products, and/or platforms, directions, and
functionality are all subject to change and may be changed by SAP SE or its affiliated companies at any time for any reason
without notice. The information in this document is not a commitment, promise, or legal obligation to deliver any material, code, or
functionality. All forward-looking statements are subject to various risks and uncertainties that could cause actual results to differ
materially from expectations. Readers are cautioned not to place undue reliance on these forward-looking statements, and they
should not be relied upon in making purchasing decisions.
SAP and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered
trademarks of SAP SE (or an SAP affiliate company) in Germany and other countries. All other product and service names
mentioned are the trademarks of their respective companies.
See www.sap.com/copyright for additional trademark information and notices.

You might also like