(DV-2008) ERP Report comparison via Python - setup

Application server prerequisites:

  • Python 2.7 or newer

  • Pandas (library) 3.4.2 or newer

SAP User prerequisites:

  • Auth. check on object S_LOG_COM

  • COMMAND = ‘python’, ‘cd’

  • OPSYSTEM = operating system of an application server

  • HOST = host on an application server

How to compare before and after images of the report using Validate is described in (DV-2008) ERP Report Execution & Backend . However, for Python to work we must first upload scripts into the database and define rules for execution. This process consists of three steps:

  1. Upload files into database

  2. Define preset for Python execution

  3. Define config set

Uploading files into database

In this part, we upload scripts/source codes that will compare before and after images into the database, so that later can Validate take those scripts from the database and save them on the application server for execution. We upload 2 types of file format into the database:

  • BIN - binary files like libraries/executables

  • ASC - ASCII files like source codes, text files or scripts

With transaction /DVD/EXT_SETUP we can launch a general user interface. We start by entering Repository set parameter and click on Manage repository button. This parameter means, that all files we upload in the next screen are going to belong the same repository set. Identifier Repository set is used to extract all files from the database that are going to be saved on the application server during execution.

 

After confirming we will get to the next screen. Here user can do three actions regarding the files

  • Upload file - uploads file from local PC into the database

  • Download file - downloads file from the database onto local PC

  • Delete file - deletes file from the database

Upload file

By choosing Upload file, we are taken to another screen.

 

  • Content ID - we may choose any ID, it has to be unique as it is key in the database table, the field is mandatory

  • Description - mandatory, description to a file

  • File to open - specifies which file from local PC is to be uploaded, upon clicking on F4 help, file browser window will open allowing us to choose file instead of typing in path

  • File name - is automatically filled when the file is chosen in the file browser, however, we can define own filename

  • File type - is automatically filled when the file is chosen in the file browser, we can change file type but it is not recommended

  • File format - if its text-like file, the user should choose ASC option and if it is a binary file then BIN option as they are stored in a different database

After filling all required fields, we can hit Save button and the file will be uploaded and we will be redirected back to the main screen.

Download file

After clicking on the icon Download file, the browser window will open, where we can specify where to save the file. The file will be saved with following name <filename.filetype>

Delete file

Deletes file from the database. Simply select line which contains file we want to delete and click on Delete icon.

Define preset for Python execution

Preset is something like an index table for the Python module in ABAP. In its database table is defined what scripts should be saved on the application server, what are inputs, what are expected outputs, and what is the main script for execution. The ID of preset is tied to the repository set. If we defined repository set with ID PYTH_SIMPLE in the previous step, we need to define preset for this repository set.

Values that are stored in the preset table are:

  • REPOSITORY - defines what repository of files to load before execution

  • EXECUTABLE - this is a path to executable file assuming scripts are already uploaded on server and we don’t need to save files from repository on the application server

  • SRC_CODE- name of source code file that is needed during execution

  • INPUT- name of the file that serves as input during execution

  • OUTPUT - name of the file that will be created during execution and we need results from this file

  • MAIN - specifies the name of file/script that is the main executable for execution

  • DELETE - name of the file that shall be deleted after or during execution

  • CONFIG_SET- specifies the ID of config set tied to a repository set

  • PYTHON_VERSION - specifies the version of python needed for execution

When we launch transaction /DVD/EXT_SETUP we can see general UI. We fill in the Preset ID which we want to Edit/Create and confirm it by clicking on Manage preset button.

 

After clicking on Execute we will be taken to the next screen, which is a modifiable table screen.

Adding or deleting rows is done by standard ALV buttons. All rows we add will be saved under the Preset ID that we entered in the first step. On the example screen above we already have defined some of the variables, like which repository set of files to load, what config to use, what is the main script that should be run at the start of execution, what are the names of inputs that script is expecting to have and lastly, what are the names of files that will be the main output of execution, so we know in what files should we look for results. After we are done Editing/Creating preset we press Save button to save the preset.

Defining config

After uploading files and creating preset we also need to define config. Config is like preset, set of variables needed for execution. The difference between preset and config is that while preset are variables mainly for python execution, config specifies how/where will execution take place. Variables we can define in config are:

  • EXE_HOST- as execution host, variable specifies under what host should be execution run

  • RFC_DEST- RFC destination, serves if we want to execute python script on another system (useful when the current system has not python installed)

  • EXE_TMP_DIR - execution temporary directory, specifies folder name where we save our scripts and that will be used during execution on the application server

When we launch /DVD/EXT_SETUP we can see a similar screen, where we enter Config set ID and confirm by clicking Manage config button.

After confirming we will be taken to the next screen.

Similar to the preset variable defining screen, we add or delete rows by standard ALV buttons. After we are done defining variables we press Save and config set of variables will be saved to the database.

Use preset

After defining repository, preset and config we can use it in Validate. In step Set comparison settings we choose Python Report Comparator from dropdown menu and field with name Preset ID will appear. We select our defined Preset and click save. Validate will then use preset, config, and Python scripts we declared for before and after image comparison.