Monday 16 January 2012

shell scripting


Host Concurrent Program

SAMPLE HOST FILE OR SHELL SCRIPT FOR SQL LOADER:

i have written the shell script it might help someone.
step1 open note pad and write the below script and save it with extension .prog ie XX_JOB_HOST_PROG.prog and deploy it in oracle server.

DATAFILE=$5
DIR_NAME=$6
LOG_BAD_PATH=$7
CTRLFILE=$8
LOG_BAD_PATH_LOG=$9
LOG_BAD_PATH_BAD=${10}
LOG_BAD_PATH_DSC=${11}
APPLTOP=$DIR_NAME/bin
FILE_NAME=${LOG_BAD_PATH}/${DATAFILE}.csv
LOGFILE=${LOG_BAD_PATH_LOG}/${CTRLFILE}.log
BADFILE=${LOG_BAD_PATH_BAD}/${DATAFILE}.bad
DISCARDFILE=${LOG_BAD_PATH_DSC}/${DATAFILE}.dsc
echo "****************************************************************************"
echo "Parameters for SQL Loader Process "
echo " "
echo "Control File:" $APPLTOP/$CTRLFILE
echo "Data File:" $FILE_NAME
echo "Log File:" $LOGFILE
echo "Bad File:" $BADFILE
echo "Discard File:" $DISCARDFILE
echo "****************************************************************************"
echo "Executing the SQL Loader Process.."

sqlldr userid=apps/apps@ebs12 control=${APPLTOP}/${CTRLFILE}.ctl data=${FILE_NAME} log=${LOGFILE} bad=${BADFILE} discard=${DISCARDFILE} errors=100000

echo "****************************************************************************"
echo "Process Complete - Exiting"
exit 0

step 2. create a soft link in unix using "ln -s $FND_TOP/bin/fndcpesr XX_JOB_HOST_PROG" (without any extension)

step 3. deploy the .ctl and the data file into oracle server.

step 4 create conc. executable as host execution method. and proceed to run the request(hope u all know how to do that)

note: while creating conc.programme please pass all the parameters.

Implementing a Host Concurrent Request
Host concurrent programs are best for performing operating system tasks such as
copying files.
Setting up a Host Concurrent program in the UNIX operating system is relatively
painless. First you must write your shell script and save the script under the
$PRODUCT_TOP/bin directory corresponding to the application that the executable is
registered under. When the host concurrent program is invoked five standard
parameters are passed in $0 thru $4. The five standard parameters do not need to be
defined on the Concurrent Program Parameters Form.
Variable Contents
$0 Name of the Concurrent Program
$1 Oracle User ID/PASSWORD
$2 User ID (numeric representation)
$3 User Name that submitted the request (character representation)
$4 Request ID for the request
The parameters in $5 thru $9 are user defined and are passed in the order defined on
the Concurrent Program Parameters form. The total number of parameters passed is
shell (ksh, csh, bourne, etc) dependent. To be able to reference parameters 6 thru N
where parameter 6 would be the equivalent of $10 you must use the shift command to
place the value of the 10 th argument into $9 variable (see example script APPENDIX
3).
If you specify “encrypt” in the Execution Options filed of the Concurrent Programs
window.
This signals the concurrent manager to pass orauser\pwd in the environment variable
fcp_login. The password of the argument $1 will be populated with asterisks (SEE UNIX
Installation Guide B-12).After you have created your host concurrent program make sure
that you save the program with an extension of “YOUR_HOST.prog”. The execution file
specified when the executable is defined should be equal to “YOUR_HOST” excluding
the .prog extension. After you have saved your executable it is important to create a
symbolic link from “YOUR_HOST” to fndcpesr in the same directory that your host
concurrent program is saved. The command to create the symbolic link is:
“ln -s fndcpesr YOUR_HOST”
If you fail to create the symbolic link the parameters passed to your program will not be
passed in separate variables rather they will be passed as one long string in the $1
parameter. It is important to remember to grant executable permissions on the script file
that is your host concurrent program. The command to do this is:
chmod 755 YOUR_HOST.prog
if you fail to do this your concurrent program will fail and exit with status 1.
If you wish to direct output to the request log or output log for your host concurrent
program it is the responsibility of the programmer to construct the correct file name
based on the user name ($3) and request id ($4) parameters. The request log is of the
format “l######.req” where ###### = request id ($4). The output files fomat is
dependent upon the environment variable $APPCPNAM. If $APPCPNAM is set to
USER.REQUID then the naming convention for output files will be USERNAME.######
where ###### = request id ($4) and USERNAME is the user that submitted the request
($3). If APPCPNAM is not set the default 8.3 naming convention will be used which is
o######.out where ###### = request id ($4).

Host Concurrent Program

Below are the steps to register host concurrent program in oracle apps

1) Define Concurrent Program with Executable Type = Host and Execution File Name = Name of .prog file without extension

2) Copy your .prog file (Shell Script) to Custom Top Bin directory (Eg: $XXCUST_TOP/bin)

3) Create symbollic link by executing below commands on Unix Server
cd $XXCUST_TOP/bin
ln -s $FND_TOP/bin/fndcpesr sample_file
WHERE sample_file = Name of your Host program script

  1. Dear Friends, i want to use host command in a concurrent request to load data in a table from a flat file .
