Home » Applications » Oracle Fusion Apps & E-Business Suite » unable to get request id (oracle 10g)
unable to get request id [message #503854] Wed, 20 April 2011 02:16 Go to next message
rahul_dorlikar
Messages: 26
Registered: June 2010
Location: PUNE
Junior Member
In this program i am submiting a request and sending mail
log file (.req file) as an attachment when the submitted
request goes into warning or error.but when program goes
in error fnd_request.submit_request() returns the
value zero or less than zero because of this i am unable
to get file name ('l' ||Request_id|| '.req').
please let me know how to get request_id
when program goes in error or warning

code:

CREATE OR REPLACE PACKAGE BODY APPS.xx_import_prog_journal
AS
   PROCEDURE submit_request(
      errbuf             OUT   VARCHAR2,
      retcode            OUT   VARCHAR2,
      Data_Access_Set_ID       number,
      Source1                   VARCHAR2,
      Ledger                  number,
      Grp_ID                   number,
      Post_Errors_to_Suspense  varchar2,
      Create_Summary_Journal   varchar2,
      Import_Des_Flexfields       varchar2


)
    
   IS
      l_senderemail     VARCHAR2 (2000) := 'ankush.deshmane@techxis.com';
      l_request_id      NUMBER;
      errmsg            VARCHAR2 (1000);
      req_id            NUMBER;
      phase             VARCHAR2 (200);
      status            VARCHAR2 (200);
      dphase            VARCHAR2 (200);
      dstatus           VARCHAR2 (200);
      MESSAGE           VARCHAR2 (200);
      wait_stat         BOOLEAN;
      l_file_name       VARCHAR2 (200);
      l_file_path       VARCHAR2 (2000);
      crlf              VARCHAR2 (4)    := CHR (13) || CHR (10);
      v_set_layout_option  BOOLEAN;
       dir_name         varchar2(100);
       v_req_id         number;
      directory_path    VARCHAR2 (2000);
      lv_subject        VARCHAR2 (100);
      lv_msg            VARCHAR2 (700);
      lv_msghdr         VARCHAR2 (100);
      lv_pdf_filename   VARCHAR2 (200);
   BEGIN

    apps.fnd_global.apps_initialize
                               (user_id           => apps.fnd_global.user_id,
                                 resp_id           =>apps.fnd_global.resp_id,
                                resp_appl_id      => apps.fnd_global.resp_appl_id
                               );
                                
                           
                                                   
          
             l_request_id :=
            apps.fnd_request.submit_request
                                  ( 'SQLGL',
                                    'GLLEZLSRS', 
                                     NULL,
                                     NULL,
                                     FALSE,                              
                                     Data_Access_Set_ID,
                                     Source1,
                                     Ledger    ,
                                     Grp_ID    ,
                                     Post_Errors_to_Suspense,
                                     Create_Summary_Journal,
                                     Import_Des_Flexfields
                                  );
                   COMMIT;
         wait_stat :=
               apps.fnd_concurrent.wait_for_request (l_request_id,
                                                     10,
                                                     360,
                                                     phase,
                                                     status,
                                                     dphase,
                                                     dstatus,
                                                     MESSAGE
                                                    );

    
                IF (l_request_id <= 0)
         THEN
                             
             dir_name :='XX_CREATE_ACCT_LOG';

               l_file_name := 'l' ||l_request_id|| '.req';
               lv_subject := NULL;
               lv_msg := NULL;
               lv_msghdr := NULL;
               lv_pdf_filename := NULL;
               lv_subject := 'testing mail :Request for Create Accounting not completed';
              
               lv_msg :=
                     'Please find attachement here with the Status Of Create Accounting Reciving 
                     from cost management SLA'
               ||  crlf;
               lv_msghdr := 'Dear Sir' ;
               lv_pdf_filename := l_file_name;
               send_mail (l_senderemail,
                          'ashish.fale@techxis.com',
                          lv_subject,
                          lv_msghdr,
                          lv_msg,
                          lv_pdf_filename,
                          'text/application',
                          dir_name
                         );   
             end if
  
   END submit_request;

   PROCEDURE send_mail (
      p_sender        IN   VARCHAR2,
      p_recipient     IN   VARCHAR2,
      p_subject       IN   VARCHAR2,
      p_mailbodyhdr   IN   VARCHAR2,
      p_mailbody      IN   VARCHAR2,
      p_filename      IN   VARCHAR2,
      p_filetype      IN   VARCHAR2,
      dir_name        in   VARCHAR2
     
   )
   AS
      v_msg                          VARCHAR2 (32000);
      src_file                       BFILE;
      i                              INTEGER             := 1;
      v_raw                          RAW (500);
      v_length                       INTEGER             := 0;
      v_buffer_size                  INTEGER             := 57;
      v_mailconn                     UTL_SMTP.connection;
      gc_crlf                        VARCHAR2 (4)      := CHR (13)
                                                          || CHR (10);
      gc_lf                          VARCHAR2 (4)        := CHR (10);
      crlf                           VARCHAR2 (2)      := CHR (13)
                                                          || CHR (10);
      gc_mailhost                    VARCHAR2 (255)      := '172.16.11.2';
      -- gc_maildomain                  VARCHAR2 (255)      := 'pune.com';
      msg                            VARCHAR2 (32767);
      boundary              CONSTANT VARCHAR2 (256)
                                           := '-----7D81B75CCC90D2974F7A1CBD';
      first_boundary        CONSTANT VARCHAR2 (256)
                                          := '--' || boundary || UTL_TCP.crlf;
      last_boundary         CONSTANT VARCHAR2 (256)
                                  := '--' || boundary || '--' || UTL_TCP.crlf;
-- A MIME type that denotes multi-part email (MIME) messages.
      multipart_mime_type   CONSTANT VARCHAR2 (256)
                          := 'multipart/mixed; boundary="' || boundary || '"';
   BEGIN
      DBMS_OUTPUT.ENABLE (100000);
      v_mailconn := UTL_SMTP.open_connection (gc_mailhost, 26);
      UTL_SMTP.helo (v_mailconn, gc_mailhost);
      UTL_SMTP.mail (v_mailconn, p_sender);
      UTL_SMTP.rcpt (v_mailconn, p_recipient);
      UTL_SMTP.open_data (v_mailconn);
      msg :=
            'Date: '
         || TO_CHAR (SYSDATE, 'Dy, DD Mon YYYY hh24:mi:ss')
         || crlf
         || 'From:ankush.deshmane@techxis.com '
      --   || p_sender
         || crlf
         || 'Subject: '
         || p_subject
         || crlf
         || 'To: ashish.fale@techxis.com'
        -- || p_recipient
         || crlf
         || 'MIME-Version: 3.1'
         || crlf
         ||                                          -- Use MIME mail standard
            'Content-Type: multipart/mixed;'
         || crlf
         || ' boundary="-----SECBOUND"'
         || crlf
         || crlf
         || '-------SECBOUND'
         || crlf
         || 'Content-Type: text/plain;'
         || crlf
         || 'Content-Transfer_Encoding: 7bit'
         || crlf
         || crlf
         || p_mailbodyhdr
         || crlf
         || crlf
         || p_mailbody
         || crlf
         || crlf
         || crlf
         || crlf
         ||                                                    -- Message body
            'Regards'
         || crlf
         || 'HR and Payroll Team'
         || crlf
         || crlf
         || ' Note- Please ignore the leave status and number of days.'
         || crlf
         || crlf
         || '-------SECBOUND'
         || crlf
         || 'Content-Type'
         || ': '
         || p_filetype
         || crlf
         || 'Content-Disposition: attachment; filename="'
       --  || 'Create Accounting'
        -- || '.REQ'      
         ||p_filename                                         -- p_filename
         || '"'
         || crlf
         || 'Content-Transfer-Encoding: base64'
         || crlf
         || crlf;
         
      UTL_SMTP.write_data (v_mailconn, msg);
      src_file := BFILENAME (dir_name, p_filename);
      DBMS_LOB.fileopen (src_file, DBMS_LOB.file_readonly);
      v_length := DBMS_LOB.getlength (src_file);

      WHILE i < v_length
      LOOP
         DBMS_LOB.READ (src_file, v_buffer_size, i, v_raw);
         UTL_SMTP.write_raw_data (v_mailconn,
                                  UTL_ENCODE.base64_encode (v_raw)
                                 );
         UTL_SMTP.write_data (v_mailconn, UTL_TCP.crlf);
         i := i + v_buffer_size;
      END LOOP while_loop;

      UTL_SMTP.write_data (v_mailconn, last_boundary);
      UTL_SMTP.write_data (v_mailconn, UTL_TCP.crlf);
      DBMS_LOB.fileclose (src_file);
      UTL_SMTP.close_data (v_mailconn);
      UTL_SMTP.quit (v_mailconn);
   EXCEPTION
      WHEN OTHERS
      THEN
         UTL_SMTP.quit (v_mailconn);
         DBMS_OUTPUT.put_line (SQLCODE || SQLERRM);
   --   FND_FILE.PUT_LINE (FND_FILE.LOG,'error while fetching values from CO_CODE'|| SQLERRM );
   END send_mail;
   
   END xx_import_prog_journal;
Re: unable to get request id [message #504127 is a reply to message #503854] Thu, 21 April 2011 11:08 Go to previous messageGo to next message
vamsi kasina
Messages: 2112
Registered: October 2003
Location: Cincinnati, OH
Senior Member
I'm not sure why you have the condition like 'IF (l_request_id <= 0)' to send the mail.

fnd_request.submit_request gives you a positive number when it could submit the request successfully.
I don't see any point why / how you want to send the attachment, when the request is not at all submitted (if l_request_id <= 0).

By
Vamsi
Re: unable to get request id [message #512686 is a reply to message #504127] Tue, 21 June 2011 08:51 Go to previous message
vishalk
Messages: 33
Registered: October 2010
Member

i think your "fnd_global.apps_initialize" is not work fine.
Please check it with hard coded values.
Previous Topic: Need to get logic to get unit price * quantity * rate
Next Topic: How to change operating system login id in 11i alert?
Goto Forum:
  


Current Time: Sun Nov 24 04:52:12 CST 2024