How to covert Spool to HTML and then send it via email
Hi
I have a report that runs in the background and then converts the ALV report to PDF and emails it as attachment. I need it to convert in HTML instead of PDF.
Here is my code...
* CALL_ALV
form call_alv.
perform build_field_catalog using field_tab[].
perform build_eventtab using events[].
perform comment_build using header_alv[].
perform build_sorttab using gt_sort[].
perform build_layout.
* Call ABAP List Viewer
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = v_repid
i_callback_user_command = 'ALV_USER_COMMAND'
i_structure_name = 'REC'
it_fieldcat = field_tab[]
it_special_groups = gt_sp_group[]
it_sort = gt_sort[]
i_save = v_save
is_variant = v_variant
it_events = events[]
is_layout = gd_layout
tables
t_outtab = REC
exceptions
program_error = 1
others = 2.
IF sy-batch EQ 'X'.
PERFORM get_job_details.
PERFORM obtain_spool_id.
PERFORM convert_spool_to_pdf.
PERFORM process_email.
if p_delspl EQ 'X'.
PERFORM delete_spool.
endif.
IF sy-sysid = c_dev.
wait up to 5 seconds.
SUBMIT rsconn01 WITH mode = 'INT'
WITH output = 'X'
AND RETURN.
ENDIF.
ELSE.
SKIP.
WRITE:/ 'Program must be executed in background in-order for spool',
'request to be created.'.
ENDIF.
endform. "call_alv
* FORM obtain_spool_id *
FORM obtain_spool_id.
CHECK NOT ( gd_jobname IS INITIAL ).
CHECK NOT ( gd_jobcount IS INITIAL ).
SELECT * FROM tbtcp
INTO TABLE it_tbtcp
WHERE jobname = gd_jobname
AND jobcount = gd_jobcount
AND stepcount = gd_stepcount
AND listident <> '0000000000'
ORDER BY jobname
jobcount
stepcount.
READ TABLE it_tbtcp INTO wa_tbtcp INDEX 1.
IF sy-subrc = 0.
message s004(zdd) with gd_spool_nr.
gd_spool_nr = wa_tbtcp-listident.
MESSAGE s004(zdd) WITH gd_spool_nr.
ELSE.
MESSAGE s005(zdd).
ENDIF.
ENDFORM.
* FORM get_job_details *
FORM get_job_details.
* Get current job details
CALL FUNCTION 'GET_JOB_RUNTIME_INFO'
IMPORTING
eventid = gd_eventid
eventparm = gd_eventparm
external_program_active = gd_external_program_active
jobcount = gd_jobcount
jobname = gd_jobname
stepcount = gd_stepcount
EXCEPTIONS
no_runtime_info = 1
OTHERS = 2.
ENDFORM.
* FORM convert_spool_to_pdf *
FORM convert_spool_to_pdf.
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = gd_spool_nr
no_dialog = c_no
dst_device = c_device
IMPORTING
pdf_bytecount = gd_bytecount
TABLES
pdf = it_pdf_output
EXCEPTIONS
err_no_abap_spooljob = 1
err_no_spooljob = 2
err_no_permission = 3
err_conv_not_possible = 4
err_bad_destdevice = 5
user_cancelled = 6
err_spoolerror = 7
err_temseerror = 8
err_btcjob_open_failed = 9
err_btcjob_submit_failed = 10
err_btcjob_close_failed = 11
OTHERS = 12.
CHECK sy-subrc = 0.
* Transfer the 132-long strings to 255-long strings
LOOP AT it_pdf_output.
TRANSLATE it_pdf_output USING ' ~'.
CONCATENATE gd_buffer it_pdf_output INTO gd_buffer.
ENDLOOP.
TRANSLATE gd_buffer USING '~ '.
DO.
it_mess_att = gd_buffer.
APPEND it_mess_att.
SHIFT gd_buffer LEFT BY 255 PLACES.
IF gd_buffer IS INITIAL.
EXIT.
ENDIF.
ENDDO.
ENDFORM.
* FORM process_email *
FORM process_email.
DESCRIBE TABLE it_mess_att LINES gd_recsize.
CHECK gd_recsize > 0.
PERFORM send_email USING p_email1.
* perform send_email using p_email2.
ENDFORM.
* FORM send_email *
* --> p_email *
FORM send_email USING p_email.
CHECK NOT ( p_email IS INITIAL ).
REFRESH it_mess_bod.
* Default subject matter
gd_subject = p_Sub.
gd_attachment_desc = p_attNm.
* CONCATENATE 'attach_name' ' ' INTO gd_attachment_name.
* it_mess_bod = 'Message Body text, line 1'.
it_mess_bod = P_line1.
APPEND it_mess_bod.
* it_mess_bod = 'Message Body text, line 2...'.
it_mess_bod = P_line2.
APPEND it_mess_bod.
* If no sender specified - default blank
IF p_sender EQ space.
gd_sender_type = space.
ELSE.
gd_sender_type = 'INT'.
ENDIF.
* Send file by email as .xls speadsheet
PERFORM send_file_as_email_attachment
tables it_mess_bod
it_mess_att
using p_email
gd_subject
'PDF'
gd_attachment_name
gd_attachment_desc
p_sender
gd_sender_type
changing gd_error
gd_reciever.
ENDFORM.
* FORM delete_spool *
FORM delete_spool.
DATA: ld_spool_nr TYPE tsp01_sp0r-rqid_char.
ld_spool_nr = gd_spool_nr.
CHECK p_delspl <> c_no.
CALL FUNCTION 'RSPO_R_RDELETE_SPOOLREQ'
EXPORTING
spoolid = ld_spool_nr.
ENDFORM.
*& Form SEND_FILE_AS_EMAIL_ATTACHMENT
* Send email
FORM send_file_as_email_attachment tables it_message
it_attach
using p_email
p_mtitle
p_format
p_filename
p_attdescription
p_sender_address
p_sender_addres_type
changing p_error
p_reciever.
DATA: ld_error TYPE sy-subrc,
ld_reciever TYPE sy-subrc,
ld_mtitle LIKE sodocchgi1-obj_descr,
ld_email LIKE somlreci1-receiver,
ld_format TYPE so_obj_tp ,
ld_attdescription TYPE so_obj_nam ,
ld_attfilename TYPE so_obj_des ,
ld_sender_address LIKE soextreci1-receiver,
ld_sender_address_type LIKE soextreci1-adr_typ,
ld_receiver LIKE sy-subrc.
data: t_packing_list like sopcklsti1 occurs 0 with header line,
t_contents like solisti1 occurs 0 with header line,
t_receivers like somlreci1 occurs 0 with header line,
t_attachment like solisti1 occurs 0 with header line,
t_object_header like solisti1 occurs 0 with header line,
w_cnt type i,
w_sent_all(1) type c,
w_doc_data like sodocchgi1.
ld_email = p_email.
ld_mtitle = p_mtitle.
ld_format = p_format.
ld_attdescription = p_attdescription.
ld_attfilename = p_filename.
ld_sender_address = p_sender_address.
ld_sender_address_type = p_sender_addres_type.
* Fill the document data.
w_doc_data-doc_size = 1.
* Populate the subject/generic message attributes
w_doc_data-obj_langu = sy-langu.
w_doc_data-obj_name = 'SAPRPT'.
w_doc_data-obj_descr = ld_mtitle .
w_doc_data-sensitivty = 'F'.
* Fill the document data and get size of attachment
CLEAR w_doc_data.
READ TABLE it_attach INDEX w_cnt.
w_doc_data-doc_size =
( w_cnt - 1 ) * 255 + STRLEN( it_attach ).
w_doc_data-obj_langu = sy-langu.
w_doc_data-obj_name = 'SAPRPT'.
w_doc_data-obj_descr = ld_mtitle.
w_doc_data-sensitivty = 'F'.
CLEAR t_attachment.
REFRESH t_attachment.
t_attachment[] = it_attach[].
* Describe the body of the message
CLEAR t_packing_list.
REFRESH t_packing_list.
t_packing_list-transf_bin = space.
t_packing_list-head_start = 1.
t_packing_list-head_num = 0.
t_packing_list-body_start = 1.
DESCRIBE TABLE it_message LINES t_packing_list-body_num.
t_packing_list-doc_type = 'RAW'.
APPEND t_packing_list.
* Create attachment notification
t_packing_list-transf_bin = 'X'.
t_packing_list-head_start = 1.
t_packing_list-head_num = 1.
t_packing_list-body_start = 1.
DESCRIBE TABLE t_attachment LINES t_packing_list-body_num.
t_packing_list-doc_type = ld_format.
t_packing_list-obj_descr = ld_attdescription.
t_packing_list-obj_name = ld_attfilename.
t_packing_list-doc_size = t_packing_list-body_num * 255.
APPEND t_packing_list.
* Add the recipients email address
CLEAR t_receivers.
REFRESH t_receivers.
t_receivers-receiver = ld_email.
t_receivers-rec_type = 'U'.
t_receivers-com_type = 'INT'.
t_receivers-notif_del = 'X'.
t_receivers-notif_ndel = 'X'.
APPEND t_receivers.
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
document_data = w_doc_data
put_in_outbox = 'X'
sender_address = ld_sender_address
sender_address_type = ld_sender_address_type
commit_work = 'X'
IMPORTING
sent_to_all = w_sent_all
TABLES
packing_list = t_packing_list
contents_bin = t_attachment
contents_txt = it_message
receivers = t_receivers
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.
* Populate zerror return code
ld_error = sy-subrc.
* Populate zreceiver return code
LOOP AT t_receivers.
ld_receiver = t_receivers-retrn_code.
ENDLOOP.
ENDFORM.
Please tell me what's the code for convert_spool_to_HTML. and do i need to do anything on the PERFORM process_email. ..
I always reward points. Thanks
I think that if you can get the list back from the spool in regular format, you can then use the WWW_HTML_FROM_LISTOBJECT function module to convert to HTML. HEre is a sample program where I am submitting the program and getting the list back from memory.
* This program works in the background,
report zrich_0003 .
data: maildata like sodocchgi1.
data: mailtxt like solisti1 occurs 10 with header line.
data: mailrec like somlrec90 occurs 0 with header line.
data: list type table of abaplist with header line.
data: ascilines(1024) type c occurs 0 with header line.
data: htmllines type table of w3html with header line.
parameters: p_check.
start-of-selection.
submit zrich_0004 exporting list to memory and return.
call function 'LIST_FROM_MEMORY'
tables
listobject = list
exceptions
not_found = 1
others = 2.
call function 'LIST_TO_ASCI'
tables
listobject = list
listasci = ascilines
exceptions
empty_list = 1
list_index_invalid = 2
others = 3.
call function 'WWW_HTML_FROM_LISTOBJECT'
tables
html = htmllines
listobject = list.
clear: maildata, mailtxt, mailrec.
refresh: mailtxt, mailrec.
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.
commit work.
wait up to 2 seconds.
submit rsconn01 with mode = 'INT'
with output = 'X'
and return.
So this works fine, but you have one more step, you need to get the LISTOBJECT from SPOOL. See if you can do it using the functino module RSPO_RETURN_ABAP_SPOOLJOB or RSPO_RETURN_ABAP_SPOOLJOB_RAW.
REgards,
RIch Heilman
Similar Messages
-
If I am using Explorer, I can go to "File" and then "Send Link" -
an email will automaticallt pop up, with the website url pasted in;
I merely put in the recipents email address, hit Send, and away it goes
With Firefox, the email does not pop up; I have to manually pull up an email ("create mail"), then copy and paste the website url
displayed by Firefox
I want to override this default to ExplorerHi,
Please try this: '''Tools''' (or '''Alt''' + '''T''') > '''Options''' > '''Applications'''. Look for or start typing '''mailto''' in the search box and for the '''Action''' change it to the desired mail client (the application that opens up in Explorer) if the value is different.
'''Options''' > '''Applications''': https://support.mozilla.com/en-US/kb/Options%20window%20-%20Applications%20panel
Managing Actions: https://support.mozilla.com/en-US/kb/Managing%20file%20types -
How do I remove my phone number from iMessage so that I could only send/receive via email?
I Need to do this because my postpaid line has recently been disconnected and after updating to IOS8, I couldn't activate iMessage anymore. I know that everytime we active iMessage and Facetime the carrier sends an international text to Apple for activation; so I'd like to temporarily delete my mobile number (since it won't activate yet) and only send / receive via email - so I can still use iMessage.
I Couldn't tick on the number because its greyed out.
Hope someone can help me. Thanks.This article explains what to do:
http://support.apple.com/kb/HT5661 -
How can I create an csv/excel file using pl/sql and then sending that file
How can I create an csv/excel file using pl/sql and then sending that file to a clients site using pl/sql?
I know how to create the csv/excel file but I can't figure out how I would get it to the clients site.968776 wrote:
How can I create an csv/excel file using pl/sql and then sending that file to a clients site using pl/sql?
I know how to create the csv/excel file but I can't figure out how I would get it to the clients site.You are trying to do it at a wrong place..
Whay do you want database (pl/sql) code to do these things?
Anyhow, you may be interested in :
{message:id=9360007}
{message:id=9984244} -
How can i hide a JFrame and then Show it again in runtime
How can i hide a JFrame and then Show it again in runtime??
Please, please help me
Its URGENTHere's even an example:
import javax.swing.*;
public class HideAndShow extends JFrame
public HideAndShow()
super("Hello");
setSize(200, 200);
setVisible(true);
try
Thread.sleep(2000);
} catch(InterruptedException e) {}
setVisible(false);
try
Thread.sleep(2000);
} catch(InterruptedException e) {}
setVisible(true);
public static void main(String[] args)
new HideAndShow();
The JFrame will show, then hide, then show again. This is at runtime. -
How to open a pdf file and then attach it with images
I am new to Indesign Server.
I'm currently working on a pdf.
I have a white blank pdf template.
that I want to attach/glue it with images.
How to open a pdf file and then attach it with images.
Please, help me.
Thanks.First step would be to make yourself familiar with InDesign desktop version.
Whatever you intend to achieve, do it there manually. (see regular app docs or forums)
Then try to automate your steps with scripting (see scripting docs or forum)
If you can do it with a script in the desktop version, that script will likely also run in ID Server. (see server forum).
If you can specify missing features not achievable thru scripting or manual use, reconsider to write a plugin (this forum).
A seasoned C++ programmer will need a few months to learn the basics, wade thru tons of documentation etc. Alternatively consider to hire a consultant to do the development work for you.
Dirk -
How to split a single file and then route it to different systems
Hi All,
I have a requirement like...my incoming file(single file) needs to be split into 3 files based on a field "company code".and then route it into different systems.
my incoming file is like this .....
Header,name,.....,.....,........,.....,.....
Detail,.....,.....,.....,.....,......,companycode(100),....,.....,......
Detail,.....,.....,.....,.....,......,companycode(101),....,.....,......
Detail,.....,.....,.....,.....,......,companycode(100),....,.....,......
Detail,.....,.....,.....,.....,......,companycode(102),....,.....,......
Detail,.....,.....,.....,.....,......,companycode(101),....,.....,......
Detail,.....,.....,.....,.....,......,companycode(102),....,.....,......
EOF.
I need to split this file and my ouput file should be like this
For 1st system
Header,name,.....,.....,........,.....,.....
Detail,.....,.....,.....,.....,......,companycode(100),....,.....,......
Detail,.....,.....,.....,.....,......,companycode(100),....,.....,......
EOF.
For 2nd system
Header,name,.....,.....,........,.....,.....
Detail,.....,.....,.....,.....,......,companycode(101),....,.....,......
Detail,.....,.....,.....,.....,......,companycode(101),....,.....,......
EOF.
For 3rd system
Header,name,.....,.....,........,.....,.....
Detail,.....,.....,.....,.....,......,companycode(102),....,.....,......
Detail,.....,.....,.....,.....,......,companycode(102),....,.....,......
EOF.
and then send it three systems based on company code.
Can anyone tell me how this can be achieved?
Thanks,
Hemanth.Hi Nallam,
I tried the same thing but in the input file as there are different company codes,It is not splitting the file into three parts and sending only concerned data to repective system instead the whole file is going to the all the systems.
I came to know that the file has to splitted in the mapping only, we are able to do it by using mapping but the problem is in Routing,as in receiver determination we makes use of source structure for giving the condition. Can you please help me on this.
Thanks,
Hemanth. -
How do I add a shape and then add gradient inside of it ?
how do I add a shape and then add gradient inside of it ?
Reader commenting and markup tools do not support gradients.
-
How do I create a signature,and then add it to an e ailed document?
How can I create a signature and then use it to sign a document in e mail?
Not sure I understand the question correctly.
Open Mail and click on Preferences under the Mail menu. Click on the Signatures icon in the toolbar. You can set up your signatures there.
But if you are talking about adding a written signature, then you cannot do that within Mail. You would need to scan in an image of your written signature then manually add it to a signature you create in mail as a graphic image. That seems to work. -
How do I scan a photo to a file and then send the file as an attachment via email.
How do I scan a photo to a file and then send the file as an attachment via email.
All of this depends largely on what printer /software you have, which Email client you use and to some extent which OS you are running.
Most HP printers have HP Solution Center which is used to set up scanning,choosing where to save,etc. Once a file/photo is scanned and saved to the folder, open the folder.Select the file and at the top of the window should be the option to 'Email'.
******Clicking the Thumbs-Up button is a way to say -Thanks!.******
**Click Accept as Solution on a Reply that solves your issue to help others** -
How to remove xcode 4.1 and then install xcode 3.2.6?
how to remove xcode 4.1 and then install xcode 3.2.6?
Just an FYI I had xcode 3.2 installed on my snow leopard system and have today just installed Lion and I just cleaned and rebuilt an App I had developed prior to the Lion install to test to see if it would work. I was told it would but wanted to make sure and it successfully rebuilt and works in the simulator.
My issue is a bit different I need to install 4.1 WITHOUT corrupting my 3.2 installation as I may have to go back to rebuild a 3.2 App as we had a fairly unique setup for our xcode. The problem as I see it currently is I do not know how LION installs things in LION xcode is an App downloaded from the App store but I need to be able to download to something other than the default directories and I am not sure if I have that option in LION when installing an App(xcode) from the App Store -
I upgraded to IOS 6, I am unable to get into my Yahoo mail. It accepts pw, and pops up and tells me how many e-mails I have and then goes right back to the sign on screen. verified that I can get in from laptop & wireless is functioning.any suggestions?
Purplehiddledog wrote:
I do backup with iCloud. I can't wait until the new iMac is available so that I can once again have my files in more than 1 location without needing to rely solely on the cloud.
I also rely on iTunes and my MacBook and Time Machine as well as backing up to iCloud. I know many users know have gone totally PC free, but I chose to use iCloud merely as my third backup.
I assume that the restore would result in my ability to open Pages and Numbers and fix the problem with deleting apps, but this would also mean that if my Numbers documents still exist solely within the app and are just not on iCloud for some reason that they would be gone forever. Is that right?
In a word, yes. In a little more detail.... When you restore from an iCloud backup, you must erase the device and start all over again. There is no other way to access the backup in iCloud without erasing the device. Consequently, you are starting all over again. Therefore, it would also be my assumption that Pages and Numbers will work again and that the deleting apps issues would be fixed as well.
If the documents are not in the backup, and you do not have a backup elsewhere, the documents could be gone forever. -
How to uninstall iTunes in mac and then install again
how to uninstall iTunes in mac and then install again
You should be able to simply visit: http://www.apple.com/itunes/download/ to download iTunes, and run the installer to overwrite your previous version...
Lamborghini98 wrote:
I want this because i can't restore my iphone 4 with my mac
I don't think this will fix your problem with restoring your iPhone 4 though. That is likely a seperate issue.
but i can do it with any windows?
Yes, you can theoretically restore your iPhone with any computer running the most current version of iTunes (10.6.3) unless there is some other issue.
I get error code(21)
According to this support article: http://support.apple.com/kb/TS3694#error21:
"These errors typically occur when security software interferes with the restore and update process. FollowTroubleshooting security software issues to resolve this issue. In rare cases, these errors may be a hardware issue. If the errors persist on another computer, the device may need service."
Do you run any anti-virus or third-party firewalls on your computer? Try disabling them and trying the restore process again. It may be possible that one of these security applications is interfering with the iPhone's ability to authenticate with Apple's servers. -
How can I enable FTP on the DMP and How can I FTP to it and then remove the files that were deployed to the DMP flash? My platform of DMS is 5.2.2
Hi Temur, ok. I do the above procedure and it worked fine
Now, I have other question?
How can I reproduce any file (for example: a video, an url page, an image), that is in the flash of DMP?
Índice de ftp://172.17.15.22/tmp/ftproot/tmp/ftproot/tmp/ftproot/usb_1/
Subir al directorio superior.
Nombre Tamaño Última modificación
Sample Videos.lnk
1 KB
17/06/2011
06:25:00 a.m.
deployment
29/06/2010
04:14:00 a.m.
lost+found
25/02/2010
12:00:00 a.m.
video futbol en la playa.mp4
1390 KB
29/06/2010
01:08:00 a.m.
videofutbol.mp4
1390 KB
29/06/2010
01:38:00 a.m.
I like, that el DMP when loss conectivity with DMM, It display at the LCD screen, the video named videofutbol.mp4, this video As I show in the picture above, already in the flash of DMP.
I appreciate your early response.
Thanks -
I have a system property node for daqmx but it does not let me change it to read when i right click on it. I am trying to have my program detect the name of the daq that is plugged in to the PC and then send that to daq assistant so that it will run properly wiithout me manually having to change the device name every time i switch hardware.
Solved!
Go to Solution.labview12110 wrote:
Im just frustrated that the only function I have is to get a list of things that I can't do anything with. MAX knows which is active can I call it up somehow?
You have do do programming. That is what LabVIEW is. MAX gives you all the tools to do everything you want and much more just program it to do what you want.
Attached is a VI that I think does what you want. I looks at all of your devices and returns the first non simulated one. Apparently this list already excludes devices not connected to the system.
Unofficial Forum Rules and Guidelines - Hooovahh - LabVIEW Overlord
If 10 out of 10 experts in any field say something is bad, you should probably take their opinion seriously.
Attachments:
Find Non Simulated Device.vi 6 KB
Maybe you are looking for
-
Erase hard drive w/o removing latest Mac OS version
I am thinking of selling my iMac 27' because I need cash money. I downloaded and installed Lion on my Mac once I got it. My question is, Is there a way I can swipe my drive clean and still keep the latest version of the Mac OS installed on the drive?
-
IPhone 4S keeps crashing when trying to use camera
Every time I receive a message my phone freezes, will not respond to the lock screen button or home button, every time I try to open the camera it crashes or crashes when I take the picture.
-
I just got the latest iPod touch software update and today I went to listen to music to see that the volume bar wasn't there. Also the volume bar doesn't appear in YouTube. How can I fix this problem? Thanks
-
INSTALLED MAC OS10.9. GET "ADOBE READER BLOCKED BLOCKED FOR THIS WEBSITE." MOSTLY FINANCIAL WEBSITES????
-
Pre-Paid call and messaging charges
To find out, check our current Pre-Paid offers and rates. To find the rates that apply to you, you'll need to know which Pre-Paid offer you're using. See more about how to check and change your Pre-Paid offer.