2011 Mar 24 6:14 AM
Hi,
I need to develop one report whcih can be use to send any report output in mail as attachment in txt of execl format. So i will be using SUBMIT statement to execute the report in my new report and i need to convert the reportout in txt or excel format and need to send as attachment in mail. This new report can be use to execute any report which may have ALV GRid, Normal outout screen. So what could be the best way to develop this kind of report.
Br,
Piyush
2011 Mar 24 6:17 AM
Hi ,
Please go through this link.
http://wiki.sdn.sap.com/wiki/display/ABAP/SendExternalMailwithattachment
2011 Mar 24 6:38 AM
Thanks Suresh But i need to first filter output which i will get from SUBMIT statement and then i need to prepare file to send as attachment.
2011 Mar 24 7:10 AM
Hello Piyush,
These are the steps you need to follow:
1. SUBMIT the report with the addition EXPORTING LIST TO MEMORY addition.
2. Call the FM 'LIST_FROM_MEMORY' to get the list object exported in Step1.
3. Call the FM 'LIST_TO_ASCI' to convert the listobject from Step2 into ASCII format.
Use the internal table from Step3 to send the mail. Hope i'm clear.
BR,
Suhas
2011 Mar 24 8:25 AM
Hi Suhas,
LIST_TO_ASCI will give me data in lines. and its difficult to separate the columns in another internal table for attachment file. As this report is going to use to send any report output so i can not fixed the delimiter. So i am looking some function which can split the data in columns when I am reading from List.
Br,
Piyush
2011 Mar 24 9:33 AM
>
> Hi Suhas,
>
> LIST_TO_ASCI will give me data in lines. and its difficult to separate the columns in another internal table for attachment file. As this report is going to use to send any report output so i can not fixed the delimiter. So i am looking some function which can split the data in columns when I am reading from List.
> Br,
> Piyush
No need to seperate nothing additionally, this will come automatically in the attached file. Draft below
DATA list_tab TYPE TABLE OF abaplist.
SUBMIT your_report EXPORTING LIST TO MEMORY
AND RETURN.
CALL FUNCTION 'LIST_FROM_MEMORY'
TABLES
listobject = list_tab
EXCEPTIONS
not_found = 1
OTHERS = 2.
DATA string_tab TYPE list_string_table.
"use table type appropriate for attchement
DATA ascii_tab TYPE soli_tab.
CALL FUNCTION 'LIST_TO_ASCI'
TABLES
listasci = ascii_tab
listobject = list_tab.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = 'C:\test.txt'
filetype = 'ASC'
TABLES
data_tab = ascii_tab.
DATA go_email_doc TYPE REF TO cl_document_bcs.
go_email_doc = cl_document_bcs=>create_document(
i_type = 'TXT'
... ).
go_email_doc->add_attachment( i_attachment_type = 'TXT'
i_attachment_subject = 'My Attachment'
i_att_content_text = ascii_tab ).
Regards
Marcin
2011 Mar 24 10:42 AM
Hi Marcin,
Its having the same problem. Is there any way to get all the data separated in columns i.e. in txt or excel. I will be runnig normally ALV reports in backgroud.
Br,
Piyush
2011 Mar 24 7:07 AM
Hi Piyush,
The below code snippet will give you the data of the called program using SUBMIT.
This will also display the data in a separate window.
After that you can add the logic of sendinf the data as mail.
In the below code, you will get the data in the internal table LIST_TAB.
DATA list_tab TYPE TABLE OF abaplist.
SUBMIT <YOURPROGRAM> EXPORTING LIST TO MEMORY
AND RETURN.
CALL FUNCTION 'LIST_FROM_MEMORY'
TABLES
listobject = list_tab
EXCEPTIONS
not_found = 1
OTHERS = 2.
CALL FUNCTION 'DISPLAY_LIST'
TABLES
listobject = list_tab.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.Here add the code for sending as mail
For sending as EMAIL you can use the function module
SO_DOCUMENT_SEND_API1
Regards
HM
2011 Mar 24 8:30 AM
I would suggest to create a Spool of submitted report (Use PRINT NEW-PAGE...). Convert Spool to PDF and send PDF as attachment. It will be difficult to segregate data in structured column format from list / ALV particularly if Structure is not known.
Regards,
Mohaiyuddin
2011 Mar 24 8:43 AM
Hi,
But my requirement to get the data in excel or txt format for further processing.
Br,
Piyush
2011 Mar 24 8:45 AM
I don't think there is a way to cast the unstructured data in columnar format without knowing it's structure.
Regards,
Mohaiyuddin
2011 Jun 03 1:39 PM
2012 Feb 13 6:46 PM
hey Piyush,
I am also using the submit statement with EXPORTING LIST TO MEMORY AND RETURN.
How did u divide the data which we get into sting format after CALL FUNCTION 'LIST_TO_ASCII' into an internal table whose structure i know ?
Thanks
Solanki Ritesh
2015 Jul 23 2:49 PM
Hi Piyush,
I have a same requirement . Can you please tell how did you do to filter the data and manage to accept any report in the selection screen.
Your inputs are much appreciated.
Thanks,
Nikhil.