How to Define Unix Host Concurrent Program in Oracle Apps

The host is one of the execution methods available in Oracle Apps while defining concurrent program executable. It allows the concurrent program to execute operating system commands. Here, the host (Operating System) could be Windows, Unix, or any supported operating system.

Here, let’s see how to define a Unix host-based concurrent program.

Unix Host Concurrent Program

UNIX/Linux is the most widely used Operating system for Oracle Apps Implementation. The shell script is a default programming language for UNIX. Simply we can say, UNIX host-based concurrent program is actually a shell script. This concurrent program executes all commands written in shell script and returns control back to the concurrent manager with the exit code.

Exit code in Unix concurrent program:

  • = 0 – program completed successfully
  • > 0 – program completed in error

In this article, I will cover how to define UNIX/Shell script-based concurrent programs.

Let’s take below as requirement,

Create a UNIX concurrent program that emails a file from a location or concurrent program output to a user using Unix mailx utility.

Concurrent program parameters,

From
To
CC
BCC
Subject
File Location

Pre-requisite

You should have a working knowledge of Oracle Apps and Basic knowledge of Unix commands.

Software/Hardware environment

  • Oracle apps 11i or R12
  • Putty
  • Winscp

Steps To Register Unix Shell Script As A Concurrent Program

1. Create shell script (. prog)

Let’s create an executable file first. It is a text file with a .prog extension. As per the Oracle Apps Developer Guide, the extension should be .prog.

In a Unix-based concurrent program, the first 5 parameters from $0 to $4 are reserved and used by Oracle to pass the below information to the shell script. User-defined parameters start from $5 onwards.

Note: This is applicable when there exists a link to fndscpr file.

— Standard Parameter—

Below parameters from $0 to $4 are reserved to hold information.

$0: Shell script to be executed
$1: Oracle user/password
$2: Applications user_id
$3: Application user_name
$4: Concurrent program request_id

— User-defined parameters—-

$5 Onwards are the custom parameters.

$5: From
$6: To
$7: CC
$8: BCC
$9: Subject
$10: File Path

Note: In some Unix operating systems you need to use curly brackets when parameter numbers are two digits {$10} or use the Unix SHIFT command to shift the parameter to the $9 position. Check the file below to understand the shift command.

# Name:- xxhost_conc_demo.prog
# Description:- Demo script to send email 
# parameters
#  From
#  To
#  CC
#  BCC
#  Subject
#  File Name

echo "print reserved parameter"

echo "0 - Shell Script " $0
echo "1 - Oracle user/password" $1
echo "2 - Applications user id" $2
echo "3 - Application user name" $3
echo "4 - Concurrent program request id" $4

echo

echo "print custom parameter"
echo "5 - From" $5
FROM=$5

echo "6 - To" $6
TO=$6

echo "7 - CC" $7
CC=$7

echo "8 - BCC" $8
BCC=$8

echo "9 - Subject" $9
SUB=$9
shift                     # this shift 10th parameter to 9th position
echo "10 -File Name" $9   # referring 10th parameter as 9th
FILE=$9

# send email using mailx command
echo "Testing Unix Host Based concurernt Program" | mailx -s $SUB -c $CC -b $BCC -r $FROM -a $FILE $TO

2. FTP this file to $XXCUSTOM_TOP/bin path

FTP this script using WinSCP or FILEZILLA to respective $XXCUSTOM_TOP/bin. Host program executable file always put under /bin directory. Make sure the encoding of the script should be in Unix format else you will get an error while running the script because of Ctrl-M (^M) Characters.

Login to Unix Server using Putty and change file permission to 755 using below command,

chmod 755 xxhost_conc_demo.prog

The above step is required to avoid file permission error, else you will get FND-CP-ESP: Child: exec:: Permission denied error. It happens because Oracle Unix users cannot execute the script.

3. Create a soft link to FNDCPESR

All parameters to shell script are passed as a single concatenated string. You need to either parse and split these parameters using SED, CUT commands or create a soft link to the FNDCPER program. This is a standard utility by the oracle which parses parameters passed to the Unix program from the concurrent program and properly segregates them as $0,$1 .. $n.

ln -s $FND_TOP/bin/fndcpesr  xxhost_conc_demo

Do not include .prog extension.

4. Define executable

Register executable for the program as shown below image. Navigation Application Developer–> Define–> Executable.

Unix Host Executable

Execution Method: Host
Execution File Name: xxhost_conc_demo ( name of file without .prog extension)

5. Define Concurrent Program

Navigate and register a concurrent program. Select the executable name defined in the previous step.

unix-host-concurrent-program-definition

unix-concurrent-program-parameter

6. Register Concurrent Program

Register a concurrent program to any valid responsibility. That’s it and you have defined a Host concurrent program in Oracle Apps.

Sample Log File

Below if the log file which will help you to understand how parameters are passed.

+---------------------------------------------------------------------------+

Current system time is 25-OCT-2017 03:51:03

+---------------------------------------------------------------------------+

print reserved parameter
0 - Shell Script /atech/app/xxcust/12.0.0/bin/xxhost_conc_demo
1 - Oracle user/password APPS/apps
2 - Applications user id 45878
3 - Application user name ATECH
4 - Concurrent program request id 90315090

print custom parameter
5 - From [email protected]
6 - To [email protected]
7 - CC [email protected]
8 - BCC [email protected]
9 - Subject Testing
10 -File Name /home/atech/sample_file

+---------------------------------------------------------------------------+
No completion options were requested.

Please share and subscribe.