Tuesday 28 December 2021

Ffile transfer Sell script , FTP & SFTP

 SFTP Script:- 

sftp_error=$(
#!/bin/bash
HOST=10.94.146.17
USER=tboecrm
PASSWORD=****
sftp -inv $HOST <<EOF
user $USER $PASSWORD
cd /home/tboecrm/testing
mput  ${FILE_NAME1}
bye
EOF
)
----------------------------------------------


Copy File Shell Script
Objectives:

Steps to Register Shell Script as a concurrent program
Sample Shell Script to copy the file from source to destination
Basic Shell Script Commands
Steps to Register Shell Script as a concurrent program

step 1:
=======
Place the .prog script under the bin directory for your
applications top directory.

For example, call the script XXFTP.prog and place it under
$CUSTOM_TOP/bin

step 2:
=======
Make a symbolic link from your script to $FND_TOP/bin/fndcpesr
For example, if the script is called XXFTP.prog use this:

ln -s $FND_TOP/bin/fndcpesr XXFTP

This link should be named the same as your script without the
.prog extension.

Put the link for your script in the same directory where the
script is located.

step 3:
=======
Register the concurrent program, using an execution method of
‘Host'. Use the name of your script without the .prog extension
as the name of the executable.

For the example above:
Use ERPS_DEMO

step 4:
=======
Your script will be passed at least 4 parameters, from $1 to $4.
$1 = orauser/pwd
$2 = userid(apps)
$3 = username,
$4 = request_id


Any other parameters you define will be passed in as $5 and higher.
Make sure your script returns an exit status also.

Sample Shell Script to copy the file from source to destination

#Note: If you see # in front of any line it means that it's a comment line not the actual code
#** ********************************************************************
# Created By : Rohidas D
# Creation Date : 21-Dec-2021
# Script Name : XXFTP.prog
# Description : This Script accepts three parameters
# 1)Data File Name 2)Source Directory Path 3)Target Directory Path
# Then copy the file from source location to target location.
# If copy fails send the error status/message to concurrent program so that user can see status.
#
#
# ========
# History
# ========
# Version #
#** ********************************************************************
#Parameters from 1 to 4 i.e $1 $2 $3 $4 are standard parameters
# $1 : username/password of the database
# $2 : userid
# $3 : USERNAME
# $4 : Concurrent Request ID
DataFileName=$5
SourceDirectory=$6
TargetDirectory=$7
echo "————————————————–"
echo "Parameters received from concurrent program .."
echo " Time : "`date`
echo "————————————————–"
echo "Arguments : "
echo " Data File Name : "${DataFileName}
echo " SourceDirectory : "${SourceDirectory}
echo " TargetDirectory : "${TargetDirectory}
echo "————————————————–"
echo " Copying the file from source directory to target directory…"
cp ${SourceDirectory}/${DataFileName} ${TargetDirectory}
if [ $? -ne 0 ]
# the $? will contain the result of previously executed statement.
#It will be 0 if success and 1 if fail in many cases
# -ne represents not "equal to"
then
echo "Entered Exception"
exit 1
# exit 1 represents concurrent program status. 1 for error, 2 for warning 0 for success
else
echo "File Successfully copied from source to destination"
exit 0
fi
echo "****************************************************************"
 

----------------------------------------------------------------

Basic Shell Script Commands

# Create Directory
mkdir
# Remove Directory
rmdir
#remove folder with files
rm -r -f
# Change Directory
cd
# Create new file
vi
#insert data into file
vi
esc i
#Save file
esc :wq enter
# exit without saving changes
esc :q! enter
# open existing file
vi
#remove file
rm
# copy file with same name
cp /
# copy file with new name
cp / /
# Move file with same name
mv /
# move file with data appended to filename in the front
mv / /`date+%H%M%d%m%y`
#print line
echo “your text here to print”
#print date
echo `date`

FNDLOAD Commands

 


To Download/Upload FND_LOOKUPS:


FNDLOAD apps/Emzci9#b 0 Y DOWNLOAD $FND_TOP/patch/115/import/aflvmlu.lct xxaoa_file_name.ldt FND_LOOKUP_TYPE APPLICATION_SHORT_NAME="HUTCH" LOOKUP_TYPE="XXVFENT_FNDD_LOOKIUPTEST"


