Quantcast
Channel: Oracle Maniacs' Notes » Abhijit Ray
Viewing all articles
Browse latest Browse all 128

Upload Corporate Credit card transactions for Oracle iExpense

$
0
0

I have discussed about Oracle iExpense flow earlier. In that article we talked about entering credit card expenses in the expense report (Step 3b in the Oracle iExpense Flow).

Credit card expenses are essentially the expenses when an employee makes using the corporate credit card provided by his employer. These expenses are sent as a data file by the bank/credit card company, that has provided the card to the employee on behalf of the employer, to the employer.

The employer then loads the data file into Oracle and keeps the expense lines ready for the employee to log in to Oracle and create his/her expense report. The process of loading the expense report data file is given below.


Step 1: Create a staging table

We have created staging table to load the file sent from the credit card company. The table structure we have created is as follows.

CREATE TABLE APPS.XX_AP_CC_TRXNS_STG_TL
(
  ATTRIBUTE1     VARCHAR2(80 BYTE),
  ATTRIBUTE2     DATE,
  ATTRIBUTE3     DATE,
  ATTRIBUTE4     NUMBER,
  ATTRIBUTE5     NUMBER,
  ATTRIBUTE6     VARCHAR2(240 BYTE),
  ATTRIBUTE7     VARCHAR2(15 BYTE),
  ATTRIBUTE8     VARCHAR2(15 BYTE),
  ATTRIBUTE9     NUMBER,
  ATTRIBUTE10    VARCHAR2(80 BYTE),
  ATTRIBUTE11    VARCHAR2(240 BYTE),
  ATTRIBUTE12    DATE,
  RECORD_STATUS  VARCHAR2(1 BYTE),
  DATA_SOURCE    VARCHAR2(60 BYTE),
  LOAD_SEQUENCE  NUMBER,
  REQUEST_ID     NUMBER,
  ERR_MSG        VARCHAR2(1000 BYTE)
)


Step 2: Create a loader program to load the file into the staging table

We have created a HOST program to load the credit card files. The host program will do the following,

  1. Use SQL Loader to load the bank file into the staging table
  2. Move the data file into a processed folder once the file has been loaded

The HOST program will be executed as a concurrent program.

Program:

Executable:

The control file (XX_AP_CC_CTL.ctl) for SQL loader is given below,

LOAD DATA
INFILE *
APPEND INTO TABLE XX_AP_CC_TRXNS_STG_TL
FIELDS TERMINATED BY ','
 OPTIONALLY ENCLOSED BY "'" TRAILING NULLCOLS
  (
   ATTRIBUTE1               "TRIM(:ATTRIBUTE1)",        -- Credit Card No
   ATTRIBUTE2               DATE 'DD/MM/YYYY',          -- Trans Date
   ATTRIBUTE3               DATE 'DD/MM/YYYY',          -- Posted Date
   ATTRIBUTE4               "TRIM(:ATTRIBUTE4)",        -- Amount Foreign Curr
   ATTRIBUTE5               "TRIM(:ATTRIBUTE5)",        -- Converted Amount in USD
   ATTRIBUTE6               "TRIM(:ATTRIBUTE6)",        -- Trans Ref Number
   ATTRIBUTE7               "TRIM(:ATTRIBUTE8)",        -- Currency Code USD
   ATTRIBUTE8               "TRIM(:ATTRIBUTE7)",        -- Transaction Currency Code
   ATTRIBUTE9               "TRIM(:ATTRIBUTE9)",        -- Currency Conversion Rate
   ATTRIBUTE10              "TRIM(:ATTRIBUTE10)",       -- Supplier Name
   ATTRIBUTE11              "TRIM(:ATTRIBUTE11)",       -- Location
   ATTRIBUTE12              DATE 'DD/MM/YYYY',           -- Statement Date    Not Available
   Record_Status            CONSTANT 'N',
   DATA_SOURCE              CONSTANT 'AP_IEXPENSES_CC',
   LOAD_SEQUENCE            SEQUENCE(MAX,1)
  )

The code for the HOST program

# ******************************************************************************
# Usage:        XX_AP_CC_LOAD.prog
# Description:  This program processes Credit Card files for IExpenses
#               available in IEXPENSES_CC folder and calls associated Data Loader Program
#
#
# History:
#
# ******************************************************************************

