---
title: "Automatic Code Upload via API for Unix OS SAP Server"
slug: "how-to-implement-automatic-custom-code-upload-using-api-for-unix-os-sap-server"
updated: 2023-05-31T08:15:34Z
published: 2023-05-31T08:15:43Z
canonical: "success.panaya.com/how-to-implement-automatic-custom-code-upload-using-api-for-unix-os-sap-server"
---

> ## Documentation Index
> Fetch the complete documentation index at: https://success.panaya.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Automatic Code Upload via API for Unix OS SAP Server

This guide is applicable for a Unix SAP server

[**Download the Ruby for Linux ZIP file**](https://cdn.document360.io/f404076c-de23-4609-848e-2dfd4ef701b0/Images/Documentation/Rubylinux.zip)The file includes the following -

1. **Xa.rb** - the ruby executable script for the Custom Code Extraction and Upload automation
2. **Config.yml**
3. **RunRuby.sh**
4. **Gemfile**
5. **InstallRuby.sh**- Ruby & Ruby Version Manager install file

---

## **Step 1 - Create a Folder for Panaya**

Create a folder named **PANAYA**on the Working directory of the SAP server e.g. /mnt/data/usr/sap/<SYSTEM_NAME>/DVEBMGS00/work/PANAYA

- The PANAYA folder must  have the same group and owner as the rest of the files in the working directory
- All files extracted must have full execution permissions

---

## **Step 2 - Install Ruby and RVM on Unix server**

This step is to be performed by a **certified Unix system admin**. The [downloaded ZIP file](https://cdn.document360.io/f404076c-de23-4609-848e-2dfd4ef701b0/Images/Documentation/Rubylinux.zip) contains the **RubyInstall.sh** file. Use it for installing Ruby and RVM on the SAP Unix server. During the RVM installation, you will need to manually be requested to execute the following script - **source ~/.rvm/scripts/rvm**

**Important!** The steps in the file should be executed by the same user executing systems commands

**To verify the installation -**

1. Use the following command  
***gem list***  
and verify that the following gems are installed-  
bigdecimal (default: 1.2.8)  
bundler (1.15.3)  
bundler-unload (1.0.2)  
did_you_mean (1.0.0)  
domain_name (0.5.20170404)  
executable-hooks (1.3.2)  
gem-wrappers (1.2.7)  
http-cookie (1.0.3)  
io-console (default: 0.4.5)  
json (default: 1.8.3)  
mime-types (3.1)  
mime-types-data (3.2016.0521)  
minitest (5.8.3)  
net-http-persistent (2.9.4)  
net-telnet (0.1.1)  
netrc (0.11.0)  
power_assert (0.2.6)  
psych (default: 2.0.17)  
rake (10.4.2)  
rdoc (default: 4.2.1)  
rest (3.0.8)  
rest-client (2.0.2)  
rubygems-bundler (1.4.4)  
rvm (1.11.3.9)  
systemu (2.6.5)  
test-unit (3.1.5)  
unf (0.1.4)  
unf_ext (0.0.7.4)  
uri-handler (1.0.2)
2. If any of the gems are missing, try to manually install the bundle by running the following - 

**gem install bundler**

Alternatively, install the gems manually by running the following - gem install systemu gem install rest-client gem install json gem install uri-handler

---

## **Step 3 - Configure the Config.yml file**

Open the **Config.yml** file and define the following -

- server_login -  https://**<PROD_SERVER_ADDRESS>**/api/accesstoken  
Use the relevant URL - https://my.panaya.com/api/accesstoken or https://emea.panaya.com/api/accesstoken
- server_erps -  https://**<PROD_SERVER_ADDRESS>**/api/erps  
Use the relevant URL - https://my.panaya.com/api/erps  or https://emea.panaya.com/api/erps
- server_etl -  https://**<PROD_SERVER_ADDRESS>**/api/accounts/  
Use the relevant URL - https://my.panaya.com/api/accounts/ or https://emea.panaya.com/api/accounts/
- username -  **<username>**- your login username to Panaya****
- token- **<token>**-  your token for the Panaya login
- workingdir - <empty>
- erpid - **<ERPID>** - provided by your CSM

---

## **Step 4 - Change parameter in runruby.sh**

Open the runruby.sh file and configure the following - system name - **<SYS_NAME>**

Verify that the **PANAYA**folder path is correct - cd /mnt/data/usr/sap/**<SYS_NAME>**/DVEBMGS00/work/PANAYA/ bundle install ruby /mnt/data/usr/sap/**<SYS_NAME>**/DVEBMGS00/work/PANAYA/xa.rb

---

## **Step 5 - Configure the Panaya Code Extractor Program**

1. Launch transaction **SA38**
2. Fill in the program name - **ZPANAYA_EXTRACT_PROG_LIB**
3. Under **Execution mode** - Select **Background Directory**and paste the**PANAYA folder path**
4. Fill in the production **RFC details**  
**![](https://cdn.document360.io/f404076c-de23-4609-848e-2dfd4ef701b0/Images/Documentation/image-1639037078819.png)**
5. Click on Save![](https://cdn.document360.io/f404076c-de23-4609-848e-2dfd4ef701b0/Images/Documentation/image-1639037090493.png) to create a variant.  
For variant name use - **API_AUTOMATION**  
For Meaning use - **API Automation ![](https://cdn.document360.io/f404076c-de23-4609-848e-2dfd4ef701b0/Images/Documentation/image-1639037104814.png)**
6. Click on Save![](https://cdn.document360.io/f404076c-de23-4609-848e-2dfd4ef701b0/Images/Documentation/image-1639037113192.png)

---

## **Step 6 - Generate an OS-Command**

1. Execute transaction **SM69**
2. Use the Create button![](https://cdn.document360.io/f404076c-de23-4609-848e-2dfd4ef701b0/Images/Documentation/image-1639037125763.png)
3. Define Command Name as **ZPANAYA_RUBY**
4. Under **Definition**, fill in the **Operating system command** -  
**<Full path to Folder PANAYA>**/runruby.sh  
![](https://cdn.document360.io/f404076c-de23-4609-848e-2dfd4ef701b0/Images/Documentation/image-1639037138012.png)

---

## **Step 7 - Generate a Scheduled Job**

1. Execute transaction **SM36**
2. Fill in the job name - **ZPANAYA_AUTOMATION_EXTRACT**
3. Click on the **Step**button
4. Under the ABAP Program section, select **ZPANAYA_EXTRACT_PROG_LIB** and variant **API_AUTOMATION**
5. Save your work. The following step should appear.
6. Click on the Create button![](https://cdn.document360.io/f404076c-de23-4609-848e-2dfd4ef701b0/Images/Documentation/image-1639037148432.png)
7. Select External Command and define the name for the External Command as **ZPANAYA_RUBY**  
For Operating sys. type **Linux**  
**![](https://cdn.document360.io/f404076c-de23-4609-848e-2dfd4ef701b0/Images/Documentation/image-1639037164949.png)**
8. Save your work. The following step should appear.  
![](https://cdn.document360.io/f404076c-de23-4609-848e-2dfd4ef701b0/Images/Documentation/image-1639037173186.png)
9. Click on the Back button and then **Start Condition**
10. Click on the **Date/Time** Button and define the date and time for the Panaya extractor to be executed.  
Check the **Periodic Job** option and then click on the **Periodic values**button.
11. Select the Weekly option and **Save**
12. Click **Save**again
13. The following screen will appear