for that i wrote one flat file(test_data_host.txt) , one control file(test_data_host.ctl) , one script file(test_data_host_prog.prog)
Finally i made one concurrent program BPIL_TEST_DATA_HOST and saved it as ‘ HOST ‘.
i added to my test_data_host_prog.prog file four compulsory parameters ,but during registration in sysadmin -> concurrent-> program -> define ,In parameters window, i had left all blank.(previously, same was running when i made one link from ‘$FND_TOP/bin/fndcpesr’ file using command: *ln -s $FND_TOP/bin/fndcpesr test_data_host_prog * through telnet.)
During running of the concurrent program it is giving error: The executable file /dev02/CPS/apps/apps_st/appl/ja/12.0.0/bin/test_data_host_prog for this concurrent program can not be executed.
my files data is attached here with:
1) test_data_host.txt file:
Tamojit,1,history
Vishnu,2,maths
Krishna,3,HRMS
*******************
2) test_data_host.ctl file:
LOAD DATA
APPEND
INTO TABLE BPIL_TEST_CONTROL_FILE
FIELDS TERMINATED BY “,”
OPTIONALLY ENCLOSED BY’”‘
TRAILING NULLCOLS
( name1,
class1,
subject,
record_status CONSTANT ‘NEW’)
*******************************
3) test_data_host_prog.prog file:
# Parameters passed into program
ORA_USER_PASS=$1
USERID=$2
USERNAME=$3
REQUESTID=$4
#LOGON_STRING=’apps/appscps@cps’
#FILENAME=$5
sqlload userid=apps/appscps@cps control=/usr/tmp/test_data_host.ctl data=/usr/tmp/test_data_host.txt log=/usr/tmp/test_data_host_log.log bad=/usr/tmp/test_data_host_bad.bad ERRORS=100000 silent=FEEDBACK <<!
!
RC=$?
echo “The sql loader exit code for loading Header table is :”$RC
if [$RC -eq 0 -o $RC -eq 3 |http://forums.oracle.com/forums/]
then
echo ‘Loading of file table successful.’
else
echo ‘Error: Loading of file table has errors. Sqlload return code is ‘$RC
exit 1
fi
case “$RC” in
0) echo “SQL*Loader execution successful” ;;
1) echo “SQL*Loader execution exited with failure, see logfile” ;;
2) echo “SQL*Loader execution exited with warning, see logfile” ;;
3) echo “SQL*Loader execution encountered a fatal error” ;;
*) echo “unknown return code $RC” ;;
esac
kindly help me with the same to run the concurrent request successfully to load the data .
Thanks & Regards
Vishnu Pratap Patel
(vishnu.patel@tcs.com)
  1. Sanjit Anand Says:September 5th, 2008 at 8:15 pm
echo should work.what is version of your oracle u are using.
Command like
echo “Line 1.”
echo “line 2.”
suppose to print
Line 1.
Line 2.
in log file.
are u sure prog completed successfully. some time access previlege also causing , as there is no debug options unless developer is realize that something pre-requssite is not performed yet.
this is simple host based concuuurent prog used to Moves files from one directory to another
Three input parameter is there.
once you put the script in to Unix box, donot forgot to run this command
ln -s -f $FND_TOP/bin/fndcpesr XXTEST
–here is code
# Initialise environment variables
echo " Initialise location specific environment variables"
ORA_USER_PASS=$1
USERID=$2
USERNAME=$3
REQUESTID=$4
P_SOURCE_DIR=`eval echo $5`
P_TARGET_DIR=`eval echo $6`
P_FILENAME=$7

DIR=`eval echo $1`

# Initialise common environment variables
echo " Initialise common environment variables"
SCRIPT=XXTEST.prog

# Variables for Load filenames
echo " "
echo "Input Directory = " $P_SOURCE_DIR

# Setting the Directory Names
CTLDIR=$XXPH_TOP/bin
LOGDIR=$XXPH_TOP/log
BADDIR=$XXPH_TOP/log

# Setting the Log file for the .prog file
REPFILE=$APPLCSF/$APPLLOG/l$REQUESTID.req
PROBLEMS=0
# ----------------------------------------------------------
echo "\n Start" $SCRIPT
echo " ************************************"
# ------------------------------------------------------------------

# Display all parameters entered
  echo " For Supplier data conversion -- Parameters entered:-" >> $REPFILE
  echo " SQL*Plus userid   = " $USERID >> $REPFILE

# Display Other parameters :-

  echo "Other Parameters :-" >> $REPFILE
  echo "--------------------" >> $REPFILE
  echo "Source directory = " $P_SOURCE_DIR >> $REPFILE
  echo "Target directory = " $P_TARGET_DIR >> $REPFILE
  echo "Filename         = " $P_FILENAME >> $REPFILE

echo "At the end of Parameter Listing " >>  $REPFILE

#
# Check if the Data Files Exist
echo "At the start of Data Files Check " >>  $REPFILE
#
if [ ! -f $P_SOURCE_DIR/$P_FILENAME ]
then
    echo  $P_SOURCE_DIR/$P_FILENAME " does not exist"
    echo "**************************************************" >> $REPFILE
    echo "*$P_SOURCE_DIR/$P_FILENAME " does not exist"           *" >> $REPFILE
    echo "**************************************************" >> $REPFILE
    PROBLEMS=1
    exit 1
fi
#
echo "At the end of Data File Check " >>  $REPFILE
#
#   Move the file to the target directory
# ------------------------------------------------------------------
mv $P_SOURCE_DIR/$P_FILENAME $P_TARGET_DIR
if [ $? != 0 ]
then
    echo "**************************************************" >> $REPFILE
    echo "*$P_SOURCE_DIR/$P_FILENAME " failed to move "          *" >> $REPFILE
    echo "**************************************************" >> $REPFILE
    PROBLEMS=1
fi
mv $P_SOURCE_DIR/$P_FILENAME'.o' $P_TARGET_DIR
if [ $? != 0 ]
then
    echo "**************************************************" >> $REPFILE
    echo "*$P_SOURCE_DIR/$P_FILENAME'.o " failed to move "    *" >> $REPFILE
    echo "**************************************************" >> $REPFILE
    PROBLEMS=1
fi
# ------------------------------------------------------------------
#
if test $PROBLEMS = 1
then
    echo "\nUnsuccessful termination of" $SCRIPT >> $REPFILE
    echo "\n------------------------------------" >> $REPFILE
    exit 1
else
    echo "\n----------------------------------" >> $REPFILE
    echo "Successful termination of" $SCRIPT >> $REPFILE
    echo "----------------------------------" >> $REPFILE
fi
exit 0
  1. Sanjit Anand Says:September 5th, 2008 at 8:33 pm
