Create Oracle Receivables Invoice using public API

| No Comments | No TrackBacks
Sample Code to create Single AR Invoice through API.

DECLARE
    p_msg_count             number;
    p_msg_data              varchar2(2000);
    p_trx_header_tbl        ar_invoice_api_pub.trx_header_tbl_type;
    p_trx_lines_tbl         ar_invoice_api_pub.trx_line_tbl_type;
    p_trx_dist_tbl          ar_invoice_api_pub.trx_dist_tbl_type;
    p_trx_salescredits_tbl  ar_invoice_api_pub.trx_salescredits_tbl_type;
    p_batch_source_rec      ar_invoice_api_pub.batch_source_rec_type;
    l_cnt number := 0;   
    l_customer_trx_id       number;
    l_return_status         varchar2(80);
    v_org_id number;
BEGIN
   DBMS_OUTPUT.PUT_LINE('*******START******');
    MO_GLOBAL.SET_POLICY_CONTEXT('S', 270);
    --MO_GLOBAL.INIT('AR'); ** IMP Comment this Line **
    select MO_GLOBAL.get_current_org_id() 
    into v_org_id from dual;
   DBMS_OUTPUT.PUT_LINE('Current MO Org_id='||v_org_id);
-- this is the header
    p_batch_source_rec.batch_source_id := 1261;
    p_trx_header_tbl(1).trx_header_id := 7267;
    p_trx_header_tbl(1).cust_trx_type_id := 1125;
    p_trx_header_tbl(1).trx_date := trunc(sysdate);
    p_trx_header_tbl(1).bill_to_customer_id := 16058;
    p_trx_header_tbl(1).trx_currency := 'USD';
    p_trx_header_tbl(1).trx_NUMBER := '10045';
    p_trx_header_tbl(1).term_id := 1003;
-- this is the first line  
    p_trx_lines_tbl(1).trx_header_id := 7267;
    p_trx_lines_tbl(1).trx_line_id := 13631;
    p_trx_lines_tbl(1).line_number := 1;
    p_trx_lines_tbl(1).description := '1st line';
    p_trx_lines_tbl(1).quantity_invoiced := 1;
    p_trx_lines_tbl(1).unit_selling_price := 10;
    p_trx_lines_tbl(1).line_type := 'LINE';
    p_trx_lines_tbl(1).inventory_item_id :=11040;
    
    AR_INVOICE_API_PUB.create_single_invoice(
             p_api_version           => 1.0,
             x_return_status         => l_return_status,
             x_msg_count             => p_msg_count,
             x_msg_data              => p_msg_data,
             x_customer_trx_id       => l_customer_trx_id,
             p_batch_source_rec      => p_batch_source_rec,
             p_trx_header_tbl        => p_trx_header_tbl,
             p_trx_lines_tbl         => p_trx_lines_tbl,
             p_trx_dist_tbl          => p_trx_dist_tbl,
             p_trx_salescredits_tbl  => p_trx_salescredits_tbl
            );
            
       DBMS_OUTPUT.PUT_LINE( 'Msg '|| substr(p_msg_data,1,225));
       DBMS_OUTPUT.PUT_LINE('Status '|| l_return_status);

   IF l_return_status = fnd_api.g_ret_sts_error OR
       l_return_status = fnd_api.g_ret_sts_unexp_error THEN
       DBMS_OUTPUT.PUT_LINE('unexpected errors found!');
   ELSE
      SELECT count(*)
      Into l_cnt
      From ar_trx_errors_gt;
      IF l_cnt = 0
      THEN
         DBMS_OUTPUT.PUT_LINE('Customer Trx id '|| l_customer_trx_id);
         COMMIT;
      ELSE
          FOR recERR in (
          SELECT DISTINCT trx_header_id, trx_line_id, error_message, invalid_value
          FROM Ar_Trx_Errors_Gt)
          LOOP
              DBMS_OUTPUT.PUT_LINE( recerr.error_message);
          END LOOP;

         DBMS_OUTPUT.PUT_LINE( 'Transaction not Created');
      END IF;
   END IF;
END;

Useful Metalink Notes:
265604.1 
1158903.1
Need to migrate concurrent program definition from one instance to another without creating it again manually. Say the program definitions have to be moved from Instance A to B.

1. Download the program definitions from one instance using FNDLOAD command
2. Use the .ldt file for download and upload, run the scripts in the UNIX box. Get the output
3. Upload the program definition using FNDLOAD command

