Thursday 27 November 2014

Oracle EBS Create Order API

Oracle EBS Release 12 create Order API from Order Management Responsibility sample procedure.




PROCEDURE cust_create_order (inq_id NUMBER)
   IS
      l_api_version_number           NUMBER                              := 1;
      l_return_status                VARCHAR2 (2000);
      l_msg_count                    NUMBER;
      l_msg_data                     VARCHAR2 (2000);
/*****************PARAMETERS****************************************/
      l_debug_level                  NUMBER                              := 1;
      -- OM DEBUG LEVEL (MAX 5)
      l_org                          NUMBER                            := 101;
      -- OPERATING UNIT
      l_no_orders                    NUMBER                              := 1;
      -- NO OF ORDERS
      l_user                         NUMBER                           := 1110;
      -- USER
      l_resp                         NUMBER                          := 51330;
      -- RESPONSIBLILTY
      l_appl                         NUMBER                            := 660;
                              -- ORDER MANAGEMENT
      /*************************INPUT VARIABLES FOR PROCESS_ORDER API****************************/
      l_header_rec                   oe_order_pub.header_rec_type;
      l_line_tbl                     oe_order_pub.line_tbl_type;
      l_action_request_tbl           oe_order_pub.request_tbl_type;
      l_line_adj_tbl                 oe_order_pub.line_adj_tbl_type;
      /****************************OUT VARIABLES FOR PROCESS_ORDER API**************************/
      l_header_rec_out               oe_order_pub.header_rec_type;
      l_header_val_rec_out           oe_order_pub.header_val_rec_type;
      l_header_adj_tbl_out           oe_order_pub.header_adj_tbl_type;
      l_header_adj_val_tbl_out       oe_order_pub.header_adj_val_tbl_type;
      l_header_price_att_tbl_out     oe_order_pub.header_price_att_tbl_type;
      l_header_adj_att_tbl_out       oe_order_pub.header_adj_att_tbl_type;
      l_header_adj_assoc_tbl_out     oe_order_pub.header_adj_assoc_tbl_type;
      l_header_scredit_tbl_out       oe_order_pub.header_scredit_tbl_type;
      l_header_scredit_val_tbl_out   oe_order_pub.header_scredit_val_tbl_type;
      l_line_tbl_out                 oe_order_pub.line_tbl_type;
      l_line_val_tbl_out             oe_order_pub.line_val_tbl_type;
      l_line_adj_tbl_out             oe_order_pub.line_adj_tbl_type;
      l_line_adj_val_tbl_out         oe_order_pub.line_adj_val_tbl_type;
      l_line_price_att_tbl_out       oe_order_pub.line_price_att_tbl_type;
      l_line_adj_att_tbl_out         oe_order_pub.line_adj_att_tbl_type;
      l_line_adj_assoc_tbl_out       oe_order_pub.line_adj_assoc_tbl_type;
      l_line_scredit_tbl_out         oe_order_pub.line_scredit_tbl_type;
      l_line_scredit_val_tbl_out     oe_order_pub.line_scredit_val_tbl_type;
      l_lot_serial_tbl_out           oe_order_pub.lot_serial_tbl_type;
      l_lot_serial_val_tbl_out       oe_order_pub.lot_serial_val_tbl_type;
      l_action_request_tbl_out       oe_order_pub.request_tbl_type;
      l_msg_index                    NUMBER;
      l_data                         VARCHAR2 (2000);
      l_loop_count                   NUMBER;
      l_debug_file                   VARCHAR2 (200);
      b_return_status                VARCHAR2 (200);
      b_msg_count                    NUMBER;
      b_msg_data                     VARCHAR2 (2000);
      l_etd_date                     DATE;
      l_qty                          NUMBER;
      l_line_no                      NUMBER;
      l_line_tbl_index               NUMBER;
      order_typ                      NUMBER;
      cust_id                        NUMBER;
      poc_num                        NUMBER;
      org_id                         NUMBER;
      mfg_org_id                     NUMBER;
      pay_term_id                    NUMBER;
      from_size                      VARCHAR2 (20);
      to_size                        VARCHAR2 (20);
      header_id                      NUMBER;
      order_num                      NUMBER;
      Line_num                       NUMBER;
   BEGIN
      DBMS_APPLICATION_INFO.set_client_info (l_org);
      mo_global.set_policy_context ('S', l_org);
      mo_global.init ('ONT');

      /**************************INITIALIZE DEBUG INFO**********************************/
      IF (l_debug_level > 0)
      THEN
         l_debug_file := oe_debug_pub.set_debug_mode ('FILE');
         oe_debug_pub.initialize;
         oe_debug_pub.setdebuglevel (l_debug_level);
         oe_msg_pub.initialize;
      END IF;

      /****************************INITIALIZE ENVIRONMENT*******************************/
      fnd_global.apps_initialize (l_user, l_resp, l_appl);
                     -- pass in user_id, responsibility_id, and application_id
      /*****************INITIALIZE HEADER RECORD*************************/
      l_header_rec := oe_order_pub.g_miss_header_rec;

      /***********POPULATE REQUIRED ATTRIBUTES ************************/
      SELECT cuoi.customer_id, cuoi.inquiry_number, cuoi.org_id,
             cuoi.payment_term_id, cuoi.from_size, cuoi.to_size
        INTO cust_id, poc_num, org_id,
             pay_term_id, from_size, to_size
        FROM cust_usg_ont_inquiry cuoi
       WHERE cuoi.inquiry_id = inq_id;

      SELECT ood.organization_id
        INTO mfg_org_id
        FROM org_organization_definitions ood
       WHERE ood.operating_unit = org_id AND ood.organization_code <> 'IMO';

      SELECT hcsu.order_type_id
        INTO order_typ
        FROM hz_parties hp,
             hz_party_sites hps,
             hz_locations hl,
             hz_cust_accounts_all hca,
             hz_cust_acct_sites_all hcsa,
             hz_cust_site_uses_all hcsu
       WHERE hp.party_id = hps.party_id
         AND hps.location_id = hl.location_id
         AND hp.party_id = hca.party_id
         AND hcsa.party_site_id = hps.party_site_id
         AND hcsu.cust_acct_site_id = hcsa.cust_acct_site_id
         AND hca.cust_account_id = hcsa.cust_account_id
         AND hca.cust_account_id = cust_id
         and hcsa.ORG_ID = l_org
         AND hcsu.site_use_code = 'BILL_TO';

      l_header_rec.order_type_id := order_typ;
      l_header_rec.sold_to_org_id := cust_id;