#Initialize parameters
#By default these four parameters will be assigned.
p_userid_passwd=$1
p_appl_login=$2
p_user_name=$3
p_request_id=$4
p_support_user=$5

CONTROL_FILE=XX_AP_CC_CTL.ctl
BASE_DIR=$XXCUST_TOP
LOADER_DIR=$BASE_DIR/bin
LOADER=$LOADER_DIR/$CONTROL_FILE
DATA_DIR=$XXCUST_TOP/IEXPENSES_CC/iexpenses_cc_unprocessed/
LOGIN_ID=`echo $1|cut -f3,3 -d=`
LOGIN_ID=`echo $LOGIN_ID|cut -f1 -d ' '`
LOGIN_ID=`echo $LOGIN_ID|tr -d '\042'`

#Initialise system variables (standard variables used for logging)
v_work_dir=$XXCUST_TOP/IEXPENSES_CC/iexpenses_cc_unprocessed/
v_file_path_name=$XXCUST_TOP/IEXPENSES_CC/iexpenses_cc_unprocessed/
v_processed_dir=$XXCUST_TOP/IEXPENSES_CC/iexpenses_cc_processed/
v_error_dir=$XXCUST_TOP/IEXPENSES_CC/iexpenses_cc_errors/
v_check_file=$XXCUST_TOP/log/"check_file_"$p_request_id.log

# --------------------
# SQL*Loader Variables
# --------------------

BAD_FILE=$XXCUST_TOP/IEXPENSES_CC/bad_files
LOG_FILE=$XXCUST_TOP/IEXPENSES_CC/log_files
DIS_FILE=$XXCUST_TOP/IEXPENSES_CC/discard_files

# -------------------
# Get Parameter value
# -------------------

RETCODE=$?
code_error=$RETCODE

cd $v_work_dir

echo "The List of Files in the Current Directory : "
echo " "

ls -1 *.*

if [ $? -ne 0 ]
then
   echo "There are no files to be processed "
   mailx -m -s "There are no files to be processed " $p_support_user
   exit 0
else
   #Main Loop
   for v_file_name in  `ls -1 *.*`
   do

   echo " \n----------------------------------------------------"
        echo " Process begin for data file  :  "$v_file_name
        echo " ----------------------------------------------------"

        v_log_file=`echo $v_file_name|cut -f1,1 -d.`
        v_bad_file=`echo $v_file_name|cut -f1,1 -d.`
        v_out_file=`echo $v_file_name|cut -f1,1 -d.`

   if [ -s $v_processed_dir$v_file_name ]
    then
     echo "The data file "$v_file_name" already exists"
     rm $v_file_name
   else
              # ----------------------------------------------------------------
              #  Count records in data file, if empty - abort.Echo to Log file
              # ----------------------------------------------------------------
              RECORD_CNT=`wc -l < $v_file_name`
              if [ "$RECORD_CNT" -eq 0 ]
              then
                 echo "Current Data File is empty, can not process...."
                 echo "The data file is moved to XXCUST_TOP/IEXPENSES_CC/iexpenses_cc_errors folder with name: "$4"-"$v_file_name
                  mv $v_file_name $v_error_dir$4"-"$v_file_name
              else
                 # ------------------------------------------------------
                 #     SQL loader to import data into interim table
                 # ------------------------------------------------------
                 echo "LOADER is: $LOADER"
                 echo "FILENAME is: $DATA_DIR/$v_file_name"
                 echo "LOG FILE is: $LOG_FILE/$v_log_file.log"
                 echo "BAD FILE is: $BAD_FILE/$v_bad_file.bad\n"

                 sqlldr userid=$LOGIN_ID \
                        control=$LOADER \
                          data=$DATA_DIR/$v_file_name \
                          log=$LOG_FILE/$v_log_file.log \
                          bad=$BAD_FILE/$v_bad_file.bad \

                echo " SQLLDR COMPLETED"
                echo " Return Code is: $RETCODE"

                 if [ $? = 0 ]
                 then
                    echo "The following file has been processed and moved to XXCUST_TOP/IEXPENSES_CC/iexpenses_cc_processed folder: "$v_file_name
                    uuencode $LOG_FILE/$v_log_file.log $v_log_file.log|mailx -m -s "AP Invoices Log File for IExpenses " $p_support_user
                    mv $v_file_name $v_processed_dir
                    if [ -s $BAD_FILE/$v_bad_file.bad ]
                      then
                        echo "The following data file has error records which are moved to XXCUST_TOP/IEXPENSES_CC/iexpenses_cc_errors folder with name: "$4"-"$v_bad_file.bad
                        uuencode $BAD_FILE/$v_bad_file.bad $v_bad_file.bad|mailx -m -s "AP Invoices Bad File for IExpenses" $p_support_user
                        mv $BAD_FILE/$v_bad_file.bad $v_error_dir$4"-"$v_bad_file.bad
                     fi
                 else
                    echo "SQL*Loader Failed for Current Data File \n"
                    mailx -m -s "SQL*Loader Failed for Current Data File" $p_support_user
                 fi
              fi
   fi
 done