FNDLOAD apps/Emzci9#b O Y UPLOAD $FND_TOP/patch/115/import/aflvmlu.lct xxaoa_file_name.ldt

---------------------------------------------------------------


Concurrent Program


FNDLOAD apps/apps O Y DOWNLOAD $FND_TOP/patch/115/import/afcpprog.lct XXCUST_CP.ldt PROGRAM APPLICATION_SHORT_NAME="XXCUST" CONCURRENT_PROGRAM_NAME="XXCUST_CP"


FNDLOAD apps/apps O Y UPLOAD $FND_TOP/patch/115/import/afcpprog.lct XXCUST_CP.ldt UPLOAD_MODE=REPLACE CUSTOM_MODE=FORCE


Lookups


FNDLOAD apps/apps O Y DOWNLOAD $FND_TOP/patch/115/import/aflvmlu.lct XXCUST_LKP.ldt FND_LOOKUP_TYPE APPLICATION_SHORT_NAME="XXCUST" LOOKUP_TYPE="XXCUST_LKP"


FNDLOAD apps/apps O Y UPLOAD $FND_TOP/patch/115/import/aflvmlu.lct  XXCUST_LKP.ldt UPLOAD_MODE=REPLACE CUSTOM_MODE=FORCE


Message


FNDLOAD apps/apps 0 Y DOWNLOAD $FND_TOP/patch/115/import/afmdmsg.lct XXCUST_MESG.ldt FND_NEW_MESSAGES APPLICATION_SHORT_NAME="XXCUST" MESSAGE_NAME="XXCUST_MESG%"


FNDLOAD apps/apps O Y UPLOAD $FND_TOP/patch/115/import/afmdmsg.lct XXCUST_MESG.ldt UPLOAD_MODE=REPLACE CUSTOM_MODE=FORCE


Request Set and Link


FNDLOAD apps/apps 0 Y DOWNLOAD $FND_TOP/patch/115/import/afcprset.lct XXCUST_RS.ldt REQ_SET REQUEST_SET_NAME='XXCUST_RS'


FNDLOAD apps/apps 0 Y DOWNLOAD $FND_TOP/patch/115/import/afcprset.lct XXCUST_LNK.ldt REQ_SET_LINKS REQUEST_SET_NAME='XXCUST_LNK'



FNDLOAD apps/apps O Y UPLOAD $FND_TOP/patch/115/import/afcprset.lct  XXCUST_RS.ldt UPLOAD_MODE=REPLACE CUSTOM_MODE=FORCE


FNDLOAD apps/apps O Y UPLOAD $FND_TOP/patch/115/import/afcprset.lct  XXCUST_LNK.ldt UPLOAD_MODE=REPLACE CUSTOM_MODE=FORCE


Form Function


FNDLOAD apps/apps 0 Y DOWNLOAD $FND_TOP/patch/115/import/afsload.lct XXCUST_FUNC.ldt FUNCTION FUNC_APP_SHORT_NAME='XXCUST' FUNCTION_NAME='XXCUST_FUNC'


FNDLOAD apps/apps 0 Y UPLOAD $FND_TOP/patch/115/import/afsload.lct XXCUST_FUNC.ldt


Profile


FNDLOAD apps/apps 0 Y DOWNLOAD $FND_TOP/patch/115/import/afscprof.lct XXCUST_PROF.ldt PROFILE PROFILE_NAME="XXCUST_PROFILE" APPLICATION_SHORT_NAME="XXCUST"


FNDLOAD apps/apps 0 Y UPLOAD $FND_TOP/patch/115/import/afscprof.lct XXCUST_FUNC.ldt 


Menu


FNDLOAD apps/apps O Y DOWNLOAD $FND_TOP/patch/115/import/afsload.lct XXCUST_MENU.ldt MENU MENU_NAME="XXCUST_MENU"


FNDLOAD apps/apps O Y UPLOAD $FND_TOP/patch/115/import/afsload.lct XXCUST_MENU.ldt