--      l_header_rec.ship_to_org_id := 1457;
      l_header_rec.ship_from_org_id := mfg_org_id;
      l_header_rec.orig_sys_document_ref := poc_num;
      l_header_rec.payment_term_id := pay_term_id;
      l_header_rec.global_attribute6 := inq_id;
      l_header_rec.global_attribute7 := from_size;
      l_header_rec.global_attribute8 := to_size;
      l_header_rec.global_attribute9 := poc_num;
      l_header_rec.ORDER_SOURCE_ID := 1001;
      
      /**********The statement indicates to the process order API that a new header has to be created**********/
      l_header_rec.operation := oe_globals.g_opr_create;
      l_line_tbl_index := 0;

      

/**************************************CALLTO PROCESS ORDER API**********************************************/
      oe_order_pub.process_order
                    (p_api_version_number          => l_api_version_number,
                     p_header_rec                  => l_header_rec,
                     p_line_tbl                    => l_line_tbl,
                     p_action_request_tbl          => l_action_request_tbl,
                     p_line_adj_tbl                => l_line_adj_tbl
/*******************************************OUT variables****************************************************/
      ,
                     x_header_rec                  => l_header_rec_out,
                     x_header_val_rec              => l_header_val_rec_out,
                     x_header_adj_tbl              => l_header_adj_tbl_out,
                     x_header_adj_val_tbl          => l_header_adj_val_tbl_out,
                     x_header_price_att_tbl        => l_header_price_att_tbl_out,
                     x_header_adj_att_tbl          => l_header_adj_att_tbl_out,
                     x_header_adj_assoc_tbl        => l_header_adj_assoc_tbl_out,
                     x_header_scredit_tbl          => l_header_scredit_tbl_out,
                     x_header_scredit_val_tbl      => l_header_scredit_val_tbl_out,
                     x_line_tbl                    => l_line_tbl_out,
                     x_line_val_tbl                => l_line_val_tbl_out,
                     x_line_adj_tbl                => l_line_adj_tbl_out,
                     x_line_adj_val_tbl            => l_line_adj_val_tbl_out,
                     x_line_price_att_tbl          => l_line_price_att_tbl_out,
                     x_line_adj_att_tbl            => l_line_adj_att_tbl_out,
                     x_line_adj_assoc_tbl          => l_line_adj_assoc_tbl_out,
                     x_line_scredit_tbl            => l_line_scredit_tbl_out,
                     x_line_scredit_val_tbl        => l_line_scredit_val_tbl_out,
                     x_lot_serial_tbl              => l_lot_serial_tbl_out,
                     x_lot_serial_val_tbl          => l_lot_serial_val_tbl_out,
                     x_action_request_tbl          => l_action_request_tbl_out,
                     x_return_status               => l_return_status,
                     x_msg_count                   => l_msg_count,
                     x_msg_data                    => l_msg_data
                    );

   

    header_id := l_header_rec_out.header_id;
    order_num := l_header_rec_out.order_number;
    line_num := 0;
    l_header_rec.operation := oe_globals.g_opr_update;
    l_header_rec.header_id := header_id;



    FOR i IN (SELECT nvl(cope.quantity,cuoi.INQUIRY_QTY) qty, cuop.final_offer price,
                       cuoi.inquiry_number inqnum , nvl(cope.ETD, cuoi.EXPECT_SHIP_DATE ) etd
                  FROM cust_ont_poc_etd cope,
                       cust_usg_ont_inquiry cuoi,
                       cust_usg_ont_pcosting cuop
                 WHERE cope.inquiry_id = cuoi.inquiry_id
                   AND cuoi.inquiry_id = cuop.inquiry_id
                   AND cope.inquiry_id = inq_id)
      LOOP
         line_num := line_num+1;
         l_line_tbl_index := l_line_tbl_index + 1;
         l_line_tbl (l_line_tbl_index) := oe_order_pub.g_miss_line_rec;