Execute this in Source Instance A
FNDLOAD usr/pwd@instance 0 Y DOWNLOAD $FND_TOP/patch/115/import/afcpprog.lct PRG_XX.ldt PROGRAM APPLICATION_SHORT_NAME="XX" CONCURRENT_PROGRAM_NAME="XX_CP"

Get the PRG_XX.ldt output file and copy into local.

Then execute the below upload in Instance B where the definition needs to be migrated.

FNDLOAD usr/pwd@instance 0 Y UPLOAD $FND_TOP/patch/115/import/afcpprog.lct PRG_XX.ldt 

Related Posts:
http://oracle.anilpassi.com/oracle-fndload-script-examples.html
http://www.oracleappshub.com/aol/its-all-about-fndload/

I faced this situation: Need to move tables from one instance to another instance in Oracle applications. I just need to extract create table definitions, so that I can execute those create statements in another instance.

Script:

    SELECT DBMS_METADATA.GET_DDL('TABLE',u.table_name)
     FROM ALL_TABLES u
     where u.table_name like 'XX_TABLE_NAME'

dbms_metadata package helps us to get the create table definition. You can use all_tables or user_tables to get the table name details.

Usage: Move table definitions from one instance to another instance. 

oracle apps scripts and commands

| No Comments | No TrackBacks

SQL Loader command :

 

sqlldr control=ctrl_file.ctl SKIP=1 log=logfile.log bad=badfile.log discard=discardfile errors=150000 userid=apps/apps@instance

--xx--

 

FNDLOAD command:

 

FNDLOAD apps/apps@instance 0 Y DOWNLOAD $FND_TOP/patch/115/import/afcpprog.lct PRG_XX.ldt PROGRAM APPLICATION_SHORT_NAME="XX" CONCURRENT_PROGRAM_NAME="XX"

--xx--

 

Set Multi org in R12:

 

Begin

       mo_global.set_policy_context('S', 99); --99 is the org id

End;

--xx--

 

To find Oracle forms fmb version, run the command in unix prompt

 

adident Header <filename>

--xx--

 

To find the folder locations of utl_file directory:

 

select value from v$parameter where name = 'utl_file_dir'

--xx--

 

To be continued....

Oracle XML Publisher Bursting Sample Program

| No Comments | No TrackBacks

<xapi:requestset xmlns:xapi="http://xmlns.oracle.com/oxp/xapi" type="bursting">

    <xapi:request select="/../../LIST_G_INVOICE/G_INVOICE">

         <xapi:delivery>

              <xapi:filesystem output="/server/outputfolder/${TRX_NUMBER}.pdf" id="1234" />

         </xapi:delivery>

     <xapi:document output-type="pdf" delivery="1234">

        <xapi:template type="rtf" location="xdo://AR.INVOICE.en.US/?getSource=true">

        </xapi:template>

      </xapi:document>

   </xapi:request>

</xapi:requestset>

 

Here we are trying to send the PDF output to Server Output Folder. 

 

xapi:delivery - Explains where the output should be delivered

xapi:filesystem - explains the output is destined to filesystem

xapi:template - specifies the template shortcode prefixed with app short code, for eg: AR.INVOICE - AR-app short code and INVOICE is the xml template short code.

 

location="xdo://AR.INVOICE.en.US/?getSource=true"

 

Above line is very important, it takes care of pulling the latest template uploaded in the XML Publisher Administrator responsibility, you don't need to put your template hanging in any UNIX servers.

 

en - Language

US - Territory code (when you create template definition, you make sure that you select United States or other country)

 

The same above example holds good for sending the output through email, fax, etc.,

To email a concurrent program PDF output. We need to call a UNIX host script to read the file from Oracle output directory and using UNIX command mailx, send the output as an attachment to the email address. 

UNIX script for sending email:

 

#====================================================== =====

# derive settings

#====================================================== =====

 

FILE_IN_BASE=o${V_CURRENT_REQ_ID}.out # output file generated by Application

FILE_ERR_BASE=l${V_CURRENT_REQ_ID}.log # log file generated by Application

FILE_OUT=${APPLCSF}/${APPLOUT} # output file directory

FILE_LOG=${APPLCSF}/${APPLLOG} # log file directory

FILE_IN=${FILE_OUT}/${V_FILE_NAME}

FILE_ERR=${FILE_LOG}/${FILE_ERR_BASE}

 

#====================================================== =====

#Email Body

#====================================================== =====