Data Definition


FNDLOAD apps/apps 0 Y DOWNLOAD $XDO_TOP/patch/115/import/xdotmpl.lct XXCUST_DD.ldt XDO_DS_DEFINITIONS APPLICATION_SHORT_NAME=XXCUST DATA_SOURCE_CODE=XXCUST_DS


FNDLOAD apps/apps O Y UPLOAD $FND_TOP/patch/115/import/afsload.lct XXCUST_DD.ldt 

Wednesday 15 December 2021

Oracle R12 Multi ORG (MOAC) COncept

 The multiorg architecture is meant to allow multiple companies or subsidiaries to store their records within a single database. The multiple Organization architecture allows this by partitioning data through views in the APPS schema. Multiorg also allows you to maintain multiple setsof books. Implementation of multiorg generally includes defining more than one Business Group.

Basically the different entities in multi-org are:
• Business Group (BG)
• Sets of Books (SOB)
• Legal entities (LE)
• Operating units (OU)
• Inventory organizations (IO)


The difference in multi-org in 11i & R12i is "MOAC" concept(Multi-Org Access Control) is
"MOAC provided the role based access, shared services, to
perform multiple tasks across different operation units from
within single application responsibility."

It is controlled by MO: Security profile.




R12 initial Setup Reference:
http://oracleebspro.blogspot.com/2016/08/multi-org-concept-in-oracle-apps-r12.html


How to set org context in Oracle Apps R12 in back-end in case of multiple org-id?

Set Multi org/Single org operating unit form plsql:
1-exec MO_GLOBAL.INIT('Give Application name');
To set Multi Org unit:
2- exec MO_GLOBAL.INIT('M');
To set Single  Org unit:
3- exec MO_GLOBAL.INIT('S');
Explanation: mo_global.init checks the application_short_name parameter against table fnd_mo_product_init and decides by the table's status column to proceed further with multiple or single org logic.

If the application_short_name parameter passed is not registered in that table, mo_global.init will fail. Oracle added the dummy short names 'M' and 'S' to fnd_mo_product_init to allow calling the procedure without a real apps name.



-Initialization of view
R12--> mo_global.set_policy_context(S,org_id) ;

11i -> dbms_application_info.set_client_info(:org_id);
If we know the user id, rep id, and app_resp_id then we can use the below query
fnd_global.apps_initialize(:p_user_id, :p_resp_id, :p_app_resp_id);

Monday 16 August 2021

Account Payables Tables

 Account Payables Tables


1)Invoice Details.
a)Ap_invoices_all(INVOICE_ID)
You can see the approved Invoices.
b)Ap_invoice_Distributions_all(INVOICE_ID)
To get Distributed Invoices information.
2)Invoice Transactions
a)ap_ae_headers_all(AE_HEADER_ID)
b)ap_ae_lines_all
Stores Distributed Accounting information.
3)Payment Schedule Information
a)ap_payment_schedules_all(INVOICE_ID)
Stores Amount remaing information and schedule payments for an invoice.
b)ap_invoice_payments_all(INVOICE_ID,CHECK_ID)
After compleing invoice payment information stores here.
4) Check Information.
a)ap_checks_all(CHECK_ID)
if you done the payment via check this information stores here.
b)AP_CHECK_FORMATS(Check_format_id)
When you create the invoice ie assciated with accouting infomation that information stores in this table.
c)AP_MC_INVOICES(invoice_id,set_of_book_id)
Contains Multiple invoice Currency information as well as Exchange Information. 
d)AP_HOLDS_ALL
Holds invoice information you places
f)AP_CHRG_ALLOCATIONS_ALL
Used for AP links with the appropriate invoice distributins.
5)Approval information
a)AP_INV_APRVL_HIST_ALL(Approval history id,invoice_id)
Invoice approval information
b)AP_HISTORY_INVOICES_ALL(Invoice_id,VENDOR_iD)
All invoice history information stores here
c)AP_INVOICE_TRANSMISSIONS(JE_BATCH_ID)
When you post the invoice to GL This table will effected.
6)Terms
a)AP_TERMS_TL(TERMS_ID)
Contains Term information.
b)AP_INTERFACE_REJECTIONS
which could not be processed by Payables Open Interface Import