/****************************************Line Attributes************************************************/
         l_line_tbl (l_line_tbl_index).inventory_item_id := 11927;
         l_line_tbl (l_line_tbl_index).ordered_quantity := i.qty;
         l_line_tbl (l_line_tbl_index).SCHEDULE_SHIP_DATE := i.etd ;
         l_line_tbl (l_line_tbl_index).orig_sys_document_ref := i.inqnum;
         l_line_tbl (l_line_tbl_index).user_item_description := order_num||'/'||line_num||'.1';         
         --l_line_tbl (l_line_tbl_index).attribute3 := 20;
         --l_line_tbl (l_line_tbl_index).attribute3 := 'Mohsin';
         l_line_tbl (l_line_tbl_index).unit_list_price := i.price;
         l_line_tbl (l_line_tbl_index).unit_selling_price := i.price;
         /**********************Indicates that this is a create operation for the line record********************/
         l_line_tbl (l_line_tbl_index).operation := oe_globals.g_opr_create;
         /*****************Indicates that this is an update operation for the line record****************************/

         --l_line_tbl(l_line_tbl_index).operation := OE_GLOBALS.G_OPR_UPDATE;

         /**********************Indicates that this is a delete operation for the line record*************************/

         --l_line_tbl(l_line_tbl_index).operation := OE_GLOBALS.G_OPR_DELETE;

         /************The below action request indicates to the process order that the order has to be booked*********/

         --l_action_request_tbl(1).request_type := oe_globals.g_book_order;
         l_action_request_tbl (l_line_tbl_index).entity_code :=
                                                   oe_globals.g_entity_header;
      END LOOP;
      
      oe_order_pub.process_order
                    (p_api_version_number          => l_api_version_number,
                     p_header_rec                  => l_header_rec,
                     p_line_tbl                    => l_line_tbl,
                     p_action_request_tbl          => l_action_request_tbl,
                     p_line_adj_tbl                => l_line_adj_tbl
/*******************************************OUT variables****************************************************/
      ,
                     x_header_rec                  => l_header_rec_out,
                     x_header_val_rec              => l_header_val_rec_out,
                     x_header_adj_tbl              => l_header_adj_tbl_out,
                     x_header_adj_val_tbl          => l_header_adj_val_tbl_out,
                     x_header_price_att_tbl        => l_header_price_att_tbl_out,
                     x_header_adj_att_tbl          => l_header_adj_att_tbl_out,
                     x_header_adj_assoc_tbl        => l_header_adj_assoc_tbl_out,
                     x_header_scredit_tbl          => l_header_scredit_tbl_out,
                     x_header_scredit_val_tbl      => l_header_scredit_val_tbl_out,
                     x_line_tbl                    => l_line_tbl_out,
                     x_line_val_tbl                => l_line_val_tbl_out,
                     x_line_adj_tbl                => l_line_adj_tbl_out,
                     x_line_adj_val_tbl            => l_line_adj_val_tbl_out,
                     x_line_price_att_tbl          => l_line_price_att_tbl_out,
                     x_line_adj_att_tbl            => l_line_adj_att_tbl_out,
                     x_line_adj_assoc_tbl          => l_line_adj_assoc_tbl_out,
                     x_line_scredit_tbl            => l_line_scredit_tbl_out,
                     x_line_scredit_val_tbl        => l_line_scredit_val_tbl_out,
                     x_lot_serial_tbl              => l_lot_serial_tbl_out,
                     x_lot_serial_val_tbl          => l_lot_serial_val_tbl_out,
                     x_action_request_tbl          => l_action_request_tbl_out,
                     x_return_status               => l_return_status,
                     x_msg_count                   => l_msg_count,
                     x_msg_data                    => l_msg_data
                    );
                    
      /**************************************CHECK RETURN STATUS**********************************************/
      IF l_return_status = fnd_api.g_ret_sts_success
      THEN
         DBMS_OUTPUT.put_line ('Order Processed Successfully');
         resultout := l_header_rec_out.order_number;
         COMMIT;
      ELSIF    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 ('Failed to create Order');
         resultout := 'Error ' || ':' || l_msg_data;
         ROLLBACK;
      END IF;
              

      /************************DISPLAY RETURN STATUS FLAGS***************************/
      IF (l_debug_level > 0)
      THEN
         DBMS_OUTPUT.put_line (   'process ORDER ret status IS: '
                               || l_return_status
                              );
         DBMS_OUTPUT.put_line ('process ORDER msg data IS: ' || l_msg_data);
         DBMS_OUTPUT.put_line ('process ORDER msg COUNT IS: ' || l_msg_count);
         DBMS_OUTPUT.put_line (   'header.order_number IS: '
                               || TO_CHAR (l_header_rec_out.order_number)
                              );
         /*DBMS_OUTPUT.put_line (   'adjustment.return_status IS: '
                               || l_line_adj_tbl_out (1).return_status
                              );*/
         DBMS_OUTPUT.put_line (   'header.header_id IS: '
                               || l_header_rec_out.header_id
                              );
         DBMS_OUTPUT.put_line (   'line.unit_selling_price IS: '
                               || l_line_tbl_out (l_line_tbl_index).unit_selling_price
                              );
      END IF;