fi
exit 0

Check the loaded records in the staging table by running the following query,

select * from xx_ap_cc_trxns_stg_tl


Step 3: Validate and load the credit card lines from the staging table to the base table

We have written a validation package to validate the credit card lines and to insert the valid records from the staging table, XX_AP_CC_TRXNS_STG_TL, into the base table, AP_CREDIT_CARD_TRXNS_ALL, table. This package will be called from a concurrent program.

Note: We can decide not validate the credit card lines and load the expense lines into AP_CREDIT_CARD_TRXNS_ALL table. In that case we need to call the seeded validation program,
Credit Card Transactions Validation Program
, to validate the data. This process is demonstrated in the appendix section below.

The concurrent program definition is as follows,

Program:

Executable:

The PL/SQL code is as follows,

CREATE OR REPLACE PACKAGE xx_ap_cc_iexpense_pkg
AS
--==============================================================================
--                            XXXXX
--                           YYYYYY
--==============================================================================
--
--
-- MODULE NAME : xx_ap_cc_iexpense_pkg.pkb
-- AUTHOR      :
-- DATE        :
-- DESCRIPTION : This Program Validates Credit Card data from Staging Table and
--               if there are no errors encountered then data is inserted into
--                 AP_CREDIT_CARD_TRXNS_ALL table. If errors then the program is
--                 aborted and logged
--
-- Change Record:
-- =============
-- VERSION    DATE             AUTHOR(S)           Remarks
-- ========   ============     ===============     ============
--
--
--==============================================================================
   gn_request_id   NUMBER;
   gn_user_id      NUMBER;
   gn_email_id     VARCHAR2 (30);

   PROCEDURE xx_ap_validate_cc_proc (errbuf OUT VARCHAR2, retcode OUT NUMBER);
END xx_ap_cc_iexpense_pkg;