Dear Vishnu,
there should not be any issue.
errors message seems there need a proper access on file in unix.
Do a quick check
1. when create a soft line you should do like
ln -s -f $FND_TOP/bin/fndcpesr test_data_host_prog
2. Make sure soft link is create or not
3. Make sure you should have proper access on the site.
When you are calling sqllodaer from its better use directly from home and just pass userid which internally passed by fndcpesr prog.
$ORACLE_HOME/bin/sqlldr USERID=$ORA_USER_PASS CONTROL=$CTLDIR/$LOADER1.ctl LOG=$LOGDIR/$LOADER1.log BAD=$BADDIR/$LOADER1.bad ERRORS=0 DATA=$LOGDIR/filenames.dat >>$REPFILE
and you can see how these are derived from parameter
ORA_USER_PASS=$1
USERID=$2
USERNAME=$3
REQUESTID=$4
P_INPUT_DIR=`echo $5`

# Setting the Control File Names
LOADER1=XXTESTLOAD

CTLDIR=$XXPH_TOP/bin
DATDIR=`echo $P_INPUT_DIR`
LOGDIR=$XXPH_TOP/log
BADDIR=$XXPH_TOP/log
Let me know , in case if this does not work, I will send you code.send me offline message.

Host Concurrent Program

SAMPLE HOST FILE OR SHELL SCRIPT FOR SQL LOADER:

i have written the shell script it might help someone.
step1 open note pad and write the below script and save it with extension .prog ie XX_JOB_HOST_PROG.prog and deploy it in oracle server.

DATAFILE=$5
DIR_NAME=$6
LOG_BAD_PATH=$7
CTRLFILE=$8
LOG_BAD_PATH_LOG=$9
LOG_BAD_PATH_BAD=${10}
LOG_BAD_PATH_DSC=${11}
APPLTOP=$DIR_NAME/bin
FILE_NAME=${LOG_BAD_PATH}/${DATAFILE}.csv
LOGFILE=${LOG_BAD_PATH_LOG}/${CTRLFILE}.log
BADFILE=${LOG_BAD_PATH_BAD}/${DATAFILE}.bad
DISCARDFILE=${LOG_BAD_PATH_DSC}/${DATAFILE}.dsc
echo "****************************************************************************"
echo "Parameters for SQL Loader Process "
echo " "
echo "Control File:" $APPLTOP/$CTRLFILE
echo "Data File:" $FILE_NAME
echo "Log File:" $LOGFILE
echo "Bad File:" $BADFILE
echo "Discard File:" $DISCARDFILE
echo "****************************************************************************"
echo "Executing the SQL Loader Process.."

sqlldr userid=apps/apps@ebs12 control=${APPLTOP}/${CTRLFILE}.ctl data=${FILE_NAME} log=${LOGFILE} bad=${BADFILE} discard=${DISCARDFILE} errors=100000

echo "****************************************************************************"
echo "Process Complete - Exiting"
exit 0

step 2. create a soft link in unix using "ln -s $FND_TOP/bin/fndcpesr XX_JOB_HOST_PROG" (without any extension)

step 3. deploy the .ctl and the data file into oracle server.

step 4 create conc. executable as host execution method. and proceed to run the request(hope u all know how to do that)

note: while creating conc.programme please pass all the parameters.

Implementing a Host Concurrent Request
Host concurrent programs are best for performing operating system tasks such as
copying files.
Setting up a Host Concurrent program in the UNIX operating system is relatively
painless. First you must write your shell script and save the script under the
$PRODUCT_TOP/bin directory corresponding to the application that the executable is
registered under. When the host concurrent program is invoked five standard
parameters are passed in $0 thru $4. The five standard parameters do not need to be
defined on the Concurrent Program Parameters Form.
Variable Contents
$0 Name of the Concurrent Program
$1 Oracle User ID/PASSWORD
$2 User ID (numeric representation)
$3 User Name that submitted the request (character representation)
$4 Request ID for the request
The parameters in $5 thru $9 are user defined and are passed in the order defined on
the Concurrent Program Parameters form. The total number of parameters passed is
shell (ksh, csh, bourne, etc) dependent. To be able to reference parameters 6 thru N
where parameter 6 would be the equivalent of $10 you must use the shift command to
place the value of the 10 th argument into $9 variable (see example script APPENDIX
3).
If you specify “encrypt” in the Execution Options filed of the Concurrent Programs
window.
This signals the concurrent manager to pass orauser\pwd in the environment variable
fcp_login. The password of the argument $1 will be populated with asterisks (SEE UNIX
Installation Guide B-12).After you have created your host concurrent program make sure
that you save the program with an extension of “YOUR_HOST.prog”. The execution file
specified when the executable is defined should be equal to “YOUR_HOST” excluding
the .prog extension. After you have saved your executable it is important to create a
symbolic link from “YOUR_HOST” to fndcpesr in the same directory that your host
concurrent program is saved. The command to create the symbolic link is:
“ln -s fndcpesr YOUR_HOST”
If you fail to create the symbolic link the parameters passed to your program will not be
passed in separate variables rather they will be passed as one long string in the $1
parameter. It is important to remember to grant executable permissions on the script file
that is your host concurrent program. The command to do this is:
chmod 755 YOUR_HOST.prog
if you fail to do this your concurrent program will fail and exit with status 1.
If you wish to direct output to the request log or output log for your host concurrent
program it is the responsibility of the programmer to construct the correct file name
based on the user name ($3) and request id ($4) parameters. The request log is of the
format “l######.req” where ###### = request id ($4). The output files fomat is
dependent upon the environment variable $APPCPNAM. If $APPCPNAM is set to
USER.REQUID then the naming convention for output files will be USERNAME.######
where ###### = request id ($4) and USERNAME is the user that submitted the request
($3). If APPCPNAM is not set the default 8.3 naming convention will be used which is
o######.out where ###### = request id ($4).

Host Concurrent Program

Below are the steps to register host concurrent program in oracle apps

1) Define Concurrent Program with Executable Type = Host and Execution File Name = Name of .prog file without extension

2) Copy your .prog file (Shell Script) to Custom Top Bin directory (Eg: $XXCUST_TOP/bin)