Saturday 14 August 2021

Oracle Fusion Reference Link

 - Oracle Cloud Applications Documentation

- https://docs.oracle.com/en/cloud/saas/index.html

Above link will provide all table names and module details.


-Use below link to kNow function setup for P2P cycle in oracle fusion cloud.

https://rpforacle.blogspot.com/2020/10/creating-inventory-org-in-oracle-fusion.html?m=1

Cursor attributes (PL/SQL)

 Each cursor has a set of attributes that enables an application program to test the state of the cursor.

These attributes are 
%ISOPEN:
This attribute is used to determine whether a cursor is in the open state. When a cursor is passed as a parameter to a function or procedure, it is useful to know (before attempting to open the cursor) whether the cursor is already open.

 %FOUND: 
This attribute is used to determine whether a cursor contains rows after the execution of a FETCH statement. If FETCH statement execution was successful, the %FOUND attribute has a value of true. If FETCH statement execution was not successful, the %FOUND attribute has a value of false. 


%NOTFOUND:
This attribute is the logical opposite of the %FOUND attribute.

%ROWCOUNT:
This attribute is used to determine the number of rows that have been fetched since a cursor was opened.

XML reports with Oracle Bursting

 

XML Bursting in Oracle Apps

XML Bursting

XML Bursting can be used to split one XML File into multiple XML Blocks. These individual xml blocks can then be used to generate reports and even use different layouts. You can also deliver the reports to multiple destinations based on a XML Element. The steps involved are listed below for your understanding:
  • Generate the XML File
  • Split the XML into multiple XML Blocks
  • Generate Report based on the individual XML Blocks
  • Deliver the report
Take a look at the below image and the process will be much more clearer:
XML Bursting Process
XML Bursting Process

Bursting Control File

Bursting control is used to identify:
  • How to split the XML file / data
  • How to deliver the Report
  • Delivery destination details
After defining the XML Bursting Control File, we will upload the same to the Data Definition. But before that, lets take a look at the XML file that we have.
<?xml version="1.0" encoding="UTF-8"?>
<INVOICEDATA>
  <LIST_G_SUPPLIER>
    <G_SUPPLIER>
      <SUPPLIER_NUMBER>1001</SUPPLIER_NUMBER>
      <SUPPLIER_NAME>VENDOR001</SUPPLIER_NAME>
      <SUPPLIER_EMAIL>contact@vendor1.com </SUPPLIER_EMAIL>
      <LIST_G_INV>
        <G_INV>
         <INV_NUMBER>INVOICE_01_001</INV_NUMBER>
         <CURRENCY_CODE>USD</CURRENCY_CODE>
         <AMOUNT>100.27</AMOUNT>
        <G/G_INV>
      </LIST_G_INV>
    </G_SUPPLIER>
    <G_SUPPLIER>
      <SUPPLIER_NUMBER>1002</SUPPLIER_NUMBER>
      <SUPPLIER_NAME>VENDOR002</SUPPLIER_NAME>
      <SUPPLIER_EMAIL>contact@vendor2.com</SUPPLIER_EMAIL>
      <LIST_G_INV>
        <G_INV>
          <INV_NUMBER>INVOICE_02_001</INV_NUMBER>
          <CURRENCY_CODE>USD</CURRENCY_CODE>
          <AMOUNT>612.99</AMOUNT>
        </G_INV>
      </LIST_G_INV>
    </G_SUPPLIER>
  </LIST_G_SUPPLIER>
