1 of 2
1
Email Concurrent Log files through a printer driver setup - Help ! 
Posted: 23 August 2005 10:17 AM   [ Ignore ]
Newbie
Rank
Total Posts:  5
Joined  2005-08-23

Hi ,

My requirement is to email the log file after a concurrent request is complete.
I am attempting a popular workaround I have heard of - a custom printer driver
that will use the ‘mail’ OS command instead of ‘ls’

The arguments columns in the driver setup looks like this -

mail emailID.. < $APPLCSF/log/hrmsdev1_hrmst/l`echo $PROFILES$.CONC_REQUEST_ID`.req

where my logfile name is like l23456.req

Unfortunately iam missing a finer unix syntax and the OS is unable to derive and substitute the
file name and concatenate the ‘l’ and ‘.req’ . The $APPLCSF environment variable is derived properly.

Please help if you can… thanks.

Madhu

Profile
 
 
Posted: 24 August 2005 06:45 AM   [ Ignore ]   [ # 1 ]
Newbie
Avatar
Rank
Total Posts:  7
Joined  2005-08-08

for arugments for driver use this one

uuencode $PROFILES$.FILENAME $PROFILES$.FILENAME_out|mailx -s $ $PROFILES$.FILENAME emailid

this will work , just try out

 Signature 

--------------------------------------------------
Braj Kishore Mahto
(Senior Oracle Apps DBA)
AS Watson Ltd
HONG KONG

Profile
 
 
Posted: 24 August 2005 08:48 AM   [ Ignore ]   [ # 2 ]
Newbie
Rank
Total Posts:  5
Joined  2005-08-23

Hello Braj,

Many thanks for your time.
My requirement is to mail the log file and not the outfile. The $PROFILES$FILENAME would have the
outfile name iam sure.

Any further ideas ?

Regards,

Madhu

Profile
 
 
Posted: 25 August 2005 01:14 AM   [ Ignore ]   [ # 3 ]
Newbie
Avatar
Rank
Total Posts:  7
Joined  2005-08-08

if you want just log file then use following

mailx -s “log of Request id :$PROFILES$.CONC_REQUEST_ID” valid_mailid <$APPLCSF/$APPLLOG/l$PROFILES$.CONC_REQUEST_ID.req

I have just tested it.

 Signature 

--------------------------------------------------
Braj Kishore Mahto
(Senior Oracle Apps DBA)
AS Watson Ltd
HONG KONG

Profile
 
 
Posted: 25 August 2005 09:26 AM   [ Ignore ]   [ # 4 ]
Newbie
Rank
Total Posts:  5
Joined  2005-08-23

Hello Braj,

Many thanks for your solutuion. It indeed worked.
I realised that I have overlooked something fundamental in my solution. The log file will not be fully made until the OS command returns the status.
Hence, the log file that is sent in this mail will not be complete and will not have the footer and the status of the concurrent program.
for example - during my previous attempts, as a result of my wrong syntax for the mail command, the file name derivation was not happening and
the command errored out. The same error used reflect in the log file, which means that the log file is still work in progress until the ‘ls’ or ‘mail’ is complete.

Now, I plan to write a wrapper PLSQL script and use DBMS_PIPE package to call OS command in PLSQL. the wrapper program will call my interface program using FND_REQUST.SUBMIT_REQUEST () , and use the concurrent_request_id returned by the SUBMIT_REQUEST and locate the appropriate log file and
mail it using the command you helped me with ! ( If this solution fails, I have to only use UTL_SMTP - which is rather much more elaborate than the others)

Thanks once again for you time !  Please share with me any further inputs / comments if you might have.

cheers!

Madhu

Profile
 
 
Posted: 25 August 2005 02:53 PM   [ Ignore ]   [ # 5 ]
Newbie
Rank
Total Posts:  5
Joined  2005-08-23

Hello Braj & Anyone else following this thread,

I thought of another simple solution for my problem, please guide me further if you can -

Like I had discovered during my previous post - the LOG file is a work-in-progress at the time when the print ( or mailx) command is executed from the driver settings. This I figured is because - the Oracle Apps process waits for the response back from the command executed from the driver settings, and updates
the log file with the status that is received back from the call to the print ( or mailx) command.

Can I workaround this by spawning off another shell session by using / enclosing my mailx command in brackets ( ) and also using a WAIT of 20 seconds.. The Oracle Apps process would get a ‘SUCCESS’ response back once the second shell is spawned successfully and the log file will be complete. At the same time the
second shell would pick be able to pick the completed log file and mailx it.

Is this solution possible at all or am I just writing science fiction here smile

Thanks for your time and any help !

Madhu

Profile
 
 
Posted: 26 August 2005 12:57 AM   [ Ignore ]   [ # 6 ]
Newbie
Avatar
Rank
Total Posts:  7
Joined  2005-08-08

I will propose simplest solution for you.

just write one shell script named it LOGMAIL
-------------------------------------

#!/bin/ksh
# get reguest id
REQ_ID=$1
# Wait time
WAITTIME=$2
#USERMAIL
MAIL_ID=$3
REQ_ID
="`echo ${REQ_ID}`"
sleep $WAIT
FILE
=$APPLCSF/$APPLLOG/l$REQ_ID.req
mailx
-s "Log file of Request id:$REQ_ID" $MAIL_ID<$FILE

now put this file any where for my case , i will use $FND_TOP/bin
so file absolute path is
$FND_TOP/bin/LOGMAIL

Now define the initialization string for printer as

$FND_TOP/bin/LOGMAIL $PROFILES$.CONC_REQUEST_ID 30 brajm@asw.com.hk &

This is working perfectly well, you can also fine tune this script for your own requirement.

 Signature 

--------------------------------------------------
Braj Kishore Mahto
(Senior Oracle Apps DBA)
AS Watson Ltd
HONG KONG

Profile
 
 
Posted: 26 August 2005 01:03 AM   [ Ignore ]   [ # 7 ]
Newbie
Avatar
Rank
Total Posts:  7
Joined  2005-08-08

change the 5 th line of code to
WAIT=$2

or whole post again
---------------------------

I will propose simplest solution for you.

just write one shell script named it LOGMAIL
-------------------------------------

#!/bin/ksh
# get reguest id
REQ_ID=$1
# Wait time
WAIT=$2
#USERMAIL
MAIL_ID=$3
REQ_ID
="`echo ${REQ_ID}`"
sleep $WAIT
FILE
=$APPLCSF/$APPLLOG/l$REQ_ID.req
mailx
-s "Log file of Request id:$REQ_ID" $MAIL_ID<$FILE

now put this file any where for my case , i will use $FND_TOP/bin
so file absolute path is
$FND_TOP/bin/LOGMAIL

Now define the initialization string for printer as

$FND_TOP/bin/LOGMAIL $PROFILES$.CONC_REQUEST_ID 30 brajm@asw.com.hk &

This is working perfectly well, you can also fine tune this script for your own requirement.

 Signature 

--------------------------------------------------
Braj Kishore Mahto
(Senior Oracle Apps DBA)
AS Watson Ltd
HONG KONG

Profile
 
 
Posted: 26 August 2005 01:56 AM   [ Ignore ]   [ # 8 ]
Newbie
Avatar
Rank
Total Posts:  7
Joined  2005-08-08

Hi!
A more elegant solution. Here is will pick of the emailid from user who has submitted the request.

#!/bin/ksh
# get reguest id
REQ_ID=$1
REQ_ID
="`echo ${REQ_ID}`"
WAIT=$2
FILE
=$APPLCSF/$APPLLOG/l$REQ_ID.req
CONN_STRING
=`cat $ORACLE_HOME/reports60/server/CGIcmd.dat |grep $TWO_TASK|grep html|awk  ' { print $2 } ' |awk -F= ' { print $2 } '`

EMAIL_ID=`sqlplus -s $CONN_STRING <<EOF1
WHENEVER SQLERROR EXIT FAILURE ROLLBACK
SET HEADING OFF
SET FEEDBACK OFF
SELECT decode(a.email_address,null,'brajm@asw.com.hk',a.email_address)
FROM fnd_user a,fnd_concurrent_requests b
WHERE b.request_id=$REQ_ID
AND a.USER_ID=b.requested_by;
exit success;
EOF1
`

EMAIL_ID="`echo $EMAIL_ID`"
sleep $WAIT
mailx
-s "Log file of Request id:$REQ_ID" $EMAIL_ID <$FILE

Now printer definition

$FND_TOP/bin/LOGMAIL $PROFILES$.CONC_REQUEST_ID  30 &

 Signature 

--------------------------------------------------
Braj Kishore Mahto
(Senior Oracle Apps DBA)
AS Watson Ltd
HONG KONG

Profile
 
 
Posted: 26 August 2005 08:49 AM   [ Ignore ]   [ # 9 ]
Newbie
Rank
Total Posts:  5
Joined  2005-08-23

Very inspiring !
Your script works like magic, indeed smile
thanks a lot !

If only I can repay you for you time…

Madhu

Profile
 
 
Posted: 26 August 2005 08:57 AM   [ Ignore ]   [ # 10 ]
Newbie
Avatar
Rank
Total Posts:  7
Joined  2005-08-08

It is good to here that this script has solved your problem.
You can contact me anytime.

 Signature 

--------------------------------------------------
Braj Kishore Mahto
(Senior Oracle Apps DBA)
AS Watson Ltd
HONG KONG

Profile
 
 
Posted: 23 October 2006 02:05 PM   [ Ignore ]   [ # 11 ]
Newbie
Rank
Total Posts:  2
Joined  2006-10-23

Hi Madhu, Braj ,

I have a similar requirement where I need to email the concurrent log file as attachment. When I tried using a custom printer, I see that only if the request is successful the email is being sent. If the request errors out no email is sent. Can you please help me with this?

Regards,
Shewanka

Profile
 
 
Posted: 29 October 2006 03:31 AM   [ Ignore ]   [ # 12 ]
Newbie
Avatar
Rank
Total Posts:  30
Joined  2006-07-14

you can not use this work-around if you want to send out email on failed requests.

Profile
 
 
Posted: 30 October 2006 06:40 PM   [ Ignore ]   [ # 13 ]
Newbie
Rank
Total Posts:  4
Joined  2006-10-30

This works only when the request ends with Success & the copies is set to 1. Does not work when copies is set to 0 either. We use this extensively to automatically email request output files (works great with text or PDF files) & log files. If anyone needs help, I will be happy to help. If someone has workaround for failed requests or for situations when the end-user fails to set copies=1, please share your thoughts.

Profile
 
 
Posted: 31 October 2006 05:52 AM   [ Ignore ]   [ # 14 ]
Newbie
Rank
Total Posts:  2
Joined  2006-10-31

Urgent

Hi Braj Kishore,
I want help from you. My requirement is also similar to this. I want to send the output of the report directly to email group. for email group i have to fetch the records from one table. Can you please guide me.

Thanks in advance.

email :

Profile
 
 
Posted: 04 November 2006 01:36 AM   [ Ignore ]   [ # 15 ]
Newbie
Avatar
Rank
Total Posts:  30
Joined  2006-07-14

instead of the mailx command call a script.
inside the script you can select whatever values u need from the tabel by calling a sqlplus -s.

Profile
 
 
   
1 of 2
1