3) Create symbollic link by executing below commands on Unix Server
cd $XXCUST_TOP/bin
ln -s $FND_TOP/bin/fndcpesr sample_file
WHERE sample_file = Name of your Host program script

  1. Dear Friends, i want to use host command in a concurrent request to load data in a table from a flat file .
for that i wrote one flat file(test_data_host.txt) , one control file(test_data_host.ctl) , one script file(test_data_host_prog.prog)
Finally i made one concurrent program BPIL_TEST_DATA_HOST and saved it as ‘ HOST ‘.
i added to my test_data_host_prog.prog file four compulsory parameters ,but during registration in sysadmin -> concurrent-> program -> define ,In parameters window, i had left all blank.(previously, same was running when i made one link from ‘$FND_TOP/bin/fndcpesr’ file using command: *ln -s $FND_TOP/bin/fndcpesr test_data_host_prog * through telnet.)
During running of the concurrent program it is giving error: The executable file /dev02/CPS/apps/apps_st/appl/ja/12.0.0/bin/test_data_host_prog for this concurrent program can not be executed.
my files data is attached here with:
1) test_data_host.txt file:
Tamojit,1,history
Vishnu,2,maths
Krishna,3,HRMS
*******************
2) test_data_host.ctl file:
LOAD DATA
APPEND
INTO TABLE BPIL_TEST_CONTROL_FILE
FIELDS TERMINATED BY “,”
OPTIONALLY ENCLOSED BY’”‘
TRAILING NULLCOLS
( name1,
class1,
subject,
record_status CONSTANT ‘NEW’)
*******************************
3) test_data_host_prog.prog file:
# Parameters passed into program
ORA_USER_PASS=$1
USERID=$2
USERNAME=$3
REQUESTID=$4
#LOGON_STRING=’apps/appscps@cps’
#FILENAME=$5
sqlload userid=apps/appscps@cps control=/usr/tmp/test_data_host.ctl data=/usr/tmp/test_data_host.txt log=/usr/tmp/test_data_host_log.log bad=/usr/tmp/test_data_host_bad.bad ERRORS=100000 silent=FEEDBACK <<!
!
RC=$?
echo “The sql loader exit code for loading Header table is :”$RC
if [$RC -eq 0 -o $RC -eq 3 |http://forums.oracle.com/forums/]
then
echo ‘Loading of file table successful.’
else
echo ‘Error: Loading of file table has errors. Sqlload return code is ‘$RC
exit 1
fi
case “$RC” in
0) echo “SQL*Loader execution successful” ;;
1) echo “SQL*Loader execution exited with failure, see logfile” ;;
2) echo “SQL*Loader execution exited with warning, see logfile” ;;
3) echo “SQL*Loader execution encountered a fatal error” ;;
*) echo “unknown return code $RC” ;;
esac
kindly help me with the same to run the concurrent request successfully to load the data .
Thanks & Regards
Vishnu Pratap Patel
(vishnu.patel@tcs.com)
  1. Sanjit Anand Says:September 5th, 2008 at 8:15 pm
echo should work.what is version of your oracle u are using.
Command like
echo “Line 1.”
echo “line 2.”
suppose to print
Line 1.
Line 2.
in log file.
are u sure prog completed successfully. some time access previlege also causing , as there is no debug options unless developer is realize that something pre-requssite is not performed yet.
this is simple host based concuuurent prog used to Moves files from one directory to another
Three input parameter is there.
once you put the script in to Unix box, donot forgot to run this command
ln -s -f $FND_TOP/bin/fndcpesr XXTEST
–here is code
# Initialise environment variables
echo " Initialise location specific environment variables"
ORA_USER_PASS=$1
USERID=$2
USERNAME=$3
REQUESTID=$4
P_SOURCE_DIR=`eval echo $5`
P_TARGET_DIR=`eval echo $6`
P_FILENAME=$7

DIR=`eval echo $1`

# Initialise common environment variables
echo " Initialise common environment variables"
SCRIPT=XXTEST.prog

# Variables for Load filenames
echo " "
echo "Input Directory = " $P_SOURCE_DIR

# Setting the Directory Names
CTLDIR=$XXPH_TOP/bin
LOGDIR=$XXPH_TOP/log
BADDIR=$XXPH_TOP/log

# Setting the Log file for the .prog file
REPFILE=$APPLCSF/$APPLLOG/l$REQUESTID.req
PROBLEMS=0
# ----------------------------------------------------------
echo "\n Start" $SCRIPT
echo " ************************************"
# ------------------------------------------------------------------

# Display all parameters entered
  echo " For Supplier data conversion -- Parameters entered:-" >> $REPFILE
  echo " SQL*Plus userid   = " $USERID >> $REPFILE

# Display Other parameters :-

  echo "Other Parameters :-" >> $REPFILE
  echo "--------------------" >> $REPFILE
  echo "Source directory = " $P_SOURCE_DIR >> $REPFILE
  echo "Target directory = " $P_TARGET_DIR >> $REPFILE
  echo "Filename         = " $P_FILENAME >> $REPFILE

echo "At the end of Parameter Listing " >>  $REPFILE

#
# Check if the Data Files Exist
echo "At the start of Data Files Check " >>  $REPFILE
#
if [ ! -f $P_SOURCE_DIR/$P_FILENAME ]
then
    echo  $P_SOURCE_DIR/$P_FILENAME " does not exist"
    echo "**************************************************" >> $REPFILE
    echo "*$P_SOURCE_DIR/$P_FILENAME " does not exist"           *" >> $REPFILE
    echo "**************************************************" >> $REPFILE
    PROBLEMS=1
    exit 1
fi
#
echo "At the end of Data File Check " >>  $REPFILE
#
#   Move the file to the target directory
# ------------------------------------------------------------------
mv $P_SOURCE_DIR/$P_FILENAME $P_TARGET_DIR
if [ $? != 0 ]
then
    echo "**************************************************" >> $REPFILE
    echo "*$P_SOURCE_DIR/$P_FILENAME " failed to move "          *" >> $REPFILE
    echo "**************************************************" >> $REPFILE
    PROBLEMS=1
