top of page
Search

Archivelink with Python and ABAP


This is an attempt to show functionality of SAP ArchiveLink in various program snippet examples using Python and ABAP. With a little imagination you can use these building blocks of code to create your own Content Management System interacting with SAP ArchiveLink. It’s a fun thing to learn in your spare time.


SAP ArchiveLink is a middleware interface that connects SAP documents and data to external storage systems, enabling document management and archiving capabilities within the SAP environment. Here’s a detailed overview of its key functionalities:

 

1. Document Linking

ArchiveLink enables the linking of external documents to SAP objects. This means documents stored outside the SAP database can be associated with SAP records, such as financial documents or human resources files.


2. Document Management

It provides comprehensive document management capabilities, including storing, retrieving, and displaying documents. ArchiveLink works with various content repositories, which can be configured to store the actual files in different physical or cloud storage systems.


3. Integration with Business Processes

ArchiveLink is deeply integrated with SAP business processes. It can trigger workflows based on the documents that are archived or retrieved, enhancing the automation of business processes.


4. Compliance and Security

The interface ensures compliance with legal and corporate data retention policies. It supports encryption and secure access to documents, essential for maintaining data privacy and security standards.


5. HTTP Content Server Support

ArchiveLink supports HTTP content servers, allowing documents to be accessed via standard web protocols, which simplifies the integration of third-party content management systems.


6. Scanning and Archiving

Supports scanning services and direct document archiving from scanning solutions, enabling digital storage of paper-based documents directly into the SAP system.


7. Version Management

It can handle multiple versions of a document, maintaining a history of changes and ensuring that users can access previous versions when necessary.


8. Search and Retrieval

Documents stored via ArchiveLink can be quickly retrieved using SAP search capabilities, ensuring that users can find the necessary documents efficiently based on various metadata fields.


9. Archiving of SAP Data

Apart from documents, ArchiveLink is used for archiving data from SAP, which helps in database size management by moving historical data to archive storage.


In SAP ArchiveLink, several tables are used to store document-related data. Here is an overview of these tables and sample ABAP code to retrieve data from one of these tables.

 

Key ArchiveLink Tables:

SIOINDEX: Stores index data for documents.

SOC3: Contains document content in a binary format.

SOOD: Stores metadata about documents.

SOST: Related to sending documents, often used for outbound emails.

 

Sample ABAP Code to Retrieve Data from SOC3:

Here's an example of how you might write ABAP code to query the SOC3 table, which contains the document contents stored in ArchiveLink:

DATA: it_soc3 TYPE STANDARD TABLE OF soc3,

      wa_soc3 TYPE soc3.

SELECT * FROM soc3 INTO TABLE it_soc3 WHERE relid = 'AO' AND srtf2 = 2.

LOOP AT it_soc3 INTO wa_soc3.

  WRITE: / wa_soc3-docid, wa_soc3-objtp, wa_soc3-objyr, wa_soc3-objno.

ENDLOOP.


Explanation:

  • SELECT Statement: This ABAP code snippet retrieves all entries from the SOC3 table where documents of a specific type and status are stored.

  • LOOP AT: Iterates over the result set and outputs the Document ID, Object Type, Year of the Object, and Object Number.

This code is a simple demonstration meant to show how data can be retrieved from one of the cores ArchiveLink tables. Modifications may be required based on the specific needs, such as filtering for specific document types or handling large volumes of data more efficiently.

 

Tables in ArchiveLink that Contain Documents: Retrieving Using ABAP and Python to Load to a Content Server


To retrieve documents from SAP ArchiveLink and load them into a content server, you'll need to access specific ArchiveLink tables using ABAP and then potentially use Python for further processing or loading. Below is a detailed guide and code for both ABAP and Python parts of this process.

 

ABAP Code to Retrieve Documents

First, use ABAP to retrieve data from the ArchiveLink tables. Common tables include SIOINDEX for document IDs and SOC3 for document content. Here’s how you can extract documents:


DATA: lt_soc3 TYPE STANDARD TABLE OF soc3.

SELECT * FROM soc3 INTO TABLE lt_soc3 WHERE relid = 'ATTA'.

LOOP AT lt_soc3 INTO DATA(lv_soc3).

  WRITE: / lv_soc3-docid, lv_soc3-srtf2.

ENDLOOP.

DATA: lt_soc3 TYPE STANDARD TABLE OF soc3.

SELECT * FROM soc3 INTO TABLE lt_soc3 WHERE relid = 'ATTA'.

