(DV-2005) 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 application server

  • HOST = host on application server

How to compare before and after images of report using Validate is described in (DV-2005) ERP Report Execution & Backend . However, for Python to work we must first upload scripts into 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 database, so that later can Validate take those scripts from database and save them on application server for execution. We upload 2 types of file format into 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 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 next screen are going to belong same repository set. Identifier Repository set is used to extract all files from database that are going to be saved on application server during execution.

 

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

  • Upload file - uploads file from local PC into database

  • Download file - downloads file from database onto local PC

  • Delete file - deletes file from 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 database table, 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 file is chosen in file browser, however, we can define own filename

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

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

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

Download file

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

Delete file

Deletes file from 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 index table for Python module in abap. In its database table is defined what scripts should be saved on application server, what are inputs, what are expected outputs and what is main script for execution. ID of preset is tied to repository set. If we defined repository set with ID PYTH_SIMPLE in previous step, we need to define preset for this repository set.

Values that are stored in preset table are:

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

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

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

  • INPUT- name of file that serves as input during exectuion

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

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

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

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

  • PYTHON_VERSION - specifies version of python needed for exectution

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 next screen, which is modifiable table screen.

Adding or deleting rows is done by standard ALV buttons. All rows we add will be saved under 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 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 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. 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 intalled)

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

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

After confirming we will be taken to next screen.

Similar to 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 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.