fi
mv $P_SOURCE_DIR/$P_FILENAME'.o' $P_TARGET_DIR
if [ $? != 0 ]
then
    echo "**************************************************" >> $REPFILE
    echo "*$P_SOURCE_DIR/$P_FILENAME'.o " failed to move "    *" >> $REPFILE
    echo "**************************************************" >> $REPFILE
    PROBLEMS=1
fi
# ------------------------------------------------------------------
#
if test $PROBLEMS = 1
then
    echo "\nUnsuccessful termination of" $SCRIPT >> $REPFILE
    echo "\n------------------------------------" >> $REPFILE
    exit 1
else
    echo "\n----------------------------------" >> $REPFILE
    echo "Successful termination of" $SCRIPT >> $REPFILE
    echo "----------------------------------" >> $REPFILE
fi
exit 0
  1. Sanjit Anand Says:September 5th, 2008 at 8:33 pm
Dear Vishnu,
there should not be any issue.
errors message seems there need a proper access on file in unix.
Do a quick check
1. when create a soft line you should do like
ln -s -f $FND_TOP/bin/fndcpesr test_data_host_prog
2. Make sure soft link is create or not
3. Make sure you should have proper access on the site.
When you are calling sqllodaer from its better use directly from home and just pass userid which internally passed by fndcpesr prog.
$ORACLE_HOME/bin/sqlldr USERID=$ORA_USER_PASS CONTROL=$CTLDIR/$LOADER1.ctl LOG=$LOGDIR/$LOADER1.log BAD=$BADDIR/$LOADER1.bad ERRORS=0 DATA=$LOGDIR/filenames.dat >>$REPFILE
and you can see how these are derived from parameter
ORA_USER_PASS=$1
USERID=$2
USERNAME=$3
REQUESTID=$4
P_INPUT_DIR=`echo $5`

# Setting the Control File Names
LOADER1=XXTESTLOAD

CTLDIR=$XXPH_TOP/bin
DATDIR=`echo $P_INPUT_DIR`
LOGDIR=$XXPH_TOP/log
BADDIR=$XXPH_TOP/log
Let me know , in case if this does not work, I will send you code.send me offline message.

Base Tables


GL Journals
GL_JE_BATCHES
GL_JE_HEADERS
GL_JE_LINES
GL_CODE_COMBINATIONS
AP Suppliers
PO_VENDORS
PO_VENDOR_SITES_ALL
PO_VENDOR_CONTACTS
----------------
AP_SUPPLIERS
AP_SUPPLIER_SITES_ALL
AP_SUPPLIER_CONTACTS
AP Invoices
AP_INVOICES_ALL
AP_INVOICE_LINES_ALL
AP_INVOICE_DISTRIBUTIONS_ALL
AP_TERMS
AP_HOLDS_ALL
PA_PROJECTS_ALL
PA_TASKS
PO_VENDORS
AR Customers
HZ_CUST_ACCOUNTS
HZ_PARTIES
HZ_CUST_ACCT_SITES_ALL
HZ_LOCATIONS
HZ_PARTY_SITES
HZ_CUST_SITE_USES_ALL
AR Customer Profiles
HZ_CUSTOMER_PROFILES
HZ_CUST_PROFILE_CLASSES
HZ_CUST_PROFILE_AMTS
AR_COLLECTORS
RA_TERMS
RA_GROUPING_RULES
AR_STATEMENT_CYCLES
AR Customer Contacts
RA_CONTACTS
RA_PHONES
AR Transactions
AR_PAYMENT_SCHEDULES_ALL
RA_CUSTOMER_TRX_ALL
RA_CUST_TRX_TYPES_ALL
RA_CUSTOMER_TRX_LINES_ALL
RA_CUST_TRX_LINE_GL_DIST_ALL
RA_TERMS
HR_OPERATING_UNITS
AR Receipts
AR_CASH_RECEIPTS_ALL
AR_CASH_RECEIPT_HISTORY_All
AR_RECEIVABLE_APPLICATIONS_ALL
AR_RECEIPT_METHODS
AR_RECEIPT_CLASSES
AR_PAYMENT_SCHEDULES_ALL
PO Standard
PO_HEADERS_ALL
PO_LINES_V
PO_LINE_LOCATIONS_ALL
PO_DISTRIBUTIONS_V
PO Releases
PO_RELEASES_ALL
PO Requisitions
PO_REQUISITION_HEADERS_V
PO_REQUISITION_LINES_V
Project Data
PA_PROJECTS_ALL
PA_TASKS
PA_PROJECT_PARTIES
PA_PROJECT_ROLE_TYPES_B
Project Transaction Data
PA_EXPENDITURE_ITEMS_ALL
PA_COST_DISTRIBUTION_LINES_ALL
PA_EXPENDITURES_ALL
PA_EXPENDITURE_COMMENTS
PA_PROJECTS_ALL
PA_TASKS
INV Items
MTL_SYSTEM_ITEMS_B
ORG_ORGANIZATION_DEFINITIONS
INV Item Categories
MTL_CATEGORY_SETS_TL
MTL_CATEGORIES
MTL_ITEM_CATEGORIES
MTL_SYSTEM_ITEMS
ORG_ORGANIZATION_DEFINITIONS
MTL_ORGANIZATIONS
INV Item SubInventory
MTL_ITEM_SUB_INVENTORIES
ORG_ORGANIZATION_DEFINITIONS
MTL_SYSTEM_ITEMS_B
MTL_ITEM_LOCATIONS
MTL_SECONDARY_LOCATORS
Attachments
FND_DOCUMENTS_LONG_TEXT
FND_DOCUMENTS_SHORT_TEXT
FND_DOCUMENT_CATEGORIES_TL
FND_DOCUMENT_DATATYPES
FND_DOCUMENTS_TL
FND_DOCUMENTS
FND_ATTACHED_DOCUMENTS
FND_DOC_CATEGORY_USAGES

APPS IMPORTANT

Overview

1) The Application Programming Interface or API is a PL/SQL packaged procedure which can be used as an alternative entry point into the system to the traditional online forms