LOOP AT lt_soc3 INTO DATA(lv_soc3).

  WRITE: / lv_soc3-docid, lv_soc3-srtf2.

ENDLOOP.

 

Python Code to Load Documents to a Content Server

Assuming the documents are accessible via a direct URL or path from the SAP server, use Python to upload these documents to a content server using requests:

import requests


def upload_document(doc_url, target_url):

    """ Upload a document to a content server. """

    response = requests.get(doc_url)  # Assuming you can directly access the document

    if response.status_code == 200:

        files = {'file': (doc_url.split('/')[-1], response.content)}

        upload_response = requests.post(target_url, files=files)

        return upload_response.status_code

    return response.status_code


# Example usage

status = upload_document(doc_url, target_url)

print(f'Document upload status: {status}')

 

Integrating ABAP with Python

To integrate the ABAP extraction with Python loading, you might use RFC or create a file dump from SAP that Python can read, depending on your infrastructure and security policies.


Steps:

  1. Extract Documents Using ABAP: As shown, extract document references from the relevant ArchiveLink tables.

  2. Transfer Data: Transfer this data from SAP to an environment where Python can access it, like through a secure file transfer or direct API calls if supported.

  3. Load to Content Server Using Python: Use the provided Python script to upload the document data to your content server.


*** Using Python to Develop a Content Server to be Accessed Using ArchiveLink ***

Developing a content server in Python that interfaces with SAP ArchiveLink involves creating an application that can receive document storage requests from SAP and manage these documents effectively. Here’s a detailed architecture and example code on how to set this up.


Architecture Overview:

  1. SAP System: Uses ArchiveLink to send document storage requests.

  2. Web Server: A Python-based server (using Flask) that receives and processes these requests.

  3. File System/Database: Stores the actual documents, either on disk or in a blob storage in a database.

 

Step 1: Set Up Python Flask Server

First, set up a basic Flask server that will listen for incoming HTTP requests from the SAP system.


from flask import Flask, request, jsonify

app = Flask(__name__)

@app.route('/store', methods=['POST'])

def store_document():

    # Extract document from the request

    document = request.files['document']

    doc_id = request.form['doc_id']

    # Store document in the file system or database

    filepath = f'/path/to/storage/{doc_id}.pdf'  # Example path

    document.save(filepath)

    return jsonify({'message': 'Document stored successfully', 'doc_id': doc_id})

if name == '__main__':

    app.run(debug=True, host='0.0.0.0', port=5000)

 

Step 2: Document Storage Function

Implement a function in your Flask app to store documents retrieved from the Flask CMS to SAP:


@app.route('/store-to-sap', methods=['POST'])

def store_to_sap():

    title = request.form['title']

    document = request.files['document_file']

    # Convert the document to a format compatible with SAP ArchiveLink

    document_content = document.read()

    # Here you would have a function to handle the SAP storage logic

    result = store_document_in_sap(sap_conn, title, document_content)

    if result:

        return redirect(url_for('index'), message="Document stored successfully")

    else:

        return "Error storing document", 500

 

Step 3: SAP Document Storage Function

This function would handle the logic to store the document in SAP. You would need to implement the RFC calls here depending on your SAP configuration:


def store document_in_sap(conn, title, content):

    try:

        # Assuming there's an RFC function in SAP that handles the storage

        response = conn.call('RFC_DOCUMENT_STORE', TITLE=title, CONTENT=content)

        return response['STATUS'] == 'SUCCESS'

    except Exception as e:

        print("Failed to store document: ", str(e))

        return False

 

Step 4: HTML Form for Document Upload

You will need a form in your Flask application to upload documents to SAP:


<!-- templates/add-content.html -->

<form method="post" action="{{ url_for('store_to_sap') }}" enctype="multipart/form-data">

    <input type="text" name="title" placeholder="Document Title" required>

    <input type="file" name="document_file" required>

    <button type="submit">Upload to SAP</button>

</form>


***Detailed Python Code for Flask Application with SAP ArchiveLink Integration***  

First, you need to ensure that your Flask application can communicate with SAP. This can be achieved by using libraries such as PyRFC or sapnwrfc, provided you have access to an SAP NetWeaver Gateway. Here's an overview of what the integration might look like:

 

Step 1: SAP Connection Setup

Before you can retrieve or store documents to SAP via ArchiveLink, you need to set up a connection using SAP's RFC protocol:

 

from pyrfc import Connection

# Configuration for the SAP connection