/********************************DISPLAY ERROR MSGS*******************************/
      IF (l_debug_level > 0)
      THEN
         FOR i IN 1 .. l_msg_count
         LOOP
            oe_msg_pub.get (p_msg_index          => i,
                            p_encoded            => fnd_api.g_false,
                            p_data               => l_data,
                            p_msg_index_out      => l_msg_index
                           );
            DBMS_OUTPUT.put_line ('message is: ' || l_header_rec_out.header_id);
            DBMS_OUTPUT.put_line (   'message index is: '
                                  || l_header_rec_out.order_number
                                 );
         END LOOP;
      END IF;

      IF (l_debug_level > 0)
      THEN
         DBMS_OUTPUT.put_line ('Debug = ' || oe_debug_pub.g_debug);
         DBMS_OUTPUT.put_line (   'Debug Level = '
                               || TO_CHAR (oe_debug_pub.g_debug_level)
                              );
         DBMS_OUTPUT.put_line (   'Debug File = '
                               || oe_debug_pub.g_dir
                               || '/'
                               || oe_debug_pub.g_file
                              );
         DBMS_OUTPUT.put_line ('*******************************************');
         oe_debug_pub.debug_off;
      END IF;
   END cust_create_order;

Monday 24 November 2014

Work Flow Builder Tutorial for beginners