2) The advantage being that the same logic used by the seeded online forms can also be used by other interfaces into the system, thus ensuring that the integrity of the data remains intact

Calling API

1) Ensure it is appropriate to allow that particular business operation

2) Validate the data passed to the API

3) Each API has a number of parameters, most of them mapped with DB column. Every parameter name starts with p_. If the parameter maps onto a database column, the remaining part of the name is usually the same as the column name

4) When calling the APIs, it is strongly recommended that you use Named Notation, instead of Positional Notation

Standard IN Parameters
1) p_api_version IN NUMBER 
This must match the version number of the API. An unexpected error is returned if the calling program version number is incompatible with the current API version number
2) p_init_msg_list IN VARCHAR2
The valid values for this parameter are:
• True = FND_API.G_TRUE
• False = FND_API.G_FALSE
• Default = FND_API.G_FALSE
If set to true, then the API makes a call to fnd_msg_pub.initialize to initialize the message stack. To set to true, use the value, "T". If set to false then the calling program must initialize the message stack. This action is required to be performed only once, even in the case where more
than one API is called. To set to false, use the value, "F".
3) p_commit IN VARCHAR2 
The valid values for this parameter are:
• True = FND_API.G_TRUE
• False = FND_API.G_FALSE
• Default = FND_API.G_FALSE
If set to true, then the API commits before returning to the calling program. To set to true, use the value, "T". If set to false, then it is the calling program’s responsibility to commit the transaction. To set to false, use the value, "F".

Standard OUT Parameters
1) x_return_status OUT NOCOPY VARCHAR2
Indicates the return status of the API. The values returned are one of the following:
• FND_API.G_RET_STS_SUCCESS
Success: Indicates the API call was successful
• FND_API.G_RET_STS_ERROR
Expected Error: There is a validation error, or missing data error.
• FND_API.G_RET_STS_UNEXP_ERROR
Unexpected Error: The calling program can not correct the error.
2) x_msg_count OUT NOCOPY NUMBER
Holds the number of messages in the message list.
3) x_msg_data OUT NOCOPY VARCHAR2
Holds the encoded message if x_msg_count is equal to one


RDF Steps

1) Define Below Parameters in Report

P_MIN_FLEX Char(200)

P_MAX_FLEX Char(200)
STRUCT_NUM Number(15)
P_CONC_REQUEST_ID Number(15)
P_LEDGER_ID Number(15)
P_USER_ID Number(15)

2) Add below code in Before Report Trigger

FND_PROFILE.GET('CONC_REQUEST_ID',:P_CONC_REQUEST_ID);

FND_PROFILE.GET('GL_SET_OF_BKS_ID',:P_LEDGER_ID);
FND_PROFILE.GET('USER_ID',:P_USER_ID);

srw.reference(:STRUCT_NUM);
srw.user_exit('FND FLEXSQL CODE="GL#" NUM=":STRUCT_NUM" APPL_SHORT_NAME="SQLGL"
OUTPUT=":WHERE_FLEX" TABLEALIAS="CC"
MODE="WHERE" DISPLAY="ALL"
OPERATOR="BETWEEN"
OPERAND1=":P_MIN_FLEX"
OPERAND2=":P_MAX_FLEX"');

:WHERE_FLEX := ' AND ' :WHERE_FLEX;

3) Add below code in Report Query to the last line

&WHERE_FLEX

Application Setup Steps

- Add below parameters alongwith value set in Concurrent program Parameters Window

1) Chart of Accounts ID
Value Set- GL_SRS_COA_UNVALIDATED
Default Type- SQL Statement
Default Value- SELECT chart_of_accounts_id FROM gl_access_sets WHERE access_set_id = :$PROFILES$.GL_ACCESS_SET_ID
Token- STRUCT_NUM

2) Account Flexfield From
Value Set- GL_SRS_LEDGER_FLEXFIELD
Range- Pair
Token- P_MIN_FLEX

3) Account Flexfield To
Value Set- GL_SRS_LEDGER_FLEXFIELD
Range- Pair
Token- P_MAX_FLEX


Standard PO
1) One time commitment to purchase goods / services
2) Specific Quantity, Rate, Delivery schedule
Blanket Purchase Agreement
1) Long Term Agreement to Purchase – e.g. Annual Rate Contract
2) Specific Quantity, Rate, but no specific Delivery schedule
Planned PO
1) Long term agreement to buy goods / services
2) Tentative delivery schedule and accounting distribution given.
3) Other terms and conditions fixed
4) Planned PO look exactly like a Standard PO
Contract Purchase Agreement
1) A master document giving Standard terms & Conditions
2) Suppliers are authorised to ship through Standard PO lines giving reference of the Contract Agreement



Below are the detailed steps:

1) Update the following Profile Option Values to Yes at User level.
• FND: Diagnostics
• Personalize Self-Service Defn

2) Go to the Java OAF Page where the SQL Query executes

3) Click on the link About this Page in the bottom Left Hand Side of the page

4) Navigate to the Page Tab on the Top Left Hand Side of the page

5) In the Business Component References Details Section (You may need to expand this
section), Go to the View Objects Sub Section.

6) Find the Object that describes the piece of information that you want to find the query for

7) Click on the Link

8) The full Query used can be cut and pasted into a SQL Editor and the query run.
Note: You will have to find the Bind Variables passed to the query in order to do this!!


-- VENDOR, PO AND INVOICE DETAILS (2 WAY MATCH)

