Import of a logo
Transaction SE78
Enter a name for your logo, select the color BitMap Image and press the Import button.
Smartform creation
Transaction SmartForms
Enter a name and press the button Create
1/15
Version 2
Select the Main Window, click on the right button, select Create --> Graphic
Enter the graphic name, the object and the ID (GRAPHICS / BMAP), select the Color BitMap Image
Select the main window, click on the right button, select Create --> Text
Enter a text ..
Now we could test our Smartform, press the Test button (F8).
SAP launch the SE37 transaction (Function module) with the function generated by the Smartforms.
Press again the test button (F8)
Press now execute (F8)
Choose a printer and press the button Print Preview
2/15
3/15
It works !
START -OF-SELECTION.
* My Smartforms.
MOVE 'ZMY_SMARTFORMS' TO w_formname.
send_error = 3
user_canceled = 4
OTHERS = 5.
END-OF-SELECTION.
START-OF-SELECTION .
* My Smartforms.
MOVE 'ZMY_SMARTFORMS' TO w_formname.
'frederic.girod@everywhere.com'
IMPORTING
ep_recipient_id = is_recipient
EXCEPTIONS
invalid_recipient = 1
OTHERS = 2 .
* Create the Sender
CALL FUNCTION 'CREATE_SENDER_OBJECT_PPF'
EXPORTING
ip_sender = sy - uname
IMPORTING
ep_sender_id = is_sender
EXCEPTIONS
invalid_sender = 1
OTHERS = 2 .
* Create the Mail Obj.
SELECT SINGLE inbyr inbno
4/15
5/15
END-OF-SELECTION.
If you haven't entry in the SOUD table you could add-it dynamically with the function
SO_USER_AUTOMATIC_INSERT.
If you use an entry of the NAST table (configuration with the NACE transaction ..), instead of creating manually the
MAIL_APPL_OBJ, MAIL_RECIPIENT, MAIL_SENDER, you only have to use the function
WFMC_PREPARE_SMART_FORM.
Result
The attachment :
Each time I show that to my users, they didn't want to use that for external mails.
Code
6/15
START-OF-SELECTION .
* My Smartforms.
MOVE 'ZMY_SMARTFORMS' TO w_formname.
7/15
* Ajoute le corps.
CALL METHOD obj_mime_helper ->set_main_html
EXPORTING
content = it_soli
filename = ''
description = 'My mail' .
* Ajoute le titre
8/15
9/15
i_subject = w_title
i_importance = '9' " 1 / 5 / 9
i_multirel_service = obj_mime_helper ).
'frederic.girod@everywhere.com' ).
* Statut change
MOVE 'N' TO w_status .
CALL METHOD obj_bcs - > set_status_attributes
EXPORTING
i_requested_status = w_status.
* Commit Work.
IF sy-subrc EQ space .
COMMIT WORK AND WAIT .
ELSE.
ROLLBACK WORK.
ENDIF.
END-OF -SELECTION.
Result
The data :
10/15
START-OF-SELECTION .
*- - --------- - - - - - - - - - - - - - - --------------------------------- -----------*
* Create the text message *
* - - --------- - - - - - - - - - - - - - - - -------------------------------- -----------*
* My Smartforms.
MOVE 'ZMY_SMARTFORMS_002' TO w_formname.
11/15
EXPORTING
inbuff = w_html_xtxt
incode = '4110'
outcode = '0000'
csubst = 'X'
substc_space = 'X'
IMPORTING
outbuff = w_html_txt
outused = w_html_len
EXCEPTIONS
OTHERS = 5 .
REPLACE ALL OCCURRENCES OF 'utf-8' IN w_html_txt WITH 'latin1'.
w_html_len = strlen ( w_html_txt ).
* Ajoute le corps.
CALL METHOD obj_mime_helper ->set_main_html
EXPORTING
content = it_soli
filename = ''
description = 'My mail' .
* Ajoute le titre
MOVE is_composer_param - tdtitle TO w_title.
12/15
Second part, create the PDF and add in attachment of the mail.
13/15
outbuff = w_xtxt .
CONCATENATE w_gr_xtxt
w_xtxt
INTO w_gr_xtxt
IN BYTE MODE .
ENDLOOP.
w_gr_xtxt = w_gr_xtxt ( w_doc_size).
w_offset = 0.
w_len = 255 .
CLEAR it_solix[] .
WHILE w_offset < w_doc_size .
w_diff = w_doc_size - w_offset .
IF w_diff > w_len .
is_solix- line = w_gr_xtxt+w_offset( w_len).
ELSE.
is_solix- line = w_gr_xtxt+w_offset( w_diff).
ENDIF.
APPEND is_solix TO it_solix .
ADD w_len TO w_offset .
ENDWHILE.
MOVE : 'Attachment' TO w_title ,
'Attachment.pdf' TO w_content_id.
w_content_type = ' ' .
w_obj_len = w_doc_size .
* Statut change
MOVE 'N' TO w_status .
CALL METHOD obj_bcs - > set_status_attributes
EXPORTING
i_requested_status = w_status.
* Commit Work.
IF sy-subrc EQ space .
COMMIT WORK AND WAIT .
ELSE.
ROLLBACK WORK.
ENDIF.
END-OF -SELECTION.
It's a little bit long, but the result is better for the end user.
Result
14/15
858Views
15/15