CREATE OR REPLACE PACKAGE BODY xx_ap_cc_iexpense_pkg
AS
--==============================================================================
--                            XXXXX
--                           YYYYYY
--==============================================================================
--
--
-- MODULE NAME : xx_ap_cc_iexpense_pkg.pkb
-- AUTHOR      :
-- DATE        :
-- DESCRIPTION : This Program Validates Credit Card data from Staging Table and
--               if there are no errors encountered then data is inserted into
--                 AP_CREDIT_CARD_TRXMS_ALL table. If errors then the program is
--                 aborted and logged
--
-- Change Record:
-- =============
-- VERSION    DATE             AUTHOR(S)           Remarks
-- ========   ============     ===============     ============
--
--==============================================================================
   PROCEDURE xx_ap_validate_cc_proc (errbuf OUT VARCHAR2, retcode OUT NUMBER)
   AS
      lv_org_id             NUMBER;
      lv_card_prg_id        VARCHAR2 (80);
      lv_err_message        VARCHAR2 (1000);
      lv_err_flag           VARCHAR2 (1);
      lv_trx_id             NUMBER;
      lv_card_number        VARCHAR2 (80);
      ln_total_emp_count    NUMBER;
      ln_total_count        NUMBER;
      ln_processed_count    NUMBER;
      ln_total_emp_failed   NUMBER;
      ln_reject_count       NUMBER;
      lc_status             VARCHAR2 (50);
      lc_wf_status          VARCHAR2 (50);

      CURSOR trans_cur (lv_request_id NUMBER)
      IS
         SELECT   attribute1   -- credit card Number
             FROM xxeyap_cc_trxns_stg_tl
            WHERE record_status <> 'P' AND request_id = lv_request_id AND data_source = 'AP_IEXPENSES_CC'
         GROUP BY attribute1, data_source;

      CURSOR trans_details_cur (l_card_no VARCHAR2, ln_request_id NUMBER)
      IS
         SELECT attribute1,   -- Credit Card Number
                attribute2,   -- Trans Date
                attribute3,   -- Posted Date
                attribute4,   -- Amount Foreign Curr
                attribute5,   -- Converted Amount in USD
                attribute6,   -- Trans Ref Number
                attribute7,   -- Currency Code USD
                attribute8,   -- Transaction Currency Code
                attribute9,   -- Currency Conversion Rate
                attribute10,  -- Supplier Name
                attribute11,  -- Location
                attribute12,  -- Statement Date
                record_status,
				data_source,
				load_sequence,
				ROWID
           FROM xx_ap_cc_trxns_stg_tl
          WHERE record_status <> 'P' AND request_id = ln_request_id AND attribute1 = l_card_no AND data_source = 'AP_IEXPENSES_CC';

      CURSOR check_ceo_trans (c_card_number VARCHAR2)
      IS
         SELECT lookup_code
           FROM fnd_lookup_values
          WHERE lookup_type = 'EY_CC_CEO_EXCLUSION'
            AND TRIM (meaning) = c_card_number
            AND NVL (enabled_flag, 'N') = 'Y'
            AND TRUNC (SYSDATE) BETWEEN TRUNC (start_date_active) AND TRUNC (NVL (end_date_active, SYSDATE));

      CURSOR status_cur (p_request_id NUMBER)
      IS
         SELECT   attribute1,   -- Credit Card Number
                             err_msg
             FROM xxeyap_cc_trxns_stg_tl
            WHERE record_status = 'E' AND data_source = 'AP_IEXPENSES_CC'
         GROUP BY attribute1, err_msg, record_status, data_source
         ORDER BY attribute1;

      lcu_check_ceo_trans   check_ceo_trans%ROWTYPE;
   BEGIN
      gn_request_id := fnd_global.conc_request_id;
      gn_user_id := fnd_profile.VALUE ('USER_ID');
      ln_total_emp_count := 0;
      ln_total_emp_failed := 0;

---------------------------------------------------------------------------
-----update the Receipt staging table with WHO columns
---------------------------------------------------------------------------
      BEGIN
         --      fnd_file.put_line (fnd_file.output, 'Request Id' ||gn_request_id);
         UPDATE xxeyap_cc_trxns_stg_tl
            SET request_id = gn_request_id
          WHERE record_status <> 'P';

         COMMIT;
      EXCEPTION
         WHEN OTHERS
         THEN
            lv_err_flag := 'E';
            lv_err_message := 'Error while Updating the Staging Table' || 'with Request Id - ' || SQLERRM;
            fnd_file.put_line (fnd_file.LOG, ' ' || lv_err_message);
      END;

      FOR trans_rec IN trans_cur (gn_request_id)
      LOOP
         lv_err_flag := 'S';
         lcu_check_ceo_trans := NULL;
---------------------------------------------------------------------------
---  Validate the Credit Card Number
---------------------------------------------------------------------------
         ln_total_emp_count := ln_total_emp_count + 1;

         BEGIN
            --       fnd_file.put_line (fnd_file.output, 'Card Number ' || SUBSTR(trans_rec.attribute1,9,16));
            SELECT card_number
              INTO lv_card_number
              FROM ap_cards_all
             WHERE SUBSTR (card_number,
                           9,
                           16
                          ) = SUBSTR (trans_rec.attribute1,
                                      9,
                                      16
                                     ) AND inactive_date IS NULL;
         EXCEPTION
            WHEN OTHERS
            THEN
               lv_err_flag := 'E';
               lv_err_message := 'Credit Card Number Not Exists';
               fnd_file.put_line (fnd_file.LOG, lv_err_message);
         END;