SELECT DISTINCT
a.org_id "ORG ID", e.segment1 "VENDOR NUM",
e.vendor_name "SUPPLIER NAME",
UPPER (e.vendor_type_lookup_code) "VENDOR TYPE",
f.vendor_site_code "VENDOR SITE CODE", f.address_line1 "ADDRESS",
f.city "CITY", f.country "COUNTRY",
TO_CHAR (TRUNC (d.creation_date)) "PO DATE", d.segment1 "PO NUM",
d.type_lookup_code "PO TYPE", c.quantity_ordered "QTY ORDERED",
c.quantity_cancelled "QTY CANCELLED", g1.quantity_received, g1.quantity_rejected, g1.quantity_billed,
g.item_id "ITEM ID",
g.item_description "ITEM DESCRIPTION", g.unit_price "UNIT PRICE",
(NVL (c.quantity_ordered, 0) - NVL (c.quantity_cancelled, 0)
)
* NVL (g.unit_price, 0) "PO LINE AMOUNT",
(SELECT DECODE (ph.approved_flag, 'Y', 'Approved')
FROM po.po_headers_all ph
WHERE ph.po_header_id = d.po_header_id) "PO APPROVED?",
a.invoice_type_lookup_code "INVOICE TYPE",
a.invoice_amount "INVOICE AMOUNT",
TO_CHAR (TRUNC (a.invoice_date)) "INVOICE DATE",
a.invoice_num "INVOICE NUMBER",
(SELECT DECODE (x.match_status_flag,
'A', 'Approved'
)
FROM ap.ap_invoice_distributions_all x
WHERE x.invoice_distribution_id = b.invoice_distribution_id)
"INVOICE APPROVED?",
a.amount_paid
FROM ap.ap_invoices_all a,
ap.ap_invoice_distributions_all b,
po.po_distributions_all c,
po.po_headers_all d,
ap.ap_suppliers e,
ap.ap_supplier_sites_all f,
po.po_lines_all g,
po.po_line_locations_all g1
WHERE a.invoice_id = b.invoice_id
AND b.po_distribution_id = c.po_distribution_id(+)
AND c.po_header_id = d.po_header_id(+)
AND e.vendor_id(+) = d.vendor_id
AND f.vendor_site_id(+) = d.vendor_site_id
AND d.po_header_id = g.po_header_id
AND g1.po_header_id = c.po_header_id
AND g1.po_line_id = g.po_line_id
AND c.po_line_id = g.po_line_id
AND c.line_location_id = g1.line_location_id
AND g1.inspection_required_flag = 'N'
AND g1.receipt_required_flag = 'N'
-- VENDOR, PO AND INVOICE DETAILS (3 WAY MATCH)
SELECT DISTINCT
a.org_id "ORG ID", e.segment1 "VENDOR NUM",
e.vendor_name "SUPPLIER NAME",
UPPER (e.vendor_type_lookup_code) "VENDOR TYPE",
f.vendor_site_code "VENDOR SITE CODE", f.address_line1 "ADDRESS",
f.city "CITY", f.country "COUNTRY",
TO_CHAR (TRUNC (d.creation_date)) "PO DATE", d.segment1 "PO NUM",
d.type_lookup_code "PO TYPE", c.quantity_ordered "QTY ORDERED",
c.quantity_cancelled "QTY CANCELLED", g1.quantity_received, g1.quantity_rejected, g1.quantity_billed,
g.item_id "ITEM ID",
g.item_description "ITEM DESCRIPTION", g.unit_price "UNIT PRICE",
(NVL (c.quantity_ordered, 0) - NVL (c.quantity_cancelled, 0)
)
* NVL (g.unit_price, 0) "PO LINE AMOUNT",
(SELECT DECODE (ph.approved_flag, 'Y', 'Approved')
FROM po.po_headers_all ph
WHERE ph.po_header_id = d.po_header_id) "PO APPROVED?",
a.invoice_type_lookup_code "INVOICE TYPE",
a.invoice_amount "INVOICE AMOUNT",
TO_CHAR (TRUNC (a.invoice_date)) "INVOICE DATE",
a.invoice_num "INVOICE NUMBER",
(SELECT DECODE (x.match_status_flag,
'A', 'Approved'
)
FROM ap.ap_invoice_distributions_all x
WHERE x.invoice_distribution_id = b.invoice_distribution_id)
"INVOICE APPROVED?",
a.amount_paid
FROM ap.ap_invoices_all a,
ap.ap_invoice_distributions_all b,
po.po_distributions_all c,
po.po_headers_all d,
ap.ap_suppliers e,
ap.ap_supplier_sites_all f,
po.po_lines_all g,
po.po_line_locations_all g1
WHERE a.invoice_id = b.invoice_id
AND b.po_distribution_id = c.po_distribution_id(+)
AND c.po_header_id = d.po_header_id(+)
AND e.vendor_id(+) = d.vendor_id
AND f.vendor_site_id(+) = d.vendor_site_id
AND d.po_header_id = g.po_header_id
AND g1.po_header_id = c.po_header_id
AND g1.po_line_id = g.po_line_id
AND c.po_line_id = g.po_line_id
AND c.line_location_id = g1.line_location_id
AND g1.inspection_required_flag = 'N'
AND g1.receipt_required_flag = 'Y'
VENDOR, PO AND INVOICE DETAILS (4 WAY MATCH)
SELECT DISTINCT
a.org_id "ORG ID", e.segment1 "VENDOR NUM",
e.vendor_name "SUPPLIER NAME",
UPPER (e.vendor_type_lookup_code) "VENDOR TYPE",
f.vendor_site_code "VENDOR SITE CODE", f.address_line1 "ADDRESS",
f.city "CITY", f.country "COUNTRY",
TO_CHAR (TRUNC (d.creation_date)) "PO DATE", d.segment1 "PO NUM",
d.type_lookup_code "PO TYPE", c.quantity_ordered "QTY ORDERED",
c.quantity_cancelled "QTY CANCELLED", g1.quantity_received, g1.quantity_rejected, g1.quantity_billed,
g.item_id "ITEM ID",
g.item_description "ITEM DESCRIPTION", g.unit_price "UNIT PRICE",
(NVL (c.quantity_ordered, 0) - NVL (c.quantity_cancelled, 0)
)
* NVL (g.unit_price, 0) "PO LINE AMOUNT",
(SELECT DECODE (ph.approved_flag, 'Y', 'Approved')
FROM po.po_headers_all ph
WHERE ph.po_header_id = d.po_header_id) "PO APPROVED?",
a.invoice_type_lookup_code "INVOICE TYPE",
a.invoice_amount "INVOICE AMOUNT",
TO_CHAR (TRUNC (a.invoice_date)) "INVOICE DATE",
a.invoice_num "INVOICE NUMBER",
(SELECT DECODE (x.match_status_flag,
'A', 'Approved'
)
FROM ap.ap_invoice_distributions_all x
WHERE x.invoice_distribution_id = b.invoice_distribution_id)
"INVOICE APPROVED?",
a.amount_paid
FROM ap.ap_invoices_all a,
ap.ap_invoice_distributions_all b,
po.po_distributions_all c,
po.po_headers_all d,
ap.ap_suppliers e,
ap.ap_supplier_sites_all f,
po.po_lines_all g,
po.po_line_locations_all g1
WHERE a.invoice_id = b.invoice_id
AND b.po_distribution_id = c.po_distribution_id(+)
AND c.po_header_id = d.po_header_id(+)
AND e.vendor_id(+) = d.vendor_id
AND f.vendor_site_id(+) = d.vendor_site_id
AND d.po_header_id = g.po_header_id
AND g1.po_header_id = c.po_header_id
AND g1.po_line_id = g.po_line_id
AND c.po_line_id = g.po_line_id
AND c.line_location_id = g1.line_location_id
AND g1.inspection_required_flag = 'Y'
AND g1.receipt_required_flag = 'Y'
-- VENDOR, PO, INVOICE AND PAYMENT DETAILS
SELECT DISTINCT a.org_id "ORG ID", e.segment1 "VENDOR NUMBER",
e.vendor_name "VENDOR NAME",
UPPER (e.vendor_type_lookup_code) "VENDOR TYPE",
f.vendor_site_code "VENDOR SITE CODE",
TO_CHAR (TRUNC (d.creation_date)) "PO DATE",
d.segment1 "PO NUM", d.type_lookup_code "PO TYPE",
c.quantity_ordered "QTY ORDERED",
c.quantity_cancelled "QTY CANCELLED",
g.item_description "ITEM DESCRIPTION",
g.unit_price "UNIT PRICE",
(NVL (c.quantity_ordered, 0) - NVL (c.quantity_cancelled, 0)
)
* NVL (g.unit_price, 0) "PO LINE AMOUNT",
(SELECT DECODE (ph.approved_flag,
'Y', 'Approved'
)
FROM po.po_headers_all ph
WHERE ph.po_header_id = d.po_header_id) "PO APPROVED?",
a.invoice_type_lookup_code "INVOICE TYPE",
a.invoice_amount "INVOICE AMOUNT",
TO_CHAR (TRUNC (a.invoice_date)) "INVOICE DATE",
a.invoice_num "INVOICE NUMBER",
(SELECT DECODE (x.match_status_flag,
'A', 'Approved'
)
FROM ap.ap_invoice_distributions_all x
WHERE x.invoice_distribution_id = b.invoice_distribution_id)
"INVOICE APPROVED?",
a.amount_paid, h.check_id, i.check_number,
h.invoice_payment_id,
TO_CHAR (TRUNC (i.check_date)) "PAYMENT DATE"
FROM ap.ap_invoices_all a,
ap.ap_invoice_distributions_all b,
po.po_distributions_all c,
po.po_headers_all d,
ap.ap_suppliers e,
ap.ap_supplier_sites_all f,
po.po_lines_all g,
ap.ap_invoice_payments_all h,
ap.ap_checks_all i
WHERE a.invoice_id = b.invoice_id
AND b.po_distribution_id = c.po_distribution_id(+)
AND c.po_header_id = d.po_header_id(+)
AND e.vendor_id(+) = d.vendor_id
AND f.vendor_site_id(+) = d.vendor_site_id
AND d.po_header_id = g.po_header_id
AND c.po_line_id = g.po_line_id
AND a.invoice_id = h.invoice_id
AND h.check_id = i.check_id
AND c.po_header_id IS NOT NULL
AND a.payment_status_flag = 'Y'
AND d.type_lookup_code != 'BLANKET'
ORDER BY E.VENDOR_NAME

