05-21-2015 6:30 AM
Dear experts,
we analyze incoming emails (SCOT) and depending on the subject, the processing is triggered.
Until now, email attachments are added to e.g. purchase order as GOS attachments.
The requirement now is to attach the email body itself as PDF to PO.
Can you please give me some advice on how to convert the email body into a PDF?
Thanks so much!
Monika
05-21-2015 9:17 AM
Hi Monica,
If you want to check all the incoming Email we can check in SOOD Table.
As SAP notification and Work items are coming under 'RAW' Document class.
get the Object: Number from ID.
and pass these details to Function Module "SO_OBJECT_GET_CONTENT" and you will get the mail content in OBJCONT.
For Convert to PDF.
As you need to attach in PO, Then you can create Program to read latest SOOD and Create attachment in PO.
Regards,
NB
05-26-2015 9:49 AM
Hi Nihit,
unfortunately the SOOD table doesn't help because we don't process SAP notifications but Emails (sent via Outlook).
We Redirect inbound messages via SCOT and in the class to process the emails we
1) get no. of body parts
l_parts = io_document->get_body_part_count( ).
2) get the subject
ls_attribute = io_document->get_body_part_attibutes( sy-index ).
3) get the Content
ls_content = io_document->get_vody_part_Content( sy-index ).
Step 2 and 3 within a loop: DO l_part TIMES - ENDDO.
The result in LS_CONTENT is HEX.
My question now is how I can convert this result into a "readable" format? A format that I can put into an internal table which I can convert to PDF.
Hope you can help me again!
Best regards, Monica
05-26-2015 11:14 AM
Hello Monika,
you should use cl_bcs_convert class,something like that should do the trick.
data cpcodepage type cpcodepage.
call function 'SCP_CODEPAGE_FOR_LANGUAGE'
exporting
language = sy-langu
importing
codepage = cpcodepage
exceptions
no_codepage = 1
others = 2.
if sy-subrc eq 0.
data(body_string) = cl_bcs_convert=>xstring_to_string( iv_xstr = cl_bcs_convert=>solix_to_xstring( it_solix = ls_content-cont_hex ) iv_cp = cpcodepage ).
endif.
Cheers
Łukasz
05-28-2015 10:38 AM
Hello Lukasz,
when I use cl_bcs_convert=>xstring_to_string I get something like this as result:
This seems to be HTML-Code, right? I don't have any experience with HTML
How can I make a PDF out of this?
As Nihit told me, I should write an ALV-list to spool and with the spool-no I can call FM convert_abapspooljob_2_pdf (as described in thread 3304679).
But with the string ls_body I cannot create an ALV Grid!
Please, help me again! Thanks so much!
Regards, Monika
05-28-2015 10:49 AM
Hi Monika
If I've understood what you mean, you need to pick up email (so outlook file), convert it to pdf format and attach it to PO by GOS.
I don't know if there's a tool in SAP to do it, you can considere it can attach the email (so in outlook format) without any convertion.
Else you can try to use an external program (a pdf converter) in order to convert the file and so to attach it
Max
05-28-2015 11:03 AM
Well mail body is usually HTML or plain text, there are some post on SCN which are about converting HTML to PDF, maybe they will be useful for you .
In my opinion you could also attach the HTML file directly instead of creating PDF from it.
By the way in mail message you can have anything, creating ALV grid from it seems bad idea and in many cases not even possible,
05-28-2015 11:05 AM
This would be even better than storing body and attachments separatelly
05-28-2015 11:31 AM
Hi Max,
yes, you understood my problem!
Today we do it as you told me - we attach the email without any conversion. Mostly it works perfect, but sometimes the attached email cannot be read.
Here's an example:
So my boss told me I have to convert the email Body to pdf, so that everyone can read it.
Can you give me a hint why the email is displayed like this? If I can solve this problem than it ist really not necessary to convert it to PFD!
Thanks!
Monika
05-28-2015 11:49 AM
Hi
You should check which application is assigned to object mail in your system, I suppose it should be outlook, if it's so perhaps it can depend on outlook release.
But the mail can be opened correctly by some users or all user can't open it?
Max
05-28-2015 12:19 PM
There are some mail attached to PO that cannot be opened by any user (it can be opened but looks like the example.
Other attachments / mails can be read!
In PO the attachment is of type HTM.
Monika
05-28-2015 1:21 PM
05-28-2015 1:56 PM
05-19-2016 7:32 PM