batch invoice uploads oracle payables ellis

Upload: vallamshetla

Post on 05-Apr-2018

226 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/31/2019 Batch Invoice Uploads Oracle Payables Ellis

    1/19

    ORAtips

    ORAtipsJournal

    January2006

    VolumeIIIssue1

    ORAtips.com ORAtips 2006 Klee Associates

    in parts. The rst would be the con-version o the legacy accounts pay-able system.

    In this article, I will discuss whatI believe is the most visible custominterace that has been deployedas part o our Oracle Application(Finance) release. Its origin camerom a major project some threeyears ago that converted the corpo-rate legacy accounts payable systemto the Oracle Applications (Finance)Payables module.

    As with any major conversion,system unctionality currently usedmust be retained. The challenge wasdeploying an Oracle Applications(Finance) batch invoice system thatmirrored the legacy system. A secondchallenge, associated with any type oconversion, is ensuring end-user buy-in. Not only do we need their accep-tance o the new interace, but alsotheir willingness to use the interacein a completely new nancial man-

    The challenge

    associated with any

    type of conversion is

    ensuring end-user

    buy-in.

    agement system. It was importantbe very conscious o the end usereactions; in other words, the eo change. The goal was to give tend users an intuitive system, easitheir ears and empowering themhave control o both their job and tsystem.

    The interace, better known Invoice Upload Interace, is higly visible because it is heavily usevery day by multiple end users.has been in production use or thryears. In the beginning, its purpowas to allow multiple end users process invoices in real-time (or paallel processing o invoice batcheAs the end users began to recognthe power o the interace, additionenhancements were requested. Som

    o these enhancements were:

    One-Time Vendor Invoice Uloads

    Match to PO Invoices Uploads

    Sharing the Process with dconnected Business Units withHumana

    Automate the process to incluMass Additions o Assets

    Discussing each o the enhancments listed above is a paper unitsel. What I will discuss is the initdeployment o the original InvoUpload Interace and the torequired to do it.

    Process RequirementsThe end users wanted to replica

    how invoice batches were processin the legacy system. The legacy pr

    Editors Note: MS Excel to loadinvoice batches to Oracle Payables!

    Even Oracle ADI doesnt do that, inact ew 3rd-party products do. Whatto do? Do as Kevin Ellis has done,develop your own in-house invoicebatch interace. And i that isntenough to pique your interest, howabout an interace or keeping your

    chart o accounts current betweenproduction legacy and Oracle sys-tems? He has done that too. And hehas shared all in this comprehensiveORAtips cover story, discussing cus-tom concurrent program and UNIXshell script development, Oracle

    Applications set-up, and end-userconsiderations.

    IntroductionIn the inaugural volume o ORAtips,

    I presented an article titled Real-Time Migration o Oracle Applica-tion Setups Done In-House. In thatarticle, I gave a little backgroundon the origin o Oracle Applica-tions (Finance) at Humana. Emph-esys was to have been the name oa spin-o company that never hap-pened. The rollout o Oracle Appli-cation (Finance) was to be the booko record or the new spin-o. As thespin-o never happened, the imple-mentation o Oracle Applications was

    retained as a sub-ledger to the corpo-rate legacy books. Emphesys was re-organized into product development.Later as time passed, senior leader-ship decided that the corporate booko record (legacy) would eventuallyneed to be enhanced or converted.The long-term goal was conversion.Better stated, Oracle Applications(Finance) would eventually be thebook o record or the corporation.However, conversion would be done

    Batch Invoice Uploads into Oracle Payables

    Using MS Excel By Kevin E

    4On Financials - Payables

  • 7/31/2019 Batch Invoice Uploads Oracle Payables Ellis

    2/19

    ORAtips

    ORAtipsJournal

    January2006

    VolumeIIIssue1

    ORAtips.com ORAtips 2006 Klee Associates

    cess involved screens. At rst thought,it would be reasonable to assume oursolution would be deployment o a

    sub-system in Oracle Applicationsusing Oracle Forms. However, therewere multiple problems with this.Our development sta members aretechnology rookies and were in acttaking Oracle Forms training classesduring this project. That coupledwith a tight budget and deadlineconstraints also eliminated bringingin external consultants to assist.

    During the analysis phase, it wasnoted the end users were comortable

    using Microsot Excel, as were theSystem Administrators, who are alsoaccounts payable experts. My yearso working with Oracle productshad helped me learn the technicalside o Oracle Payables, and I havea good working knowledge o Excel.This triggered the idea o creating anOracle Payables business template inExcel (administered by our unctionalsystem administrators) as the key tothis challenge. A concurrent program

    could be used to process and load thetemplate into Oracle Payables via anopen interace. This solution wouldmeet two major requirements: easeo use and limited training.

    Still, there were other hurdles toovercome: business requirements.One has already been discussed: mul-tiple end users running the process inparallel. To meet this requirement,our design was simple enough, andthis is discussed urther in the System

    Design section. At a quick glance:

    1. A batch number uniquely identi-es each batch.

    2. The end users save the Excel tem-plate batches as comma-delimitedles (or CSV les).

    3. The system uses a CSV le or-mat to load data into tables viaSQL*Loader.

    This solution allowed the interaceto be executed multiple times in par-allel.

    As previously mentioned, OracleApplications (Finance) was to berolled out as part o the spin-o.The chart o accounts (COA) struc-ture diered in Oracle Applications(Finance) rom that o the legacysystem. It was concluded that themapping between Oracle and legacyCOA combinations would be main-tained on the legacy side o the busi-ness. Since the end users required theability to continue booking invoices

    using the legacy COA structure, acustom interace was required topull the COA mappings down sothat the invoices could be bookedto the correct COA combination inOracle. Given that the COA combi-nations are changed daily, the inter-ace (COA mappings) would need tobe scheduled to run daily so that theOracle mappings remained current.In the event o an emergency map-ping, the interace also needed to be

    fexible so that it could be executedon demand.

    Our solution was to develop sub-system that mimics legacy sytem unctionality. Excel is used as

    substitute or the legacy system anis the data entry point. A processdeployed to maintain COA mapings between the legacy system aOracle, scheduled to run daily withe ability to be executed on demanA concurrent program is deployewhich can be submitted multiptimes simultaneously or dierebatches to take care o translatithe legacy COA values to Oracle COcombinations. The actual mappinare managed and maintained on t

    legacy system.

    System DesignSystem design is airly simple ro

    the standpoint o the end user:

    A predened Excel template data entry

    A location on the server to stothe Excel template batches

    A concurrent program thwould select, process, and lothe invoices stored in the Exctemplate batches into OracPayables

    The concept is straightorward. Tdetails are another story. Ownersho the design or the Excel templawas given to the unctional sta sinthey were accounts payable experplus had a comort level designing Excel template. Granted, some neg

    tiation was necessary. For instancthe technical team knew Oracle prcessed invoices in a drill down soo ashion. Batches are composed invoices and invoices are composo lines. Also, consideration or maitaining the COA mappings had to actored in. Figure 1 demonstrat(rom a business perspective) tdesign o the system.

    4On Financials - Payables

    Excel is used as a

    substitute for the

    legacy system and

    is the data

    entry point.

  • 7/31/2019 Batch Invoice Uploads Oracle Payables Ellis

    3/19

    ORAtips

    ORAtipsJournal

    January2006

    VolumeIIIssue1

    ORAtips.com ORAtips 2006 Klee Associates

    Enter Invoice Batch is done via apre-dened Excel template. Oncethe template is populated, it is savedas a comma-delimited le to a spe-cic directory on a specic networkserver. The le name includes thebatch number as determined by theend user. The number is used as arun-time parameter when executingthe concurrent program to pull thecomma-delimited le rom the net-work server to UNIX. Not only does

    the batch number allow the concur-rent program to identiy the correctdata le to pull, but also allows otherend users to process dierent batchesat the same time. In other words, thesystem is designed to allow parallelprocessing o invoice batches.

    Because the end users use the cor-porate COA structure to enter invoicebatches, the COA mappings must bepulled rom the mainrame to Oracleor proper accounting o the invoic-

    es in the Oracle Payables system. Aprocess on the mainrame generatesthe required data, the COA mappingle. In Oracle, a concurrent programpulls the COA mappings to Oracleor reerence when processing invoicebatches.

    At this point, I will discuss tdetails o the system. Please nothat I will not elaborate on the CO

    mapping portion since it may only unique to our company and may neven be necessary or yours. Evenit were relevant to your company, tstructures would dier. Additionalthe discussion o the COA mappintakes away rom the major goal this article, which is the processingthe invoices in batch ormat

    The MS Excel TemplateAs mentioned previously, the da

    entry point is the Excel template.

    Humana, we designed the templawith two goals in mind: items thpertained to the business and thothat are required to be processed vOracle Payables.

    The rst three lines o the template are reserved. The rst line the template is header labels or tbatch. Basic batch level inormatiis entered into the second line. Tthird line contains invoice line labe

    identiying the columns or each daelement to be entered or an involine. The bulk o the data (involines) are entered starting at lineorward. Figures 2 and 3 are examples o our Excel template.

    Line 2 contains the basics abothe batch. The end user enters t

    4On Financials - Payables

    Figure 1: Business System Design

    Figure 2: Excel Template, Part 1

    Enter Invoice Batch

    into Excel Templatae

    & save as CSV fle

    Maintain COA

    Mappings on

    Mainrame

    Execute Concurrent

    Program to load and

    process Invoice Batch

    Generate COA Mapping

    File

    Execute Concurrent

    Program to pull COA

    Mappings

    Mainrame

    Oracle

    Invoice Batch CSV fles

    COA Mappings

  • 7/31/2019 Batch Invoice Uploads Oracle Payables Ellis

    4/19

    ORAtips

    ORAtipsJournal

    January2006

    VolumeIIIssue1

    ORAtips.com ORAtips 2006 Klee Associates

    batch number along with the batchcontrol total, batch date, accountingperiod, the batch control count, and

    their Oracle user id (created by). Theother batch header columns are cal-culated elds. In other words, Excelcomputes the accumulated batchtotal and the dierence displayed inthe column titled Batch Variance.Likewise, Excel calculates the Accu-mulated Batch Count eld and thevariance displayed in the eld titledBatch Count Variance. Additional-ly, there is one other calculated eldcalled Invoice Count, which tellsthe user (once all invoice lines have

    been entered) the number o uniqueinvoices in the batch.

    At the invoice line level, the enduser enters data about each invoiceline included in the batch. Data relat-ed to each specic invoice is denotedby the burgundy color o the headercolumn. Likewise, invoice line leveldata is denoted by the yellow color othe header column. You may noticethat there are column headers listed

    in blue. These items represent anenhancement that was applied to theinterace related to perorming auto-mated mass additions. These attri-butes are optional since they are onlyrelevant to invoices involving assets.With every invoice, the ollowing isrequired:

    Batch number

    Date the invoice was received

    The invoice date

    Invoice number

    Vendor identication (either anumber or code)

    Special handle

    Pay alone

    Terms

    Other inormation (such as or-eign PO number, invoice descriptioncomments and secure inormation) isoptional. At the line level, the ollow-ing is required:

    Line number

    COA inormation (COID & UDN/Acct)

    Distribution amount

    Likewise, there is optional inomation (such as state tax, county talocal tax, distribution descriptiomajor & minor category, tag numbserial number, and expense UDAcct). It should be noted that daentered into state, county, or lotax will result in an extra involine being created. In other wordeach invoice line listed in the Exspreadsheet will create rom one

    our invoice line entries in OraPayables pending tax inormatirendered.

    The Custom ConcurrentProgram

    The custom concurrent prograexecutable is built using UNIX scriwhich will be discussed urther in tUNIX Shell Program Design sectioThe custom concurrent progracalls the custom executable. The cutom concurrent program setup is d

    played in Figure 4.

    The concurrent program is composed o several parameters, mostwhich are invisible to the end usHowever, one is visible and requirebatch number. All o the parameteare displayed in Figures 5 and 6. Fthe batch number, a custom valset was deployed (Figure 7). Theis nothing special about this valset other than it denes the bat

    4On Financials - Payables

    Figure 3: Excel Template - Part 2

    .. data entered

    for state, county

    or local tax will

    create an

    additional invoice

    line

  • 7/31/2019 Batch Invoice Uploads Oracle Payables Ellis

    5/19

    ORAtips

    ORAtipsJournal

    January2006

    VolumeIIIssue1

    ORAtips.com ORAtips 2006 Klee Associates

    4On Financials - Payables

    Figure 5: Parameters Part 1

    Figure 4: Custom Concurrent Program

    Figure 6: Parameters Part 2

  • 7/31/2019 Batch Invoice Uploads Oracle Payables Ellis

    6/19

    ORAtips

    ORAtipsJournal

    January2006

    VolumeIIIssue1

    ORAtips.com ORAtips 2006 Klee Associates

    number as an alpha-numeric stringo up to ten characters in length withno validation. It is possible that this

    rule may change in the uture. TheUNIX script uses all o the otherparameters.

    The UNIX Shell ProgramDesign

    What we have seen up to this pointis the cosmetic portion o the inter-ace. Now comes the guts: the back-ground process. The data fow o thebackground process is illustrated inFigure 8. The rst part o the process

    is simple: pull over the invoice batchdata le rom the NT server to UNIX.This is accomplished via a FTP ses-sion. Because the interace must beable to process multiple batches atthe same time, the le name o eachbatch contains the batch number.

    Pulling the Data File toUNIX

    In our deployment, UNIX was usedto drive the entire interace. The con-

    current program initiates a call toa UNIX shell program. UNIX shellprograms or Oracle Applicationscan be set up in many ways. Oneway is by using a UNIX link. This isbenecial to the developer in termso uture enhancements. We did usethis deployment method because atthe time o development, we did nothave any knowledge that UNIX shellprograms could be setup in that ash-ion. Instead we used AWK to parsethe parameter string sent rom the

    concurrent program. The code orexecuting the FTP in this ashion isshown in Figure 9.

    4On Financials - Payables

    Figure 7: Value Set

    Figure 8: Background Data Flow

    Execute the Oracle provide

    concurrent program "Payables

    Open Interace Import"

    ap.ap_batches_all ap.ap_invoices_all ap.ap_invoice_distributions_all

    Load data into

    Payables Open

    Interace Tables

    Process data and

    validate against

    Business Rules

    Pull Invoice Batch CSV

    File rom NT Server to

    UNIX

    Invoice batch CSV fle

    ap.ap_invoice_lines_interaceap.ap_invoices_interace

    Exit in Error

    Batch HeaderStaging Table

    Invoice LinesStaging Table

    All ValidationsMet?

    Load Invoice Batch

    data into custom

    Staging Tables

    FTP

    SQLSQL

    Yes

    No

    InsertInsert

    SQLSQL

    SQL

    SQL *Loader SQL *Loader

  • 7/31/2019 Batch Invoice Uploads Oracle Payables Ellis

    7/19

    ORAtips

    ORAtipsJournal

    January2006

    VolumeIIIssue1

    ORAtips.com ORAtips 2006 Klee Associates

    4On Financials - Payables

    #*****************************************************

    #*** Retrieve Parameters from Concurrent Program ***

    #*****************************************************

    REQUESTID=`echo $1 | awk {print $2} | sed s;FCP_REQID=;;`USERPASS=`echo $1 | awk {print $3} | sed s;FCP_LOGIN=;; | sed s;;;g`

    USERID=`echo $1 | awk {print $4} | sed s;FCP_USERID=;;`

    ORGID=`echo $1 | awk {print $9} | sed s;;;g`

    RESPID=`echo $1 | awk {print $10} - | sed s;;;g`

    RESPAPPLID=`echo $1 | awk {print $11} - | sed s;;;g`

    SECGRPID=`echo $1 | awk {print $12} - | sed s;;;g`

    BATCH_NUMBER=`echo $1 | awk {print $13} - | sed s;;;g`

    LOGINID=`echo $1 | awk {print $14} - | sed s;;;g`

    #*************************

    #*** Setup Constants ***

    #*************************

    FILENAME_BASE=empap_humvp

    DIRECTORY_XFER=/staging

    DIRECTORY_DATA=${EMPCUST_TOP}/inbound

    #********************************************

    #*** Retrieve E*Mail Address for Caller ***

    #********************************************

    EMAILADDR1=`echo set heading off

    set echo off

    select email_address

    from apps.fnd_user

    where user_id = ${USERID}; | sqlplus -s ${USERPASS}`

    EMAILADDR1=`echo ${EMAILADDR1} | sed s;^ ;;g`

    echo Batch Name :${BATCH_NUMBER}

    #*****************************************************

    #*** Attempt to retr ieve Invoice Batch Data File ***

    #*** from NT Server ***

    #*****************************************************

    echo Retrieving batch data le ${FILENAME_BASE}${BATCH_NUMBER}.csv

    ftp -inv humana.ap.invoices.batch_upload

  • 7/31/2019 Batch Invoice Uploads Oracle Payables Ellis

    8/19

    ORAtips

    ORAtipsJournal

    January2006

    VolumeIIIssue1

    ORAtips.com ORAtips 2006 Klee Associates

    4On Financials - Payables

    All parameters set up in the concur-rent program, plus some that Oraclesends automatically (like the requestID, APPS/password connection tothe Oracle Database, the user ID exe-cuting the concurrent program, theuser name, selected printer, etc.), canbe reerenced by the rst parameter($1) in a UNIX shell program. In this

    example, we are only going to look atthose that are pertinent to perorm-ing the FTP.

    In the example, I have listed all othe parameters that have been setup by the design o the concurrentprogram. I wanted to point out thatcustom parameters are reerencedin a UNIX shell program starting atthe 9 position o parameter $1. Inother words, to get the Org ID youmust parse through to the 9 string in

    parameter $1 in order to obtain itsvalue. Likewise, the 10th string inparameter $1 represents the Respon-sibility ID, and so orth. The rst 8strings in parameter $1 are reservedand are passed to a UNIX shell pro-gram automatically. We will usesome o these to perorm the logicabove. Also important to note is thatthe batch number will be saved in aUNIX variable ${BATCH_NUMBER}and is the 13 string in parameter $1.

    Once the parameters have beenreceived rom the concurrent pro-gram, constants are set up. In thiscase, the constants serve as place-holders or the base name or thedata le that is to be pulled over, thedirectory that the data le will initial-ly be placed in, and the nal stagingarea that the data le will be placed

    in, provided that we were successulin pulling it over in the rst place. Alldata les have a base name. In thiscase, it is empap_humvp, stand-ing or Emphesys Account Payableor Humana Vendor Payments. Thisstring is stored in the constant vari-able ${FILENAME_BASE}. That isbasically what our invoice uploadprocess is or: processing invoices orservices provided by external ven-dors. What ollows that le nameis the batch number. Since the end

    user saves the invoice batch as ancomma-delimited le, on the remoteserver the le can be reerenced bythe concatenation o UNIX variables${FILENAME_BASE}${BATCH_NUMBER}.csv.

    Up to this point, I have demon-strated how we retrieve the concur-rent program parameters and howwe determine what le to pull. Nowlet us actually try nding it. This

    is perormed via an FTP sessionhave placed some dummy names reerence a server I call humanap.invoices.batch_upload. Likwise, I assume there is an account up or us called oracle_upload athat the password to this accountpassword. This would not be vesecure by any means, but I wanted

    keep this part o the demonstratisimple. I also assume that the assciates save their comma-delimitinvoice batch le under a directocalled /ap/oracle/csv.

    Given these assumptions, I hacongured the UNIX script to conect to the remote server at that poand attempt to nd and pull a that is equivalent to the value storrom reerencing ${FILENAMBASE}${BATCH_NUMBER}.csv

    Assuming that the le exists, it pulled rom the remote server aplaced on a directory in UNIX call/staging. My next step is to detmine i a le was received. I no is received, I must notiy the callerthe concurrent program o the prolem and terminate the UNIX shprogram. To terminate a UNIX shprogram abnormally is accomplishusing the exit command. This wcause the concurrent program th

    #*******************************************************

    ls ${DIRECTORY_XFER}/${FILENAME_BASE}${BATCH_NUMBER}.csv

    if [ $? -ne 0 ];then

    echo Error: data le ${FILENAME_BASE}${BATCH_NUMBER}.csv does not exist. Please download invoice batch le anre-run concurrent program EMPAP: Invoice Upload Interface.

    (echo Data le ${FILENAME_BASE}${BATCH_NUMBER}.csv does not exist. Please download invoice batch le and rerun concurrent program EMPAP: Invoice Upload Interface.)|mailx -s EMPAP: Invoice Upload; Error, Request ID ${REQUESTID}${EMAILADDR1}

    exit 1

    else

    echo Data le downloaded to transfer directory.

    echo Moving data le to data directory.

    mv ${DIRECTORY_XFER}/${FILENAME_BASE}${BATCH_NUMBER}.csv

    ${DIRECTORY_DATA}/${FILENAME_BASE}${BATCH_NUMBER}.csv

    Figure 9: FTP - continued from previous page

  • 7/31/2019 Batch Invoice Uploads Oracle Payables Ellis

    9/19

    ORAtips

    ORAtipsJournal

    January2006

    VolumeIIIssue1

    ORAtips.com ORAtips 2006 Klee Associates

    executed it to immediately completein error. As part o this process, I sendan e-mail to the caller, stating that the

    concurrent program has completedin error. I also send them the requestID so that they can quickly nd andreview the report or the problem inquestion via the concurrent manager.I the le was ound, then I simplymove the invoice batch le to a dataprocessing directory.

    At this point you might ask me,how do you know which person tosend the e-mail to. Using the 3rd and4th strings in parameter $1, you can

    identiy the Oracle APPS/passwordconnection string o the User ID othe caller that executed the concur-rent program. Again, I assume thatthe e-mail address has been set up inOracle Applications and can be oundin the AOL table called FND_USER.Starting a SQL*Plus session, I makea simple SQL select statement pull-ing the e-mail address or the user ID.Once the e-mail address is returned,trim it or unnecessary characters.

    Load the Data into CustomStaging

    Assuming that the comma-delim-ited le was retrieved successullyrom the remote server onto UNIX,the next step can commence. The stepis loading the data to custom stag-ing tables. The design splits the datainto 2 separate tables: one or headerinormation (batch level) and theother containing the actual invoicedistributions (or lines). SQL*Loader

    is used to accomplish this task. Thecontrol les developed or this taskare shown in Figures 10 and 11.

    The header control le (Figure 10)would process the header inormationo the invoice batch. For each batch,a single record is retrieved rom thecomma-delimited le. It is the secondphysical line in the le. Note, the rstphysical line contains the labels oreach eld associated with the batch

    level header inormation. The batchlevel record is loaded into a tablecalled empap_humvp_header_tl thatexists in a custom schema calledempcustom. Additionally, data load-

    ed into this table is appended. Thereason is that there are custom Dis-coverer reports (not discussed in thisarticle) that have been provided tothe end users or reporting on currentand previous invoice batch uploads.

    The lines control le (Figure 11)loads all o the invoice lines or thebatch in question. All invoice linesstart at the physical ourth line othe comma-delimited le. The third

    physical line o the le contains tlabels or the invoice lines that low. The only limitations or enteriinvoice lines in a batch are depedent on how many rows o data Ex

    can handle. The invoice line recorare loaded into a custom table callempap_humvp_lines_tl, which stored in a custom schema callempcustom. Just to note, we alloor no errors to occur during loaAny errors encountered will resultthe interace terminating in error.

    Lets say, or instance, that tinvoice batch being processed is batch 12351. The associate respo

    Figure 10: Header Control File

    Figure 11: Line Control File

    4On Financials - Payables

  • 7/31/2019 Batch Invoice Uploads Oracle Payables Ellis

    10/19

    ORAtips

    ORAtipsJournal

    January2006

    VolumeIIIssue1

    ORAtips.com ORAtips 2006 Klee Associates

    sible or this batch would have pro-duced a comma-delimited le calledempap_humvp12351.csv. For

    simplicity, lets say that the batchcontains two invoices: one with threedistributions and the other with two.The batch would consist o a total ove invoice lines to populate, at theminimum. It is possible (given ourbusiness design) that other invoicelines may be created. This conceptwill be discussed later under thetopic o loading data to the PayablesOpen Interace tables. Figure 12 is anexample o what the comma-delim-ited le would look like.

    This is the same comma-delimitedle that will be processed by bothSQL*Loader control les. The head-er control le will process a singlerecord: that which exists on the sec-ond physical line or the le. The line

    control le will process all invoice

    lines starting at the ourth physicline orward.

    Let us now review how this woube executed via the UNIX shell prgram. Figures 13 and 14 are samp

    o the UNIX scripting code that ex

    Figure 12: Comma-Delimited File

    /***********************************//*** Set SQL*Loader Parameters ***//***********************************/P_CTL=${DIRECTORY_SQLLDR}/empap_humvp_header_tl.ctlP_DATA=${DIRECTORY_DATA}/${FILENAME_BASE}${BATCH_NUMBER}.ctlP_BAD=${DIRECTORY_BAD}/${REQUESTID}h.badP_LOG=${DIRECTORY_BAD}/${REQUESTID}h.logP_DSC=${DIRECTORY_BAD}/${REQUESTID}h.dsc

    /***************************************//*** Display SQL*Loader Parameters ***//***************************************/echo Control le : ${P_CTL}echo Log le : ${P_LOG}echo Data le : ${P_DATA}echo Bad le : ${P_BAD}echo Discard le : ${P_DSC}

    /************************************//*** Execute SQL*Loader Session ***//************************************/sqlldr ${USERPASS} control=${P_CTL} data=${P_DATA} bad=${P_BAD} log=${P_LOG} discard=${P_DSC}

    /******************************************/

    /*** Determine if there were problems ***//******************************************/ls ${P_BAD}if [ $? -ne 0 ];then

    echo Data le loaded successfully into table empap_humvp_header_tl.else

    echo ERROR: Problems occurred during data load into table empap_humvp_header_tl.(cat ${P_BAD})|mailx -s EMPAP: Invoice Upload Interface, Error with Concurrent Request ${REQUESTID

    ${EMAILADDR1}exit 2

    Figure 13: UNIX Code for Header Control File

    4On Financials - Payables

  • 7/31/2019 Batch Invoice Uploads Oracle Payables Ellis

    11/19

    ORAtips

    ORAtipsJournal

    January2006

    VolumeIIIssue1

    ORAtips.com ORAtips 2006 Klee Associates

    cutes SQL*Loader to accomplish thedata load or each custom table.

    For simplicity, the rst thing I dois set up SQL*Loader parameters.In the event I would have to changethe settings, all I would need to dois change the values set against theparameter. The parameters are usedto display results to the concurrentprogram executing the SQL*Loader.They can be returned to the caller(via e-mail) or review in the eventan error occurs. One important noteabout the listing above, all o theoutput les that are generated ater

    executing SQL*Loader are denoted

    by the concurrent request ID ol-lowed by the letter h. This signiesthat the le is related to SQL*Loader

    header results or the given Concur-rent Request ID. I a problem occursduring the data load, a bad le isgenerated. I that le exists, an errormessage e-mail is sent to the callerand the concurrent program is termi-nated in error.

    The lines SQL*Loader process isvery similar in most respects. Themajor dierence is the control lebeing executed along with the nameso the potential les that are gener-

    ated rom executing SQL*Loader.

    All les generated are denoted by tconcurrent request ID plus the letl representing line inormation.

    Validations and Loadinginto the Open InterfaceTables

    The next step in the interace isdetermine i there are any problemwith the data and, i there are nonloading the data into the PayabOpen Interace Tables. This is accomplished by executing a SQL*Plus sesion embedded in the UNIX shprogram, which in turn calls a PSQL script. The core o the co

    is compiled in a custom packa

    /***********************************//*** Set SQL*Loader Parameters ***//***********************************/P_CTL=${DIRECTORY_SQLLDR}/empap_humvp_lines_tl.ctlP_DATA=${DIRECTORY_DATA}/${FILENAME_BASE}${BATCH_NUMBER}.ctlP_BAD=${DIRECTORY_BAD}/${REQUESTID}l.badP_LOG=${DIRECTORY_BAD}/${REQUESTID}l.logP_DSC=${DIRECTORY_BAD}/${REQUESTID}l.dsc

    /***************************************//*** Display SQL*Loader Parameters ***/

    /***************************************/echo Control le : ${P_CTL}echo Log le : ${P_LOG}echo Data le : ${P_DATA}echo Bad le : ${P_BAD}echo Discard le : ${P_DSC}

    /************************************//*** Execute SQL*Loader Session ***//************************************/sqlldr ${USERPASS} control=${P_CTL} data=${P_DATA} bad=${P_BAD} log=${P_LOG} discard=${P_DSC}

    /******************************************//*** Determine if there were problems ***/

    /******************************************/ls ${P_BAD}if [ $? -ne 0 ];then

    echo Data le loaded successfully into table empap_humvp_lines_tl.else

    echo ERROR: Problems occurred during data load into table empap_humvp_lines_tl.(cat ${P_BAD})|mailx -s EMPAP: Invoice Upload Interface, Error with Concurrent

    Request ${REQUESTID} ${EMAILADDR1}exit 3

    Figure 14: UNIX Code for Lines Control File

    4On Financials - Payables

  • 7/31/2019 Batch Invoice Uploads Oracle Payables Ellis

    12/19

    ORAtips

    ORAtipsJournal

    January2006

    VolumeIIIssue1

    ORAtips.com ORAtips 2006 Klee Associates

    which is executed rom the PL/SQLprogram. The package validates thedata, including the translation o the

    corporate COA combination into thespin-o COA combination, previous-ly discussed. Figure 15 demonstrateshow a PL/SQL program is executedrom within a UNIX shell program.

    The UNIX script not only exe-cutes the PL/SQL program, but alsochecks the status as to the success o

    data validation, loading the data intothe Payables Open Interace tables,and the execution o Payables OpenInterace Import. I all o these eventswere successul, UNIX sends a suc-cess e-mail to the caller, reporting

    the success along with the request or the concurrent request the calsubmitted plus the request ID or t

    spawned concurrent request execued within PL/SQL code or PayabOpen Interace Import. Simply putsuccessul run o the Invoice UploInterace will produce two concurent requests: one or the intera

    P_PROGRAM=${EMPCUST_TOP}/sql/empap_humvp_import.sql

    /********************************/

    /*** Execute PL/SQL Program ***/

    /********************************/

    sqlplus -s ${USERPASS} @${P_PROGRAM} ${USERNAME} ${ORGID} ${LOGINID}

    ${BATCH_NUMBER} ${RESPID} ${RESPAPPLID} ${SECGRPID}ret_code=$?

    /*********************************************************/

    /*** Send Error Message if PL/SQL Program terminated ***/

    /*** in error. ***/

    /*********************************************************/

    if test ${ret_code} -eq 1

    then

    (echo Exception error has occurred with request ${REQUESTID}, program EMPAP:

    Invoice Upload Interface.)|mailx -s EMPAP: Invoice Upload; Error, Request ID ${REQUESTID}

    ${EMAILADDR1}

    exit 4

    /*********************************************************/

    /*** Send Error Message if there was a problem ***/

    /*** in loading the data to the Payables Open ***/

    /*** Interface tables. ***/

    /*********************************************************/

    elif test ${ret_code} -eq 2

    then

    (echo Problem with loading data into Payables Open Interface tables. Please readoutput for request ${REQUESTID}, program EMPAP: Invoice Upload Interface.)|mailx -sEMPAP: Invoice Upload; Error, Request ID ${REQUESTID} ${EMAILADDR1}

    exit 5

    /*********************************************************//*** Send Error Message if there was a problem in ***/

    /*** executing Payable Open Interface Import. ***/

    /*********************************************************/

    elif test ${ret_code} -eq 3

    then

    (echo Unable to submit Payables Open Interface Import from request ${REQUESTID},program EMPAP: Invoice Upload Interface.)|mailx -s EMPAP: Invoice Upload; Error, Request ID

    Figure 15: Executing PL/SQL Program - continued on next page

    4On Financials - Payables

  • 7/31/2019 Batch Invoice Uploads Oracle Payables Ellis

    13/19

    ORAtips

    ORAtipsJournal

    January2006

    VolumeIIIssue1

    ORAtips.com ORAtips 2006 Klee Associates

    and another or the Payable OpenInterace Import, a child process othe interace.

    So ar I have only shown the exe-cution o a concurrent program romwithin a UNIX shell program anddiscussed what general tasks areperormed. Let us now look at thetasks more in-depth. The process-ing o data is too broad in scope todiscuss in this article. Rather, I willlist some highlights. Here are some othe validations, all perormed withina PL/SQL package compiled on thedatabase:

    Asset processing

    Validation o invoice numberbased on vendor

    Validation o vendor and site

    Determine i PO # (i provided)exists

    Validation o Humana COA com-bination

    Investigate accrued state tax, iprovided

    Investigate accrued county taxprovided

    Investigate accrued local tax,

    provided

    Validation o payment tername

    Validation o invoice receivdate

    Validation o pay alone fvalue

    Validation o special handle Fl

    ${REQUESTID} ${EMAILADDR1}

    exit 6

    /*********************************************************//*** Send Error Message if there was a problem in ***/

    /*** there was a data issue discovered during the ***/

    /*** execution of Payables Open Interface Import. ***/

    /*********************************************************/

    elif test ${ret_code} -eq 4

    then

    (echo Problem with Payables Open Interface Import, program EMPAP: Invoice UploadInterface.)|mailx -s EMPAP: Invoice Upload; Error, Request ID ${REQUESTID}${EMAILADDR1}

    exit 7

    /*********************************************************/

    /*** Send Success Message if data validation was ***//*** met and Payables Open Interface Import ***/

    /*** completed successfully. ***/

    /*********************************************************/

    else

    REQUESTID02= echo set heading off

    set echo off

    select request_id

    from empcustom.empap_humvp_header_tl

    where batch_number = ${BATCH_NUMBER} and rownum = 1; | sqlplus -s

    ${USERPASS}`

    REQUESTID02= echo ${REQUESTID02} | sed s;^ ;;g`

    (echo Payables Open Interface Import has been executed, request ${REQUESTID02},program EMPAP: Invoice Upload Interface, request ${REQUESTID}.)|mailx -s EMPAP: InvoiceUpload; Completed, Request ID ${REQUESTID} ${EMAILADDR1}

    Figure 15: Executing PL/SQL Program - continued from previous page

    4On Financials - Payables

  • 7/31/2019 Batch Invoice Uploads Oracle Payables Ellis

    14/19

    ORAtips

    ORAtipsJournal

    January2006

    VolumeIIIssue1

    ORAtips.com ORAtips 2006 Klee Associates

    Determine i payment method hasbeen set up or vendor or site

    Asset location validation, iinvoice is or an asset

    Asset major/minor category vali-dation, i invoice is or an asset

    Asset tag # validation, i invoiceis or an asset

    Asset expense account validation,i invoice is or an asset

    Determine i period is either open

    or uture

    Determine i the line count isconsistent with the control count

    Determine i the line amountis consistent with the controlamount

    Likewise, there are several tasksthat must be perormed beore add-ing an invoice to the Open Interace

    tables. Invoices (not the Distribu-tions) are added to a table called AP_

    INVOICES_INTERFACE. The datasetup task required beore recordsare added to this table, are the

    ollowing:

    Retrieval o the respective vendorID

    Retrieval o the respective vendorsite ID

    Retrieval o the respective paygroup Code

    Generation o a new invoice ID

    Retrieval o the terms ID

    Retrieval o the payment methodor either the vendor or site

    For each invoice there must be atleast one distribution added to theOpen Interace Tables. Invoice Dis-tributions are added to a table calledAP_INVOICE_LINES_INTERFACE.According to our business design, adistribution amount has to be entered

    into the Excel template. That valuewill be used alone or one distribu-

    tion. The ollowing is required beoadding a distribution to the OpInterace Table:

    Translate the Humana COcombination to Emphesys COcombination

    Generate a new invoice line ID

    Determine the real line (distribtion) count

    A special note was made previouabout the end users wanting to retatheir original method or accounti

    (the Humana COA combinationThis is the point where we take toriginal method o accounting atranslate to the accounting methsetup or Oracle Applications (Empesys COA combination).

    The nal step is the actual exection o the concurrent program Paables Open Interace Import. Figu16 gives a sample o the PL/SQcode that accomplishes this task.

    4On Financials - Payables

    /*********************************//*** Dene Return Parameter ***//*********************************/variable ret_val number

    /*********************************//*** Dene Input Parameters ***//*********************************/dene in_user_name = &1dene in_org_id = &2dene in_login_id = &3

    dene in_batch_num = &4dene in_resp_id = &5dene in_resp_appl_id = &6dene in_sec_grp_id = &7

    /**********************************//*** Dene Program Variables ***//**********************************/declare

    v_retcode number;v_user_id apps.fnd_user.user_id%type;v_login_id number;

    Figure 16: Payables Open Interface Execution - Continued on next page

  • 7/31/2019 Batch Invoice Uploads Oracle Payables Ellis

    15/19

    ORAtips

    ORAtipsJournal

    January2006

    VolumeIIIssue1

    ORAtips.com ORAtips 2006 Klee Associates

    4On Financials - Payables

    v_batch_num empcustom.empap_humvp_header_tl.batch_number%type;v_user_name apps.fnd_user.user_name%type;v_org_id ap.ap_invoices_interface.org_id%type;

    v_req_id number;v_import boolean;v_period empcustom.empap_humvp_header_tl.accounting_period%type;

    begin:ret_val := 0;

    /*******************************************************//*** Store Input Parameters into Program Variables ***//*******************************************************/

    v_user_name := &in_user_name;v_org_id := &in_org_id;v_login_id := &in_login_id;v_batch_num := &in_batch_num;

    v_resp_id := &in_resp_id;v_resp_appl_id := &in_resp_appl_id;v_sec_grp_id := &in_sec_grp_id;

    /*********************************//*** Perform Data Validation ***//*********************************/

    empcustom.empap_humvp_pk.process_excel_transactions_pr (v_user_id,v_login_id,v_org_id,v_batch_num,v_resp_name,v_import

    );

    /************************************************//*** Execute Payables Open Interface Import ***//*** data passes validation. ***//************************************************/

    if v_import = true thenv_period := empcustom.empap_humvp_pk.get_period_fn(v_batch_num);v_req_id := fnd_request.submit_request (

    SQLAP,APXIIMPT,Payables Open Interface Import,null,false,

    EMPAP_HUMVP,v_batch_num,v_batch_num,null,null,to_date(01-||v_period, DD-MON-YY),Y,N,N,N,1000,

    Figure 16: Payables Open Interface Execution - Continued on next page

  • 7/31/2019 Batch Invoice Uploads Oracle Payables Ellis

    16/19

    ORAtips

    ORAtipsJournal

    January2006

    VolumeIIIssue1

    ORAtips.com ORAtips 2006 Klee Associates

    This PL/SQL script is slightly busy.

    First, the input parameters (romthe UNIX shell script) are denedalong with a return parameter thatindicates the status or executingthe PL/SQL script. All parametersare assigned to program variables.Validation is perormed by a call toa custom package procedure: emp-custom.empap_humvp_pk.process_excel_transactions_pr.

    I the validation process has anyerrors, the return status indicator is

    set and returned to the UNIX shell

    program where, in turn, the concur-rent program will be terminated inerror. However, i all validation wassuccessul, Payables Open InteraceImport is executed. First, the periodor the batch is retrieved via a call tothe custom package unction: emp-custom.empap_humvp_pk.get_peri-od_n.

    Next, Payables Open InteraceImport is executed using the Oracleprovided utility nd_request.submit_

    request. I a request ID other th

    0 is returned, the concurrent prgram was submitted successul. Tprogram, in turn, records the chrequest ID or reporting purposes.

    Lets take a closer look at the excution o Payables Open InteraImport. A normal way o executithis job rom Oracle Applicationsdemonstrated in Figure 17.

    You may notice that the source Figure 17 diers rom that in t

    4On Financials - Payables

    Figure 16: Payables Open Interface Execution - continued from previous pages

    v_user_id,v_login_id

    );

    /************************************************//*** If the Request ID is 0, then there was ***//*** a problem in submitting the request. ***//************************************************/

    if v_req_id = 0 thendbms_output.put_line (

    Unable to submit Payables Open Interface Import.);:ret_val := 3;

    /******************************************************//*** Else, the request was submitted successfully ***//*** so record the Request ID for reporting. ***/

    /******************************************************/else

    dbms_output.put_line (Update batch for request id...

    );update empcustom.empap_humvp_header_tlset request_id = v_req_idwhere batch_number = v_batch_num;:ret_val := 0;

    end if;

    /*******************************************/

    /*** Send back Validation Error Status ***//*******************************************/

    else:ret_val := 2;

    end if;end;/exit :ret_val;

  • 7/31/2019 Batch Invoice Uploads Oracle Payables Ellis

    17/19

    ORAtips

    ORAtipsJournal

    January2006

    VolumeIIIssue1

    ORAtips.com ORAtips 2006 Klee Associates

    4On Financials - Payables

    source code in Figure 16. The sourcein Figure 16 is listed as EMPAP_HUMVP, where in Figure 17, it is

    Humana Upload. The reason isthat the program in Oracle Applica-tions accepts the user-riendly reer-ence or meaning o the source. Thecode is used with nd_request.sub-mit_request. Since this is an inter-ace, the source diers rom thosethat are standard with Oracle Appli-cations. Hence, the source must beset up. The source or loading invoic-es outside o Oracle Payables (suchas through SQL*Loader) must be setup. This is accomplished by using the

    Oracle Payables Lookups window inOracle Applications. Figure 18 dem-onstrates the source setup or thisinterace.

    View of the Final ProductWe have nally arrived at the nal

    product o the interace. This is theeasy part: demonstrating the execu-tion o the interace. Depending onthe responsibility, go into OracleApplications and submit a concur-

    rent request. In this case, our requestwill be a concurrent program calledEMPAP: Invoice Interace Upload.It requires only one parameter romthe caller: the batch number. Provid-ed that you have populated the Exceltemplate and saved it as a comma-delimited le with proper namingconvention, you will have a successulrun o uploading an invoice batch toOracle Payables. Figure 19 demon-strates submitting EMPAP: InvoiceInterace Upload.

    Figure 17: Payable Open Interface Import

    Figure 18: Oracle Payables Lookups Window

  • 7/31/2019 Batch Invoice Uploads Oracle Payables Ellis

    18/19

    ORAtips

    ORAtipsJournal

    January2006

    VolumeIIIssue1

    ORAtips.com ORAtips 2006 Klee Associates

    ConclusionAs stated at the beginning, this is

    probably the busiest interace thathas been deployed at Humana as

    part o Finance implementation oOracle Payables. The interace hasbeen a great success in processing.Given its power and perormance,our associates are constantly review-ing the interace or enhancements.Stated briefy, it has been adapted toincorporate the process o mass addi-tions via automation. Additionally,Humana incorporated the processo doing invoices or temporary ven-dors; or better stated, vendors that areinvoiced only once. This incorporates

    the creation o vendors and sites priorto the creation o the invoices; a com-plicated process, yet extremely pow-erul tool. Also, enhancements havebeen provided or PO matching. Theenhancements continue to this day.Given its success, I believe it providesother company benets as well.

    Figure 19: EMPAP: Invoice Upload Interface

    Kevin Ellis,Humana Kevin hasserved as Technology / Applica-tions Engineer or Humana at theirheadquarters in Louisville, KY since

    June 2000. His primary responsibil-ity is to provide on-going supporto Humanas Finance ERP (OracleApplications 11.5.9). Additionally,he serves as the turn release man-ager or all enhancements releasedto the QA/Production environments.Kevin shares direct technical supportwith his sta or General Ledger,Payables, Fixed Assets, Purchas-ing, and Cash Management modulesand writes SQL scripts or Discov-erer workbooks, custom library, and

    orms. Additionally, Kevin (adjunctproessor) teaches a graduate coursein database theory at BellarmineUniversity (a private Catholic insti-tution located in Louisville, KY).Kevin also teaches computer coursesat Jeerson Community & TechnicalCollege. Kevin may be contacted [email protected].

    4On Financials - Payables

  • 7/31/2019 Batch Invoice Uploads Oracle Payables Ellis

    19/19

    ORAtips

    ORAtipsJournal

    January2006

    VolumeIIIssue1 The inormation on our website and in our publications is the copyrighted work o Klee Associates, Inc. and is owned by Klee Associates, Inc. NO WARRANTY: T

    documentation is delivered as is, and Klee Associates, Inc. makes no warranty as to its accuracy or use. Any use o this documentation is at the risk o the user. Altho

    we make every good aith eort to ensure accuracy, this document may include technical or other inaccuracies or typographical errors. Klee Associates, Inc. reserthe right to make changes without prior notice. NO AFFILIATION: Klee Associates, Inc. and this publication are not afliated with or endorsed by Oracle CorporatOracle is a registered trademark o Oracle Corporation and/or its afliates. Klee Associates, Inc. is a member o the Oracle Partner Network

    Journal

    This article was originally published by Klee Associates, Inc., publishers of JDEtips and SAPtips.For training, consulting, and articles on JD Edwards or SAP, please visit our websites:www.JDEtips.com and www.SAPtips.com.