How to send a concurrent request output as an email notification in 11.5.pdf

download How to send a concurrent request output as an email notification in 11.5.pdf

of 16

description

How to send a concurrent request output as an email notification in 11.5.pdf

Transcript of How to send a concurrent request output as an email notification in 11.5.pdf

  • Setup For Concurrent Request output sending as Email Notification

    Page 1 of 16

    Created by: Kannan Mahalingam, Oracle Apps Technical Consultant Chain-sys India Pvt. Ltd.

    Objective The purpose of the white paper is to send the output of a concurrent request as an email notification which not available in 11.5.8 version normally. Here we want to send a mail notification which contains collective informations from various modules of the past week. Through which business users will have a gist of information about all the necessary data. The white paper will be useful for the starters to get an idea about the steps to follow to map the concurrent request output to the email notification. Here we want to know collective details of total sales, total payables, and total receipts of the past week. So that for the reporting purpose and for collection purpose the next week tasks will be easy. Step 1) Defining the E-mail id for the notified users In order to send the attachment to the notified users, first we need to define the e-mail id of the users. This is to be done in Inventory Responsibility as shown in the below mentioned screen shot. Responsibility: SKG India Local Inventory ==> Setup ==> Lookups ==> Query on Type SONA THROUGHPUT EMAIL USERS

    Code ==> User Name Meaning ==> Email Address Description ==> Department Tag ==> CC / TO / BCC (Upper or Lower)

  • Setup For Concurrent Request output sending as Email Notification

    Page 2 of 16

    Created by: Kannan Mahalingam, Oracle Apps Technical Consultant Chain-sys India Pvt. Ltd.

    Step 2) Define Printer Here we are to copy the concurrent request output file from report directory to \usr\tmp Directory. So we would create a printer named COPY and printer type as EPSON.

    Here we have to create a printer driver named COPYTEST

    And the argument is cp $PROFILES$.FILENAME /usr/tmp

  • Setup For Concurrent Request output sending as Email Notification

    Page 3 of 16

    Created by: Kannan Mahalingam, Oracle Apps Technical Consultant Chain-sys India Pvt. Ltd.

    Here we are adding the paper size with COPYTEST driver.

  • Setup For Concurrent Request output sending as Email Notification

    Page 4 of 16

    Created by: Kannan Mahalingam, Oracle Apps Technical Consultant Chain-sys India Pvt. Ltd.

    In the following picture extract the report RDF we add the following script in after report trigger

    In the following we are calling the procedure sona_utilities.throughput_email_concurrent FUNCTION afterreport RETURN BOOLEAN IS l_copies NUMBER; l_printer VARCHAR2 (30); BEGIN SELECT number_of_copies, printer INTO l_copies, l_printer FROM fnd_concurrent_requests WHERE request_id = :p_conc_request_id; IF l_copies = 1 AND l_printer = 'COPY' THEN BEGIN sona_utilities.throughput_email_concurrent (:p_conc_request_id, :p_from_date, :p_to_date, :p_segment2 ); SRW.MESSAGE ('1', 'Email Concurrent Success'); EXCEPTION WHEN OTHERS THEN SRW.MESSAGE ('1', 'Email Concurrent Failed'); END; ELSE SRW.MESSAGE ('1','Please select Printer is "COPY" and give number of copies = 1'); END IF; RETURN (TRUE); END;

  • Setup For Concurrent Request output sending as Email Notification

    Page 5 of 16

    Created by: Kannan Mahalingam, Oracle Apps Technical Consultant Chain-sys India Pvt. Ltd.

    sona_utilities.throughput_email_concurrent The following is script of the procedure sona_utilities.throughput_email_concurrent PROCEDURE THROUGHPUT_EMAIL_CONCURRENT ( p_request_id IN VARCHAR2, p_from_date IN DATE, p_to_date IN DATE, p_company IN VARCHAR2 ) IS v_request_id NUMBER; BEGIN fnd_global.apps_initialize (6871, 50095, 401); v_request_id := fnd_request.submit_request (application => 'INV', --Application Name program => 'SONATPEMAIL', --Short Name description => NULL, --Description start_time => TO_CHAR(SYSDATE + 2 / 1440,'dd-mon-yy hh24:mi:ss'), sub_request => FALSE, argument1 => p_request_id, --Argument argument2 => '[email protected]', argument3 => p_from_date, argument4 => p_to_date, argument5 => p_company ); COMMIT; IF NVL (v_request_id, 0) = 0 THEN fnd_file.put_line (fnd_file.LOG, 'Email Concurrent Failed.'); ELSE fnd_file.put_line (fnd_file.LOG, 'Email concurrent running successfully, Req. ID:' || p_request_id ); END IF; END; This procedure launches the following concurrent.

  • Setup For Concurrent Request output sending as Email Notification

    Page 6 of 16

    Created by: Kannan Mahalingam, Oracle Apps Technical Consultant Chain-sys India Pvt. Ltd.

    Create Parameters (100 Characters) Concurrent Request Id From Address From Date To Date Company

  • Setup For Concurrent Request output sending as Email Notification

    Page 7 of 16

    Created by: Kannan Mahalingam, Oracle Apps Technical Consultant Chain-sys India Pvt. Ltd.

    In the concurrent request we are attaching an executable file. So that it will call the procedure. The following is the procedure which will create the email notification with attachment sona_utilities.sona_throughput_report_email PROCEDURE SONA_THROUGHPUT_REPORT_EMAIL ( errbuf OUT VARCHAR2, retcode OUT VARCHAR2, p_request_id IN VARCHAR2, p_from IN VARCHAR2 DEFAULT '[email protected]', p_from_date IN DATE, p_to_date IN DATE, p_company IN VARCHAR2 ) IS ls_email_body LONG := NULL; v_from VARCHAR2 (80) := NULL; v_recipients LONG := NULL; v_cc LONG := NULL; v_bcc LONG := NULL; v_subject VARCHAR2 (200) := NULL; v_mail_host VARCHAR2 (30) := '10.1.4.35'; v_mail_conn UTL_SMTP.connection; crlf VARCHAR2 (2) := CHR (13) || CHR (10); ll_count NUMBER; filename1 VARCHAR2 (300); v_directory_name VARCHAR2 (100); v_file_name VARCHAR2 (300); v_line VARCHAR2 (1000); mesg VARCHAR2 (32767); v_slash_pos NUMBER; v_file_handle UTL_FILE.file_type; invalid_path EXCEPTION; CURSOR c1 IS SELECT lookup_code, meaning, description, tag, start_date_active, end_date_active, enabled_flag, lookup_type FROM fnd_lookup_values_vl

  • Setup For Concurrent Request output sending as Email Notification

    Page 8 of 16

    Created by: Kannan Mahalingam, Oracle Apps Technical Consultant Chain-sys India Pvt. Ltd.

    WHERE ( NVL ('', territory_code) = territory_code OR territory_code IS NULL ) AND (lookup_type = 'SONA THROUGHPUT EMAIL USERS') AND (view_application_id = 700) AND (security_group_id = 0) AND (end_date_active > SYSDATE OR end_date_active IS NULL) ORDER BY lookup_code; BEGIN v_from := p_from; v_subject := p_company || ' - Sona Throughput Report - All Org for the period from ' || TO_CHAR (p_from_date, 'DD-MON-YYYY') || ' to ' || TO_CHAR (p_to_date, 'DD-MON-YYYY'); fnd_global.apps_initialize (6871, 50095, 401); SELECT outfile_name INTO filename1 FROM fnd_concurrent_requests WHERE request_id = p_request_id; v_mail_conn := UTL_SMTP.open_connection (v_mail_host, 26); UTL_SMTP.helo (v_mail_conn, v_mail_host); UTL_SMTP.mail (v_mail_conn, v_from); FOR email_user IN c1 LOOP IF UPPER (email_user.tag) = 'TO' THEN UTL_SMTP.rcpt (v_mail_conn, email_user.meaning); IF (v_recipients IS NULL) THEN v_recipients := 'To: ' || email_user.meaning; ELSE v_recipients := v_recipients || ', ' || email_user.meaning; END IF; ELSIF UPPER (email_user.tag) = 'CC' THEN UTL_SMTP.rcpt (v_mail_conn, email_user.meaning); IF (v_cc IS NULL) THEN v_cc := 'Cc: ' || email_user.meaning; ELSE v_cc := v_cc || ', ' || email_user.meaning; END IF; ELSIF UPPER (email_user.tag) = 'BCC' THEN UTL_SMTP.rcpt (v_mail_conn, email_user.meaning); IF (v_bcc IS NULL) THEN v_bcc := 'Bcc: ' || email_user.meaning; ELSE v_bcc := v_bcc || ', ' || email_user.meaning; END IF; END IF;

  • Setup For Concurrent Request output sending as Email Notification

    Page 9 of 16

    Created by: Kannan Mahalingam, Oracle Apps Technical Consultant Chain-sys India Pvt. Ltd.

    END LOOP; UTL_SMTP.open_data (v_mail_conn); mesg := 'Date: ' || TO_CHAR (SYSDATE, 'Dy, DD Mon YYYY hh24:mi:ss') || crlf || 'From: ' || v_from || crlf || 'Subject: ' || v_subject || crlf || 'To: ' || v_recipients || crlf || 'Cc: ' || v_cc || crlf || 'Mime-Version: 1.0' || crlf || 'Content-Type: multipart/mixed; boundary="DMW.Boundary.605592468"' || crlf || '' || crlf || '--DMW.Boundary.605592468' || crlf || 'Content-Type: text/plain; name="message.txt"; charset=US-ASCII' || crlf || 'Content-Disposition: inline; filename="message.txt"' || crlf || 'Content-Transfer-Encoding: 7bit' || crlf || crlf || 'Dear All,' || crlf || crlf || 'Please find attached "' || p_company || ' - Sona Throughput Report - All Org" for the period from ' || TO_CHAR (p_from_date, 'DD-MON-YYYY') || ' to ' || TO_CHAR (p_to_date, 'DD-MON-YYYY') || '.' || crlf || 'This is an automatically generated mail.' || crlf || 'For any clarifications, please send a mail to [email protected]' || crlf || crlf || 'Regards,' || crlf || 'Erp.Support' || crlf || crlf || crlf; UTL_SMTP.write_data (v_mail_conn, mesg); IF filename1 IS NOT NULL THEN

  • Setup For Concurrent Request output sending as Email Notification

    Page 10 of 16

    Created by: Kannan Mahalingam, Oracle Apps Technical Consultant Chain-sys India Pvt. Ltd.

    BEGIN v_slash_pos := INSTR (filename1, '/', -1); IF v_slash_pos = 0 THEN v_slash_pos := INSTR (filename1, '\', -1); END IF; v_directory_name := '/usr/tmp'; v_file_name := SUBSTR (filename1, v_slash_pos + 1); v_file_handle := UTL_FILE.fopen (v_directory_name, v_file_name, 'r'); -- generate the MIME boundary line ... mesg := crlf || '--DMW.Boundary.605592468' || crlf || 'Content-Type: application/octet-stream; name="' || v_file_name || '"' || crlf || 'Content-Disposition: attachment; filename="' || v_file_name || '"' || crlf || 'Content-Transfer-Encoding: 7bit' || crlf || crlf; UTL_SMTP.write_data (v_mail_conn, mesg); LOOP UTL_FILE.get_line (v_file_handle, v_line); mesg := v_line; UTL_SMTP.write_data (v_mail_conn, mesg); END LOOP; EXCEPTION WHEN UTL_FILE.invalid_path THEN DBMS_OUTPUT.put_line ('ERROR: INVALID_PATH ' || SQLERRM); UTL_FILE.fclose_all; WHEN UTL_FILE.invalid_mode THEN DBMS_OUTPUT.put_line ('ERROR: INVALID_MODE ' || SQLERRM); UTL_FILE.fclose_all; WHEN UTL_FILE.invalid_filehandle THEN DBMS_OUTPUT.put_line ('ERROR: INVALID_FILEHANDLE ' || SQLERRM); UTL_FILE.fclose_all; WHEN UTL_FILE.invalid_operation THEN DBMS_OUTPUT.put_line ('ERROR: INVALID_OPERATION ' || SQLERRM); UTL_FILE.fclose_all; WHEN UTL_FILE.read_error THEN DBMS_OUTPUT.put_line ('ERROR: READ_ERROR ' || SQLERRM); UTL_FILE.fclose_all; WHEN UTL_FILE.write_error THEN DBMS_OUTPUT.put_line ('ERROR: WRITE_ERROR ' || SQLERRM); UTL_FILE.fclose_all; WHEN UTL_FILE.internal_error

  • Setup For Concurrent Request output sending as Email Notification

    Page 11 of 16

    Created by: Kannan Mahalingam, Oracle Apps Technical Consultant Chain-sys India Pvt. Ltd.

    THEN DBMS_OUTPUT.put_line ('ERROR: INTERNAL_ERROR ' || SQLERRM); UTL_FILE.fclose_all; WHEN UTL_FILE.invalid_maxlinesize THEN DBMS_OUTPUT.put_line ('ERROR: INVALID_MAXLINESIZE ' || SQLERRM); UTL_FILE.fclose_all; WHEN NO_DATA_FOUND THEN DBMS_OUTPUT.put_line ('ERROR: NO_DATA_FOUND ' || SQLERRM); UTL_FILE.fclose_all; WHEN VALUE_ERROR THEN DBMS_OUTPUT.put_line ('ERROR: VALUE_ERROR ' || SQLERRM); UTL_FILE.fclose_all; WHEN OTHERS THEN DBMS_OUTPUT.put_line ('ERROR: OTHERS ' || SQLERRM); UTL_FILE.fclose_all; END; END IF; mesg := crlf || '--DMW.Boundary.605592468--' || crlf; UTL_SMTP.close_data (v_mail_conn); UTL_SMTP.quit (v_mail_conn); END;

  • Setup For Concurrent Request output sending as Email Notification

    Page 12 of 16

    Created by: Kannan Mahalingam, Oracle Apps Technical Consultant Chain-sys India Pvt. Ltd.

    Step 3.(a) Run Concurrent Request Sona Throughput Report - All Org The concurrent request Sona Throughput Report All Org is to be run from Inventory responsibility

    Here user has to select the printer which is mandatory.

  • Setup For Concurrent Request output sending as Email Notification

    Page 13 of 16

    Created by: Kannan Mahalingam, Oracle Apps Technical Consultant Chain-sys India Pvt. Ltd.

    Step 2. (b) Next, mandatory, click Options Button and select Printer COPY from the LOV and input the number of copy to 1 as shown in the screen shot below. This will enable the output file to be copied from REPORT_DIR to UTL_FILE_DIR. This step is required if email notification to users is to be sent. Incase email notification is not required, then selection of printer is not necessary.

    User has to select the printer as COPY and the copies as 1.

  • Setup For Concurrent Request output sending as Email Notification

    Page 14 of 16

    Created by: Kannan Mahalingam, Oracle Apps Technical Consultant Chain-sys India Pvt. Ltd.

    Step3 Then we have to submit the concurrent request. Once Sona Throughput Report - All Org Concurrent is completed normal, then automatically. Sona Throughput Report - All Org Email Notification concurrent will run after 2 minutes. This is shown in the following screen shot.

    Once the above concurrent is completed, then mail would be sent to designated users with Sona Throughput Report - All Org Report Output as an attachment as shown in the following screen shot.

    Finally, the concurrent Sona Throughput Report Schedule Concurrent needs to be scheduled daily in order to get the output of the reports as per the following table:

    Once the above concurrent is completed This concurrent will be spawned

  • Setup For Concurrent Request output sending as Email Notification

    Page 15 of 16

    Created by: Kannan Mahalingam, Oracle Apps Technical Consultant Chain-sys India Pvt. Ltd.

    From Date To Date Concurrent request fire date 01st day of the month 07th day of the month 09th day of every month 08th day of the month 15th day of the month 17th day of every month 16th day of the month 23rd day of the month 25th day of every month 24th day of the month Last day of the month 02nd day of the following month

  • Setup For Concurrent Request output sending as Email Notification

    Page 16 of 16

    Created by: Kannan Mahalingam, Oracle Apps Technical Consultant Chain-sys India Pvt. Ltd.

    sona_utilities.throughput_schedule_concurrent PROCEDURE THROUGHPUT_SCHEDULE_CONCURRENT ( errbuf OUT VARCHAR2, retcode OUT VARCHAR2, p_org_id IN VARCHAR2, p_organization_id IN VARCHAR2, p_company IN VARCHAR2, p_set_of_books_id IN VARCHAR2 ) IS v_request_id NUMBER; l_print_option BOOLEAN; l_from_date VARCHAR2 (25); l_to_date VARCHAR2 (25); l_day VARCHAR2 (25); BEGIN SELECT TO_CHAR (SYSDATE, 'DAY'), TO_CHAR ((TRUNC (SYSDATE) - 9), 'YYYY/MM/DD HH24:MI:SS'), TO_CHAR ((TRUNC (SYSDATE) - 4), 'YYYY/MM/DD HH24:MI:SS') INTO l_day, l_from_date, l_to_date FROM DUAL; IF l_day = 'WEDNESDAY' THEN fnd_global.apps_initialize (6871, 50095, 401); l_print_option := fnd_request.set_print_options (printer => 'COPY', style => 'BACS1', copies => 1, save_output => TRUE, print_together => 'N' ); IF l_print_option = TRUE THEN v_request_id := fnd_request.submit_request (application => 'INV', --Application_Name program => 'SONATHRCSKG', --Short Name description => NULL, --Description start_time => TO_CHAR(SYSDATE,'dd-mon-yy hh24:mi:ss'), sub_request => FALSE, argument1 => p_org_id, --Argument argument2 => p_organization_id, argument3 => p_company, argument4 => p_set_of_books_id, argument5 => l_from_date, argument6 => l_to_date ); COMMIT; IF NVL (v_request_id, 0) = 0 THEN fnd_file.put_line(fnd_file.LOG, 'Schedule Concurrent Failed.'); ELSE fnd_file.put_line(fnd_file.LOG,'Schedule Concurrent running successfully'); END IF; ELSE fnd_file.put_line (fnd_file.LOG, 'Concurrent Print Option Failed.'); END IF; END IF; END;