Need Help Sending Email Attachment in CSV Format U... - SAP Community
Need Help Sending Email Attachment in CSV Format U... - SAP Community
- SAP Community
SFactor
Explorer
07-19-2008 3:00 PM
Pr
0 Kudos
'SO_NEW_DOCUMENT_ATT_SEND_API1'.
Has anybody use method method cl_hrrcf_services_mail to do this? Any ideas on how I can do this will be
appreciated.
Thanks
Margariet
Reply 3 REPLIES
Former Member
07-19-2008 3:16 PM
0 Kudos
Hi,
Check this sample code: It calls a smartforms, generates a PDF and sends as attachment to external mailbox.
REPORT ytest_email.
INCLUDE rlb_invoice_data_declare.
https://community.sap.com/t5/application-development-discussions/need-help-sending-email-attachment-in-csv-format-using-method/m-p/420951… 1/6
28/4/24, 16:34 Need help sending email attachment in CSV format u... - SAP Community
DATA:
DATA : recipient TYPE REF TO if_recipient_bcs
if_recipient_bcs..
DATA:
DATA : bcs_exception TYPE REF TO cx_bcs
cx_bcs..
DATA:
DATA : sent_to_all TYPE os_boolean.
os_boolean.
START-OF-SELECTION.
START-OF-SELECTION .
main.
PERFORM main .
*---------------------------------------------------------------------*
* FORM main *
*---------------------------------------------------------------------*
main.
FORM main .
DATA:
DATA : ls_bil_invoice TYPE lbbil_invoice.
lbbil_invoice.
DATA:
DATA : lf_fm_name rs38l_fnam.
TYPE rs38l_fnam .
DATA:
DATA : ls_control_param ssfctrlop.
TYPE ssfctrlop .
DATA:
DATA : ls_composer_param TYPE ssfcompop.
ssfcompop.
DATA:
DATA : ls_recipient swotobjid.
TYPE swotobjid .
DATA:
DATA: ls_sender TYPE swotobjid.
swotobjid.
DATA:
DATA: lf_formname tdsfname.
TYPE tdsfname .
DATA:
DATA : ls_addr_key addr_key.
LIKE addr_key .
DATA:
DATA : ls_dlv
ls_dlv--land vbrk-
LIKE vbrk -land1
land1. .
DATA:
DATA : ls_job_info ssfcrescl.
TYPE ssfcrescl .
DATA:
DATA : I_CUST TYPE SCUSTOM
SCUSTOM.
.
DATA:
DATA: I_BOOK TYPE TY_BOOKINGS,
TY_BOOKINGS,
TY_CONNECTIONS.
I_CONN TYPE TY_CONNECTIONS .
DATA:
DATA : W_I_SIZE TYPE I,
I_DOCS TYPE TABLE OF DOCS,
DOCS,
I_LINES TYPE TABLE OF TLINE.
TLINE.
DATA:
DATA: I_OTF TYPE TSFOTF.
TSFOTF.
DATA:
DATA : I_BIN TYPE SOLIX_TAB
SOLIX_TAB..
data:
data : gd_buffer type string
string,,
it_mess_bod LIKE solisti1 OCCURS 0 WITH HEADER LINE
LINE,,
it_mess_att LIKE solisti1 OCCURS 0 WITH HEADER LINE.
LINE.
.
DATA:
DATA : WA_LINES LIKE LINE OF I_LINES
I_LINES,,
I_BIN.
WA_PDF LIKE LINE OF I_BIN .
DATA:
DATA : PDF_CONTENT TYPE SOLIX_TAB.
SOLIX_TAB.
DATA:
DATA : LP_PDF_SIZE TYPE SO_OBJ_LEN.
SO_OBJ_LEN.
data:
data : w_xstr xstring,
type xstring ,
w_len type i.
TRY.
TRY .
* SF_EXAMPLE_01
https://community.sap.com/t5/application-development-discussions/need-help-sending-email-attachment-in-csv-format-using-method/m-p/420951… 2/6
28/4/24, 16:34 Need help sending email attachment in CSV format u... - SAP Community
ENDIF.
ls_control_param-getotf = 'X'.
ls_control_param-NO_DIALOG = 'X'.
I_OTF = LS_JOB_INFO-OTFDATA[].
endif.
DO.
it_mess_att = gd_buffer.
APPEND it_mess_att.
SHIFT gd_buffer LEFT BY 255 PLACES.
IF gd_buffer IS INITIAL.
https://community.sap.com/t5/application-development-discussions/need-help-sending-email-attachment-in-csv-format-using-method/m-p/420951… 3/6
28/4/24, 16:34 Need help sending email attachment in CSV format u... - SAP Community
EXIT.
EXIT .
ENDIF.
ENDIF .
ENDDO.
ENDDO .
CL_DOCUMENT_BCS=>
PDF_CONTENT = CL_DOCUMENT_BCS=>XSTRING_TO_SOLIX
XSTRING_TO_SOLIX(
( IP_XSTRING = w_xstr ).
* -------- create persistent send request ------------------------
cl_bcs=>
send_request = cl_bcs =>create_persistent
create_persistent(( ).
*
*
* add document to send request
send_request->
CALL METHOD send_request ->set_document
set_document(( document ).
*
* --------- set sender -------------------------------------------
* note: this is necessary only if you want to set the sender
* different from actual user (SY-UNAME). Otherwise sender is
* set automatically with actual user.
*
* sender = cl_sapuser_bcs=>create( sy-uname ).
* CALL METHOD send_request->set_sender
* EXPORTING
* i_sender = sender.
*
* --------- add recipient (e-mail address) -----------------------
* create recipient - please replace e-mail address !!!
cl_cam_address_bcs=>
recipient = cl_cam_address_bcs =>create_internet_address
create_internet_address((
'give email address here' ).
*
* add recipient with its respective attributes to send request
send_request->
CALL METHOD send_request ->add_recipient
add_recipient
EXPORTING
i_recipient = recipient
i_express = 'X'.
'X'.
*
*
cl_sapuser_bcs=>
recipient = cl_sapuser_bcs =>create
create(( sy
sy--uname ).
send_request->
CALL METHOD send_request ->add_recipient
add_recipient
EXPORTING
https://community.sap.com/t5/application-development-discussions/need-help-sending-email-attachment-in-csv-format-using-method/m-p/420951… 4/6
28/4/24, 16:34 Need help sending email attachment in CSV format u... - SAP Community
i_recipient = recipient
i_express = 'X'.
'X'.
*
*
*
* ---------- send document ---------------------------------------
send_request->
CALL METHOD send_request ->send
send((
EXPORTING
i_with_error_screen = 'X'
RECEIVING
result = sent_to_all ).
'X'.
IF sent_to_all = 'X' .
text-003
WRITE text- 003.
.
ENDIF.
ENDIF.
WORK.
COMMIT WORK .
* -----------------------------------------------------------
* * exception handling
* -----------------------------------------------------------
* * replace this very rudimentary exception handling
* * with your own one !!!
* -----------------------------------------------------------
bcs_exception.
CATCH cx_bcs INTO bcs_exception .
WRITE:
WRITE : text-
text-001
001.
.
WRITE:
WRITE : text-
text-002
002,
, bcs_exception
bcs_exception->
->error_type
error_type..
EXIT.
EXIT .
ENDTRY.
ENDTRY .
ENDFORM.
ENDFORM . "main
Reply
SFactor
Explorer
07-25-2008 11:11 AM
0 Kudos
Hi
When I open the attachment all my data is in one line and the format is not correct.
Can somebody please help? I am using function module FUNCTION 'SO_DOCUMENT_SEND_API1' to send
the mail to a Notes email address.
Thanks
Margariet
SAP Managed Tags:
ABAP Development
Reply
https://community.sap.com/t5/application-development-discussions/need-help-sending-email-attachment-in-csv-format-using-method/m-p/420951… 5/6
28/4/24, 16:34 Need help sending email attachment in CSV format u... - SAP Community
Former Member
In response to SFactor
07-25-2008 11:18 AM
0 Kudos
SO_NEW_DOCUMENT_ATT_SEND_API1.
Using se37 go into function module. Read its Documenation. You will find your solution.
regards
rajesh
SAP Managed Tags:
ABAP Development
Reply
https://community.sap.com/t5/application-development-discussions/need-help-sending-email-attachment-in-csv-format-using-method/m-p/420951… 6/6