Below are the steps to register host concurrent program in oracle apps

1) Define Concurrent Program with Executable Type = Host and Execution File Name = Name of .prog file without extension

2) Copy your .prog file (Shell Script) to Custom Top Bin directory (Eg: $XXCUST_TOP/bin)

3) Create symbollic link by executing below commands on Unix Server
cd $XXCUST_TOP/bin
ln -s $FND_TOP/bin/fndcpesr sample_file
WHERE sample_file = Name of your Host program script

Query to Find list of peoples Locking AP Object 
SELECT c.owner, c.object_name, c.object_type, fu.user_name locking_user_name,
fl.start_time, vs.module, vs.machine, vs.osuser, vs.SID, vp.pid,
vp.spid AS os_process_to_kill, vs.serial#, vs.status, vs.saddr,
vs.audsid, vs.process
FROM fnd_logins fl,
fnd_user fu,
v$locked_object vlocked,
v$process vp,
v$session vs,
dba_objects c
WHERE vs.SID = vlocked.session_id
AND vlocked.object_id = c.object_id
AND vs.paddr = vp.addr
AND vp.spid = fl.process_spid(+)
AND vp.pid = fl.pid(+)
AND fl.user_id = fu.user_id(+)
AND c.object_name LIKE 'AP%';
-- Command to Kill Session for Releasing Lock 
ALTER SYSTEM KILL SESSION '(sid, serial#)';
-- Check Users who are Online
SELECT
p.spid -- The UNIX PID
,s.sid ,s.serial#
,p.username as os_user
,s.username ,s.status
,p.terminal ,p.program
FROM v$session s ,v$process p
WHERE p.addr = s.paddr
ORDER BY s.username ,p.spid ,s.sid ,s.serial# ;
-- Locked Table Information
SELECT
p.spid -- The UNIX PID
,s.sid ,s.serial#
,p.username as os_user
,s.username ,s.status
,p.terminal ,p.program
FROM v$session s ,v$process p
WHERE p.addr = s.paddr
ORDER BY s.username ,p.spid ,s.sid ,s.serial# ;

No comments:

Post a Comment