Read and Download SAP Attachment Files
The following article shows how to extract attachment files of all formats from an SAP system, e.g., .pdf files of purchase orders.
About this Workflow
This article leads you through all necessary steps to set up the following workflows:
- Get a list of attached files from the SAP ERP system (Object IDs and file names)
- Use the Object IDs to download SAP attachment files of any format
SAP System | SAP Objects | Xtract for Alteryx Component |
---|---|---|
SAP ERP | SRGBTBREL (Relationships in GOS Environment) SOOD (SAPoffice: Object Definition) | Xtract Table |
SAP ERP | SO_DOCUMENT_READ_API1 (SAPoffice: View object from folder using RFC) | Xtract BAPI |
Prerequisites
To use the Xtract BAPI component and the Xtract Table component, access to the designated authority objects (RFC) in SAP must be available, see SAP User Rights: BAPI and SAP User Rights: Table.
Get a List of all SAP Attachments
Follow the steps below to set up the following workflow:
- Read the table SRGBTBREL to get all object IDs that are attached to business objects
- Read the table SOOD to get the corresponding file names and extensions of the object IDs.
- Drag & drop the Xtract Table component into your Alteryx workflow .
- Select an SAP connection . If no SAP connection is available, create a new connection, see Documentation: SAP Connection.
- Click [Edit] to open the main window of the Xtract Table component.
- Look up the SAP table SRGBTBREL.
- Select the columns TYPEID_A (source of the attached file) and INSTID_B (Object ID) for output.
- Click [OK] to save the table extraction.
- Optional: Add a Formula tool after the Xtract Table component to separate the key objects of INSTID_B into the following columns: "Object", "OBJTP" (object type), "OBJYR" (object year) and "OBJNO" (object number).
The processed list of attached files contains the following information:
- Drag & drop the Xtract Table component into your Alteryx workflow.
- Select an SAP connection. If no SAP connection is available, create a new connection, see Documentation: SAP Connection.
- Look up the SAP table SOOD. The table contains all document IDs attached to business objects.
- Select the columns OBJTP, OBJYR and OBJNO for output.
- Click [Edit parameters] and create a runtime parameter OBJNO of type string.
- Navigate to the WHERE Clause tab and create the following WHERE clause:
SOOD~OBJNO IN [OBJNO]
.
- Click [OK] to save the table extraction.
- Define an object number as the input for the runtime parameter of the Xtract Table component, e.g., 000000001276.
- Add a Join tool to join the results of the two table extraction into a single list.
Note
The workflow provided in the Alteryx community contains further steps to download the first file in the list of attached files in the SAP ERP system.
Download SAP Attachment Files
Follow the steps below to download SAP attachment files using their Object ID as input:
- Drag & drop the Xtract BAPI component into your Alteryx workflow .
- Select an SAP connection . If no SAP connection is available, create a new connection, see Documentation: SAP Connection.
- Click [Edit] to open the main window of the Xtract BAPI component.
- In the main window of the component click . The window “Function Module Lookup Lookup” opens.
- Look up the function module SO_DOCUMENT_READ_API1.
- Click [Edit parameters] and create a runtime parameter ObjectIdentifier of type string.
- In the Import tab, set the DOCUMENT_ID to the runtime parameter ObjectIdentifier.
- In the Export tab, select DOCUMENT_DATA for output.
- In the Table tab, select CONTENTS_HEX for the output. CONTENTS_HEX contains the attachment file in the format of a HEX string.
- Click [OK] to save your input.
-
Define an Object ID as the input for the runtime parameter of the Xtract BAPI component, e.g., FOL18 4 EXT45000000000229.
Tip
Object IDs are available in the SAP table SRGBTBREL, see Get a List of all SAP Attachments.
-
Add a Summarize tool to concatenate the multi-line HEX string returned by the Xtract BAPI component into a single line.
- Add a Select and a Formula tool to concatenate the file name using the Xtract BAPI output fields OBJDES and FILE_EXT, e.g.,
example.pdf
.
- Add a Append Fields tool to append the file name to the HEX string.
- Add a Blob Convert tool to convert the HEX string to a Binary Large OBject (BLOB). BLOB data types can store multiple file types, e.g., images, audio, and other objects, see Alteryx Documentation: Blob Convert Tool for more information.
- Add a Blob Output tool to save the file.
Related Links
- Alteryx Community - Read SAP Attachment Files
- Documentation: Xtract Table
- Documentation: Xtract BAPI
- Sample Workflows
Written by: Simon Rech, Valerie Schipka