sap_config = {

    'user': 'your_username',

    'passwd': 'your_password',

    'ashost': 'your_sap_host',

    'sysnr': '00',

    'client': '100'

}

 

# Establishing the SAP connection

sap_conn = Connection(**sap_config)

 

Step 2: Document Storage Function

Implement a function in your Flask app to store documents retrieved from the Flask CMS to SAP


@app.route('/store-to-sap', methods=['POST'])

def store_to_sap():

    title = request.form['title']

    document = request.files['document_file']

    # Convert the document to a format compatible with SAP ArchiveLink

    document_content = document.read()

    # Here you would have a function to handle the SAP storage logic

    result = store_document_in_sap(sap_conn, title, document_content)

    if result:

        return redirect(url_for('index'), message="Document stored successfully")

    else:

        return "Error storing document", 500

 

Step 3: SAP Document Storage Function

This function would handle the logic to store the document in SAP. You would need to implement the RFC calls here depending on your SAP configuration:


def store_document_in_sap(conn, title, content):

    try:

        # Assuming there's an RFC function in SAP that handles the storage

        response = conn.call('RFC_DOCUMENT_STORE', TITLE=title, CONTENT=content)

        return response['STATUS'] == 'SUCCESS'

    except Exception as e:

        print("Failed to store document: ", str(e))

        return False

 

Step 4: HTML Form for Document Upload

You will need a form in your Flask application to upload documents to SAP:


<!-- templates/add-content.html -->

<form method="post" action="{{ url_for('store_to_sap') }}" enctype="multipart/form-data">

    <input type="text" name="title" placeholder="Document Title" required>

    <input type="file" name="document_file" required>

    <button type="submit">Upload to SAP</button>

</form>


*** Python Process to Render Documents for Viewing from ArchiveLink Tables ***

To render documents from SAP ArchiveLink tables such as SIOINDEX, SOC3, SOOD, and SOST using Python, you would need to access these tables through an SAP connection, extract the relevant data, and then format or decode the data for viewing. This example assumes you are using the PyRFC library for connecting to SAP and that you have appropriate permissions to access the data.


Step 1: Setup SAP Connection

First, you need to set up a connection to SAP to be able to query the ArchiveLink tables.


from pyrfc import Connection

# SAP connection parameters

sap_config = {

    'user': 'your_username',

    'passwd': 'your_password',

    'ashost': 'your_sap_host',

    'sysnr': '00',

    'client': '100',

    'saprouter': '/H/your/sap/router',

}

# Establish connection

conn = Connection(**sap_config)

 

Step 2: Query Document Content from SOC3

Query the SOC3 table to get the binary content of documents.

def get_document_content(doc_id):

    result = conn.call('RFC_READ_TABLE', QUERY_TABLE='SOC3', OPTIONS=[{'TEXT': f"DOCID = '{doc_id}'"}])

    if result['DATA']:

        raw_content = ''.join(item['WA'] for item in result['DATA'])

        return raw_content

    return None

 

Step 3: Decode and Render the Document

Assuming the document is in a binary format, such as PDF, you would need to decode it from the base64 encoding and save or display it.


import base64

def render_document(doc_content, output_path):

    if doc_content:

        doc_binary = base64.b64decode(doc_content)

        with open(output_path, 'wb') as f:

            f.write(doc_binary)

        print(f'Document rendered at {output_path}')

    else:

        print('No content to render')


# Example usage

doc_id = 'YOUR_DOC_ID'

document_content = get_document_content(doc_id)

render_document(document_content, '/path/to/your/output.pdf')


Explanation

  • SAP Connection: Uses PyRFC to establish a connection to SAP.

  • Query Document Content: Fetches the document content using its DOCID from the SOC3 table.

  • Decode and Render: Converts the base64 encoded content back to binary and writes it to a file, potentially as a PDF or other formats depending on the document type.

This example is highly simplified and assumes that you have direct access to the SAP system and necessary permissions. Additionally, handling different document formats and more complex SAP structures may require additional logic.


***SAP ABAP Code to Create ArchiveLink Connection to a Content Server***

To create an ArchiveLink connection to a content server using ABAP in SAP, you will generally follow these steps programmatically:

 

1.Define a Content Repository: First, you define a content repository in the SAP system that points to your external content server. This involves creating an entry in the content repository table with the necessary parameters like repository ID, document area, and connection information.


Example ABAP Code: Below is a simplified example of ABAP code that might be used to create an ArchiveLink connection to a content server:


DATA: lv_repid TYPE sioindex-repid,

      lv_docarea TYPE sioindex-docarea,

      lv_conntype TYPE sioindex-conntype.

lv_repid = 'ZCONTENT_REPO'.       " Repository ID

lv_docarea = 'BC-SRV-ARL'.        " Document area

lv_conntype = 'HTTP'.             " Connection type

CALL FUNCTION 'SIO_CREATE_REPOSITORY'

  EXPORTING

    repid       = lv_repid

    docarea     = lv_docarea

    conntype    = lv_conntype

  IMPORTING

    subrc       = lv_subrc

  EXCEPTIONS

    error       = 1

    OTHERS      = 2.

IF lv_subrc EQ 0.

  WRITE: / 'Repository Created Successfully.'.

ELSE.

  WRITE: / 'Error Creating Repository.'.

ENDIF.


Explanation:

  • SIO_CREATE_REPOSITORY: This function module is used to create a new content repository in SAP. You need to specify the repository ID, document area, and connection type.

  • lv_repid, lv_docarea, lv_conntype: These variables are used to store the parameters for the content repository. You would replace 'ZCONTENT_REPO' and other parameters with actual values according to your system configuration.

  • Error Handling: The code checks if the repository was created successfully and displays an appropriate message.

This example is quite basic and would need to be adjusted to fit the specific details and security requirements of your SAP system and content server.


*** Python Code to Connect SAP ArchiveLink to Content Server Repository ***

Connecting to an SAP ArchiveLink content server repository using Python involves interfacing with the SAP system to retrieve or manage documents. Typically, Python does not directly interact with SAP ArchiveLink, but you can use libraries like PyRFC or SAP NetWeaver RFC SDK to execute RFC functions that interact with SAP.


Here is a conceptual example using Python to call a function module in SAP that might be used to interact with an ArchiveLink content repository. This example assumes you have the necessary SAP RFC function modules available that facilitate such an interaction.


from pyrfc import Connection

# SAP connection parameters

sap_config = {

    'user': 'your_username',

    'passwd': 'your_password',

    'ashost': 'your_sap_host',

    'sysnr': '00',

    'client': '100'

}

# Connect to SAP

conn = Connection(**sap_config)

# Define the parameters for the RFC call

function_module = 'RFC_ARCHIVE_CONNECT'

rfc_parameters = {

    'REPOSITORY_ID': 'REPO_ID',

    'DOCUMENT_TYPE': 'DOCTYPE'

}

# Make the RFC call to SAP to interact with the ArchiveLink repository

result = conn.call(function_module, **rfc_parameters)

print(result)

Explanation:

  • Connection Setup: The connection to SAP is set up using the PyRFC library, which requires parameters like user ID, password, host, system number, and client.

  • RFC Call: A Remote Function Call (RFC) to a function module (assumed here as RFC_ARCHIVE_CONNECT) is made. This function module would need to be specifically designed or available in your SAP system to handle requests to ArchiveLink content repositories.

  • Parameters: Parameters such as REPOSITORY_ID and DOCUMENT_TYPE are placeholders and should be replaced with actual data relevant to your use case.

This script is purely illustrative and might need substantial adjustments based on actual available RFC modules in your SAP system and the specifics of your ArchiveLink configuration.


*** Python Extracting Data from SAP Using ArchiveLink and Loading into Content Server***

Extracting data from SAP using ArchiveLink and loading it into a content server using Python involves several steps, including interfacing with SAP to retrieve data, and then processing and uploading that data to an external content server. Here's a detailed example using Python:


Step 1: Retrieve Data from SAP

You will need to use a library capable of interfacing with SAP, like PyRFC or SAP NetWeaver RFC SDK. This example uses PyRFC


from pyrfc import Connection

# Connection Parameters

sap_config = {

    'user': 'username',

    'passwd': 'password',

    'ashost': 'host',

    'sysnr': 'system_number',

    'client': 'client_id'

}

# Establish Connection

conn = Connection(**sap_config)

# Function to retrieve data

def get_sap_data():

    result = conn.call('RFC_READ_TABLE', QUERY_TABLE='your_sap_table')

    return result['DATA']

# Extract data

sap_data = get_sap_data()

print(sap_data)

 

Step 2: Process Data (if necessary)

Depending on your needs, process the data received from SAP.

def process_data(data):

    # Example: Convert data into a suitable format

    processed_data = [record['WA'] for record in data]

    return processed_data

processed_data = process_data(sap_data)

 

