Basics of Email Report Output as an Attachment
I need to have a report emailed as an attachement upon completion.
I have seen the many messages on the topic but they discuss topics beyond where I need them to start in the developement process.
Is anyone aware of documentation on how to do this from Oracle Applications 11i with reports 6i?
I know that DESNAME and DESTYPE are parameters but I have never changed them. Is it as simple as setting those PARMs and enabling something on the server?
A push in the right direction would be appreciated.
Dan
null
From the applications:
Set them in the after parm form trigger?
Can the destination be a comma delimited list of email addresses?
Isn't there something to configure on the server?
Thanks a bunch for replying.
Similar Messages
-
Email report output as an attachment
hi all,
i am trying to send the output of a report to an external email as an attachment using the FM SO_NEW_DOCUMENT_ATT_SEND_API1.
when i use the document type as RAW it is working fine.
now my requirement is to send it as an excel attachment.
i tried using the document type as both XLS and XXL separately.though i am getting the mail with an excel attachment, all the data appears in a single column whereas it should appear fieldwise in each column.
is this possible?
any help would be appreciated.
thanks in advance
sandeepHi Ravi/Anurag
i tried the FM SO_NEW_DOCUMENT_ATT_SEND_API1 and it is working fine when i send the mail(with an excel attachment) to SAP inbox.when i open the attachemnt with excel the data format is correct.but when i send it as an external mail and open the attachement in excel,all the data appears in one row only.
what could be the problem?
Can anyone of you please help me out in this regard?
Reward points guaranteed.
thanks
Sandeep -
Report output as an attachment in.XLS format via email.
Hi all,
When i run my report in back ground, my alv report output is to be sent as an email attachment in excel (.XLS) format. The issue i am facing is that i have around 40 fields in the output and i need to create a Header line with the Field Description in the Excel file. I am using the FM 'SO_DOCUMENT_SEND_API1', and passing the report output in to the table CONTENTS_BIN LIKE SOLISTI1 which is of Char 255. but my report output header is exceeding that length.
Kindly suggest me on how to acheive this.
Regards,
JoseHi Jose,
As for your first question you may place cl_abap_char_utilities=>horizontal_tab between contetaned fields' values. It will place then a tab mark between each two fields, which will be considered by excel as new column.
Using cl_abap_char_utilities=>newline is also correct. I will probably only result in one extra line at the end as after you append your last line to BIN table, also newline will be placed. cl_abap_char_utilities=>lf on the other hand should be placed in front of each line as this denotes Carriage Return so it simply means: "place the cursor at the beginning of each line just before writing this line".
Regards
Marcin -
Send report output as pdf attachment (without collecting spool )
I used to do this requirement by collecting the spool and then convert it to pdf. But in this case we should use the report output ( NOT FROM SPOOL ) and convert it to PDF and send it as email attachment.
Please help.
Thanks!Hi,
I can think of these options. Please explore on the possibilities.
1) Create one MAIN Report , which will submit your report. Get the List output from memory. Convert the Data to PDF and send the PDF as attachment in mail.
2) Create a smartform which will be called in your report. Convert the returned data to PDF and then send the PDF as attachment in mail.
3) Create one MAIN Report , which will submit your report thorugh a JOB. Wait for the JOB to be completed. Convert the ABAP Spool data to PDF and send the PDF as attachment in mail.
Regards,
Abhishek -
REP-0081 error when emailing report output
I am using RUN_REPORT_OBJECT to execute a report from a form. I have the report set up as a Report object in the form. The report runs fine to screen or to file, but I am getting an error when attempting to email report in batch mode:
REP-0081: Error during file I/O operation.
REP-0110: Unable to open file 'mpa02448.pdf'.
scaba 14
Execution Mode = Batch
Report Destination = Mail
Report Destination Name = [email protected]
Report Destination Format = PDF
I am able to send email to the same address via UTL_SMTP directly from the form, so it is not an email handler problem.
Any ideas?I have verified the latest patches.
Addresses are indeed in Windows address book.
As far as verifying permissions on the file, the file does not exist. It would appear that the error is generated when creating the PDF file, before emailing occurs. Again, however, I do not have problems writing to file directly.
Is there a default directory used when emailing report for file creation? Perhaps the permissions on that directory need to be changed. Please advise. -
E-mailing report output as an attachment
Hi Experts,
My requirement is to automatically e-mail the output of a report. I want my program to e-mail whatever appears on the output screen as an attachment(pdf or html), when the report is executed.
Thanks,
Rakesh.hi rakesh,
you can check this program.
here you can replace
1. your internal table
2. body message
3. attatchment.
4. receivers
please debug this one you will get clear idea where you can have correct replacement.
please check this.
report y_cr17_mail.
data method1 like sy-ucomm.
data g_user like soudnamei1.
data g_user_data like soudatai1.
data g_owner like soud-usrnam.
data g_receipients like soos1 occurs 0 with header line.
data g_document like sood4 .
data g_header like sood2.
data g_folmam like sofm2.
data g_objcnt like soli occurs 0 with header line.
data g_objhead like soli occurs 0 with header line.
data g_objpara like selc occurs 0 with header line.
data g_objparb like soop1 occurs 0 with header line.
data g_attachments like sood5 occurs 0 with header line.
data g_references like soxrl occurs 0 with header line.
data g_authority like sofa-usracc.
data g_ref_document like sood4.
data g_new_parent like soodk.
data: begin of g_files occurs 10 ,
text(4096) type c,
end of g_files.
data : fold_number(12) type c,
fold_yr(2) type c,
fold_type(3) type c.
parameters ws_file(4096) type c default 'c:\debugger.txt'.
Can me any file fromyour pc ....either xls or word or ppt etc ...
g_user-sapname = sy-uname.
call function 'SO_USER_READ_API1'
exporting
user = g_user
PREPARE_FOR_FOLDER_ACCESS = ' '
importing
user_data = g_user_data
EXCEPTIONS
USER_NOT_EXIST = 1
PARAMETER_ERROR = 2
X_ERROR = 3
OTHERS = 4
if sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
fold_type = g_user_data-outboxfol+0(3).
fold_yr = g_user_data-outboxfol+3(2).
fold_number = g_user_data-outboxfol+5(12).
clear g_files.
refresh : g_objcnt,
g_objhead,
g_objpara,
g_objparb,
g_receipients,
g_attachments,
g_references,
g_files.
method1 = 'SAVE'.
g_document-foltp = fold_type.
g_document-folyr = fold_yr.
g_document-folno = fold_number.
g_document-objtp = g_user_data-object_typ.
*g_document-OBJYR = '27'.
*g_document-OBJNO = '000000002365'.
*g_document-OBJNAM = 'MESSAGE'.
g_document-objdes = 'sap-img.com testing by program'.
g_document-folrg = 'O'.
*g_document-okcode = 'CHNG'.
g_document-objlen = '0'.
g_document-file_ext = 'TXT'.
g_header-objdes = 'sap-img.com testing by program'.
g_header-file_ext = 'TXT'.
call function 'SO_DOCUMENT_REPOSITORY_MANAGER'
exporting
method = method1
office_user = sy-uname
ref_document = g_ref_document
new_parent = g_new_parent
importing
authority = g_authority
tables
objcont = g_objcnt
objhead = g_objhead
objpara = g_objpara
objparb = g_objparb
recipients = g_receipients
attachments = g_attachments
references = g_references
files = g_files
changing
document = g_document
header_data = g_header
FOLMEM_DATA =
RECEIVE_DATA =
File from the pc to send...
method1 = 'ATTCREATEFROMPC'.
g_files-text = ws_file.
append g_files.
call function 'SO_DOCUMENT_REPOSITORY_MANAGER'
exporting
method = method1
office_user = g_owner
ref_document = g_ref_document
new_parent = g_new_parent
importing
authority = g_authority
tables
objcont = g_objcnt
objhead = g_objhead
objpara = g_objpara
objparb = g_objparb
recipients = g_receipients
attachments = g_attachments
references = g_references
files = g_files
changing
document = g_document
header_data = g_header
method1 = 'SEND'.
g_receipients-recnam = 'MK085'.
g_receipients-recesc = 'B'.
g_receipients-sndex = 'X'.
append g_receipients.
call function 'SO_DOCUMENT_REPOSITORY_MANAGER'
exporting
method = method1
office_user = g_owner
ref_document = g_ref_document
new_parent = g_new_parent
importing
authority = g_authority
tables
objcont = g_objcnt
objhead = g_objhead
objpara = g_objpara
objparb = g_objparb
recipients = g_receipients
attachments = g_attachments
references = g_references
files = g_files
changing
document = g_document
header_data = g_header.
One more code:
REPORT ZSAP_EMAIL MESSAGE-ID Z001.
*TABLES: rlgrap, btcxpm." zlookup.
DATA:
V_ZCODE(3) TYPE C,
*svrname LIKE zlookup-zdesc,
WA_ERROR(80) TYPE C,
GLOBAL_FILEMASK_ALL(80).
DATA: T_SOUD LIKE SOUD.
DATA: P_INFOLDER LIKE SOFDK.
DATA: P_OUTFOLDER LIKE SOFDK.
DATA: OBJECT_HD_DISPLAY LIKE SOOD2.
DATA: OBJECT_ID LIKE SOODK.
DATA: DOCUMENT LIKE SOOD4.
DATA: HEADER_DATA LIKE SOOD2.
DATA: LINK_FOLDER_ID LIKE SOODK.
DATA: FOLDER_SELECTIONS LIKE SOFDS.
DATA: FOLDER_LIST LIKE SOXLI OCCURS 0 WITH HEADER LINE.
DATA: RECEIVERS LIKE SOOS1 OCCURS 0 WITH HEADER LINE.
DATA: OBJCONT LIKE SOLI OCCURS 0 WITH HEADER LINE.
DATA: OBJHEAD LIKE SOLI OCCURS 0 WITH HEADER LINE.
DATA: OBJECT_CONTENT LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE.
DATA: OBJECT_HD_CHANGE LIKE SOOD1.
DATA: BEGIN OF FILES OCCURS 0,
LINE(200) TYPE C,
END OF FILES.
DATA: LISTOBJECT LIKE ABAPLIST OCCURS 1 WITH HEADER LINE.
*Email to addresses
SELECTION-SCREEN: BEGIN OF BLOCK BL1 WITH FRAME TITLE TEXT-BL1.
PARAMETERS: P_MAILTO(240) TYPE C.
*PARAMETERS:P_MAILTO TYPE SOLI-LINE.
SELECTION-SCREEN SKIP 1.
SELECTION-SCREEN COMMENT 10(2) TEXT-001.
*Use zlookup-ztype as group to define multiple email to addresses
*SELECT-OPTIONS: s_mailto FOR zlookup-ztype.
SELECTION-SCREEN: END OF BLOCK BL1.
*Subject
SELECTION-SCREEN: BEGIN OF BLOCK BL2 WITH FRAME TITLE TEXT-BL2.
PARAMETERS: P_SUBJ LIKE DOCUMENT-OBJDES.
SELECTION-SCREEN: END OF BLOCK BL2.
*Body
SELECTION-SCREEN: BEGIN OF BLOCK BL3 WITH FRAME TITLE TEXT-BL3.
PARAMETERS: P_BODY1 LIKE SOLISTI1-LINE LOWER CASE.
PARAMETERS: P_BODY2 LIKE SOLISTI1-LINE LOWER CASE.
PARAMETERS: P_BODY3 LIKE SOLISTI1-LINE LOWER CASE.
PARAMETERS: P_BODY4 LIKE SOLISTI1-LINE LOWER CASE.
PARAMETERS: P_BODY5 LIKE SOLISTI1-LINE LOWER CASE.
PARAMETERS: P_BODY6 LIKE SOLISTI1-LINE LOWER CASE.
SELECTION-SCREEN: END OF BLOCK BL3.
*Attachments
SELECTION-SCREEN: BEGIN OF BLOCK BL4 WITH FRAME TITLE TEXT-BL4.
PARAMETERS: P_FNAME1 LIKE FILES-LINE.
PARAMETERS: P_FNAME2 LIKE FILES-LINE.
PARAMETERS: P_FNAME3 LIKE FILES-LINE.
PARAMETERS: P_FNAME4 LIKE FILES-LINE.
PARAMETERS: P_FNAME5 LIKE FILES-LINE.
PARAMETERS: P_FNAME6 LIKE FILES-LINE.
SELECTION-SCREEN: END OF BLOCK BL4.
AT SELECTION-SCREEN.
PERFORM CHK_SELECTION.
IF NOT WA_ERROR IS INITIAL.
MESSAGE E001 WITH WA_ERROR.
ENDIF.
START-OF-SELECTION.
END-OF-SELECTION.
PERFORM SEND_EMAIL.
FORM chk_selection
FORM CHK_SELECTION.
CLEAR WA_ERROR.
*Loop only once ???
*If more checkings to be done.
*Think about it and if not clear.
*Let it sink in for a couple of minutes.
*Still doesn't make sence? Go home and sleep on it.
DO 1 TIMES.
*Check Email to
IF P_MAILTO IS INITIAL .
*AND s_mailto IS INITIAL.
WA_ERROR = 'Invalid or no EMAIL TO selection'.
EXIT.
ENDIF.
ENDDO.
ENDFORM. "chk_selection
*& Form send_email
*text
*--> p1 text
*<-- p2 text
FORM SEND_EMAIL.
PERFORM GET_FOLDER_INFO.
PERFORM FILL_BODY.
PERFORM INS_NEW_OBJECT.
PERFORM CRT_ATTACHMENTS.
PERFORM FILL_RECEIVERS_INFO.
PERFORM SND_EMAIL.
ENDFORM. " send_email
*--+--
*FORM Get_folder_info
FORM GET_FOLDER_INFO.
CLEAR T_SOUD.
*Small so should be quick.
SELECT * FROM SOUD
INTO T_SOUD
WHERE SAPNAM = SY-UNAME.
P_INFOLDER-FOLTP = 'FOL'.
P_INFOLDER-FOLYR = T_SOUD-INBYR. "inbox
P_INFOLDER-FOLNO = T_SOUD-INBNO.
P_OUTFOLDER-FOLTP = 'FOL'.
P_OUTFOLDER-FOLYR = T_SOUD-OUTYR. "outbox
P_OUTFOLDER-FOLNO = T_SOUD-OUTNO.
ENDSELECT.
ENDFORM. "get_folder_info
*FORM fill_body *
FORM FILL_BODY.
OBJECT_CONTENT-LINE = P_BODY1.
APPEND OBJECT_CONTENT.
OBJECT_CONTENT-LINE = P_BODY2.
APPEND OBJECT_CONTENT.
OBJECT_CONTENT-LINE = P_BODY3.
APPEND OBJECT_CONTENT.
OBJECT_CONTENT-LINE = P_BODY4.
APPEND OBJECT_CONTENT.
OBJECT_CONTENT-LINE = P_BODY5.
APPEND OBJECT_CONTENT.
OBJECT_CONTENT-LINE = P_BODY6.
APPEND OBJECT_CONTENT.
ENDFORM. "fill_body
*FORM ins_new_object *
FORM INS_NEW_OBJECT.
OBJECT_HD_CHANGE-OBJNAM = 'Notes'.
OBJECT_HD_CHANGE-OBJDES = P_SUBJ.
CALL FUNCTION 'SO_OBJECT_INSERT'
EXPORTING
FOLDER_ID = P_OUTFOLDER
OBJECT_HD_CHANGE = OBJECT_HD_CHANGE
OBJECT_TYPE = 'RAW'
OWNER = SY-UNAME
IMPORTING
OBJECT_HD_DISPLAY = OBJECT_HD_DISPLAY
OBJECT_ID = OBJECT_ID
TABLES
OBJCONT = OBJECT_CONTENT
OBJHEAD = OBJHEAD
EXCEPTIONS
ACTIVE_USER_NOT_EXIST = 1
COMMUNICATION_FAILURE = 2
COMPONENT_NOT_AVAILABLE = 3
DL_NAME_EXIST = 4
FOLDER_NOT_EXIST = 5
FOLDER_NO_AUTHORIZATION = 6
OBJECT_TYPE_NOT_EXIST = 7
OPERATION_NO_AUTHORIZATION = 8
OWNER_NOT_EXIST = 9
PARAMETER_ERROR = 10
SUBSTITUTE_NOT_ACTIVE = 11
SUBSTITUTE_NOT_DEFINED = 12
SYSTEM_FAILURE = 13
X_ERROR = 14
OTHERS = 15.
IF SY-SUBRC 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. "ins_new_object
*FORM crt_attachments *
*--> P_SUBJ *
FORM CRT_ATTACHMENTS.
DOCUMENT-FOLTP = P_OUTFOLDER-FOLTP.
DOCUMENT-FOLYR = P_OUTFOLDER-FOLYR.
DOCUMENT-FOLNO = P_OUTFOLDER-FOLNO.
DOCUMENT-OBJTP = OBJECT_ID-OBJTP.
DOCUMENT-OBJYR = OBJECT_ID-OBJYR.
DOCUMENT-OBJNO = OBJECT_ID-OBJNO.
DOCUMENT-OBJNAM = 'Notes'.
DOCUMENT-OBJDES = P_SUBJ.
DOCUMENT-OKCODE = 'CHNG'.
DOCUMENT-FILE_EXT = 'TXT'.
LINK_FOLDER_ID = OBJECT_ID.
HEADER_DATA-OBJLA = 'EN'.
HEADER_DATA-OBJNAM = DOCUMENT-OBJNAM.
HEADER_DATA-OBJDES = DOCUMENT-OBJDES.
HEADER_DATA-OBJPRI = '5'.
HEADER_DATA-OBJSNS = 'O'.
HEADER_DATA-FILE_EXT = 'TXT'.
REFRESH FILES.
CLEAR FILES.
IF NOT P_FNAME1 IS INITIAL.
FILES-LINE = P_FNAME1.
APPEND FILES.
ENDIF.
IF NOT P_FNAME2 IS INITIAL.
FILES-LINE = P_FNAME2.
APPEND FILES.
ENDIF.
IF NOT P_FNAME3 IS INITIAL.
FILES-LINE = P_FNAME3.
APPEND FILES.
ENDIF.
IF NOT P_FNAME4 IS INITIAL.
FILES-LINE = P_FNAME4.
APPEND FILES.
ENDIF.
IF NOT P_FNAME5 IS INITIAL.
FILES-LINE = P_FNAME5.
APPEND FILES.
ENDIF.
IF NOT P_FNAME6 IS INITIAL.
FILES-LINE = P_FNAME6.
APPEND FILES.
ENDIF.
IF NOT FILES[] IS INITIAL.
CALL FUNCTION 'SO_DOCUMENT_REPOSITORY_MANAGER'
EXPORTING
METHOD = 'ATTCREATEFROMPC'
TABLES
FILES = FILES
CHANGING
DOCUMENT = DOCUMENT
HEADER_DATA = HEADER_DATA.
IF SY-SUBRC = 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDIF.
ENDFORM. "crt_attachments
*FORM fill_receivers_info *
FORM FILL_RECEIVERS_INFO.
DATA: BEGIN OF RECLIST OCCURS 0,
REC LIKE RECEIVERS-RECEXTNAM,
END OF RECLIST.
*Build reclist
REFRESH RECLIST.
IF NOT P_MAILTO IS INITIAL.
RECLIST-REC = P_MAILTO.
APPEND RECLIST.
ENDIF.
*IF NOT s_mailto IS INITIAL.
*SELECT zdesc
*INTO reclist-rec
*FROM zlookup
*WHERE ztype IN s_mailto.
*APPEND reclist.
*ENDSELECT.
*ENDIF.
REFRESH RECEIVERS.
LOOP AT RECLIST.
FOLDER_SELECTIONS-FOLNAM = 'INBOX'.
CALL FUNCTION 'SO_FOLDER_LIST_READ'
EXPORTING
FOLDER_SELECTIONS = FOLDER_SELECTIONS
OWNER = SY-UNAME
REGION = 'P'
TABLES
FOLDER_LIST = FOLDER_LIST
EXCEPTIONS
COMPONENT_NOT_AVAILABLE = 1
OPERATION_NO_AUTHORIZATION = 2
OWNER_NOT_EXIST = 3
PARAMETER_ERROR = 4
X_ERROR = 5
OTHERS = 6.
IF SY-SUBRC = 0.
CLEAR RECEIVERS.
MOVE: SY-DATUM TO RECEIVERS-RCDAT,
SY-UZEIT TO RECEIVERS-RCTIM,
' ' TO RECEIVERS-RECESC,
P_MAILTO TO RECEIVERS-RECNAM,
'X' TO RECEIVERS-SNDEX.
APPEND RECEIVERS.
u2022 RECEIVERS-RCDAT = SY-DATUM.
u2022 RECEIVERS-RCTIM = SY-UZEIT.
u2022 RECEIVERS-RECNAM = RECLIST-REC.
u2022 RECEIVERS-RECNO = FOLDER_LIST-PARNO.
u2022 RECEIVERS-RECTP = FOLDER_LIST-PARTP.
u2022 RECEIVERS-RECYR = FOLDER_LIST-PARYR.
u2022 RECEIVERS-SNDTP = FOLDER_LIST-PARTP.
u2022 RECEIVERS-SNDYR = FOLDER_LIST-PARYR.
u2022 RECEIVERS-SNDNO = FOLDER_LIST-PARNO.
u2022 RECEIVERS-SNDNAM = SY-UNAME.
u2022 RECEIVERS-SNDPRI = '1'.
u2022 RECEIVERS-MSGID = 'SO'.
u2022 RECEIVERS-MSGNO = '619'.
u2022 RECEIVERS-DELIVER = 'X'.
u2022 RECEIVERS-NOT_DELI = 'X'.
u2022 RECEIVERS-READ = 'X'.
u2022 RECEIVERS-MAILSTATUS = 'E'.
**receivers-ADR_NAME
u2022 RECEIVERS-RESEND = ' '.
u2022 RECEIVERS-SORTFIELD = ' '. "'USER WF_BATCH INDIGO BATCH'.
u2022 RECEIVERS-SORTCLASS = '5'.
u2022 APPEND RECEIVERS.
ELSE.
CLEAR RECEIVERS.
RECEIVERS-SEL = 'X'.
RECEIVERS-RECESC = 'U'.
RECEIVERS-RECNAM = 'U-'.
RECEIVERS-RECEXTNAM = RECLIST-REC.
RECEIVERS-DELIVER = 'X'.
RECEIVERS-NOT_DELI = 'X'.
RECEIVERS-READ = 'X'.
RECEIVERS-MAILSTATUS = 'E'.
RECEIVERS-ADR_NAME = RECLIST-REC.
RECEIVERS-SORTFIELD = RECLIST-REC.
RECEIVERS-SORTCLASS = '5'.
APPEND RECEIVERS.
ENDIF.
ENDLOOP.
ENDFORM. "fill_receivers_info
*FORM snd_email *
FORM SND_EMAIL.
CALL FUNCTION 'SO_OBJECT_SEND'
EXPORTING
FOLDER_ID = P_OUTFOLDER
OBJECT_ID = OBJECT_ID
OUTBOX_FLAG = 'X'
OWNER = SY-UNAME
CHECK_SEND_AUTHORITY = 'X'
ORIGINATOR_TYPE = 'J'
LINK_FOLDER_ID = LINK_FOLDER_ID
TABLES
OBJCONT = OBJECT_CONTENT
RECEIVERS = RECEIVERS
EXCEPTIONS
ACTIVE_USER_NOT_EXIST = 1
COMMUNICATION_FAILURE = 2
COMPONENT_NOT_AVAILABLE = 3
FOLDER_NOT_EXIST = 4
FOLDER_NO_AUTHORIZATION = 5
FORWARDER_NOT_EXIST = 6
NOTE_NOT_EXIST = 7
OBJECT_NOT_EXIST = 8
OBJECT_NOT_SENT = 9
OBJECT_NO_AUTHORIZATION = 10
OBJECT_TYPE_NOT_EXIST = 11
OPERATION_NO_AUTHORIZATION = 12
OWNER_NOT_EXIST = 13
PARAMETER_ERROR = 14
SUBSTITUTE_NOT_ACTIVE = 15
SUBSTITUTE_NOT_DEFINED = 16
SYSTEM_FAILURE = 17
TOO_MUCH_RECEIVERS = 18
USER_NOT_EXIST = 19
ORIGINATOR_NOT_EXIST = 20
X_ERROR = 21
OTHERS = 22.
IF SY-SUBRC 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. "snd_email
reward me if it is useful.
thanks
AM -
Email Report List as an attachment
Hello Experts,
I need to write a new program which will run in background and should be able to send its list as an attachement in an email. (I really appreciate if that can send the report's spool (if PDF format) as an attachment). I know that there are some sample programs which I can find in SDN. I have been searching for those in vain. Can anybody please let me know if you find a link? I really appriciate your help.
Thanks.
PS: We use SAP R/3 4.6c version.Hi SAM
check this code.. a part of it will be useful to you..
WWW_LIST_TO_HTML need to replaced with ur PDF FM
data: list type table of abaplist with header line.
data: htmllines type table of w3html with header line.
data: maildata like sodocchgi1.
data: mailtxt like solisti1 occurs 10 with header line.
data: mailrec like somlrec90 occurs 0 with header line.
start-of-selection.
* Produce a list
do 100 times.
write:/ sy-index, at 30 sy-index, at 50 sy-index.
enddo.
* Save the list
call function 'SAVE_LIST'
tables
listobject = list
exceptions
list_index_invalid = 1
others = 2.
* Convert the list
call function 'WWW_LIST_TO_HTML'
tables
html = htmllines.
* Send mail
maildata-obj_name = 'TEST'.
maildata-obj_descr = 'Test Subject'.
loop at htmllines.
mailtxt = htmllines.
append mailtxt.
endloop.
mailrec-receiver = '[email protected]'.
mailrec-rec_type = 'U'.
append mailrec.
call function 'SO_NEW_DOCUMENT_SEND_API1'
exporting
document_data = maildata
document_type = 'HTM'
put_in_outbox = 'X'
tables
object_header = mailtxt
object_content = mailtxt
receivers = mailrec
exceptions
too_many_receivers = 1
document_not_sent = 2
document_type_not_exist = 3
operation_no_authorization = 4
parameter_error = 5
x_error = 6
enqueue_error = 7
others = 8.
if sy-subrc 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif. -
Reg emailing the output of a concurrent program as an attachment
Hi,
Our requirement is to email the output of a concurrent program?(SQL*PLUS Report Output) as an attachment to the supplied Email Id, without using seperate Shell Script.
We have configured a printer and passed the Printer Driver argument as
uuencode $PROFILES$.FILENAME Budget_Report.csv | /bin/mailx -"Cisco AS Budget Report" $Email_id
The Problem is we are passing the Email address directly to the command.Can't we use the Parameter value to that command?
And also a junk character 'end gets displayed in the mail body.
Sometimes the concurrent Program ends with warning message as
APP-FND-00500 : AFPPRN received a return code of failure from routine FDUPRN.
An error occured while AOL tried to spawn the print process.
Please suggest some ways on getting proper output?
Thanks.Hi,
Email address can be Profile Option - create a new profile option, set value and reference like the $PROFILES$.FILENAME.
For logging pipe standard out and error to a logfile. Note I haven't tested the command below, just to give you an idea. Would be better to create a shell script then you can change without having to go to the Printer Drivers and bounce Conc Mgr.
Ie. if you profile option is XX_EMAIL_ADDRESS then
uuencode $PROFILES$.FILENAME Budget_Report.csv | /bin/mailx -"Cisco AS Budget Report" $PROFILES$.FILENAME >/mypath/myfile 2>&1
With regards to the failure, if your uuencode or mailx returns 1 (ie, can't find file or whatever) then your print job fails. This is why you should either log or create shell script to handle the error better.
Regards,
Gareth
Blog: http://garethroberts.blogspot.com/
Message was edited by:
gareth.roberts
oops, have tested changed to haven't tested! -
Report output sending as an attachement through mail
we are facing one problem while sending report output as an attachement to specific mail-ids.
Every thing is working fine.But for each row upto 255 characteers only it is printig.
Remaining is not comming.
We are using Function Module SO_DOCUMENT_SEND_API1.
Please help us to solve this.
Regards,
Phanicheck this code sample
<a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/5931ff64-0a01-0010-2bb7-ff2f9a6165a0">E-mail ABAP Report List output in HTML format</a>
Regards
Raja -
Report output to be sent via mail
Hi Experts,
I want to send my customized ABAP report output to an email address (e.g my own email ID) as I need to send to the vendor (who doesn't have SAP access) as per the requirement.
Can you please let me know is there any transaction or any other way with the help of which i can just input this report name and the email Id and then it will automatically send the output of the report to that email id.
Thanks in advance.
Any helpful entry will be rewarded.
Warm regards,
Raman.You might want to write a small program that retrieves your spool information, and send the corresponding ALV (internal table) by converting it and sending it via SAP Connect. Here is a sample of hos to attach and send your internal table:
FORM send_file .
DATA: send_request TYPE REF TO cl_bcs,
text TYPE bcsy_text,
document TYPE REF TO cl_document_bcs,
recipient TYPE REF TO if_recipient_bcs,
copy TYPE ad_smtpadr,
bcs_exception TYPE REF TO cx_bcs,
sent_to_all TYPE os_boolean,
att_name TYPE sood-objdes,
subject TYPE so_obj_des.
Get attachment name
CONCATENATE g_ret_id '_' sy-datum sy-uzeit '_' g_fileid '.CSV' INTO
att_name.
TRY.
Create the send request
send_request = cl_bcs=>create_persistent( ).
Create the document with attachments
Main document
APPEND 'Attachment test' TO text.
document = cl_document_bcs=>create_document(
i_type = 'RAW'
i_text = text
i_subject = subject ).
Add text attachment to document
document->add_attachment( i_attachment_type = 'CSV'
i_attachment_subject = att_name
i_att_content_text = itab_file ).
send_request->set_document( document ).
Create recipient and add to send request
LOOP AT itab_recipients INTO wa_recipients.
IF wa_recipients-copy IS INITIAL.
"To recipient
MOVE wa_recipients-address TO g_rec_send.
recipient = cl_cam_address_bcs=>create_internet_address(
g_rec_send ).
send_request->add_recipient( i_recipient = recipient ).
CLEAR g_rec_send.
ELSE.
"CC
MOVE wa_recipients-address TO g_rec_send.
recipient = cl_cam_address_bcs=>create_internet_address(
g_rec_send ).
send_request->add_recipient( i_recipient = recipient
i_copy = 'X' ).
CLEAR g_rec_send.
ENDIF.
ENDLOOP.
Send
sent_to_all = send_request->send( i_with_error_screen = 'X' ).
IF sent_to_all = 'X'.
MESSAGE s022.
ENDIF.
CATCH cx_bcs INTO bcs_exception.
MESSAGE e865 WITH bcs_exception->error_type.
ENDTRY.
ENDFORM. " send_file
REPORT TO EMAIL
ALV output to email
How to send ALV Grid report to Email?
Check the code...on http://sap4.com/wiki/index.php?title=ZOUTLOOK
sending the output of a program through an email
report output to email
Sending ABAP Report by email
Rewards if useful..............
Minal -
Report output getting truncated in email attachment
Hello Gurus,
My requirement is to send a report output as an email attachment.
I have done the coding for this but have a small problem. In the attachment the report is getting truncated after certain length.
Can you advise wats the problem ?
Regards,
SuhasHello Guys,
I too was contemplating on those lines. But actually i was calculating the File Size incorrectly.
Changed the code & now it working !!!!!!!
BR,
Suhas -
Send report output via email as zipped attachment
Is it possible for the report output to be zipped before being attached to an email when running on a windows reports_server? On unix we theoretically have the ability to modify the mail.sh shell script that performs the mail operation for reports.
Hi Richard
This is a Reports 9i solution.
You may create a batch file that runs the report, compresses the file and invokes, say, a Java application that mails the given .zip file.
More "advanced" options would be:
You may create a pluggable destination that captures report output. Next, your code does the compresses the output file and mails it.
A simpler solution would be to run two reports. First, that creates the reports output file. In its AFTER_REPORT trigger, call Java method (thru. Java Importer), that picks up the output file and compresses it. Second, that uses XML distribution feature of Reports 9i and mails the .zip file as a file attachment using appropriate construct.
Regard
Sripathy -
Simple report list output sent as attachment thru email
Hi All,
Here's my task : I need to schedule a bi-weekly report that obviously runs in the background and produces output. From that output, I want to capture (with no manual intervention) the list output to an attachment and email a recipient. I've looked over code snippets and understand most of the <b>LIST</b> functions, but most deal with uploading a file from the frontend, which I do not want. Any ideas? Thx in advance.
JimHi
see the sample report to send mail as attachement
modify it as per your requirement
Mailing with Attachment by ABAP Coding
Refer this link:
Mail with attachment.
FORM send_list_to_basis .
DATA: w_path LIKE rlgrap OCCURS 0 WITH HEADER LINE,
lt_index TYPE sy-tabix,
doc_type(3) TYPE c,
descr LIKE it_objpack_basis-obj_descr,
temp_data LIKE w_path,
temp1 TYPE string,
tab_lines TYPE i,
langu(15) TYPE c,
expirydate TYPE so_obj_edt,
L_FILE1(100).
CONCATENATE 'C:\' sy-repid '_' sy-datum '.XLS' INTO L_FILE1.
W_PATH-FILENAME = L_FILE1.
APPEND w_path.
CLEAR w_path.
wa_doc_chng-obj_descr = 'User List not logged on for 180 days'.
wa_doc_chng-obj_langu = 'E'.
wa_doc_chng-obj_expdat = sy-datum.
CLEAR w_subject.
CONCATENATE 'Please find attached document with list of users'
'not logged on for 180 days for client' sy-mandt
INTO w_subject SEPARATED BY space.
it_objtxt_basis-line = w_subject.
APPEND it_objtxt_basis.
CLEAR it_objtxt_basis.
it_objtxt_basis-line = text-004.
APPEND it_objtxt_basis.
CLEAR it_objtxt_basis.
CLEAR w_tab_line.
DESCRIBE TABLE it_objtxt_basis LINES w_tab_line.
READ TABLE it_objtxt_basis INDEX w_tab_line INTO l_cline.
wa_doc_chng-doc_size =
( w_tab_line - 1 ) * 255 + STRLEN( l_cline ).
CLEAR it_objpack_basis-transf_bin.
it_objpack_basis-head_start = 1.
it_objpack_basis-head_num = 0.
it_objpack_basis-body_start = 1.
it_objpack_basis-body_num = w_tab_line.
it_objpack_basis-doc_type = 'RAW'.
APPEND it_objpack_basis.
CLEAR it_objpack_basis.
LOOP AT w_path.
temp1 = w_path.
descr = w_path.
CALL FUNCTION 'STRING_REVERSE'
EXPORTING
string = descr
lang = 'E'
IMPORTING
rstring = descr.
CALL FUNCTION 'STRING_SPLIT'
EXPORTING
delimiter = '\'
string = descr
IMPORTING
head = descr
tail = temp_data.
CALL FUNCTION 'STRING_REVERSE'
EXPORTING
string = descr
lang = 'E'
IMPORTING
rstring = descr.
CALL FUNCTION 'STRING_SPLIT'
EXPORTING
delimiter = '.'
string = descr
IMPORTING
head = temp_data
tail = doc_type.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = temp1
filetype = 'BIN'
header_length = 0
read_by_line = 'X'
replacement = '#'
TABLES
data_tab = it_upload.
DESCRIBE TABLE it_upload LINES tab_lines.
DESCRIBE TABLE it_objbin_basis LINES lt_index.
lt_index = lt_index + 1.
LOOP AT it_upload.
wa_objbin_basis-line = it_upload-line.
APPEND wa_objbin_basis TO it_objbin_basis.
CLEAR wa_objbin_basis.
ENDLOOP.
it_objpack_basis-transf_bin = 'X'.
it_objpack_basis-head_start = 0.
it_objpack_basis-head_num = 0.
it_objpack_basis-body_start = lt_index.
it_objpack_basis-body_num = tab_lines.
it_objpack_basis-doc_type = doc_type.
it_objpack_basis-obj_descr = descr.
it_objpack_basis-doc_size = tab_lines * 255.
APPEND it_objpack_basis.
CLEAR it_objpack_basis.
ENDLOOP.
it_reclist_basis-receiver = '[email protected]'.
it_reclist_basis-rec_type = 'U'.
APPEND it_reclist_basis.
CLEAR it_reclist_basis.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = wa_doc_chng
put_in_outbox = 'X'
commit_work = 'X'
TABLES
packing_list = it_objpack_basis
contents_txt = it_objtxt_basis
contents_bin = it_objbin_basis
receivers = it_reclist_basis
EXCEPTIONS
too_many_receivers = 1
document_not_sent = 2
operation_no_authorization = 4
OTHERS = 99.
IF sy-subrc EQ 0.
SUBMIT rsconn01 WITH mode = 'INT' AND RETURN.
ENDIF.
ENDFORM. " send_list_to_basis
Reward points if useful
Regards
Anji -
Report output as an email attachment
Hi ,
I am sending report output as email attachment by using 'mail recipient ' CLTR+ F7' option in alv list.
But this is sending mail as pdf attachment. I want it as excel format.
Is there any option to change type of attachment which sending mail?Hi,
This is not possible to change the filetype of the attachment. Instead you can have your own functionality in the program to send email with excel attachment
Refer to this link..http://docs.google.com/Doc?id=dfv2hmgs_0fm22tggx&hl=en -
Re: Sending report output in the body of Email (Not as an attachment)
Hi,
My requirement is to send the report output in body part of the mail itself. I am able to send the mail with the output as an attachment but requirement is it shoud be in the body part not as an attachment..
Thanks,
Anshuman.Hi Anshu,
Can you please let me know is the ERMS configured in your system or you are sending
the mail to the customer using Action Profiles. If you are sending the mail using a smartform
assigned to an Action profile then you can display that report internal table data or etc.. in
the smartform itself so that the output data will be available in the e-mail body itself.
Please let me know the way you are sending the e-mail if the above ones are incorrect.
Thanks
Arun
Maybe you are looking for
-
Is there a way to save over previous files without renaming when packaging InDesign files?
I am finding the file management a nightmare with having to package my work from Creative Cloud at home in order to work in Creative Suite at school. I usually have to do this back and forth multiple times for the same project creating multiple files
-
In the web version of my form the message FRM-40200 field protected from change does not appear (show in CS). Any idea why not. or if there are other messages that won't show.
-
Hard drive access and beach ball
Whenever I open Safari, I hear my hard drive being accessed constantly and get the beach ball. This slows down my computer and makes Safari almost useless. I wasn't sure what the casue of the beach ball was, so I posted something in the OSX forum (ht
-
Ipod wont turn on, or cant be seen on my computer or anyothere
The only thing i can do to it is click the holf on and off, then hit the middle button and left for about 6 seconds, that turns on the screen, but i have tried the click hold, adn menu and center button I have tired this about 40 times, any other Sug
-
Bricked my iPhone using iFile! What do I do?
So I was using iFile, and I wasn't thinking straight and I put the Library folder into the Media folder... now when I reboot I get stuck at the apple loading screen and can't get into my phone. Any help?