</INVOICEDATA>
As you can see the above XML file has details of two Suppliers (VENDOR001 and VENDOR002). I want the invoice details of VENDOR001 to be emailed to contact@vendor1.com and invoice details of VENDOR002 to be emailed to contact@vendor2.com. In this case, I know that I have to split the XML File into two.
The first thing that we need to do is to identify the Level at which the file has to be split, so that we get two different XML files. If you take a closer look at the XML file, you will see that the <G_SUPPLIER> … </G_SUPPLIER> group is repeated twice. So to get two different XML Files, we will split the actual file at /INVOICEDATA/LIST_G_SUPPLIER/G_SUPPLIER Level. The result is the below XML Files.
Split XML Files
XML Files After Splitting
We also know that we need to deliver these reports by email. We will use the G_SUPPLIER/SUPPLIER_EMAIL element to get the email id from the XML file. Now let us take a look at the Bursting Control File.
<?xml version="1.0" encoding="utf-8"?>
<xapi:requestset xmlns:xapi="http://xmlns.oracle.com/oxp/xapi">
  <xapi:request select="/INVOICEDATA/LIST_G_SUPPLIER/G_SUPPLIER">
     <xapi:delivery>
       <xapi:email id="${SUPPLIER_NUMBER}" reply-to="ap@quest4apps.com" from="ap@quest4apps.com" port="25" server="ora.q4apps.us">
         <xapi:message subject="Invoice Details" attachment="true" to="${SUPPLIER_EMAIL}" id="${SUPPLIER_NUMBER}">
          Please find your electronically formatted Invoice Details.
         </xapi:message>
       </xapi:email>
     </xapi:delivery>
     <xapi:document delivery="${SUPPLIER_NUMBER}" output-type="pdf" output="/data/test1/interfaces/out/${SUPPLIER_NUMBER}.pdf">
       <xapi:template type="rtf" location="xdo://Q4A.XXQ4ASUPINV.en.00/?getSource=true" />
     </xapi:document>
  </xapi:request>
</xapi:requestset>
Please find below details of the XML tags.
xapi:request: Give details of how you want to split the XML File
xapi:email: Give details of the Email
  • id: This is a unique value that identifies each group. In our case it is the Supplier Number.
  • reply-to: This is the reply to email address
  • from: This is the from email address that will be used while sending the email
  • port: The port number of the email server. Check with your DBA / System Administrator for this value.
  • server: The details of the email server
xapi:message: Give details of the Email Message
  • subject: Subject of the Email
  • attachment: We are attaching the report output with the email. So the value should be “true”.
  • to: The email id of the Supplier, which is the recipient’s email address.
  • id: This is a unique value that identifies each group. In our case it is the Supplier Number.
xapi:document: Here we define the output document details
  • output-type: The output type of the report output.
  • output: The folder in which the output file will be saved.
xapi:template: Give details of the RTF Template
  • type: Give the details of the Template Type. In our case it is RTF
  • location: Location of the RTF Template.
Lets take a closer look at the location:
location="xdo://Q4A.XXQ4ASUPINV.en.00/?getSource=true"
For simplicity the above statement can be broken down as
location="xdo://Application Short Name.Template Code.Default Language.Default Territory/?getSource=true"
And you can use the below SQL Statement to get the details of the Template.
select   xtb.application_short_name||'.'||
         xtb.template_code ||'.'||
         xtb.default_language ||'.'||
         xtb.default_territory
  from   apps.xdo_templates_b xtb
 where   xtb.template_code ='<Template Code>';

Uploading the Bursting Control File

Once the bursting control file has been defined, you need to attach the same to the Data Definition. Query for the Data Definition and open the defintion. And then click on “Add File” button and upload the XML file that we have defined. Save the changes and you are all set to test the process.
Check the below image for more details:
Upload Bursting Control File

Submitting the Bursting Process

Attaching the XML Bursting Control file will not burst the report just yet. You need to submit the “XML Publisher Report Bursting Program” Concurrent program after the XML Publisher Report is completed. You can either manually Submit the program or use the below SQL Code Snippet in the After Report Trigger to submit the bursting program once the XML Publisher Report is completed.
DECLARE
   l_conc_id     NUMBER;
   g_request_id  NUMBER;
BEGIN
   l_conc_id :=
   fnd_request.submit_request
           (
             application   => 'XDO'
            ,program       => 'XDOBURSTREP'
            ,description   => NULL
            ,start_time    => SYSDATE
            ,sub_request   => FALSE
            ,argument1     => NULL         
            ,argument2     => g_request_id  -– Request ID of XML Publisher Report
            ,argument3     => 'Y'           -– debug Flag
           );
 
   COMMIT;
END;