Step 3: Upload Data to Content Server

This step depends on the content server's API. Assuming a REST API, you can use requests to post data.

python


import requests

def upload_to_server(data):

    headers = {'Content-Type': 'application/json'}

    response = requests.post(url, json=data, headers=headers)

    return response.status_code

upload_result = upload_to_server(processed_data)

print(f'Upload Status Code: {upload_result}')

 

Complete Workflow

Combining all the steps to create a full workflow.


def main():

    sap_data = get_sap_data()

    processed_data = process_data(sap_data)

    result = upload_to_server(processed_data)

    print(f'Result: {result}')

if name == "__main__":

    main()


***Tables in ArchiveLink that Contain Documents: Retrieving Using ABAP and Python to Load to a Content Server ***


To retrieve documents from SAP ArchiveLink and load them into a content server, you'll need to access specific ArchiveLink tables using ABAP and then potentially use Python for further processing or loading. Below is a detailed guide and code for both ABAP and Python parts of this process.


ABAP Code to Retrieve Documents

First, use ABAP to retrieve data from the ArchiveLink tables. Common tables include SIOINDEX for document IDs and SOC3 for document content. Here’s how you can extract documents:


DATA: lt_soc3 TYPE STANDARD TABLE OF soc3.

SELECT * FROM soc3 INTO TABLE lt_soc3 WHERE relid = 'ATTA'.

LOOP AT lt_soc3 INTO DATA(lv_soc3).

  WRITE: / lv_soc3-docid, lv_soc3-srtf2.

ENDLOOP.


Python Code to Load Documents to a Content Server

Assuming the documents are accessible via a direct URL or path from the SAP server, use Python to upload these documents to a content server using requests:


import requests

def upload_document(doc_url, target_url):

    """ Upload a document to a content server. """

    response = requests.get(doc_url)  # Assuming you can directly access the document

    if response.status_code == 200:

        files = {'file': (doc_url.split('/')[-1], response.content)}

        upload_response = requests.post(target_url, files=files)

        return upload_response.status_code

    return response.status_code


# Example usage

status = upload_document(doc_url, target_url)

print(f'Document upload status: {status}')

 

Integrating ABAP with Python

To integrate the ABAP extraction with Python loading, you might use RFC or create a file dump from SAP that Python can read, depending on your infrastructure and security policies.


Steps:

  1. Extract Documents Using ABAP: As shown, extract document references from the relevant ArchiveLink tables.

  2. Transfer Data: Transfer this data from SAP to an environment where Python can access it, like through a secure file transfer or direct API calls if supported.

  3. Load to Content Server Using Python: Use the provided Python script to upload the document data to your content server.

***Create Using Python: ArchiveLink Integration for Linking External Documents to SAP Objects ***

To link external documents to SAP objects using Python, you would typically use a Python script to interface with an SAP system via ArchiveLink. The script would handle the uploading of documents to a content server and linking these documents to specific SAP records. Below is an example of how this might be conceptualized using Python with hypothetical function calls.

 

Step 1: Prepare the Document

First, ensure the document is ready to be uploaded, either from a local file system or obtained from an external source.


def read_document(file_path):

    with open(file_path, 'rb') as file:

        return file.read()

 

Step 2: Upload Document to Content Server

Using a REST API, upload the document to a content server that is configured to work with SAP ArchiveLink.


import requests

def upload_document_to_server(doc_data, server_url):

    response = requests.post(server_url, files={'document': doc_data})

    return response.json()  # Assuming the server returns JSON with a document ID

 

Step 3: Link Document to SAP Object

Assuming you have a service in place that can communicate with SAP to create the link between the document and an SAP object (e.g., a financial record or HR file).


def link_document_to_sap(doc_id, sap_object_id, sap_link_service_url):

    payload = {'doc_id': doc_id, 'sap_object_id': sap_object_id}

    response = requests.post(sap_link_service_url, json=payload)

    return response.status_code

 

Step 4: Full Workflow

Combine the functions to complete the document linking process.


def main():

    file_path = 'path/to/document.pdf'

    sap_link_service_url = 'http://your-sap-service.com/link'

    sap_object_id = '0001234567'  # Example SAP object ID

    # Read and upload document

    document = read_document(file_path)

    upload_result = upload_document_to_server(document, server_url)

    if upload_result.get('success'):

        doc_id = upload_result['doc_id']

        # Link document to SAP object

        link_status = link_document_to_sap(doc_id, sap_object_id, sap_link_service_url)

        print(f'Link Status: {link_status}')

    else:

        print('Failed to upload document')