Work Flow Builder Tutorial for beginners
Learn Work Flow builder usage with step by step instructions.

Pre Requisite:
  • Work Flow Builder installed on your system.
  • A customized form where you want to implement it.
Scenario:
We start with a simple scenario, we have a module where when a document is completed should go for approval to concern department head. We have to pass the primary key to workflow and then a notification will be emailed to concerned department head and then we will update the document flag based on the primary key passed to the workflow on the selection of Approval/Reject button.


Package Used:

CREATE OR REPLACE PACKAGE APPS.cust_sample_notify
IS
       
PROCEDURE run_cust_wf (sample_id IN NUMBER);
       
PROCEDURE appr_sam ( itemtype    IN       VARCHAR2,
                              itemkey     IN       VARCHAR2,
                              actid       IN       NUMBER,
                              funcmode    IN       VARCHAR2,
                              resultout   IN OUT   VARCHAR2);
        
PROCEDURE rej_sam ( itemtype    IN       VARCHAR2,
                              itemkey     IN       VARCHAR2,
                              actid       IN       NUMBER,
                              funcmode    IN       VARCHAR2,
                              resultout   IN OUT   VARCHAR2);
    
PROCEDURE get_sample_details (
      document_id     IN              VARCHAR2,
      display_type    IN              VARCHAR2,
      document        IN OUT NOCOPY   CLOB,
      document_type   IN OUT NOCOPY   VARCHAR2
   );
    
    END cust_sample_notify;
/


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

CREATE OR REPLACE PACKAGE BODY APPS.cust_sample_notify
    IS
    
       PROCEDURE run_cust_wf (sample_id IN NUMBER)
        IS
      itemtype      VARCHAR2 (100)  := 'NEW_TYPE';
      itemkey       VARCHAR2 (100)
                                  := sample_id || '_' || poc_wf_appr_seq.NEXTVAL;
      wfprocess     VARCHAR2 (100)  := 'NEW_PROCESS';
      
      p_user_id     NUMBER;
      p_requestor   VARCHAR2 (100);
      p_resp_id     NUMBER;
      p_appl_id     NUMBER;
      p_org_id      NUMBER;
      ERROR_CODE    VARCHAR2 (100);
      error_msg     VARCHAR2 (1000);
      vSampleDetails        CLOB;
      nl            VARCHAR2 (10)     := fnd_global.NEWLINE;
      
   BEGIN
      p_user_id := 1110;--fnd_profile.VALUE ('user_id');
      p_resp_id := 21623; --fnd_profile.VALUE ('resp_id');
      p_appl_id := 660; --fnd_profile.VALUE ('resp_appl_id');
      p_org_id := 81;--fnd_profile.VALUE ('org_id');

      
       SELECT user_name
        INTO p_requestor
        FROM fnd_user
       WHERE user_id = p_user_id;

      fnd_global.apps_initialize (p_user_id, p_resp_id, p_appl_id);
      wf_engine.createprocess (itemtype      => itemtype,
                               itemkey       => itemkey,
                               process       => wfprocess
                              );
      wf_engine.SETITEMATTRTEXT ( itemtype => itemtype,
                          itemkey => itemkey,
                          aname => 'REQUESTOR',
                          avalue =>  p_requestor); 
                          
      wf_engine.SETITEMATTRNUMBER ( itemtype => itemtype,
                          itemkey => itemkey,
                          aname => 'SAMPLEID',
                          avalue =>  sample_id);                                         
      
      
      vSampleDetails := 'PLSQL:CUST_SAMPLE_NOTIFY.GET_SAMPLE_DETAILS/' || sample_id;
      
      wf_engine.SETITEMATTRTEXT ( itemtype => itemtype,
                          itemkey   => itemkey,
                          aname     => 'MSG',
                          avalue    =>  vSampleDetails);
                          
      wf_engine.startprocess (itemtype => itemtype, itemkey => itemkey);

      COMMIT;

   EXCEPTION
      WHEN OTHERS
      THEN
         ERROR_CODE := SQLCODE;
         error_msg := SQLERRM (SQLCODE);
         fnd_file.put_line (fnd_file.output, ERROR_CODE);
         fnd_file.put_line (fnd_file.output, error_msg);
   END run_cust_wf;
    
    PROCEDURE appr_sam(
        itemtype    IN       VARCHAR2,
      itemkey     IN       VARCHAR2,
      actid       IN       NUMBER,
      funcmode    IN       VARCHAR2,
      resultout   IN OUT   VARCHAR2)
    IS
    BEGIN
    
        
        
    
    
        UPDATE custusg.cust_sample_temp
        SET flag = 'Y'
        where id = wf_engine.GETITEMATTRTEXT ( itemtype => itemtype,
                                      itemkey => itemkey,
                                      aname => 'SAMPLEID'
                                      );
        
        COMMIT;
        
    EXCEPTION
      WHEN OTHERS
      THEN