---------------------------------------------------------------------------
---  Check the transaction Belongs to CEO (Ver 1.1 Starts Here)
---------------------------------------------------------------------------
         OPEN check_ceo_trans (trans_rec.attribute1);

         FETCH check_ceo_trans
          INTO lcu_check_ceo_trans;

         CLOSE check_ceo_trans;

         IF lcu_check_ceo_trans.lookup_code IS NOT NULL
         THEN
            lv_err_flag := 'E';
            lv_err_message := 'CEO Credit Card Transacation';
            fnd_file.put_line (fnd_file.LOG, lv_err_message);
         END IF;   --Ver 1.1 Ends Here

---------------------------------------------------------------------------
---  Fetch the Org_id and Card Program Id, Based on the Credit Card Number
---------------------------------------------------------------------------
         BEGIN
            SELECT org_id, card_program_id
              INTO lv_org_id, lv_card_prg_id
              FROM ap_cards_all
             WHERE SUBSTR (card_number,
                           9,
                           16
                          ) = SUBSTR (trans_rec.attribute1,
                                      9,
                                      16
                                     ) AND inactive_date IS NULL;
         EXCEPTION
            WHEN OTHERS
            THEN
               lv_err_flag := 'E';
               lv_err_message := 'Error while getting the details Based on Credit Card No';
               fnd_file.put_line (fnd_file.LOG, lv_err_message);
         END;

         IF lv_err_flag <> 'E'
         THEN
            FOR trans_details_rec IN trans_details_cur (trans_rec.attribute1, gn_request_id)
            LOOP
               --To Fetch the trx_id sequence numbering
               SELECT xxey_ap_cc_seq_s.NEXTVAL
                 INTO lv_trx_id
                 FROM DUAL;

               BEGIN
                  INSERT INTO ap_credit_card_trxns_all
                              (trx_id, validate_code, card_program_id, expensed_amount, card_number,
                               reference_number,
                                                --                            transaction_type,
                                                transaction_date,
                               transaction_amount, debit_flag,
                               billed_date, billed_amount, billed_currency_code,
                               posted_date, posted_amount, posted_currency_code,
                               currency_conversion_rate,
                                                        --                            sic_code,
                                                        --                            merchant_reference,
                                                        merchant_name1, merchant_city,
                                                                                      --                            merchant_country,
                                                                                      org_id,
                               last_update_date, last_updated_by, last_update_login, creation_date, created_by, payment_flag,
                               merchant_activity, CATEGORY, payment_due_from_code, request_id, trx_available_date
                              )
                       VALUES (lv_trx_id, 'N', lv_card_prg_id, 0, trans_details_rec.attribute1,   -- Credit Card Num
                               trans_details_rec.attribute6 || '_' || lv_trx_id,   -- Trx Ref Num
                                                                                --                             trans_details_rec.transaction_type,
                                                                                trans_details_rec.attribute2,   -- Trx Date
                               trans_details_rec.attribute4,   -- Amount Foreign Curr
                                                            DECODE (SIGN (trans_details_rec.attribute4),
                                                                    -1, 'F',
                                                                    'T'
                                                                   ),
                               trans_details_rec.attribute3,   -- Posted date
                                                            trans_details_rec.attribute5,   -- Amount Foreign Curr
                                                                                         trans_details_rec.attribute8,   -- Transaction Currency Code
                               trans_details_rec.attribute3,   -- Posted Date
                                                            trans_details_rec.attribute5,   -- Amount Foreign Curr
                                                                                         trans_details_rec.attribute7,   -- Currency Code USD
                               trans_details_rec.attribute9,   -- Currency Conversion Rate
                                                            --                             trans_details_rec.sic_code,
                                                            --                             trans_details_rec.merchant_reference,
                                                            trans_details_rec.attribute10,   -- Supplier Name
                                                                                          trans_details_rec.attribute11,   -- Location
                                                                                                                        --                             trans_details_rec.merchant_country,
                                                                                                                        lv_org_id,
                               SYSDATE, gn_user_id, gn_user_id, SYSDATE, gn_user_id, 'N',
                               'M', 'BUSINESS', 'COMPANY', gn_request_id, trans_details_rec.attribute12
                              );

                  UPDATE xxeyap_cc_trxns_stg_tl
                     SET record_status = 'P',
                         err_msg = 'Record Processed'
                   WHERE ROWID = trans_details_rec.ROWID AND data_source = 'AP_IEXPENSES_CC';

                  -- AND SUBSTR(card_number,9,16) = SUBSTR(trans_rec.card_number,9,16);
                  COMMIT;
               EXCEPTION
                  WHEN OTHERS
                  THEN
                     fnd_file.put_line (fnd_file.LOG, 'Error in inserting record Data :-' || SQLERRM);
               END;
            END LOOP;
         ELSE
            ln_total_emp_failed := ln_total_emp_failed + 1;

            UPDATE xxeyap_cc_trxns_stg_tl
               SET record_status = 'E',
                   err_msg = lv_err_message
             WHERE SUBSTR (attribute1,
                           9,
                           16
                          ) = SUBSTR (trans_rec.attribute1,
                                      9,
                                      16
                                     );
         --           fnd_file.put_line (fnd_file.output, 'In Else of If for Error') ;
         END IF;
      END LOOP;

      BEGIN
         SELECT COUNT (*)
           INTO ln_total_count
           FROM xxeyap_cc_trxns_stg_tl
          WHERE request_id = gn_request_id;
      EXCEPTION
         WHEN OTHERS
         THEN
            fnd_file.put_line (fnd_file.LOG, 'Error in Others Exception for Receipt Created Count');
      END;

      BEGIN
         SELECT COUNT (*)
           INTO ln_processed_count
           FROM xxeyap_cc_trxns_stg_tl
          WHERE record_status = 'P' AND request_id = gn_request_id;
      EXCEPTION
         WHEN OTHERS
         THEN
            fnd_file.put_line (fnd_file.LOG, 'Error in Others Exception for Receipt Processed Count');
      END;

      BEGIN
         SELECT COUNT (*)
           INTO ln_reject_count
           FROM xxeyap_cc_trxns_stg_tl
          WHERE record_status = 'E' AND request_id = gn_request_id;
      EXCEPTION
         WHEN OTHERS
         THEN
            fnd_file.put_line (fnd_file.LOG, 'Error in Others Exception for Receipt Reject Count');
      END;

      fnd_file.put_line (fnd_file.output, 'EY IExpenses Credit Card Validation Program To AP, Run ON ' || SYSDATE);
      fnd_file.put_line (fnd_file.output, 'Summary Of Run : ');
      fnd_file.put_line (fnd_file.output, ' ');
      fnd_file.put_line (fnd_file.output, ' ');
      fnd_file.put_line (fnd_file.output, RPAD ('*',
                                                90,
                                                '*'
                                               ));
      fnd_file.put_line (fnd_file.output, '    Result of EY IExpenses Credit Card Validation Program       ');
      fnd_file.put_line (fnd_file.output, RPAD ('*',
                                                90,
                                                '*'
                                               ));
      fnd_file.put_line (fnd_file.output, 'Total No. Of Records Avaliable in Staging Table       :- ' || ln_total_count);
      fnd_file.put_line (fnd_file.output, 'Total No. Of Employees Records Processed              :- ' || ln_processed_count);
      fnd_file.put_line (fnd_file.output, 'Total No. Of Employees Records to be Processed        :- ' || ln_total_emp_count);
      fnd_file.put_line (fnd_file.output, 'Total No. Of Employees Records Failed                 :- ' || ln_total_emp_failed);
      fnd_file.put_line (fnd_file.output, 'Total No. Of Records Failed                           :- ' || ln_reject_count);
      fnd_file.put_line (fnd_file.output, RPAD ('*',
                                                90,
                                                '*'
                                               ));
      fnd_file.put_line (fnd_file.output, ' ');

      IF (ln_reject_count > 0)
      THEN
         fnd_file.put_line (fnd_file.output, RPAD ('*',
                                                   90,
                                                   '*'
                                                  ));
         fnd_file.put_line (fnd_file.output, ' ');
         fnd_file.put_line (fnd_file.output, ' Failed Records Information');
         fnd_file.put_line (fnd_file.output, '*****************************');
         fnd_file.put_line (fnd_file.output, '  ');
         fnd_file.put_line (fnd_file.output, RPAD ('*',
                                                   90,
                                                   '*'
                                                  ));
         fnd_file.put_line (fnd_file.output, RPAD ('Card Number ',
                                                   25,
                                                   ' '
                                                  ) || RPAD ('Error Message',
                                                             65,
                                                             ' '
                                                            ));
         fnd_file.put_line (fnd_file.output, RPAD ('*',
                                                   90,
                                                   '*'
                                                  ));
         fnd_file.put_line (fnd_file.output, ' ');

         FOR i IN status_cur (gn_request_id)
         LOOP
            fnd_file.put_line (fnd_file.output, RPAD (i.attribute1, 25) || RPAD (i.err_msg, 65));
         END LOOP;
      END IF;

      fnd_file.put_line (fnd_file.output, ' ');
      fnd_file.put_line (fnd_file.output, ' ');
      fnd_file.put_line (fnd_file.output, 'Request Id : ' || gn_request_id);
      fnd_file.put_line (fnd_file.output,
                         '****** Please See the Log of Request Id for Errors and Exceptions occured during execution In-Detail');
      fnd_file.put_line (fnd_file.output, ' ');
      fnd_file.put_line (fnd_file.output, ' ');
      fnd_file.put_line (fnd_file.output, '***** End of the Report *****');

      /*
      BEGIN
       XXEY_CC_INT_PK.INIT_NOTY_PR(gn_request_id,lc_status);
      EXCEPTION
       WHEN OTHERS THEN
          fnd_file.put_line (fnd_file.log, 'Error while Initiate the Workflow :-'||SQLERRM ) ;
      END;
      */
      BEGIN
         xxey_cc_notify.init_wf (gn_request_id, lc_wf_status);
      EXCEPTION
         WHEN OTHERS
         THEN
            fnd_file.put_line (fnd_file.LOG, 'Error while Initiate the Workflow :-' || SQLERRM);
      END;
   EXCEPTION
      WHEN OTHERS
      THEN
         fnd_file.put_line (fnd_file.LOG, 'Error while Inserting data into Base Table :-' || SQLERRM);
   END xx_ap_validate_cc_proc;