if name == '__main__':

    main()


***Create a Content Management System (CMS) Using Python: Detailed Architecture ***

Creating a Content Management System (CMS) using Python involves setting up a web server, a database to manage content, and a front-end for user interactions. Python's flexibility and rich ecosystem make it ideal for such a task, using frameworks like Flask or Django for web development.


High-Level Architecture:

  1. Web Server: Handles HTTP requests and serves the web application using Python.

  2. Database: Stores and retrieves content, user settings, and other data.

  3. Front-End: Interface for users to interact with the CMS.

  4. Back-End: Business logic of the CMS, handling data processing, storage, and retrieval.

 

Detailed Steps and Technologies:

Step 1: Set Up the Web Server

Using Flask, a lightweight WSGI web application framework:


from flask import Flask, render_template, request, redirect, url_for

app = Flask(__name__)

 @app.route('/')

def index():

    return render_template('index.html')

 if name == "__main__":

    app.run(debug=True)

This code starts a basic Flask app that can be accessed locally.

 

Step 2: Database Integration

Using SQLAlchemy, an ORM (Object-Relational Mapping) library for database management:

from flask_sqlalchemy import SQLAlchemy

app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///cms.db'

db = SQLAlchemy(app)

class Content(db.Model):

    id = db.Column(db.Integer, primary_key=True)

    title = db.Column(db.String(100), nullable=False)

    body = db.Column(db.Text, nullable=False)

    def repr(self):

        return '<Content %r>' % self.title

This setup creates a simple SQLite database for storing CMS content.

 

Step 3: User Interface

Using HTML and Jinja2 templating in Flask for rendering pages:

<!-- templates/index.html -->

<html>

<head>

    <title>CMS Home</title>

</head>

<body>

    <h1>Welcome to the CMS</h1>

    <a href="/add-content">Add Content</a>

    <!-- List contents -->

</body>

</html> This is a basic template for the homepage.

 

Step 4: Adding and Managing Content

Implement routes to add and manage content

@app.route('/add-content', methods=['GET', 'POST'])

def add_content():

    if request.method == 'POST':

        title = request.form['title']

        body = request.form['body']

        new_content = Content(title=title, body=body)

        db.session.add(new_content)

        db.session.commit()

        return redirect(url_for('index'))

    return render_ This route allows adding new content via a web form.

 

Step 5: Front-End Interaction

Use JavaScript and CSS to enhance the interactivity and style of the CMS.

 

Deployment

Deploy the CMS on a server using Gunicorn or a similar WSGI HTTP server, and use Nginx or Apache as a reverse proxy for production environments.


***Document Linking code in Python and ABAP ***


Example in ABAP

REPORT zarchivelink_example.

DATA: lv_document_id TYPE toavk-arc_doc_id,

      lt_links TYPE TABLE OF toavk,

      lv_return_code TYPE sy-subrc.

* Create a new ArchiveLink document

CALL FUNCTION 'ARCHIV_CONNECTION_INSERT'

  EXPORTING

    archiv_id                  = 'ZARCHIVE'

    document_id                = lv_document_id

    object_id                  = 'YOUR_OBJECT_ID'

    object_type                = 'BUS2035'

  IMPORTING

    return_code                = lv_return_code

  TABLES

    archive_links              = lt_links.

IF lv_return_code = 0.

  WRITE: / 'Document linked successfully'.

ELSE.

  WRITE: / 'Error linking document', lv_return_code.

ENDIF.

 

Example in Python

import requests

def archive_link_document(server_url, archive_id, document_id, object_id, object_type):

    payload = {

        'ARCHIV_ID': archive_id,

        'DOCUMENT_ID': document_id,

        'OBJECT_ID': object_id,

        'OBJECT_TYPE': object_type

    }

    response = requests.post(f"{server_url}/archive_link", data=payload)

    if response.status_code == 200:

        print("Document linked successfully")

    else:

        print("Error linking document", response.status_code)


# Example usage

archive_link_document(

    server_url="http://sapserver.example.com",

    archive_id="ZARCHIVE",

    document_id="YOUR_DOCUMENT_ID",

    object_id="YOUR_OBJECT_ID",

    object_type="BUS2035"

)


Have fun and achieve growth!

18 views0 comments

Comments

Couldn’t Load Comments
It looks like there was a technical problem. Try reconnecting or refreshing the page.

Featured Blog Post

bottom of page