#MESSAGE="Test Message"

#====================================================== =====

#Check for Outfile Validity and existence

#====================================================== =====

 

DATAFILE_COUNT='ls -l $FILE_IN | wc -l'

 

if [ $DATAFILE_COUNT -eq 1 ]

then

echo "file!"

fi

 

if [ $DATAFILE_COUNT -lt 1 ]

then

echo "No input file exists"

exit 1

fi

 

echo ======================================================= ========

echo "Emailing Outfile "

echo ======================================================= ========

 

uuencode $FILE_IN Output.pdf| mailx -s "Test Request Output " $V_EMAILID

 

exit 0

#====================================================== =====

In Oracle R12, there is a huge change in maintaining Customer Master records, we have a new centralized module called TCA(Trading Community Architecture) which will take care of maintaining customer related information.

All tables are stored in HZ module with table names starting in HZ%.

HZ tables are all related and architecture of the TCA module is,


HZ_PARTIES (party-person,organization) <--->> HZ_CUST_ACCOUNTS (customer accounts)

A party may contain one or more customer accounts related to it.

HZ_PARTIES.PARTY_ID = HZ_CUST_ACCOUNTS.PARTY_ID

jh

HZ_CUST_ACCOUNTS <--->> HZ_CUST_ACCT_SITES_ALL

Linking column: CUST_ACCT_SITE_ID


HZ_CUST_ACCT_SITES_ALL <---> HZ_PARTY_SITES_ALL

Linking column: PARTY_SITE_ID


HZ_CUST_SITE_USES_ALL <---> HZ_CUST_ACCT_SITES_ALL

Linking column: CUST_ACCT_SITE_ID


Below query explains the link and how we fetch info from HZ tables.


                     select hz.party_name customer_name, hca.account_number customer_number, 

                               hps.party_site_number site_number, hcsu.location loc_number

                     from hz_cust_site_uses_all hcsu,

                          hz_cust_accounts hca,

                          hz_parties hp

                          hz_cust_acct_sites_all hcas,

                          hz_party_sites hps

                      where hcas.cust_account_id   = hca.cust_account_id

                      and   hcsu.cust_acct_site_id = hcas.cust_acct_site_id

                      and   hcas.party_site_id     = hps.party_site_id

                      and   hp.party_id = hca.party_id

                      and   hcsu.location          = :3

                      and   hca.account_number     = :1

                      and   hps.party_site_number  = :2


There are many APIs to create/update/delete HZ parties, customers, site and location information.

Pls refer these packages,

HZ_CUST_ACCOUNT_SITE_V2PUB - To update customer sites

HZ_CUST_ACCOUNT_V2PUB - To update customers

hz_party_v2pub - To update Parties

HZ_CUSTOMER_PROFILE_V2PUB - To update customer profiles


More information can be found in Oracle TCA technical implementation user guides and also lot of samples found in Metalink when you search any of the above package names.


TCA is also used by lot of other modules include,

- TeleSales

- CRM


In R12, all TCA front end screens are in OA framework.


Oracle Item Import Interface - SQL Loader scripts

| No Comments | No TrackBacks

Item has to be loaded into Oracle. We can import items into Oracle using item interface table mtl_system_items_interface.

Steps to load item into Oracle.

1. Populate interface table mtl_system_items_interface through SQL Loader(no biz validation) or plsql programs with validation

2. Run "Import Items" concurrent program under Inventory responsibility.

 

Sample Control File for a .csv data file:

 

 load data

 infile 'datafile.csv' "str '|\r\n'"

 insert/replace/append into table mtl_system_items_interface  

 fields terminated by "," optionally enclosed by '"'               

 trailing nullcols

 (          Process_Flag,

            Set_Process_Id,

            Transaction_Type,

            Organization_Id,

            inventory_item_id,

            segment1,

            description

)

 

"str '|\r\n'" - this will help in getting the last field of every record without carriage return or linefeed character on it.

 

Command to run SQL Loader:

 

1. Login to UNIX box and run this, sqlldr usr/pwd@instance_sid control_file.ctl log_file.log

2. The SQL loader can also be run from our local PC if Oracle client is installed and it can be verified by checking under oracle_home/bin. Also the oracle_home/bin should be set under environment variable, so that if we type the sqlldr command in windows prompt, it should get executed.

 

More info should be found in the Inventory Open Interfaces user guides.

Hello World

| No Comments | No TrackBacks
Hello Oracle Apps World!