END xx_ap_cc_iexpense_pkg;
/


Step 4: Check the records

Query the credit card transactions base table to view the loaded records,

select * from ap_credit_card_trxns_all


Step 5: Create request set for both programs

You can create a request set so that both programs are executed in sequence. The request set will be like the following,

Stages

Once the programs are executed the credit card lines are loaded into AP_CREDIT_CARD_TRXNS_ALL table. The users subsequently create their own expense report after logging in to Oracle iExpense as shown in Step 3a in this article.

Important:
Only when the expense report is submitted for Credit Card, the expense lines are created in AP_EXPENSE_REPORT_LINES_ALL table. If the expense report is created but saved for later the expense lines remain in the AP_CREDIT_CARD_TRXNS_ALL table.


Code to list pending credit card transactions

The following code lists the employees for whom there are pending credit card transactions that have to be submitted as expense reports.

SELECT   ppx.employee_number, ppx.full_name, accta.card_number, COUNT (accta.card_number) "Num of Transactions"
    FROM ap_cards_all aca, ap_credit_card_trxns_all accta, per_people_x ppx
   WHERE aca.card_number = accta.card_number AND aca.employee_id = ppx.person_id
GROUP BY ppx.employee_number, ppx.full_name, accta.card_number

Appendix

When the seeded validation program, , is used to validate the credit card expense lines the custom program in step 3 above, only needs to transfer the data from the custom table to the credit card table, AP_CREDIT_CARD_TRXNS_ALL.

Once the records are loaded in the table, execute the seeded program named, Credit Card Transactions Validation Program

Responsibility: Payables responsibility

Navigation: View > Requests

After the program completes you can check the credit card table, AP_CREDIT_CARD_TRXNS_ALL, table to view the transactions from the database.

Execute query

select * from ap_credit_card_trxns_all order by trx_id desc

The output

Note the column, VALIDATE_CODE. The value “Y” in this column indicates that the credit card data is valid. You can see some lines with “Y” and some lines with an error message, “INVALID_CARD_NUMBER“.

Now the iExpense credit card users can log in and create their expense reports for the valid credit card transactions in the database against their user names and credit cards (Step 3b in the Oracle iExpense Flow)

Cheers!



Viewing all articles
Browse latest Browse all 128

Trending Articles