--         ERROR_CODE := SQLCODE;
--         error_msg := SQLERRM (SQLCODE);
         fnd_file.put_line (fnd_file.output, SQLCODE);
         fnd_file.put_line (fnd_file.output, SQLERRM (SQLCODE));
   END ;
    
    
    
   PROCEDURE rej_sam (
            itemtype    IN       VARCHAR2,
            itemkey     IN       VARCHAR2,
            actid       IN       NUMBER,
            funcmode    IN       VARCHAR2,
            resultout   IN OUT   VARCHAR2)
    IS
    BEGIN
    
        UPDATE custusg.cust_sample_temp
        SET flag = 'N'
        where id = wf_engine.GETITEMATTRTEXT ( itemtype => itemtype,
                                      itemkey => itemkey,
                                      aname => 'SAMPLEID'
                                      );    
        
        COMMIT;
    END;
    
        
  

PROCEDURE get_sample_details (
      document_id     IN              VARCHAR2,
      display_type    IN              VARCHAR2,
      document        IN OUT NOCOPY   CLOB,
      document_type   IN OUT NOCOPY   VARCHAR2
   )
   IS
      l_body    clob;
      inq_id    NUMBER;
      nl        VARCHAR2 (1)     := fnd_global.NEWLINE;
      l_sr_no   NUMBER           := 0;
   --l_apprv      VARCHAR2 (100);
   BEGIN
      document_type := 'text/html';
      --
      l_body := nl || nl ||'<P><B><U>';
      l_body :=
            l_body
         || '<TABLE border=0 cellpadding=0 cellspacing=0 <width=100%><TR>
          <td align=LEFT valign=baseline ><font color=#336699 face="Arial, Helvetica, Geneva, sans-serif" size=2>'
         || '<u><b>'
         || 'POC Fabric Lines'
         || '</u></b>'
         || '</TD></TR></TABLE>'
         || nl;
      l_body := l_body || '</B>' 
      || nl 
      || '</P>';
      l_body :=
            l_body
         || '<table  cellspacing="2" ; cellpadding="5"; width=100%> <thead><tr>'
         || '<TH bgcolor="#d9e5ef"><font-family:Arial,Helvetica,Geneva,sans-serif; color:#000001><font size=2>'
         || 'SR No.'
         || '</TH>'
         || nl
         || '<TH bgcolor="#d9e5ef"><font-family:Arial,Helvetica,Geneva,sans-serif; color:#000001><font size=2>'
         || 'Item Description'
         || '</TH>'
         || nl
         || '<TH bgcolor="#d9e5ef"><font-family:Arial,Helvetica,Geneva,sans-serif; color:#000001><font size=2>'
         || 'UOM'
         || '</TH>'
         || nl
         || '<TH bgcolor="#d9e5ef"><font-family:Arial,Helvetica,Geneva,sans-serif; color:#000001><font size=2>'
         || 'Material Type'
         || '</TH>'
         || nl
         || '<TH bgcolor="#d9e5ef"><font-family:Arial,Helvetica,Geneva,sans-serif; color:#000001><font size=2>'
         || 'Quantity'
         || '</TH>'
         || nl
         || '<TH bgcolor="#d9e5ef"><font-family:Arial,Helvetica,Geneva,sans-serif; color:#000001><font size=2>'
         || 'Rate'
         || '</TH>'
         || nl
         || '<TH bgcolor="#d9e5ef"><font-family:Arial,Helvetica,Geneva,sans-serif; color:#000001><font size=2>'
         || 'Cost Amount'
         || '</TH>'
         || nl
         || '<TH bgcolor="#d9e5ef"><font-family:Arial,Helvetica,Geneva,sans-serif; color:#000001><font size=2>'
         || 'Amount (FCY)'
         || '</TH>'
         || nl
         || '<TH bgcolor="#d9e5ef"><font-family:Arial,Helvetica,Geneva,sans-serif; color:#000001><font size=2>'
         || 'Description / Remarks'
         || '</TH>'
         || nl
         || '</thead>
            </tr>
            <tbody>';

      FOR i IN (SELECT rawmaterial_id,measure_unit_id,remarks,quantity
                from cust_ont_sample_lines
                WHERE PERCOSTING_ID = 104
                order by percosting_id)
      LOOP
         BEGIN
            l_sr_no := l_sr_no + 1;
            l_body :=
                  l_body
               || '<tr> <td nowrap align=middle font color=#000000 face="Arial, Helvetica, Geneva, sans-serif" bgcolor="#eeeeee"><font size=2>'
               || l_sr_no
               || '</td> <td nowrap align=left font color=#000000 face="Arial, Helvetica, Geneva, sans-serif" bgcolor="#eeeeee"><font size=2>'
               || i.rawmaterial_id
               || '</td> <td nowrap align=middle font color=#000000 face="Arial, Helvetica, Geneva, sans-serif" bgcolor="#eeeeee"><font size=2>'
               || i.measure_unit_id
               || '</td> <td nowrap align=middle font color=#000000 face="Arial, Helvetica, Geneva, sans-serif" bgcolor="#eeeeee"><font size=2>'
               || i.remarks
               || '</td> <td nowrap align=middle font color=#000000 face="Arial, Helvetica, Geneva, sans-serif" bgcolor="#eeeeee"><font size=2>'
               || i.quantity
               || '</td> <td nowrap align=middle font color=#000000 face="Arial, Helvetica, Geneva, sans-serif" bgcolor="#eeeeee"><font size=2>'
               || NULL
               || '</td> <td nowrap align=middle font color=#000000 face="Arial, Helvetica, Geneva, sans-serif" bgcolor="#eeeeee"><font size=2>'
               || NULL
               || '</td> <td nowrap align=middle font color=#000000 face="Arial, Helvetica, Geneva, sans-serif" bgcolor="#eeeeee"><font size=2>'
               || NULL
               || '</td> <td nowrap align=left font color=#000000 face="Arial, Helvetica, Geneva, sans-serif" bgcolor="#eeeeee"><font size=2>'
               || i.remarks
               || '</td> </tr> </tbody> ';
         END;
      END LOOP;

      l_body := l_body || '</table>';
      document := l_body;
--
--Setting document type which is nothing but MIME type
--
      document_type := 'text/html';
   EXCEPTION
      WHEN OTHERS
      THEN
         document := '<H4>Error: ' || SQLERRM || '</H4>';
   END get_sample_details;


    
    
END  cust_sample_notify;
/





Tags: Oracle Work Flow Builder,