SO_NEW_DOCUMENT_ATT_SEND_API1 ERROR
Hi Everyone,
I am facing problem when i am calling the function module 'SO_NEW_DOCUMENT_ATT_SEND_API1' the attachment is automatically getting converted into encripted form.
Actually my attachment having only 3 records after the calling the function module its giving 6 record with that converted format.
Please give some of your inputs on this.
Thannks and regards
Lakshman.
Hi Everyone,
I am facing problem when i am calling the function module 'SO_NEW_DOCUMENT_ATT_SEND_API1' the attachment is automatically getting converted into encripted form.
Actually my attachment having only 3 records after the calling the function module its giving 6 record with that converted format.
Please give some of your inputs on this.
Thannks and regards
Lakshman.
Similar Messages
-
Hi all,<br><br>
I am using following code just to send out an email to Users Notifying that Directory is Not empty. No attachment is required.
<br><br><pre>
data: p_file type salfile-longname.
data: ifile type table of salfldir with header line.
data: lt_mailrecipients type standard table of somlrec90 with header line,
lt_mailtxt type standard table of soli with header line,
lt_attachment type standard table of solisti1 with header line,
lt_mailsubject type sodocchgi1,
lt_packing_list type standard table of sopcklsti1 with header line,
gv_cnt type i.
data: v_spool like tsp01-rqident.
p_file = '/usr/sap/tmp'.
call function 'RZL_READ_DIR_LOCAL'
exporting
name = p_file
tables
file_tbl = ifile
exceptions
argument_error = 1
not_found = 2
others = 3.
if ifile[] is initial.
write: 'Empty'.
elseif ifile[] is not initial.
lt_mailrecipients-rec_type = 'U'.
lt_mailrecipients-com_type = 'INT'.
lt_mailrecipients-receiver = '*******''.
append lt_mailrecipients.
clear lt_mailrecipients.
lt_mailtxt = 'Hi How are you'.
append lt_mailtxt. clear lt_mailtxt.
lt_mailtxt = 'direcory not empty'.
append lt_mailtxt. clear lt_mailtxt.
lt_mailsubject-obj_name = 'MAILATTCH'.
lt_mailsubject-obj_langu = sy-langu.
lt_mailsubject-obj_descr = 'You have got mail'.
lt_mailsubject-sensitivty = 'F'.
call function 'SO_NEW_DOCUMENT_ATT_SEND_API1'
exporting
document_data = lt_mailsubject
put_in_outbox = 'X'
commit_work = 'X'
tables
packing_list = lt_packing_list
contents_bin = lt_attachment
contents_txt = lt_mailtxt
receivers = lt_mailrecipients
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 eq 0.
commit work.
write: 'Non Empty'.
submit rsconn01 with mode = 'INT' and return.
endif.
endif.</pre><br><br>
The code runs fine without any error and writes "Non empty" as output but no email is received. We also have "INT - Internet" configured in SCOT, which shows no request.<br>
Please let me know if anything more needs to be configured.<br><br>
Thanks<br><br>
Diksha.<br><br>
<br><br><br><br> Edited by: Matt on Nov 4, 2009 7:58 AM - fixed formattingHi all,
Thanks for your help. I really appreciate it.
Here is my code which works.
*& Report ZBW_KHALIX_BI_CHECK_PRG
report zbw_khalix_bi_check_prg.
data: p_file type epsf-epsdirnam.
data: ifile type table of epsfili with header line.
data: lt_mailrecipients type standard table of somlrec90 with header line,
lt_mailtxt type standard table of soli with header line,
lt_attachment type standard table of solisti1 with header line,
lt_mailsubject type sodocchgi1,
lt_packing_list type standard table of sopcklsti1 with header line,
gv_cnt type i.
data: v_spool like tsp01-rqident.
data: oref type ref to cx_root.
data text type string.
p_file = '/userdata/home/bw_outbound1/temp'.
try.
call function 'EPS_GET_DIRECTORY_LISTING'
exporting
dir_name = p_file
tables
dir_list = ifile
exceptions
invalid_eps_subdir = 1
sapgparam_failed = 2
build_directory_failed = 3
no_authorization = 4
read_directory_failed = 5
too_many_read_errors = 6
empty_directory_list = 7
others = 8.
catch cx_root into oref.
text = oref->get_text( ).
endtry.
if ifile[] is initial.
write: 'Empty'.
elseif ifile[] is not initial.
lt_mailrecipients-rec_type = 'U'.
lt_mailrecipients-com_type = 'INT'.
lt_mailrecipients-receiver = '*****'.
append lt_mailrecipients.
clear lt_mailrecipients.
lt_mailtxt = 'Hi How are you'.
append lt_mailtxt. clear lt_mailtxt.
lt_mailtxt = 'direcory is not empty'.
append lt_mailtxt. clear lt_mailtxt.
lt_mailsubject-obj_name = 'MAILATTCH'.
lt_mailsubject-obj_langu = sy-langu.
lt_mailsubject-obj_descr = 'You have got mail'.
lt_mailsubject-sensitivty = 'F'.
lt_packing_list-transf_bin = space.
lt_packing_list-head_start = 1.
lt_packing_list-head_num = 0.
lt_packing_list-body_start = 1.
lt_packing_list-body_num = lines( lt_mailtxt ).
lt_packing_list-doc_type = 'RAW'.
append lt_packing_list. clear lt_packing_list.
call function 'SO_NEW_DOCUMENT_ATT_SEND_API1'
exporting
document_data = lt_mailsubject
put_in_outbox = 'X'
commit_work = 'X'
tables
packing_list = lt_packing_list
contents_bin = lt_attachment
contents_txt = lt_mailtxt
receivers = lt_mailrecipients
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.
case sy-subrc.
when 1.
write: / 'No authorization for sending to the specified number',
'of recipients'.
when 2.
write: / 'Document could not be sent to any recipient'.
when 4.
write: / 'No send authorization'.
when 5.
write: / 'Parameter error'.
when 6.
write: / 'x_error'.
when 7.
write: / 'enqueue error'.
when 8.
write: / 'Error occurred while sending'.
endcase.
endif.
Can anyone tell me if we can create a .txt file through ABAP?
Thanks
Diksha
Edited by: Diksha Chopra on Nov 4, 2009 8:08 PM -
Hi ALL,
I HAVE THE REQUIREMENT AS SEND A REPORT AS A MAIL. IAM USING FM 'SO_NEW_DOCUMENT_ATT_SEND_API1' WHILE EXECUTING ITS NOT SHOWING ANY ERROR. BUT IAM NOT GETTING ANY MAIL. I CHECKED IN 'SOST' TCODE. THERE I SEE A MESSAGE LIKE 'CANNOT PROCESS THE MSG TYPE IN SAP SYSTEM'. PLS TELL ME THE WHAT IS THE PROBLE.Hi
Please dont write in Capital letters, it considered as shouting. Hope you are aware of the forum rules.
You can check if you have made anything wrong in coding by referring wiki link.
[Sending Mails |http://wiki.sdn.sap.com/wiki/display/ABAP/SendingMails-HomePage]
Regards
Abhii -
ERROR WHILE USING SO_NEW_DOCUMENT_ATT_SEND_API1
An exception occurred that is explained in detail below.
The exception, which is assigned to class 'CX_SY_DYN_CALL_ILLEGAL_TYPE', was
not caught in
procedure "ENTRY_NEU" "(FORM)", nor was it propagated by a RAISING clause.
Since the caller of the procedure could not have anticipated that the
exception would occur, the current program is terminated.
The reason for the exception is:
In the function "SO_NEW_DOCUMENT_ATT_SEND_API1", the STRUCTURE parameter
"CONTENTS_HEX" is typed in such a way
that only actual parameters are allowed, which are compatible in Unicode
with respect to the fragment view. However, the specified actual
parameter "I_OBJBIN" has an incompatible fragment view.
*Declararions Used
*Internal Table declarations
DATA: i_otf TYPE itcoo OCCURS 0 WITH HEADER LINE,
i_tline TYPE TABLE OF tline WITH HEADER LINE,
i_receivers TYPE TABLE OF somlreci1 WITH HEADER LINE,
i_record LIKE solisti1 OCCURS 0 WITH HEADER LINE,
*Objects to send mail.
i_objpack LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,
i_objtxt LIKE solisti1 OCCURS 0 WITH HEADER LINE,
i_objbin LIKE solisti1 OCCURS 0 WITH HEADER LINE,
i_reclist LIKE somlreci1 OCCURS 0 WITH HEADER LINE,
*Work Area declarations
w_objhead TYPE soli_tab,
w_ctrlop TYPE ssfctrlop,
w_compop TYPE ssfcompop,
w_return TYPE ssfcrescl,
w_doc_chng typE sodocchgi1,
w_data TYPE sodocchgi1,
w_buffer TYPE string,"To convert from 132 to 255
Please help me thanks in advance
Points will be rewardedSending External Mail via ABAP
REPORT ZSENDEXTERNAL.
DATA: OBJPACK LIKE SOPCKLSTI1 OCCURS 2 WITH HEADER LINE.
DATA: OBJHEAD LIKE SOLISTI1 OCCURS 1 WITH HEADER LINE.
DATA: OBJBIN LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.
DATA: OBJTXT LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.
DATA: RECLIST LIKE SOMLRECI1 OCCURS 5 WITH HEADER LINE.
DATA: DOC_CHNG LIKE SODOCCHGI1.
DATA: TAB_LINES LIKE SY-TABIX.
Creation of the document to be sent
File Name
DOC_CHNG-OBJ_NAME = 'SENDFILE'.
Mail Subject
DOC_CHNG-OBJ_DESCR = 'Send External Mail'.
Mail Contents
OBJTXT = 'Minimum bid : $250000'.
APPEND OBJTXT.
OBJTXT = 'A representation of the pictures up for auction'.
APPEND OBJTXT.
OBJTXT = 'was included as attachment.'.
APPEND OBJTXT.
DESCRIBE TABLE OBJTXT LINES TAB_LINES.
READ TABLE OBJTXT INDEX TAB_LINES.
DOC_CHNG-DOC_SIZE = ( TAB_LINES - 1 ) * 255 + STRLEN( OBJTXT ).
Creation of the entry for the compressed document
CLEAR OBJPACK-TRANSF_BIN.
OBJPACK-HEAD_START = 1.
OBJPACK-HEAD_NUM = 0.
OBJPACK-BODY_START = 1.
OBJPACK-BODY_NUM = TAB_LINES.
OBJPACK-DOC_TYPE = 'RAW'.
APPEND OBJPACK.
Creation of the document attachment
(Assume that the data in OBJBIN is in BMP format)
*OBJBIN = ' \O/ '. APPEND OBJBIN.
*OBJBIN = ' | '. APPEND OBJBIN.
*OBJBIN = ' / \ '. APPEND OBJBIN.
*DESCRIBE TABLE OBJBIN LINES TAB_LINES.
*OBJHEAD = 'PICTURE.BMP'.
*APPEND OBJHEAD.
Creation of the entry for the compressed attachment
*OBJPACK-TRANSF_BIN = 'X'.
*OBJPACK-HEAD_START = 1.
*OBJPACK-HEAD_NUM = 1.
*OBJPACK-BODY_START = 1.
*OBJPACK-BODY_NUM = TAB_LINES.
*OBJPACK-DOC_TYPE = 'BMP'.
*OBJPACK-OBJ_NAME = 'PICTURE'.
*OBJPACK-OBJ_DESCR = 'Representation of object 138'.
*OBJPACK-DOC_SIZE = TAB_LINES * 255.
*APPEND OBJPACK.
Completing the recipient list
RECLIST-RECEIVER = '[email protected]'.
RECLIST-REC_TYPE = 'U'.
APPEND RECLIST.
*RECLIST-RECEIVER = 'SAPUSERNAME'.
*RECLIST-REC_TYPE = 'P'.
*APPEND RECLIST.
Sending the document
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
DOCUMENT_DATA = DOC_CHNG
PUT_IN_OUTBOX = 'X'
TABLES
PACKING_LIST = OBJPACK
OBJECT_HEADER = OBJHEAD
CONTENTS_BIN = OBJBIN
CONTENTS_TXT = OBJTXT
RECEIVERS = RECLIST
EXCEPTIONS
TOO_MANY_RECEIVERS = 1
DOCUMENT_NOT_SENT = 2
OPERATION_NO_AUTHORIZATION = 4
OTHERS = 99.
CASE SY-SUBRC.
WHEN 0.
WRITE: / 'Result of the send process:'.
LOOP AT RECLIST.
WRITE: / RECLIST-RECEIVER(48), ':'.
IF RECLIST-RETRN_CODE = 0.
WRITE 'The document was sent'.
ELSE.
WRITE 'The document could not be sent'.
ENDIF.
ENDLOOP.
WHEN 1.
WRITE: / 'No authorization for sending to the specified number',
'of recipients'.
WHEN 2.
WRITE: / 'Document could not be sent to any recipient'.
WHEN 4.
WRITE: / 'No send authorization'.
WHEN OTHERS.
WRITE: / 'Error occurred while sending'.
ENDCASE.
Reward if helpful
Regards
Vodka. -
Experts:
I am working on sending Excel as an email attachment thro the function module 'SO_NEW_DOCUMENT_ATT_SEND_API1'
I am able to send mail successfully but I face the following two issues while opening the attachment.
1. While opening it says 'un recognized format' , on pressing 'OK' it opens the excel file.
2. The column heading (first row) which should be in Korean character is displayed in junk char. I tried to
specify the unicode (Code Page = '8500') but does not know how to do it.
I am reading the column header text from standard text.
Please let me know what mistake I have commited in my code and where I should specify the unicode transformation. I refered many samples but could not make it.
Please let me know the error.
The code is as follows.
FORM sendemail_barcodedata.
TYPE-POOLS: truxs.
DATA: objpack LIKE sopcklsti1 OCCURS 2 WITH HEADER LINE.
DATA: objhead LIKE solisti1 OCCURS 1 WITH HEADER LINE.
DATA: objbin LIKE solisti1 OCCURS 10 WITH HEADER LINE.
DATA: objbin1 LIKE solisti1 OCCURS 10 WITH HEADER LINE.
DATA: objtxt LIKE solisti1 OCCURS 10 WITH HEADER LINE.
DATA: reclist LIKE somlreci1 OCCURS 5 WITH HEADER LINE.
DATA: doc_chng LIKE sodocchgi1.
DATA: tab_lines LIKE sy-tabix.
DATA: l_sent_to_all TYPE sonv-flag.
* Creating the document to be sent
* File Name
doc_chng-obj_name = 'BCODEINFO'.
* Mail Subject
doc_chng-obj_descr = 'Delivery Barcode Information'.
* Mail Content
objtxt = 'Hi:'.
APPEND objtxt.
objtxt = 'Find attached, Delivery Barcode Information'.
APPEND objtxt.
CONCATENATE 'Attachment : <<' w_fname1 '>>' INTO objtxt.
APPEND objtxt.
DESCRIBE TABLE objtxt LINES tab_lines.
READ TABLE objtxt INDEX tab_lines.
doc_chng-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objtxt ).
doc_chng-obj_langu = sy-langu.
doc_chng-sensitivty = 'F'.
* Creating the entry for the compressed document
CLEAR objpack-transf_bin.
objpack-head_start = 1.
objpack-head_num = 0.
objpack-body_start = 1.
objpack-body_num = tab_lines.
objpack-doc_type = 'RAW'.
APPEND objpack.
* Creating the document attachment
* Get column names for Barcode Data
CLEAR objbin.
CONCATENATE text-h23
text-h24
text-h25
text-h26
text-h27
INTO objbin SEPARATED BY con_tab .
CONCATENATE objbin con_cret INTO objbin.
APPEND objbin.
CLEAR objbin.
LOOP AT it_excel2 INTO wa_excel2.
CONCATENATE wa_excel2-zz_date
wa_excel2-zz_delivery
wa_excel2-zz_barcode
wa_excel2-blank1
wa_excel2-blank2
INTO objbin SEPARATED BY con_tab.
CONCATENATE objbin con_cret INTO objbin.
APPEND objbin.
CLEAR objbin.
ENDLOOP.
DESCRIBE TABLE objbin LINES tab_lines.
objhead = w_fname1.
APPEND objhead.
* Creating the entry for the compressed attachment
objpack-transf_bin = 'X'.
objpack-head_start = 1.
objpack-head_num = 1.
objpack-body_start = 1.
objpack-body_num = tab_lines.
objpack-doc_type = 'XLS'.
objpack-obj_name = 'Barcode Information'.
objpack-obj_descr = 'Barcode Information'.
objpack-doc_size = tab_lines * 255.
APPEND objpack.
* Entering names in the distribution list
reclist-receiver = p_email.
reclist-rec_type = 'U'.
APPEND reclist.
* Sending the document
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = doc_chng
put_in_outbox = ' '
commit_work = 'X'
IMPORTING
sent_to_all = l_sent_to_all
TABLES
packing_list = objpack
object_header = objhead
contents_bin = objbin
contents_txt = objtxt
receivers = reclist
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.
CASE sy-subrc.
WHEN 0.
MESSAGE i000(z65f_msgclass) WITH text-211.
WHEN 1.
WRITE: / 'no authorization to send to the specified number of'.
WHEN 2.
WRITE: / 'document could not be sent to any of the recipients!'.
WHEN 4.
WRITE: / 'no authorization to send !'.
WHEN OTHERS.
WRITE: / 'error occurred during sending !'.
ENDCASE.
ENDFORM.
Thanks in advance.
Regards
VijaiHi:
Can any one provide me a solution for this?
regards
vijai -
Hi all,
I'm currently using SO_NEW_DOCUMENT_ATT_SEND_API1 to send out the email and together with a pdf attachment. However when I tried to open the attachment, it has the decoded incorrectly error.
What am I missing?
Thanks.
Below is the code, this is just testing purposes. I apologized for the messy code.
DATA: OBJPACK LIKE SOPCKLSTI1 OCCURS 2 WITH HEADER LINE.
DATA: OBJHEAD LIKE SOLISTI1 OCCURS 1 WITH HEADER LINE.
DATA: OBJBIN LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.
DATA: OBJTXT LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.
DATA: RECLIST LIKE SOMLRECI1 OCCURS 5 WITH HEADER LINE.
DATA: DOC_CHNG LIKE SODOCCHGI1.
DATA: TAB_LINES LIKE SY-TABIX.
DATA: l_functionmodule TYPE rs38l_fnam.
DATA: l_spoolid TYPE rspoid,
l_control_parameters TYPE ssfctrlop,
l_output_options TYPE ssfcompop,
l_user_settings TYPE tdbool VALUE ' ',
l_document_output_info TYPE ssfcrespd,
l_job_output_info TYPE ssfcrescl,
l_job_output_options TYPE ssfcresop,
l_spoolid_del TYPE rqident,
l_status TYPE sysubrc,
li_table01 TYPE TABLE OF YGLXX_PDF_S_TABLE,
lw_table01 LIKE YGLXX_PDF_S_TABLE,
bin TYPE xstring.
DATA: i_otfdata TYPE STANDARD TABLE OF itcoo INITIAL SIZE 0.
DATA: l_otfdata TYPE itcoo.
DATA: lv_bytes TYPE p,
lv_bin_file TYPE xstring,
gt_pdfdata TYPE STANDARD TABLE OF tline INITIAL SIZE 0,
CONTENT_OUT TYPE TABLE OF SOLISTI1.
data: begin of itab occurs 0,
line(255) type c,
end of itab.
Creating the document to be sent
DOC_CHNG-OBJ_NAME = 'OFFER'.
DOC_CHNG-OBJ_DESCR = 'Auction of a Picasso jr'.
OBJTXT = 'Reserve price : $250000'.
APPEND OBJTXT.
OBJTXT = 'A reproduction of the painting to be auctioned'.
APPEND OBJTXT.
OBJTXT = 'is enclosed as an attachment.'.
APPEND OBJTXT.
DESCRIBE TABLE OBJTXT LINES TAB_LINES.
READ TABLE OBJTXT INDEX TAB_LINES.
DOC_CHNG-DOC_SIZE = ( TAB_LINES - 1 ) * 255 + STRLEN( OBJTXT ).
Creating the entry for the compressed document
CLEAR OBJPACK-TRANSF_BIN.
OBJPACK-HEAD_START = 1.
OBJPACK-HEAD_NUM = 0.
OBJPACK-BODY_START = 1.
OBJPACK-BODY_NUM = TAB_LINES.
OBJPACK-DOC_TYPE = 'RAW'.
APPEND OBJPACK.
Creating the document attachment (PDF)
Get Function Module of Smartform
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = 'YGLPA_IDR'
IMPORTING
fm_name = l_functionmodule
EXCEPTIONS
no_form = 1
no_function_module = 2
OTHERS = 3.
Set Print Parameters
l_control_parameters-langu = 'EN'.
l_control_parameters-no_dialog = 'X'.
l_control_parameters-getotf = 'X'.
l_output_options-tddest = 'LOCL'.
LOOP AT li_table01 INTO lw_table01.
lw_table01-line = '0002'.
APPEND lw_table01 TO li_table01.
ENDLOOP.
Call Smartform Function Module
CALL FUNCTION l_functionmodule
EXPORTING
control_parameters = l_control_parameters
output_options = l_output_options
user_settings = l_user_settings
pernr = '20'
begda = sy-datum
endda = '99991231'
langu = sy-langu
audience = ''
data01 = ''
data02 = ''
data03 = ''
data04 = ''
data05 = ''
IMPORTING
document_output_info = l_document_output_info
job_output_info = l_job_output_info
job_output_options = l_job_output_options
TABLES
table01 = li_table01
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
OTHERS = 5.
Populate OTF data table
LOOP AT l_job_output_info-otfdata INTO l_otfdata.
APPEND l_otfdata TO i_otfdata.
CLEAR l_otfdata.
ENDLOOP. " LOOP AT t_outtab-otfdata
Convert OTF into PDF
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF'
IMPORTING
bin_filesize = lv_bytes
bin_file = bin
TABLES
otf = i_otfdata
lines = gt_pdfdata
EXCEPTIONS
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 3
OTHERS = 4.
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
EXPORTING
BUFFER = bin
TABLES
BINARY_TAB = itab
objbin = itab.
APPEND objbin.
DESCRIBE TABLE OBJBIN LINES TAB_LINES.
*OBJHEAD = 'attach.pdf'. APPEND OBJHEAD.
Creating the entry for the compressed attachment
OBJPACK-TRANSF_BIN = 'X'.
OBJPACK-HEAD_START = 1.
OBJPACK-HEAD_NUM = 1.
OBJPACK-BODY_START = 1.
OBJPACK-BODY_NUM = TAB_LINES.
OBJPACK-DOC_TYPE = 'PDF'.
OBJPACK-OBJ_NAME = 'ATTACHMENT'.
OBJPACK-OBJ_DESCR = 'Attachment'.
OBJPACK-DOC_SIZE = TAB_LINES * 255.
APPEND OBJPACK..
Entering names in the distribution list
RECLIST-RECEIVER = '<emailadd>'.
RECLIST-REC_TYPE = 'U'.
APPEND RECLIST.
RECLIST-RECEIVER = 'DLI-NEUREICH'.
RECLIST-REC_TYPE = 'P'.
APPEND RECLIST.
Sending the document
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
DOCUMENT_DATA = DOC_CHNG
PUT_IN_OUTBOX = 'X'
COMMIT_WORK = 'X'
TABLES
PACKING_LIST = OBJPACK
OBJECT_HEADER = OBJHEAD
CONTENTS_BIN = OBJBIN
CONTENTS_TXT = OBJTXT
CONTENTS_HEX = itab
RECEIVERS = RECLIST
EXCEPTIONS
TOO_MANY_RECEIVERS = 1
DOCUMENT_NOT_SENT = 2
OPERATION_NO_AUTHORIZATION = 4
OTHERS = 99.
CASE SY-SUBRC.
WHEN 0.
WRITE: / 'Result of the send process:'.
LOOP AT RECLIST.
WRITE: / RECLIST-RECEIVER(48), ':'.
IF RECLIST-RETRN_CODE = 0.
WRITE 'sent successfully'.
ELSE.
WRITE 'not sent'.
ENDIF.
ENDLOOP.
WHEN 1.
WRITE: / 'no authorization to send to the specified number of recipients!'.
WHEN 2.
WRITE: / 'document could not be sent to any of the recipients!'.
WHEN 4.
WRITE: / 'no authorization to send !'.
WHEN OTHERS.
WRITE: / 'error occurred during sending !'.
ENDCASE.Hi all,
I'm currently using SO_NEW_DOCUMENT_ATT_SEND_API1 to send out the email and together with a pdf attachment. However when I tried to open the attachment, it has the decoded incorrectly error.
What am I missing?
Thanks.
Below is the code, this is just testing purposes. I apologized for the messy code.
DATA: OBJPACK LIKE SOPCKLSTI1 OCCURS 2 WITH HEADER LINE.
DATA: OBJHEAD LIKE SOLISTI1 OCCURS 1 WITH HEADER LINE.
DATA: OBJBIN LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.
DATA: OBJTXT LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.
DATA: RECLIST LIKE SOMLRECI1 OCCURS 5 WITH HEADER LINE.
DATA: DOC_CHNG LIKE SODOCCHGI1.
DATA: TAB_LINES LIKE SY-TABIX.
DATA: l_functionmodule TYPE rs38l_fnam.
DATA: l_spoolid TYPE rspoid,
l_control_parameters TYPE ssfctrlop,
l_output_options TYPE ssfcompop,
l_user_settings TYPE tdbool VALUE ' ',
l_document_output_info TYPE ssfcrespd,
l_job_output_info TYPE ssfcrescl,
l_job_output_options TYPE ssfcresop,
l_spoolid_del TYPE rqident,
l_status TYPE sysubrc,
li_table01 TYPE TABLE OF YGLXX_PDF_S_TABLE,
lw_table01 LIKE YGLXX_PDF_S_TABLE,
bin TYPE xstring.
DATA: i_otfdata TYPE STANDARD TABLE OF itcoo INITIAL SIZE 0.
DATA: l_otfdata TYPE itcoo.
DATA: lv_bytes TYPE p,
lv_bin_file TYPE xstring,
gt_pdfdata TYPE STANDARD TABLE OF tline INITIAL SIZE 0,
CONTENT_OUT TYPE TABLE OF SOLISTI1.
data: begin of itab occurs 0,
line(255) type c,
end of itab.
Creating the document to be sent
DOC_CHNG-OBJ_NAME = 'OFFER'.
DOC_CHNG-OBJ_DESCR = 'Auction of a Picasso jr'.
OBJTXT = 'Reserve price : $250000'.
APPEND OBJTXT.
OBJTXT = 'A reproduction of the painting to be auctioned'.
APPEND OBJTXT.
OBJTXT = 'is enclosed as an attachment.'.
APPEND OBJTXT.
DESCRIBE TABLE OBJTXT LINES TAB_LINES.
READ TABLE OBJTXT INDEX TAB_LINES.
DOC_CHNG-DOC_SIZE = ( TAB_LINES - 1 ) * 255 + STRLEN( OBJTXT ).
Creating the entry for the compressed document
CLEAR OBJPACK-TRANSF_BIN.
OBJPACK-HEAD_START = 1.
OBJPACK-HEAD_NUM = 0.
OBJPACK-BODY_START = 1.
OBJPACK-BODY_NUM = TAB_LINES.
OBJPACK-DOC_TYPE = 'RAW'.
APPEND OBJPACK.
Creating the document attachment (PDF)
Get Function Module of Smartform
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = 'YGLPA_IDR'
IMPORTING
fm_name = l_functionmodule
EXCEPTIONS
no_form = 1
no_function_module = 2
OTHERS = 3.
Set Print Parameters
l_control_parameters-langu = 'EN'.
l_control_parameters-no_dialog = 'X'.
l_control_parameters-getotf = 'X'.
l_output_options-tddest = 'LOCL'.
LOOP AT li_table01 INTO lw_table01.
lw_table01-line = '0002'.
APPEND lw_table01 TO li_table01.
ENDLOOP.
Call Smartform Function Module
CALL FUNCTION l_functionmodule
EXPORTING
control_parameters = l_control_parameters
output_options = l_output_options
user_settings = l_user_settings
pernr = '20'
begda = sy-datum
endda = '99991231'
langu = sy-langu
audience = ''
data01 = ''
data02 = ''
data03 = ''
data04 = ''
data05 = ''
IMPORTING
document_output_info = l_document_output_info
job_output_info = l_job_output_info
job_output_options = l_job_output_options
TABLES
table01 = li_table01
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
OTHERS = 5.
Populate OTF data table
LOOP AT l_job_output_info-otfdata INTO l_otfdata.
APPEND l_otfdata TO i_otfdata.
CLEAR l_otfdata.
ENDLOOP. " LOOP AT t_outtab-otfdata
Convert OTF into PDF
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF'
IMPORTING
bin_filesize = lv_bytes
bin_file = bin
TABLES
otf = i_otfdata
lines = gt_pdfdata
EXCEPTIONS
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 3
OTHERS = 4.
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
EXPORTING
BUFFER = bin
TABLES
BINARY_TAB = itab
objbin = itab.
APPEND objbin.
DESCRIBE TABLE OBJBIN LINES TAB_LINES.
*OBJHEAD = 'attach.pdf'. APPEND OBJHEAD.
Creating the entry for the compressed attachment
OBJPACK-TRANSF_BIN = 'X'.
OBJPACK-HEAD_START = 1.
OBJPACK-HEAD_NUM = 1.
OBJPACK-BODY_START = 1.
OBJPACK-BODY_NUM = TAB_LINES.
OBJPACK-DOC_TYPE = 'PDF'.
OBJPACK-OBJ_NAME = 'ATTACHMENT'.
OBJPACK-OBJ_DESCR = 'Attachment'.
OBJPACK-DOC_SIZE = TAB_LINES * 255.
APPEND OBJPACK..
Entering names in the distribution list
RECLIST-RECEIVER = '<emailadd>'.
RECLIST-REC_TYPE = 'U'.
APPEND RECLIST.
RECLIST-RECEIVER = 'DLI-NEUREICH'.
RECLIST-REC_TYPE = 'P'.
APPEND RECLIST.
Sending the document
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
DOCUMENT_DATA = DOC_CHNG
PUT_IN_OUTBOX = 'X'
COMMIT_WORK = 'X'
TABLES
PACKING_LIST = OBJPACK
OBJECT_HEADER = OBJHEAD
CONTENTS_BIN = OBJBIN
CONTENTS_TXT = OBJTXT
CONTENTS_HEX = itab
RECEIVERS = RECLIST
EXCEPTIONS
TOO_MANY_RECEIVERS = 1
DOCUMENT_NOT_SENT = 2
OPERATION_NO_AUTHORIZATION = 4
OTHERS = 99.
CASE SY-SUBRC.
WHEN 0.
WRITE: / 'Result of the send process:'.
LOOP AT RECLIST.
WRITE: / RECLIST-RECEIVER(48), ':'.
IF RECLIST-RETRN_CODE = 0.
WRITE 'sent successfully'.
ELSE.
WRITE 'not sent'.
ENDIF.
ENDLOOP.
WHEN 1.
WRITE: / 'no authorization to send to the specified number of recipients!'.
WHEN 2.
WRITE: / 'document could not be sent to any of the recipients!'.
WHEN 4.
WRITE: / 'no authorization to send !'.
WHEN OTHERS.
WRITE: / 'error occurred during sending !'.
ENDCASE. -
Error Sending Mail Using FM 'SO_NEW_DOCUMENT_ATT_SEND_API1'
Dear All,
I am calling the function module 'SO_NEW_DOCUMENT_ATT_SEND_API1' inside the program to send mail to ( i.e [email protected]) either yahoo or gmail or etc.
After calling this function module i am getting error message ''Document could not be sent to any recipient'' i.e sy-subrc = 2.
But i am using same function module with SAPUSER ID as a receiver list its working fine.
Please let me know why this problem comming to send email to extenal.
Sending the document
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = doc_chng
put_in_outbox = 'X'
COMMIT_WORK = 'X'
TABLES
packing_list = g_t_packing
object_header = g_t_objheader
contents_txt = g_t_objtxt
receivers = g_t_receivers
EXCEPTIONS
too_many_receivers = 1
document_not_sent = 2
operation_no_authorization = 4
OTHERS = 99.
CASE sy-subrc.
WHEN 0.
WRITE 'The document was sent'.
WHEN 1.
WRITE: / 'No authorization for sending to the specified number',
'of recipients'.
WHEN 2.
WRITE: / 'Document could not be sent to any recipient'.
WHEN 4.
WRITE: / 'No send authorization'.
WHEN OTHERS.
WRITE: / 'Error occurred while sending'.
ENDCASE.TABLES
packing_list = g_t_packing
object_header = g_t_objheader
contents_txt = g_t_objtxt
receivers = g_t_receivers
where is hte body of the content ?
i think this is missing .
<b>contents_bin</b> = objbin
just check the same
regards,
vijay -
Error in using FM 'SO_NEW_DOCUMENT_ATT_SEND_API1'
Hi,Guy ,
Now I want to send mail with attachment in my workflow step to the approver . someone advise me to use the FM 'SO_NEW_DOCUMENT_ATT_SEND_API1' . but, when I run the report ,the system show me the error message 'Document no sent' . whehter i omit some basic configuration or my source code is wrong ? can someone send my the correct simple code or document material ?
Thanks in advance .
Jialiang.QiuHi,
Please see the function module documentation for sample code.
I recommend you check the following blogs also.
<a href="/people/thomas.jung3/blog/2004/09/08/sending-e-mail-from-abap--version-610-and-higher--bcs-interface">Sending E-Mail from ABAP - Version 610 and Higher - BCS Interface</a>
<a href="/people/gregor.wolf3/blog/2006/05/25/extend-thomas-jung146s-simple-mail-function-with-attachment-filename Thomas Jungs simple mail function with Attachment Filename</a>
<a href="/people/thomas.jung3/blog/2004/09/07/sending-e-mail-from-abap--version-46d-and-lower--api-interface">Sending E-Mail from ABAP - Version 46D and Lower - API Interface</a>
Cheers,
Ramki Maley. -
Output File error (SO_NEW_DOCUMENT_ATT_SEND_API1)
Dear Experts,
I am sending a text attachment through SO_NEW_DOCUMENT_ATT_SEND_API1,
the mail attachment contains everything right till 127th char,
after that the data is not coming instead some special characters are coming.
Below I am sending the sample of the file i n which u can sewe that after the 127th char i.e. closu---->爀攀(Special char are coming)
LR No.,Vehicle No.,Route Name,Consigner Name,Consignee Name,Dispatch Date,Dispatch Time,Carrier Name,Expected Consignment Closu 爀攀 u2020
327457,MH12327457,Pune-hosur,TIPD Hinjewadi TATA AUTOCOMP SYSTEMS LTD.,Ashok Leyland hosur,18.02.2010,12:21:21,,u2020
Thanks for your support and co-operation
Regards,
VikasHi,
I did not get it,
Got a CR/LF (carriage return, line feed hex '0D0A') stuck on the end of the line? That's what it looks like to me...
can u please elobrate it,
Thanks for your response,
Regards.
Vikas -
Dear Experts,
My requirement is that i need to send the PDF attachment via Outlook Express as Mail. I am using the FM "SO_NEW_DOCUMENT_ATT_SEND_API1" for sending to Outlook Express. Here i need to check "Commit work" flag. Else it will not be sent to the mail. When i do this, i am getting the short dump saying "MESSAGE_TYPE_X" - Pre_commit check.
Is the above issue related to any configuration settings done by Basis. I checked the forum but i could not get suitable post.
Kindly help me in this regard.
Regards,
Ramesh ManoharanHi Ramesh,
Check subrc and RETRN_CODE value for the table RECEIVERS. If subrc is inintial and Return_code is fine.
Then check with your basis team. They might need to do some config change.
I have used used a Z-FM to do this job. Find the code below.
FUNCTION z_send_pdf_2_email .
*"*"Local Interface:
*" IMPORTING
*" VALUE(EMAILID) TYPE INTAD
*" VALUE(SUBJECT) TYPE CHAR200
*" VALUE(ATTACH_NAME) TYPE CHAR200
*" VALUE(PONUM) TYPE EBELN
*" VALUE(PODATE) TYPE BEDAT
*" EXPORTING
*" REFERENCE(RETURN) TYPE SUBRC
*" TABLES
*" I_OTF STRUCTURE ITCOO
TYPES : t_record TYPE solisti1,
t_objpack TYPE sopcklsti1,
t_objtxt TYPE solisti1,
t_reclist TYPE somlreci1.
DATA : l_lines_bin TYPE i,
l_lines_txt TYPE i,
l_len_in TYPE sood-objlen,
l_date TYPE char10,
i_record TYPE TABLE OF t_record,
i_objpack TYPE TABLE OF t_objpack,
i_objtxt TYPE TABLE OF t_objtxt,
i_objbin TYPE TABLE OF t_objtxt,
i_reclist TYPE TABLE OF t_reclist,
i_tline TYPE TABLE OF tline,
w_record TYPE t_record,
w_objpack TYPE t_objpack,
w_objtxt TYPE t_objtxt,
w_objbin TYPE t_objtxt,
w_reclist TYPE t_reclist,
w_tline TYPE tline,
w_doc_chng TYPE sodocchgi1,
w_buffer TYPE string,
w_objhead TYPE soli_tab.
CONSTANTS: c_smart(5) TYPE c VALUE 'SMART',
c_u TYPE c VALUE 'U',
c_raw(3) TYPE c VALUE 'RAW',
c_f TYPE c VALUE 'F',
c_pdf(3) TYPE c VALUE'PDF',
c_x TYPE c VALUE 'X'.
* Convert OTF data to PDF
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = c_pdf
max_linewidth = 132
IMPORTING
bin_filesize = l_len_in
TABLES
otf = i_otf
lines = i_tline
EXCEPTIONS
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 3
err_bad_otf = 4
OTHERS = 5.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
LOOP AT i_tline INTO w_tline.
TRANSLATE w_tline USING '~'.
CONCATENATE w_buffer w_tline INTO w_buffer.
ENDLOOP.
TRANSLATE w_buffer USING '~'.
DO.
w_record = w_buffer.
APPEND w_record TO i_record.
SHIFT w_buffer LEFT BY 255 PLACES.
IF w_buffer IS INITIAL.
EXIT.
ENDIF.
ENDDO.
* Attachment
REFRESH: i_reclist,
i_objtxt,
i_objbin,
i_objpack.
CLEAR w_objhead.
i_objbin[] = i_record[].
CONCATENATE podate+6(2) '.' podate+4(2) '.' podate(4) INTO l_date.
* Create Message Body Title and Description
w_objtxt = text-003.
APPEND w_objtxt TO i_objtxt.
CLEAR w_objtxt.
CONCATENATE l_date text-004 ponum text-005 INTO w_objtxt SEPARATED BY space.
APPEND w_objtxt TO i_objtxt.
CLEAR: w_objtxt, l_date.
w_objtxt = text-006.
APPEND w_objtxt TO i_objtxt.
CLEAR w_objtxt.
w_objtxt = space.
APPEND w_objtxt TO i_objtxt.
CLEAR w_objtxt.
w_objtxt = text-007.
APPEND w_objtxt TO i_objtxt.
CLEAR w_objtxt.
w_objtxt = space.
APPEND w_objtxt TO i_objtxt.
CLEAR w_objtxt.
w_objtxt = text-008.
APPEND w_objtxt TO i_objtxt.
CLEAR w_objtxt.
DESCRIBE TABLE i_objtxt LINES l_lines_txt.
READ TABLE i_objtxt INTO w_objtxt INDEX l_lines_txt.
w_doc_chng-obj_name = subject.
w_doc_chng-expiry_dat = sy-datum + 10.
w_doc_chng-obj_descr = subject.
w_doc_chng-sensitivty = c_f.
w_doc_chng-doc_size = l_lines_txt * 255.
*Main Text
CLEAR w_objpack-transf_bin.
w_objpack-head_start = 1.
w_objpack-head_num = 0.
w_objpack-body_start = 1.
w_objpack-body_num = l_lines_txt.
w_objpack-doc_type = c_raw.
APPEND w_objpack TO i_objpack.
CLEAR w_objpack.
* Attachment (pdf-Attachment)
w_objpack-transf_bin = c_x.
w_objpack-head_start = 1.
w_objpack-head_num = 0.
w_objpack-body_start = 1.
DESCRIBE TABLE i_objbin LINES l_lines_bin.
READ TABLE i_objbin INTO w_objbin INDEX l_lines_bin.
w_objpack-doc_size = l_lines_bin * 255 .
w_objpack-body_num = l_lines_bin.
w_objpack-doc_type = c_pdf.
w_objpack-obj_name = c_smart.
w_objpack-obj_descr = attach_name.
APPEND w_objpack TO i_objpack.
CLEAR w_reclist.
w_reclist-receiver = emailid.
w_reclist-rec_type = c_u.
APPEND w_reclist TO i_reclist.
CLEAR:w_reclist.
* Send Mail
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = w_doc_chng
put_in_outbox = c_x
* commit_work = c_x
TABLES
packing_list = i_objpack
object_header = w_objhead
contents_bin = i_objbin
contents_txt = i_objtxt
receivers = i_reclist
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.
ENDIF.
READ TABLE i_reclist INTO w_reclist INDEX 1.
IF sy-subrc IS INITIAL.
return = w_reclist-retrn_code.
ENDIF.
*Clear Refresh Data
CLEAR: l_lines_bin,
l_lines_txt,
l_len_in,
i_record,
i_objpack,
i_objtxt,
i_objbin,
i_reclist,
i_tline,
w_record,
w_objpack,
w_objtxt,
w_objbin,
w_reclist,
w_tline,
w_doc_chng,
w_buffer,
w_objhead.
REFRESH:i_record,
i_objpack,
i_objtxt,
i_objbin,
i_reclist,
i_tline.
ENDFUNCTION. -
Attaching text file using SO_NEW_DOCUMENT_ATT_SEND_API1
hello guys, i'm a newbie here.
I'm having trouble attaching an existing text file using function 'SO_NEW_DOCUMENT_ATT_SEND_API1'. It seems i can't find the right combination of parameters that are being passed to this function.
first, i'm using WS_UPLOAD to upload the text file to an internal table then i'm creating all the neccessary internal tables that will be use by this function..
By the way, i'm trying to send mail w/ attachments to external mail and SAPids. Below is my code.
REPORT ZHR_TESTEMAIL .
TABLES: USR02, PA0105, SOSU, SOUC, RLGRAP, IBIPPARMS, DYNPREAD, RSCSEL.
DATA: FOLD_YR(2) TYPE C,
FOLD_TYPE(3) TYPE C,
G_HEADER LIKE SOOD2,
G_FOLMAM LIKE SOFM2,
METHOD1 LIKE SY-UCOMM,
G_DOCUMENT LIKE SOOD4,
G_USER LIKE SOUDNAMEI1,
FOLD_NUMBER(12) TYPE C,
G_NEW_PARENT LIKE SOODK,
G_OWNER LIKE SOUD-USRNAM,
G_REF_DOCUMENT LIKE SOOD4,
G_USER_DATA LIKE SOUDATAI1,
G_AUTHORITY LIKE SOFA-USRACC,
G_OBJCNT LIKE SOLI OCCURS 0 WITH HEADER LINE,
G_OBJHEAD LIKE SOLI OCCURS 0 WITH HEADER LINE,
G_OBJPARA LIKE SELC OCCURS 0 WITH HEADER LINE,
G_OBJPARB LIKE SOOP1 OCCURS 0 WITH HEADER LINE,
G_RECIPIENTS LIKE SOOS1 OCCURS 0 WITH HEADER LINE,
G_REFERENCES LIKE SOXRL OCCURS 0 WITH HEADER LINE,
G_ATTACHMENTS LIKE SOOD5 OCCURS 0 WITH HEADER LINE.
DATA: BEGIN OF G_FILES OCCURS 10 ,
TEXT(4096) TYPE C,
END OF G_FILES.
DATA: BEGIN OF IT_WS_FILE OCCURS 0,
WS_FILE LIKE RLGRAP-FILENAME,
END OF IT_WS_FILE.
DATA: BEGIN OF IT_SAPID OCCURS 0,
SAPID LIKE USR02-BNAME,
END OF IT_SAPID.
DATA: BEGIN OF IT_EMAIL OCCURS 0,
EMAILADD LIKE PA0105-USRID_LONG,
END OF IT_EMAIL.
DATA: BEGIN OF IT_TSP01 OCCURS 0.
INCLUDE STRUCTURE TSP01.
DATA: END OF IT_TSP01.
DATA: BEGIN OF TAB2 OCCURS 50,
TEXT(200) TYPE C,
END OF TAB2.
DATA: V_DOCDATA TYPE SODOCCHGI1,
V_OBJPACK LIKE SOPCKLSTI1 OCCURS 0 WITH HEADER LINE,
V_OBJHEAD LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
V_OBJTXT LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
V_OBJBIN LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
V_OBJHEX LIKE SOLIX OCCURS 0 WITH HEADER LINE,
IT_RECVRS TYPE SOMLRECI1 OCCURS 0 WITH HEADER LINE,
IT_CONTNT TYPE SOLISTI1 OCCURS 0 WITH HEADER LINE,
IT_BODY LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE,
V_TLIN TYPE I,
V_LINE TYPE I.
DATA: BEGIN OF IT_TEXTLINE OCCURS 500,
TEXTLINE(5000),
END OF IT_TEXTLINE.
DATA: FYL LIKE RLGRAP-FILENAME,
GV_SUBNO LIKE SOSU-SUBNO,
GV_EMAIL LIKE PA0105-USRID_LONG,
GV_NEXTDAY LIKE SY-DATUM,
YEAR(4) TYPE C,
RECFLAG TYPE C.
SELECTION-SCREEN BEGIN OF BLOCK PARAM WITH FRAME TITLE TEXT-001.
PARAMETERS: SUBJ(254) TYPE C OBLIGATORY, "Subject
DESC(254) TYPE C. "Message
SELECT-OPTIONS: SAPID FOR USR02-BNAME NO INTERVALS. "Recipient's SAP ID
SELECT-OPTIONS: EMAILADD FOR PA0105-USRID_LONG NO INTERVALS.
SELECTION-SCREEN END OF BLOCK PARAM.
SELECTION-SCREEN BEGIN OF BLOCK PARAM2 WITH FRAME TITLE TEXT-002.
SELECT-OPTIONS: WS_FILE FOR DYNPREAD-FIELDNAME NO INTERVALS.
SELECTION-SCREEN END OF BLOCK PARAM2.
SELECTION-SCREEN BEGIN OF BLOCK PARAM3 WITH FRAME TITLE TEXT-003.
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS: RBUT1 RADIOBUTTON GROUP A USER-COMMAND BUT. "Local PC
SELECTION-SCREEN COMMENT 5(20) FOR FIELD RBUT1.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS: RBUT2 RADIOBUTTON GROUP A. "Server
SELECTION-SCREEN COMMENT 5(20) FOR FIELD RBUT2.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS: RBUT3 RADIOBUTTON GROUP A. "Spool
SELECTION-SCREEN COMMENT 5(20) FOR FIELD RBUT3.
PARAMETERS: SPOOLNUM LIKE RSPOTYPE-RQNUMBER. "Spool Number
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK PARAM3.
SELECTION-SCREEN BEGIN OF BLOCK PROC WITH FRAME TITLE TEXT-004.
SELECTION-SCREEN BEGIN OF LINE.
PARAMETER: BPROC AS CHECKBOX USER-COMMAND BCK. "Background Processing
SELECTION-SCREEN COMMENT 5(50) FOR FIELD BPROC.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK PROC.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR WS_FILE-LOW.
DATA: WS_FILE_TEMP TYPE IBIPPARMS-PATH.
CLEAR: WS_FILE_TEMP.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
PROGRAM_NAME = SY-REPID
DYNPRO_NUMBER = SY-DYNNR
FIELD_NAME = 'WS_FILE'
IMPORTING
FILE_NAME = WS_FILE_TEMP.
WS_FILE-LOW = WS_FILE_TEMP.
AT SELECTION-SCREEN.
SELECT SAPNAM FROM SOUC
INTO TABLE IT_SAPID
WHERE SAPNAM IN SAPID
AND DELETED = ''.
GV_NEXTDAY = SY-DATUM + 1.
LOOP AT EMAILADD.
IT_EMAIL-EMAILADD = EMAILADD-LOW.
APPEND IT_EMAIL.
CLEAR: IT_EMAIL.
ENDLOOP.
IF NOT BPROC IS INITIAL.
CLEAR: RBUT1, RBUT3.
RBUT2 = 'X'.
ELSE.
CLEAR: RBUT2.
ENDIF.
IF NOT RBUT3 IS INITIAL.
REFRESH: WS_FILE.
ENDIF.
IF SAPID IS INITIAL AND EMAILADD IS INITIAL.
MESSAGE E000(ZZ) WITH TEXT-201.
ELSEIF NOT SAPID IS INITIAL AND EMAILADD IS INITIAL.
CLEAR IT_SAPID.
READ TABLE IT_SAPID.
SELECT SINGLE SUBNO FROM SOSU
INTO GV_SUBNO
WHERE USRNO IN ( SELECT USRNO FROM SOUC
WHERE SAPNAM = IT_SAPID-SAPID ).
IF SY-SUBRC NE 0.
MESSAGE E000(ZZ) WITH TEXT-202.
ENDIF.
CLEAR: IT_SAPID.
ELSEIF NOT SAPID IS INITIAL AND NOT EMAILADD IS INITIAL.
CLEAR: IT_SAPID, IT_EMAIL.
READ TABLE IT_SAPID.
READ TABLE IT_EMAIL.
SELECT SINGLE SUBNO FROM SOSU
INTO GV_SUBNO
WHERE USRNO IN ( SELECT USRNO FROM SOUC
WHERE SAPNAM = IT_SAPID-SAPID ).
IF SY-SUBRC NE 0.
SUBMIT RSSOADM0 WITH USRNAM EQ IT_SAPID-SAPID
WITH NEW_SUBS EQ IT_EMAIL-EMAILADD
WITH SUB_ESC EQ 'U'
WITH EDAT EQ SY-DATUM
WITH BDAT EQ SY-DATUM
WITH BDAT EQ GV_NEXTDAY
WITH EDAT EQ '99991231'
WITH BTIM EQ SY-UZEIT
WITH ETIM EQ '240000'
WITH FORW_ALL EQ 'X'
WITH PSTHR2 EQ ''
AND RETURN.
ENDIF.
CLEAR: IT_SAPID.
ELSEIF NOT EMAILADD IS INITIAL AND SAPID IS INITIAL.
RECFLAG = 'X'.
ENDIF.
START-OF-SELECTION.
PERFORM B_SENDMAIL.
FORM B_SENDMAIL.
YEAR = SY-DATUM+0(4).
LOOP AT WS_FILE.
CLEAR: FYL.
FYL = WS_FILE-LOW.
REFRESH: TAB2.
CALL FUNCTION 'WS_UPLOAD'
EXPORTING
FILENAME = FYL
FILETYPE = 'BIN'
TABLES
DATA_TAB = TAB2.
IT_TEXTLINE[] = TAB2[].
DOCUMENT_DATA (SUBJECT OF MAIL)
V_DOCDATA-OBJ_NAME = DESC.
V_DOCDATA-OBJ_DESCR = SUBJ.
V_DOCDATA-OBJ_LANGU = SY-LANGU.
V_DOCDATA-SENSITIVTY = 'C'.
V_DOCDATA-OBJ_PRIO = '1'.
BODY OF MAIL
IT_BODY-LINE = 'Collection Report'.
APPEND IT_BODY.
CONTENTS_TXT (Attachments)
IT_CONTNT[] = IT_TEXTLINE[].
DESCRIBE TABLE IT_CONTNT LINES V_LINE.
READ TABLE IT_CONTNT INDEX V_LINE.
PACKING_LIST
V_OBJPACK-DOC_SIZE = ( V_LINE - 1 ) * 255 + STRLEN( IT_CONTNT ).
V_OBJPACK-TRANSF_BIN = 'X'.
V_OBJPACK-HEAD_START = 1.
V_OBJPACK-HEAD_NUM = 0.
V_OBJPACK-BODY_START = 1.
V_OBJPACK-BODY_NUM = V_LINE.
V_OBJPACK-DOC_TYPE = 'TXT'.
V_OBJPACK-OBJ_NAME = 'ATTACHMENT'.
V_OBJPACK-OBJ_DESCR = 'Attached Document'.
APPEND V_OBJPACK.
CLEAR V_OBJPACK.
RECEIVERS of mail
IF RECFLAG IS INITIAL.
LOOP AT IT_SAPID.
IT_RECVRS-RECEIVER = IT_SAPID-SAPID.
IT_RECVRS-REC_TYPE = 'B'.
IT_RECVRS-COM_TYPE = ''.
IT_RECVRS-EXPRESS = 'X'.
IT_RECVRS-NO_FORWARD = ''.
IT_RECVRS-NO_PRINT = ''.
APPEND IT_RECVRS.
CLEAR IT_RECVRS.
ENDLOOP.
ELSE.
LOOP AT EMAILADD.
IT_RECVRS-RECEIVER = EMAILADD-LOW.
IT_RECVRS-REC_TYPE = 'U'.
IT_RECVRS-COM_TYPE = 'INT'.
IT_RECVRS-EXPRESS = 'X'.
APPEND IT_RECVRS.
CLEAR IT_RECVRS.
ENDLOOP.
ENDIF.
OBJECT_HEADER (Filename)
CONCATENATE 'Collection Report' '_'
SY-DATUM+4(4) YEAR '.TXT'
INTO V_OBJHEAD-LINE.
V_OBJHEAD-LINE = FYL+16(25).
APPEND V_OBJHEAD.
CLEAR V_OBJHEAD.
Function Module For Sending Mail with Attachment
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
DOCUMENT_DATA = V_DOCDATA
TABLES
PACKING_LIST = V_OBJPACK
OBJECT_HEADER = V_OBJHEAD
CONTENTS_HEX = IT_CONTNT
CONTENTS_TXT = IT_BODY
RECEIVERS = IT_RECVRS
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 S000(ZZ) WITH TEXT-005.
ELSE.
MESSAGE S000(ZZ) WITH TEXT-006.
ENDIF.
ENDLOOP.
end of my code *
please help me guys... when i run this program, DOCUMENT_NOT_SENT is what i always get..
waiting for ur reply... thank you vey much and godbless.Hi,
Try this sample code.
FORM SEND_TO_EMAIL USING zFName.
DATA: OBJPACK LIKE SOPCKLSTI1 OCCURS 2 WITH HEADER LINE.
DATA: OBJHEAD LIKE SOLISTI1 OCCURS 1 WITH HEADER LINE.
DATA: OBJBIN LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.
DATA: OBJTXT LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.
DATA: RECLIST LIKE SOMLRECI1 OCCURS 5 WITH HEADER LINE.
DATA: DOC_CHNG LIKE SODOCCHGI1.
DATA: TAB_LINES LIKE SY-TABIX.
DATA: ctmp(50) TYPE C.
Creation of the document to be sent
DOC_CHNG-OBJ_NAME = 'JOURNAL'.
CONCATENATE 'SAP Payroll Journal file Period' pybegda INTO ctmp
SEPARATED BY SPACE.
DOC_CHNG-OBJ_DESCR = cTmp.
OBJTXT = 'SAP Payroll Journal'.
APPEND OBJTXT.
CONCATENATE 'For Period' pybegda INTO ctmp
SEPARATED BY SPACE.
OBJTXT = ctmp.
APPEND OBJTXT.
CONCATENATE 'Attached File :' zFname INTO ctmp
SEPARATED BY SPACE.
OBJTXT = ctmp.
APPEND OBJTXT.
OBJTXT = 'Please find the attachment.'.
APPEND OBJTXT.
DESCRIBE TABLE OBJTXT LINES TAB_LINES.
READ TABLE OBJTXT INDEX TAB_LINES.
DOC_CHNG-DOC_SIZE = ( TAB_LINES - 1 ) * 255 + STRLEN( OBJTXT ).
Creation of the entry for the compressed document
CLEAR OBJPACK-TRANSF_BIN.
OBJPACK-HEAD_START = 1.
OBJPACK-HEAD_NUM = 0.
OBJPACK-BODY_START = 1.
OBJPACK-BODY_NUM = TAB_LINES.
OBJPACK-DOC_TYPE = 'RAW'.
APPEND OBJPACK.
Creation of the document attachment
<b>LOOP AT xMail.
CONDENSE xMail-aline.
OBJBIN = xMail-aline.
APPEND OBJBIN.
CLEAR OBJBIN.
ENDLOOP.</b>
DESCRIBE TABLE OBJBIN LINES TAB_LINES.
OBJHEAD = zFname. APPEND OBJHEAD.
Creation of the entry for the compressed attachment
OBJPACK-TRANSF_BIN = 'X'.
OBJPACK-HEAD_START = 1.
OBJPACK-HEAD_NUM = 1.
OBJPACK-BODY_START = 1.
OBJPACK-BODY_NUM = TAB_LINES.
OBJPACK-DOC_TYPE = 'RAW'.
OBJPACK-OBJ_NAME = 'DATA'.
OBJPACK-OBJ_DESCR = 'SAP Payroll File'.
OBJPACK-DOC_SIZE = TAB_LINES * 255.
APPEND OBJPACK.
Completing the recipient list
LOOP AT PENERIMA.
CONDENSE PENERIMA-PNRM.
RECLIST-RECEIVER = PENERIMA-PNRM.
RECLIST-REC_TYPE = 'U'.
APPEND RECLIST.
ENDLOOP.
Sending the document
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
DOCUMENT_DATA = DOC_CHNG
PUT_IN_OUTBOX = ' '
TABLES
PACKING_LIST = OBJPACK
OBJECT_HEADER = OBJHEAD
CONTENTS_BIN = OBJBIN
CONTENTS_TXT = OBJTXT
RECEIVERS = RECLIST
EXCEPTIONS
TOO_MANY_RECEIVERS = 1
DOCUMENT_NOT_SENT = 2
OPERATION_NO_AUTHORIZATION = 4
OTHERS = 99.
CASE SY-SUBRC.
WHEN 0.
WRITE: / 'Result of the send process:'.
LOOP AT RECLIST.
WRITE: / RECLIST-RECEIVER(48), ':'.
IF RECLIST-RETRN_CODE = 0.
WRITE / 'The document was sent'.
ELSE.
WRITE / 'The document could not be sent'.
ENDIF.
ENDLOOP.
WHEN 1.
WRITE: / 'Too many receiver'.
WHEN 2.
WRITE: / 'Document could not be sent to any recipient'.
WHEN 4.
WRITE: / 'No send authorization'.
WHEN OTHERS.
WRITE: / 'Error occurred while sending'.
ENDCASE.
ENDFORM. -
Error while sendinf pdf file as attachment
hi all.,
am trying to send the pdf file of a smartform as attachment thru mail .. but its getting failed am getting error (sy-subrc = 6 ) after calling the fm so_new_document_att_send_api1 .. pls. suggest the possible cause of errors.
CALL FUNCTION 'CONVERT_OTF_2_PDF'
IMPORTING
bin_filesize = lv_bin_filesize
TABLES
otf = ls_job_output_info-otfdata
doctab_archive = it_docs
lines = it_lines
EXCEPTIONS
err_conv_not_possible = 1
err_otf_mc_noendmarker = 2
OTHERS = 3.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
*--- Get filename to store DYNAMIC
IF p_lsdir IS NOT INITIAL.
MOVE p_lsdir TO lv_path.
ENDIF.
CONDENSE wa_kna1-kunnr.
CONCATENATE 'SOA' wa_kna1-kunnr '.pdf' INTO lv_name.
CONCATENATE lv_path lv_name INTO lv_fullpath.
break ibm_prasad.
CLEAR wa_buffer.
LOOP AT it_lines.
TRANSLATE it_lines USING '~'.
CONCATENATE wa_buffer it_lines INTO wa_buffer.
ENDLOOP.
TRANSLATE wa_buffer USING '~'.
DO.
i_record = wa_buffer.
APPEND i_record.
SHIFT wa_buffer LEFT BY 255 PLACES.
IF wa_buffer IS INITIAL.
EXIT.
ENDIF.
ENDDO.
REFRESH: i_reclist,
i_objtxt,
i_objbin,
i_objpack.
CLEAR wa_objhead.
i_objbin[] = i_record[].
i_objtxt = 'SOA test with pdf-Attachment!'.
APPEND i_objtxt.
DESCRIBE TABLE i_objtxt LINES v_lines_txt.
READ TABLE i_objtxt INDEX v_lines_txt.
wa_doc_chng-obj_name = 'SOA'.
wa_doc_chng-expiry_dat = sy-datum + 10.
wa_doc_chng-obj_descr = 'SOA'.
wa_doc_chng-sensitivty = 'F'.
wa_doc_chng-doc_size = v_lines_txt * 255.
* Maint Text
CLEAR i_objpack-transf_bin.
i_objpack-head_start = 1.
i_objpack-head_num = 0.
i_objpack-body_start = 1.
i_objpack-body_num = v_lines_txt.
i_objpack-doc_type = 'RAW'.
APPEND i_objpack.
* Attachment (pdf-Attachment)
i_objpack-transf_bin = 'X'.
i_objpack-head_start = 1.
i_objpack-head_num = 0.
i_objpack-body_start = 1.
DESCRIBE TABLE i_objbin LINES v_lines_bin.
READ TABLE i_objbin INDEX v_lines_bin.
i_objpack-doc_size = v_lines_bin * 255 .
i_objpack-body_num = v_lines_bin.
i_objpack-doc_type = 'PDF'.
i_objpack-obj_name = 'SOA Eail'.
i_objpack-obj_descr = 'test'.
APPEND i_objpack.
CLEAR i_reclist.
i_reclist-receiver = <mail id>
i_reclist-rec_type = 'U'.
APPEND i_reclist.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = wa_doc_chng
put_in_outbox = 'X'
commit_work = 'X'
TABLES
packing_list = i_objpack
object_header = wa_objhead
contents_bin = i_objbin
contents_txt = i_objtxt
receivers = i_reclist
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.
thanks
sureshu need to use this SO_NEW_DOCUMENT_ATT_SEND_API1
check this code tutorial on how to add pdf file as an attachment
u need to modify the code to read the pdf from directory then rest of code is same
https://www.sdn.sap.com/irj/scn/wiki?path=/display/snippets/mailsendthroughoutputcontrols
кu03B1ятu03B9к
Edited by: kartik tarla on Mar 9, 2009 7:31 PM -
Hi experts
i did a print prg for sending the pdf attachment by smartforms.
but it's getting dumpped,this is my code
plz help me,its urgent.
i checked even SDN Forums also.i made some changes,
even though i don't get the output.
it shows not matching the I_OBJBIN in "SO_NEW_DOCUMENT_ATT_SEND_API1" function module.
REPORT ZCS_SF6.
Internal Table declarations
DATA: i_otf TYPE itcoo OCCURS 0 WITH HEADER LINE,
i_tline TYPE TABLE OF tline WITH HEADER LINE, i_receivers TYPE TABLE OF somlreci1 WITH HEADER LINE, i_record LIKE solisti1 OCCURS 0 WITH HEADER LINE,
Objects to send mail.
i_objpack LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,
i_objtxt LIKE solisti1 OCCURS 0 WITH HEADER LINE,
i_objbin LIKE solisti1 OCCURS 0 WITH HEADER LINE,
i_reclist LIKE somlreci1 OCCURS 0 WITH HEADER LINE,
Work Area declarations
w_objhead TYPE soli_tab,
w_ctrlop TYPE ssfctrlop,
w_compop TYPE ssfcompop,
w_return TYPE ssfcrescl,
w_doc_chng typE sodocchgi1,
w_data TYPE sodocchgi1,
w_buffer TYPE string,
Variables declarations
v_form_name TYPE rs38l_fnam,
v_len_in LIKE sood-objlen,
v_len_out LIKE sood-objlen,
v_len_outn TYPE i,
v_lines_txt TYPE i,
v_lines_bin TYPE i.
call function 'SSF_FUNCTION_MODULE_NAME'
exporting
formname = 'ZCS_FORM6'
importing
fm_name = v_form_name
exceptions
no_form = 1
no_function_module = 2
others = 3.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
w_ctrlop-getotf = 'X'.
w_ctrlop-no_dialog = 'X'.
w_compop-tdnoprev = 'X'.
CALL FUNCTION v_form_name
EXPORTING
ARCHIVE_INDEX =
ARCHIVE_INDEX_TAB =
ARCHIVE_PARAMETERS =
CONTROL_PARAMETERS = W_CTRLOP
MAIL_APPL_OBJ =
MAIL_RECIPIENT =
MAIL_SENDER =
OUTPUT_OPTIONS = W_COMPOP
USER_SETTINGS = 'X'
IMPORTING
DOCUMENT_OUTPUT_INFO =
JOB_OUTPUT_INFO = W_RETURN
JOB_OUTPUT_OPTIONS =
EXCEPTIONS
FORMATTING_ERROR = 1
INTERNAL_ERROR = 2
SEND_ERROR = 3
USER_CANCELED = 4
OTHERS = 5
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
i_otf[] = w_return-otfdata[].
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF'
max_linewidth = 132
LINES-TDLINE
IMPORTING
bin_filesize = v_len_in
TABLES
otf = i_otf
lines = i_tline
EXCEPTIONS
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 3
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
Convert PDF from 132 to 255.
LOOP AT i_tline.
Replacing space by ~
TRANSLATE i_tline USING '~'.
CONCATENATE w_buffer i_tline INTO w_buffer.
ENDLOOP.
Replacing ~ by space
TRANSLATE w_buffer USING '~'.
DO.
i_record = w_buffer.
Appending 255 characters as a record
APPEND i_record.
SHIFT w_buffer LEFT BY 255 PLACES.
IF w_buffer IS INITIAL.
EXIT.
ENDIF.
ENDDO.
Attachment
Refresh: i_reclist,
i_objtxt,
i_objbin,
i_objpack.
clear w_objhead.
Object with PDF.
i_objbin[] = i_record[].
*******DESCRIBE TABLE i_objbin LINES v_lines_bin.
Object with main text of the mail.
i_objtxt = 'Find attached the output of the smart form.'.
APPEND i_objtxt.
*i_objtxt = 'Regards,'.
*APPEND i_objtxt.
*i_objtxt = 'Chandu'.
*APPEND i_objtxt.
DESCRIBE TABLE i_objtxt LINES v_lines_txt.
read table i_objtxt index v_lines_txt.
Document information.
w_doc_chng-obj_name = 'Smartform'.
w_doc_chng-expiry_dat = sy-datum + 10.
w_doc_chng-obj_descr = 'Smart form output'.
w_doc_chng-sensitivty = 'F'.
w_doc_chng-doc_size = v_lines_txt * 255.
Pack to main body as RAW.
CLEAR i_objpack-transf_bin.
i_objpack-head_start = 1.
i_objpack-head_num = 0.
i_objpack-body_start = 1.
i_objpack-body_num = v_lines_txt.
i_objpack-doc_type = 'RAW'.
APPEND i_objpack.
Packing as PDF.
i_objpack-transf_bin = 'X'.
i_objpack-head_start = 1.
i_objpack-head_num = 1.
i_objpack-body_start = 1.
describe table i_objbin lines v_lines_bin.
read table i_objbin index v_lines_bin.
i_objpack-doc_size = v_lines_bin * 255.
i_objpack-body_num = v_lines_bin.
i_objpack-doc_type = 'PDF'.
i_objpack-obj_name = 'Smartform'.
i_objpack-obj_descr = 'sf output'
APPEND i_objpack.
Document information.
CLEAR i_reclist.
e-mail receivers.
i_reclist-receiver = '[email protected]'.
*i_reclist-express = 'X'. "Send express
i_reclist-rec_type = 'U'.
APPEND i_reclist.
Sending mail.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = w_doc_chng
put_in_outbox = 'X'
TABLES
packing_list = i_objpack
object_header = w_objhead
contents_hex = i_objbin
contents_txt = i_objtxt
receivers = i_reclist
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.
points wl be rewarded,if it is useful
thanks in advance.HI,
Here is the complete program for you.. I have done the same requirment..
P R O G R A M D E C L A R A T I O N *
PROGRAM ID : ZF_QUERY_BANK
AUTHOR : Mahesh Raganmoni
OWNER(Process Team) :
CREATE DATE : 03/04/2004
R/3 RELEASE VERSION : 4.72
BASED-ON PROGRAM : none
ADS : BP14.B&CF.301
DESCRIPTION : This program calles the Bank Query Smartform
and sends this smartforms as an email to the
bank
MODIFICATION LOG CONTROL (Most recent on top):
DATE AUTHOR CTS REQ DESCRIPTION
*09/13/2004 Mahesh Raganmoni DR1K901766 Original Version *
T A B L E S *
TABLES : BUT021, "BP: Address usages
BUT020, "BP: Addresses
T001, "Company Codes
DFKKZP, "Payment lot: Data for payment
BUT000, "BP: General data I
ADR3, "Fax Numbers (Business Address Services)
BNKA, "Bank master record
T012. "House Banks
Internal Tables *
*Address Details of Business Partner
DATA :IT_ADDRESS LIKE STANDARD TABLE OF BUS020_EXT WITH HEADER LINE.
*Return Table
DATA : IT_RETURN LIKE STANDARD TABLE OF BAPIRET2.
PDF Data to hold the data to be sent as an attachment
DATA : IT_PDF_NUC_DATA TYPE STANDARD TABLE OF SOLI.
Converted data from OTF
DATA : IT_PDF_TABLE TYPE RCL_BAG_TLINE.
Data Declaration for Sendig Email
DATA: IT_OBJPACK LIKE SOPCKLSTI1 OCCURS 1 WITH HEADER LINE,
IT_OBJHEAD LIKE SOLISTI1 OCCURS 1 WITH HEADER LINE,
IT_OBJTXT LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE,
IT_OBJBIN LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE,
IT_OBJHEX LIKE SOLIX OCCURS 10 WITH HEADER LINE,
IT_RECLIST LIKE SOMLRECI1 OCCURS 1 WITH HEADER LINE,
IT_LISTOBJECT LIKE ABAPLIST OCCURS 1 WITH HEADER LINE.
Structures *
DATA :WA_BUS000 TYPE BUS000_EXT, "Business Partner Details
WA_ADDRESS TYPE BAPIADDR3, "Collector Address
WA_OUTPUT_OPTIONS TYPE SSFCOMPOP,
WA_CONTROL_PARAMETERS TYPE SSFCTRLOP,
WA_OUTPUT_DATA TYPE SSFCRESCL,
WA_HEADER TYPE ZFCOLL_HEADER, "Smartform Header Info
WA_DFKKZP TYPE DFKKZP,
WA_DOCDATA LIKE SODOCCHGI1.
Variables *
DATA : W_FORMNAME TYPE TDSFNAME, "Smartform Name
W_NAME_ORG TYPE CHAR35, "Business Partner Name
W_ADDRNUMBER LIKE BUT021-ADDRNUMBER, "Address Number of BP
W_ADDRESS1 TYPE CHAR35, "Address Line 1
W_ADDRESS2 TYPE CHAR35, "Address Line 2
W_ADDRESS3 TYPE CHAR35, "Address Line 3
W_GE_NAME TYPE CHAR35, "GE Contact Name
W_GE_PHONE TYPE CHAR35, "GE Contact Phone
W_GE_PHONE1 TYPE CHAR35, "GE Contact Phone
W_GE_PHONE_EX TYPE CHAR10, "GE Contact Phone
W_GE_EMAIL TYPE CHAR35, "GE Contact Email
W_CLIENT_NAME TYPE CHAR30, "Client Name
W_GE_FAX TYPE CHAR35, "GE Fax No
W_GE_FAX1 TYPE CHAR35, "GE Fax No
W_CLIENT_FAX TYPE CHAR35, "Client's Fax No
W_PDF_LEN TYPE I, "Length of PDF file
W_ERR_MESG(120) TYPE C, "Error Message
W_ORG1R LIKE DFKKCR-ORG1R, "Company Code
W_REFERENCE LIKE DFKKCR-REFERENCE, "Payment Reference
W_FNAME TYPE RS38L_FNAM, "Smartform Function Module
" Name
W_SFNAME TYPE TDSFNAME, " Smart Form Name
W_BANKN TYPE CHAR18, "Bank Account Number
W_BETRZ TYPE CHAR15, " Credit AMount
W_WAERS TYPE CHAR5, " Credit Currency
W_VALUT TYPE DFKKZP-VALUT. " Value Date
VARIABLES FOR EMAIL
DATA: W_TAB_LINES TYPE I,
W_DOC_SIZE TYPE I,
W_ATT_TYPE LIKE SOODK-OBJTP,
W_DATFM TYPE XUDATFM.
VARIABLES FOR DATE
DATA: W_DAY(2) TYPE C,
W_MONTH(2) TYPE C,
W_YEAR(4) TYPE C,
W_DATE(10) TYPE C.
Constants *
DATA : C_SELECTED TYPE C VALUE 'X', "Constant for Checked
C_COMMA(2) TYPE C VALUE ', ',"Constant for Comma
C_HYPHEN TYPE C VALUE '-'. "Constant for Hypen
Selection Screen *
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
PARAMETERS: P_KEYZ1 TYPE RFKZ0-KEYZ1 OBLIGATORY, "Payment Lot
P_POSZA TYPE DFKKZP-POSZA OBLIGATORY. "Item Number
SELECTION-SCREEN END OF BLOCK b1.
SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-002.
PARAMETERS: P_REMIT TYPE C AS CHECKBOX DEFAULT 'X', " Remitter Form
P_GENRL TYPE C AS CHECKBOX USER-COMMAND RG1, " General Form
P_TEXT TYPE AD_SMTPADR MODIF ID SC1. " Free Text
SELECTION-SCREEN END OF BLOCK b2.
SELECTION-SCREEN BEGIN OF BLOCK b3 WITH FRAME TITLE text-003.
PARAMETERS:P_MAIL TYPE C AS CHECKBOX USER-COMMAND RG2, "Send Email
P_MAILID TYPE AD_SMTPADR MODIF ID SC2.
SELECTION-SCREEN END OF BLOCK b3.
Initialization *
WA_OUTPUT_OPTIONS-XDFCMODE = 'X'.
WA_OUTPUT_OPTIONS-XDF = SPACE.
WA_OUTPUT_OPTIONS-XSFCMODE = 'X'.
WA_OUTPUT_OPTIONS-XDF = SPACE.
At Selection Screen Output *
AT SELECTION-SCREEN OUTPUT.
LOOP AT SCREEN.
IF SCREEN-GROUP1 = 'SC1'.
IF P_GENRL = C_SELECTED.
SCREEN-INPUT = 1.
ELSE.
CLEAR P_TEXT.
SCREEN-INPUT = 0.
ENDIF.
ENDIF.
IF SCREEN-GROUP1 = 'SC2'.
IF P_MAIL = C_SELECTED.
SCREEN-INPUT = 1.
ELSE.
CLEAR P_MAILID.
SCREEN-INPUT = 0.
ENDIF.
ENDIF.
MODIFY SCREEN.
ENDLOOP.
AT SELECTION-SCREEN.
IF P_REMIT NE C_SELECTED AND P_GENRL NE C_SELECTED.
MESSAGE E004 WITH TEXT-004.
ENDIF.
Start of selection *
START-OF-SELECTION.
IF P_GENRL EQ C_SELECTED.
IF P_TEXT IS INITIAL.
MESSAGE I004 WITH TEXT-023.
STOP.
ENDIF.
ENDIF.
IF P_MAIL EQ C_SELECTED.
IF P_MAILID IS INITIAL.
MESSAGE I004 WITH TEXT-005.
STOP.
ENDIF.
ENDIF.
**Getting Payment Lot and Payment Lot number
PERFORM GET_PAYMENT_DETAILS.
IF NOT WA_DFKKZP IS INITIAL.
Getting the Bank Details
PERFORM GET_BANK_DETAILS.
**Getting the Ge Contact Details
PERFORM GET_GE_CONTACT_DETAILS .
Populating the Structure fields to pass to smartform
PERFORM FILL_EXPORT_STRUCTURES.
CLEAR W_FNAME.
Getting the Function Module name for the Smartform
IF P_REMIT EQ C_SELECTED AND P_GENRL NE C_SELECTED.
W_SFNAME = 'ZF_REMITTER_FORM'.
PERFORM GET_FORMNAME .
ELSEIF P_REMIT NE C_SELECTED AND P_GENRL EQ C_SELECTED.
W_SFNAME = 'ZF_GENERAL_FORM'.
PERFORM GET_FORMNAME .
ELSEIF P_REMIT EQ C_SELECTED AND P_GENRL EQ C_SELECTED.
W_SFNAME = 'ZF_QUERY_BANK_FORM'.
PERFORM GET_FORMNAME .
ENDIF.
IF NOT W_FNAME IS INITIAL.
PERFORM CALL_FORM.
IF P_MAIL EQ 'X'.
IF NOT P_MAILID IS INITIAL.
PERFORM SET_PARAMETERS.
PERFORM DEVICE_TYPE.
PERFORM CALL_FORM.
PERFORM CONVERT_TO_PDF.
PERFORM CONVERT_PDF_TO_BINARY.
PERFORM SEND_MAIL_NO_DISPLAY.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
*& Form GET_FORMNAME
Fetch the Function module name for the Smartform
FORM GET_FORMNAME .
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = W_SFNAME
IMPORTING
FM_NAME = W_FNAME
EXCEPTIONS
NO_FORM = 1
NO_FUNCTION_MODULE = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " GET_FORMNAME
*& Form CALL_FORM
To Call the Smartform
FORM CALL_FORM .
SHIFT W_BETRZ LEFT DELETING LEADING SPACE.
CALL FUNCTION W_FNAME
EXPORTING
CONTROL_PARAMETERS = WA_CONTROL_PARAMETERS
OUTPUT_OPTIONS = WA_OUTPUT_OPTIONS
USER_SETTINGS = 'X'
S_HEADER = WA_HEADER
V_ACNO = W_BANKN
V_AMOUNT = W_BETRZ
V_CURR = W_WAERS
V_DATE = W_VALUT
V_TEXT = P_TEXT
IMPORTING
JOB_OUTPUT_INFO = WA_OUTPUT_DATA
EXCEPTIONS
FORMATTING_ERROR = 1
INTERNAL_ERROR = 2
SEND_ERROR = 3
USER_CANCELED = 4
OTHERS = 5.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " CALL_FORM
*& Form FILL_EXPORT_STRUCTURES
Populate the structure to send to the smartform as input
FORM FILL_EXPORT_STRUCTURES .
WA_HEADER-BANKA = BNKA-BANKA.
WA_HEADER-ADDR_1 = BNKA-STRAS.
WA_HEADER-ADDR_2 = BNKA-ORT01.
WA_HEADER-ADDR_3 = BNKA-PROVZ.
WA_HEADER-ZZSRCBPNM = T012-NAME1.
SHIFT WA_HEADER-ZZSRCBPNM LEFT DELETING LEADING SPACE.
WA_HEADER-FAX_NUMBER = W_CLIENT_FAX.
WA_HEADER-BUTXT = T001-BUTXT.
WA_HEADER-NAME1 = W_GE_NAME.
WA_HEADER-TEL_NUMBER = W_GE_PHONE.
WA_HEADER-TEL_EXTENS = W_GE_PHONE_EX.
WA_HEADER-SMTP_ADDR = W_GE_EMAIL.
WA_HEADER-GE_FAX_NUMBER = W_GE_FAX.
ENDFORM. " FILL_EXPORT_STRUCTURES
*& FORM CONVERT_TO_PDF
Convert the final doucment (OTF FORMAT) into pdf format
FORM CONVERT_TO_PDF .
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
FORMAT = 'PDF'
IMPORTING
BIN_FILESIZE = W_PDF_LEN
TABLES
OTF = WA_OUTPUT_DATA-OTFDATA
LINES = IT_PDF_TABLE
EXCEPTIONS
ERR_MAX_LINEWIDTH = 1
ERR_FORMAT = 2
ERR_CONV_NOT_POSSIBLE = 3
ERR_BAD_OTF = 4
OTHERS = 5.
ENDFORM. " CONVERT_TO_PDF
*& FORM SET_PARAMETERS
Set control parameters to get the output format (OTF) from smart form*
FORM SET_PARAMETERS .
WA_CONTROL_PARAMETERS-NO_DIALOG = 'X'.
WA_CONTROL_PARAMETERS-GETOTF = 'X'.
WA_CONTROL_PARAMETERS-LANGU = SY-LANGU.
ENDFORM. " SET_PARAMETERS
*& FORM DEVICE_TYPE
Get the Device type
FORM DEVICE_TYPE .
CALL FUNCTION 'SSF_GET_DEVICE_TYPE'
EXPORTING
I_LANGUAGE = WA_CONTROL_PARAMETERS-LANGU
IMPORTING
E_DEVTYPE = WA_OUTPUT_OPTIONS-TDPRINTER
EXCEPTIONS
NO_LANGUAGE = 1
LANGUAGE_NOT_INSTALLED = 2
NO_DEVTYPE_FOUND = 3
SYSTEM_ERROR = 4
OTHERS = 5.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " DEVICE_TYPE
*& FORM CONVERT_PDF_TO_BINARY
To convert PDF file to Binary format
FORM CONVERT_PDF_TO_BINARY .
CALL FUNCTION 'QCE1_CONVERT'
TABLES
T_SOURCE_TAB = IT_PDF_TABLE
T_TARGET_TAB = IT_PDF_NUC_DATA
EXCEPTIONS
CONVERT_NOT_POSSIBLE = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " CONVERT_PDF_TO_BINARY
*& FORM SEND_MAIL_NO_DISPLAY
To send a email
FORM SEND_MAIL_NO_DISPLAY .
DATA: L_SLINE(255) TYPE C,
L_INDEX TYPE SY-TABIX.
IT_OBJBIN[] = IT_PDF_NUC_DATA[].
Title and Description of the mail
WA_DOCDATA-OBJ_DESCR = TEXT-012.
Mail Body content
PERFORM MAIL_BODY.
DESCRIBE TABLE IT_OBJTXT LINES W_TAB_LINES.
READ TABLE IT_OBJTXT INDEX W_TAB_LINES INTO L_SLINE.
L_INDEX = W_TAB_LINES + 1.
WA_DOCDATA-DOC_SIZE = ( W_TAB_LINES ) * 255 + STRLEN( L_SLINE ).
WA_DOCDATA-OBJ_EXPDAT = '29991231'.
WA_DOCDATA-SENSITIVTY = 'O'.
WA_DOCDATA-OBJ_PRIO = '5'.
WA_DOCDATA-EXPIRY_DAT = '29991231'.
WA_DOCDATA-PROC_TYPE = 'R'.
CLEAR IT_OBJPACK-TRANSF_BIN .
IT_OBJPACK-HEAD_START = 0.
IT_OBJPACK-HEAD_NUM = 0.
IT_OBJPACK-BODY_START = 1.
IT_OBJPACK-BODY_NUM = W_TAB_LINES.
IT_OBJPACK-DOC_TYPE = 'RAW'.
IT_OBJPACK-OBJ_DESCR = TEXT-013.
APPEND IT_OBJPACK.
Create message attachment
W_ATT_TYPE = 'PDF'.
DESCRIBE TABLE IT_OBJBIN LINES W_TAB_LINES.
READ TABLE IT_OBJBIN INDEX W_TAB_LINES.
L_INDEX = W_TAB_LINES + 1.
IT_OBJPACK-DOC_SIZE = ( W_TAB_LINES ) * 255 .
IT_OBJPACK-TRANSF_BIN = 'X'.
IT_OBJPACK-HEAD_START = 0.
IT_OBJPACK-HEAD_NUM = 0.
IT_OBJPACK-BODY_START = 1.
IT_OBJPACK-BODY_NUM = W_TAB_LINES.
IT_OBJPACK-DOC_TYPE = W_ATT_TYPE.
IT_OBJPACK-OBJ_DESCR = TEXT-013.
APPEND IT_OBJPACK.
Create receiver list
IT_RECLIST-RECEIVER = P_MAILID. "<-- CHANGE ADDRESS
IT_RECLIST-REC_TYPE = 'U'.
IT_RECLIST-EXPRESS = 'X'.
APPEND IT_RECLIST.
Send Email
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
DOCUMENT_DATA = WA_DOCDATA
PUT_IN_OUTBOX = 'X'
COMMIT_WORK = 'X' "USED FROM REL.6.10
TABLES
PACKING_LIST = IT_OBJPACK
CONTENTS_BIN = IT_OBJBIN
CONTENTS_TXT = IT_OBJTXT
RECEIVERS = IT_RECLIST
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 'SO' TYPE 'S' NUMBER '023'
WITH WA_DOCDATA-OBJ_NAME.
ELSE.
SUBMIT RSCONN01 WITH MODE = 'INT' AND RETURN.
SET SCREEN 0.
ENDIF.
ENDFORM. " SEND_MAIL_NO_DISPLAY
*& Form GET_PAYMENT_DETAILS
Get the Payment Lot and Payment Number
FORM GET_PAYMENT_DETAILS .
Get the Payment Lot and Payment Number
SELECT SINGLE BETRZ
BVRKO
BUKRS
WAERS
VALUT
BANKS
BANKL
BANKN
FROM DFKKZP
INTO (WA_DFKKZP-BETRZ,WA_DFKKZP-BVRKO,
WA_DFKKZP-BUKRS,WA_DFKKZP-WAERS,WA_DFKKZP-VALUT,
WA_DFKKZP-BANKS,WA_DFKKZP-BANKL,WA_DFKKZP-BANKN)
WHERE KEYZ1 = P_KEYZ1
AND POSZA = P_POSZA.
IF SY-SUBRC NE 0.
MESSAGE I004 WITH TEXT-100.
EXIT.
ELSE.
W_ORG1R = WA_DFKKZP-BUKRS.
W_BETRZ = WA_DFKKZP-BETRZ.
W_BANKN = WA_DFKKZP-BANKN.
W_WAERS = WA_DFKKZP-WAERS.
W_VALUT = WA_DFKKZP-VALUT.
ENDIF.
ENDFORM. " GET_PAYMENT_DETAILS
*& Form GET_BANK_DETAILS
To Retrive the Bank Details
FORM GET_BANK_DETAILS .
*Get the Bank Address Details
SELECT SINGLE BANKA
STRAS
ORT01
PROVZ
FROM BNKA
INTO (BNKA-BANKA,BNKA-STRAS,BNKA-ORT01,BNKA-PROVZ)
WHERE BANKS = WA_DFKKZP-BANKS
AND BANKL = WA_DFKKZP-BANKL.
IF SY-SUBRC NE 0.
MESSAGE I004 WITH TEXT-101.
EXIT.
ENDIF.
GET The Bank Contact Name.
SELECT SINGLE NAME1
FROM T012
INTO T012-NAME1
WHERE BANKS = WA_DFKKZP-BANKS
AND BANKL = WA_DFKKZP-BANKL.
IF SY-SUBRC NE 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
IF NOT W_ORG1R IS INITIAL.
Get the GE Legal Entity Name
SELECT SINGLE BUTXT FROM T001
INTO T001-BUTXT
WHERE BUKRS = W_ORG1R.
IF SY-SUBRC NE 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDIF.
ENDFORM. " GET_BANK_DETAILS
*& Form GET_COLLECTOR_DETAILS
To get the Collector Address Details
FORM GET_GE_CONTACT_DETAILS .
*Getting the Collector details
CALL FUNCTION 'BAPI_USER_GET_DETAIL'
EXPORTING
USERNAME = SY-UNAME
IMPORTING
ADDRESS = WA_ADDRESS
TABLES
RETURN = IT_RETURN.
IF NOT WA_ADDRESS IS INITIAL.
CONCATENATE WA_ADDRESS-FIRSTNAME0(18) WA_ADDRESS-LASTNAME0(17)
INTO W_GE_NAME SEPARATED BY SPACE.
W_GE_PHONE = WA_ADDRESS-TEL1_NUMBR.
W_GE_PHONE_EX = WA_ADDRESS-TEL1_EXT.
W_GE_EMAIL = WA_ADDRESS-E_MAIL.
IF NOT WA_ADDRESS-FAX_EXTENS IS INITIAL.
CONCATENATE WA_ADDRESS-FAX_NUMBER C_HYPHEN WA_ADDRESS-FAX_EXTENS
INTO W_GE_FAX.
ELSE.
W_GE_FAX = WA_ADDRESS-FAX_NUMBER.
ENDIF.
ENDIF.
ENDFORM. " GET_GE_CONTACT_DETAILS
*& Form MAIL_BODY
To Build the email body
FORM MAIL_BODY .
PERFORM GET_USER_DATE_FORMAT.
W_YEAR = W_VALUT+0(4).
W_MONTH = W_VALUT+4(2).
W_DAY = W_VALUT+6(2).
PERFORM GET_DATE.
IF P_REMIT EQ 'X' .
CONCATENATE TEXT-020 WA_HEADER-ZZSRCBPNM ',' INTO IT_OBJTXT-LINE
SEPARATED BY SPACE.
APPEND IT_OBJTXT.
CONCATENATE SPACE SPACE SPACE INTO IT_OBJTXT-LINE.
APPEND IT_OBJTXT.
CONCATENATE TEXT-021 WA_HEADER-BUTXT ',' TEXT-022
INTO IT_OBJTXT-LINE SEPARATED BY SPACE.
APPEND IT_OBJTXT.
CONCATENATE SPACE SPACE SPACE INTO IT_OBJTXT-LINE.
APPEND IT_OBJTXT.
SHIFT W_BETRZ LEFT DELETING LEADING SPACE.
CONCATENATE TEXT-024 W_DATE
TEXT-025 W_BETRZ W_WAERS TEXT-026
INTO IT_OBJTXT-LINE SEPARATED BY SPACE.
APPEND IT_OBJTXT.
CONCATENATE SPACE SPACE SPACE INTO IT_OBJTXT-LINE.
APPEND IT_OBJTXT.
IT_OBJTXT-LINE = TEXT-027.
APPEND IT_OBJTXT.
CONCATENATE SPACE SPACE SPACE INTO IT_OBJTXT-LINE.
APPEND IT_OBJTXT.
IT_OBJTXT-LINE = WA_HEADER-NAME1.
APPEND IT_OBJTXT.
CONCATENATE SPACE SPACE SPACE INTO IT_OBJTXT-LINE.
APPEND IT_OBJTXT.
CONCATENATE TEXT-028 WA_HEADER-BUTXT INTO
IT_OBJTXT-LINE SEPARATED BY SPACE.
APPEND IT_OBJTXT.
IT_OBJTXT-LINE = TEXT-029.
APPEND IT_OBJTXT.
CONCATENATE TEXT-030 W_GE_FAX INTO IT_OBJTXT-LINE
SEPARATED BY SPACE.
APPEND IT_OBJTXT.
CONCATENATE TEXT-031 W_GE_PHONE TEXT-035 W_GE_PHONE_EX INTO
IT_OBJTXT-LINE SEPARATED BY SPACE.
APPEND IT_OBJTXT.
CONCATENATE TEXT-032 WA_HEADER-SMTP_ADDR INTO
IT_OBJTXT-LINE SEPARATED BY SPACE.
APPEND IT_OBJTXT.
CONCATENATE SPACE SPACE SPACE INTO IT_OBJTXT-LINE.
APPEND IT_OBJTXT.
CONCATENATE TEXT-033 WA_HEADER-BUTXT INTO
IT_OBJTXT-LINE SEPARATED BY SPACE.
APPEND IT_OBJTXT.
ELSEIF P_GENRL EQ 'X'.
CLEAR IT_OBJTXT.
REFRESH IT_OBJTXT.
CONCATENATE TEXT-020 WA_HEADER-ZZSRCBPNM ',' INTO IT_OBJTXT-LINE
SEPARATED BY SPACE.
APPEND IT_OBJTXT.
CONCATENATE SPACE SPACE SPACE INTO IT_OBJTXT-LINE.
APPEND IT_OBJTXT.
CONCATENATE TEXT-021 WA_HEADER-BUTXT '.'
INTO IT_OBJTXT-LINE SEPARATED BY SPACE.
APPEND IT_OBJTXT.
CONCATENATE SPACE SPACE SPACE INTO IT_OBJTXT-LINE.
APPEND IT_OBJTXT.
CONCATENATE TEXT-034 P_TEXT '.'
INTO IT_OBJTXT-LINE SEPARATED BY SPACE.
APPEND IT_OBJTXT.
IT_OBJTXT-LINE = TEXT-027.
APPEND IT_OBJTXT.
CONCATENATE SPACE SPACE SPACE INTO IT_OBJTXT-LINE.
APPEND IT_OBJTXT.
IT_OBJTXT-LINE = WA_HEADER-NAME1.
APPEND IT_OBJTXT.
CONCATENATE SPACE SPACE SPACE INTO IT_OBJTXT-LINE.
APPEND IT_OBJTXT.
CONCATENATE TEXT-028 WA_HEADER-BUTXT INTO
IT_OBJTXT-LINE SEPARATED BY SPACE.
APPEND IT_OBJTXT.
IT_OBJTXT-LINE = TEXT-029.
APPEND IT_OBJTXT.
CONCATENATE TEXT-030 W_GE_FAX INTO IT_OBJTXT-LINE
SEPARATED BY SPACE.
APPEND IT_OBJTXT.
CONCATENATE TEXT-031 W_GE_PHONE TEXT-035 W_GE_PHONE_EX INTO
IT_OBJTXT-LINE SEPARATED BY SPACE.
APPEND IT_OBJTXT.
CONCATENATE TEXT-032 WA_HEADER-SMTP_ADDR INTO
IT_OBJTXT-LINE SEPARATED BY SPACE.
APPEND IT_OBJTXT.
ELSEIF ( P_REMIT EQ 'X' AND P_GENRL EQ 'X' ).
CONCATENATE TEXT-020 WA_HEADER-ZZSRCBPNM ',' INTO IT_OBJTXT-LINE
SEPARATED BY SPACE.
APPEND IT_OBJTXT.
CONCATENATE SPACE SPACE SPACE INTO IT_OBJTXT-LINE.
APPEND IT_OBJTXT.
CONCATENATE TEXT-021 WA_HEADER-BUTXT ',' TEXT-022
INTO IT_OBJTXT-LINE SEPARATED BY SPACE.
APPEND IT_OBJTXT.
CONCATENATE SPACE SPACE SPACE INTO IT_OBJTXT-LINE.
APPEND IT_OBJTXT.
SHIFT W_BETRZ LEFT DELETING LEADING SPACE.
CONCATENATE TEXT-024 W_DATE TEXT-025 W_BETRZ W_WAERS TEXT-026
INTO IT_OBJTXT-LINE SEPARATED BY SPACE.
APPEND IT_OBJTXT.
CONCATENATE SPACE SPACE SPACE INTO IT_OBJTXT-LINE.
APPEND IT_OBJTXT.
IT_OBJTXT-LINE = TEXT-027.
APPEND IT_OBJTXT.
CONCATENATE SPACE SPACE SPACE INTO IT_OBJTXT-LINE.
APPEND IT_OBJTXT.
IT_OBJTXT-LINE = WA_HEADER-NAME1.
APPEND IT_OBJTXT.
CONCATENATE SPACE SPACE SPACE INTO IT_OBJTXT-LINE.
APPEND IT_OBJTXT.
CONCATENATE TEXT-028 WA_HEADER-BUTXT INTO
IT_OBJTXT-LINE SEPARATED BY SPACE.
APPEND IT_OBJTXT.
IT_OBJTXT-LINE = TEXT-029.
APPEND IT_OBJTXT.
CONCATENATE TEXT-030 W_GE_FAX INTO IT_OBJTXT-LINE
SEPARATED BY SPACE.
APPEND IT_OBJTXT.
CONCATENATE TEXT-031 W_GE_PHONE TEXT-035 W_GE_PHONE_EX INTO
IT_OBJTXT-LINE SEPARATED BY SPACE.
APPEND IT_OBJTXT.
CONCATENATE TEXT-032 WA_HEADER-SMTP_ADDR INTO
IT_OBJTXT-LINE SEPARATED BY SPACE.
APPEND IT_OBJTXT.
CONCATENATE SPACE SPACE SPACE INTO IT_OBJTXT-LINE.
APPEND IT_OBJTXT.
CONCATENATE TEXT-033 WA_HEADER-BUTXT INTO
IT_OBJTXT-LINE SEPARATED BY SPACE.
APPEND IT_OBJTXT.
ENDIF.
ENDFORM. " MAIL_BODY
*& Form get_user_date_format
to get the User Date Format from USR01 table
FORM GET_USER_DATE_FORMAT.
CLEAR W_DATFM.
SELECT SINGLE DATFM INTO W_DATFM
FROM USR01
WHERE BNAME = SY-UNAME.
ENDFORM. " get_user_date_format
*& Form GET_DATE
Get the date in the user format
FORM GET_DATE .
CLEAR W_DATE.
CASE W_DATFM.
WHEN '1'.
CONCATENATE W_DAY '.' W_MONTH '.' W_YEAR INTO W_DATE.
WHEN '2'.
CONCATENATE W_MONTH '/' W_DAY '/' W_YEAR INTO W_DATE.
WHEN '3'.
CONCATENATE W_MONTH '-' W_DAY '-' W_YEAR INTO W_DATE.
WHEN '4'.
CONCATENATE W_YEAR '.' W_MONTH '.' W_DAY INTO W_DATE.
WHEN '5'.
CONCATENATE W_YEAR '/' W_MONTH '/' W_DAY INTO W_DATE.
WHEN '6'.
CONCATENATE W_YEAR '-' W_MONTH '-' W_DAY INTO W_DATE.
ENDCASE.
ENDFORM. " GET_DATE
Thanks
Mahesh -
Error while emailing pdf Smartform- help needed
Hi All,
I have successsully saved smartform as pdf on my local machine and while trying to send the same as an attachment.i am encountering a run time error in SCOT transaction on pressing send message.
Error details are as follows:-
CPIC-CALL: THE SAPECMINIT UNABLE TO DETERMINE HOST ADDRESS
Source Code: SAPMSSY1
CALL RFCIMPORT
The program is given below. Kindly reply me the solution.
All helpful answers will b rewarded.
Regards,
Eureka.
*& Report Z24436_SMARTFORM2 *
REPORT Z24436_SMARTFORM2 .
Global Variables Declarations
DATA: MAt_id TYPE MATNR VALUE '1%',
fm_name TYPE rs38l_fnam.
DATA: ITAB_MAkt TYPE STANDARD TABLE OF MAkt.
DATA: p_form TYPE tdsfname VALUE 'ZUDAY_SMARTFORMS1'.
All Database Selections are here
*Getting Materials belonging to the given plant
SELECT * FROM MAkt INTO TABLE ITAB_MAkt
WHERE MATNR LIKE MAT_id.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = p_form
VARIANT = ' '
DIRECT_CALL = ' '
IMPORTING
fm_name = fm_name
EXCEPTIONS
no_form = 1
no_function_module = 2
OTHERS = 3
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
EXIT.
ENDIF.
DATA : gw_ssfcrescl TYPE ssfcrescl.
DATA: gt_otf TYPE STANDARD TABLE OF itcoo ,
gt_tline TYPE STANDARD TABLE OF tline,
gt_pdf TYPE STANDARD TABLE OF tline,
gv_len LIKE sood-objlen,
gw_ssfctrlop TYPE ssfctrlop, "for CONTROL_PARAMETERS
gw_ssfcompop TYPE ssfcompop. "for OUTPUT_OPTIONS
gw_ssfctrlop-getotf = 'X'.
gw_ssfctrlop-no_dialog = 'X'.
gw_ssfcompop-tdnoprev = 'X'.
**Calling the generated function module
CALL FUNCTION fm_name
EXPORTING
ARCHIVE_INDEX =
ARCHIVE_INDEX_TAB =
ARCHIVE_PARAMETERS =
CONTROL_PARAMETERS = gw_ssfctrlop
MAIL_APPL_OBJ =
MAIL_RECIPIENT =
MAIL_SENDER =
OUTPUT_OPTIONS = gw_ssfcompop
USER_SETTINGS = 'X'
customer_info = customer
IMPORTING
DOCUMENT_OUTPUT_INFO =
JOB_OUTPUT_INFO = gw_ssfcrescl
JOB_OUTPUT_OPTIONS =
TABLES
it_makt = itab_makt
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
OTHERS = 5
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
gt_otf[] = gw_ssfcrescl-otfdata[].
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF'
max_linewidth = 132
IMPORTING
bin_filesize = gv_len
TABLES
otf = gt_otf
lines = gt_pdf
EXCEPTIONS
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 3
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
DATA:
gt_pdf TYPE TABLE OF tline,
gt_xi_pdf TYPE TABLE OF tline,
gt_pdf_conv TYPE TABLE OF solisti1,
gt_xi_temp TYPE TABLE OF bapiqcmime.
CONSTANTS:
lc_x(1) TYPE c VALUE 'X',
lc_raw(3) TYPE c VALUE 'RAW',
lc_pdf(3) TYPE c VALUE 'PDF',
lc_attach(12) TYPE c VALUE 'ATTACHMENT'.
DATA:
lv_spool TYPE rspoid, "Spool Number
lv_pdf_size TYPE i, "PDF Size
lv_subject(40) TYPE c, "Email subject
lv_tab_lines TYPE sytabix, "Table Lines
lv_date(10) TYPE c, "Variable for date
lv_time(8) TYPE c. "Variable for Time
DATA:
For Compressing document
ls_objpack TYPE sopcklsti1,
lt_objpack TYPE STANDARD TABLE OF sopcklsti1,
To specify subject
lt_objhead TYPE STANDARD TABLE OF solisti1,
ls_objhead TYPE solisti1,
To send the PDF
lt_objbin TYPE STANDARD TABLE OF solisti1,
ls_objbin TYPE solisti1,
Email body
lt_objtxt TYPE STANDARD TABLE OF solisti1,
ls_objtxt TYPE solisti1,
To specify Receivers
lt_reclist TYPE STANDARD TABLE OF somlreci1,
ls_reclist TYPE somlreci1,
Documenting Data
ls_doc_chng TYPE sodocchgi1,
ls_pdf_conv TYPE solisti1.
CONSTANTS: lc_under(1) TYPE c VALUE '_'.
**Copy the Spool request to a Local Variable
lv_spool = sy-spono.
Convert spool job to PDF
***************this is normal report spool to pdf.
but your case it will be smartform to pdf
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = lv_spool
no_dialog = lc_x
IMPORTING
pdf_bytecount = lv_pdf_size
TABLES
pdf = gt_pdf
EXCEPTIONS
OTHERS = 0.
To Format the PDF file so as each row contains 255 characters
PERFORM page_format .
Transfer the file to objbin table
LOOP AT gt_pdf_conv INTO ls_pdf_conv.
ls_objbin-line = ls_pdf_conv-line.
APPEND ls_objbin TO lt_objbin.
CLEAR ls_objbin.
ENDLOOP.
*// Creating the document to be sent - Mail subject creation
ls_doc_chng-obj_name = sy-repid.
lv_subject = text-008. "Mail subject
WRITE sy-datum TO lv_date USING EDIT MASK '__/__/____'.
WRITE sy-uzeit TO lv_time USING EDIT MASK '__:__:__'.
CONCATENATE lv_subject lc_under lv_date lc_under lv_time
INTO ls_doc_chng-obj_descr.
*// Email body
PDF attachment of Product Allocation for Open orders
ls_objtxt = text-009.
APPEND ls_objtxt TO lt_objtxt.
Write Date when the mail was sent in the email body
CONCATENATE text-010 lv_date INTO ls_objtxt.
APPEND ls_objtxt TO lt_objtxt.
Write Time when the mail was sent in the email body
CONCATENATE text-011 lv_time INTO ls_objtxt.
APPEND ls_objtxt TO lt_objtxt.
DESCRIBE TABLE lt_objtxt LINES lv_tab_lines.
READ TABLE lt_objtxt INTO ls_objtxt INDEX lv_tab_lines.
Calculate the document size
ls_doc_chng-doc_size = ( lv_tab_lines - 1 ) * 255 +
STRLEN( ls_objtxt ).
*// Creating the entry for the compressed document
CLEAR ls_objpack-transf_bin.
ls_objpack-head_start = 1.
ls_objpack-head_num = 0.
ls_objpack-body_start = 1.
ls_objpack-body_num = lv_tab_lines.
ls_objpack-doc_type = 'RAW' . "RAW
APPEND ls_objpack TO lt_objpack.
CLEAR lv_tab_lines.
DESCRIBE TABLE lt_objbin LINES lv_tab_lines.
ls_objhead = ls_doc_chng-obj_descr.
APPEND ls_objhead TO lt_objhead.
*// Creating the entry for the compressed attachment
ls_objpack-transf_bin = lc_x.
ls_objpack-head_start = 1.
ls_objpack-head_num = 1.
ls_objpack-body_start = 1.
ls_objpack-body_num = lv_tab_lines.
ls_objpack-doc_type = 'PDF'. "PDF
ls_objpack-obj_name = 'ATTACHMENT'. "ATTACHMENT
CONCATENATE lv_subject lc_under lv_date lc_under lv_time
INTO ls_objpack-obj_descr.
CLEAR: ls_objbin.
READ TABLE lt_objbin INTO ls_objbin INDEX lv_tab_lines.
ls_objpack-doc_size = ( lv_tab_lines - 1 ) * 255 +
STRLEN( ls_objbin ).
APPEND ls_objpack TO lt_objpack.
ls_reclist-receiver = '[email protected]'.
ls_reclist-receiver = gv_email_addr.
ls_reclist-rec_type = 'U'.
APPEND ls_reclist TO lt_reclist.
IF ls_reclist-receiver IS INITIAL.
MESSAGE i175.
ELSE.
*// Send EMail
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = ls_doc_chng
put_in_outbox = lc_x
commit_work = lc_x
TABLES
packing_list = lt_objpack
object_header = lt_objhead
contents_bin = lt_objbin
contents_txt = lt_objtxt
receivers = lt_reclist
EXCEPTIONS
too_many_receivers = 1
document_not_sent = 2
operation_no_authorization = 3
OTHERS = 99.
CASE sy-subrc.
WHEN 0.
Mail successfully delivered
*// Do nothing
WHEN 1.
This will never occur as at any point of time mail will be
sent to one processor only.
*// Do nothing
WHEN 2.
MESSAGE i175.
WHEN 3.
MESSAGE i175.
*// Do nothing
ENDCASE.
ENDIF.
REFRESH: lt_objpack,
lt_objbin,
lt_objtxt,
lt_objhead,
lt_reclist.
CLEAR: ls_reclist,
ls_doc_chng,
ls_objpack,
ls_objhead,
ls_objtxt.
DATA : gv_filename LIKE rlgrap-filename VALUE 'C:\Udaya4.pdf'.
CALL FUNCTION 'DOWNLOAD'
EXPORTING
bin_filesize = gv_len
filename = gv_filename
filetype = 'BIN'
filetype_no_show = 'X'
IMPORTING
act_filename = gv_filename
filesize = gv_len
cancel = ''
TABLES
data_tab = gt_pdf.
FORM page_format .
Local data
DATA : lv_lines TYPE i,
lv_temp(500) TYPE c,
lv_offset TYPE p,
lv_lineslen(2) TYPE p,
lv_mimelen(2) TYPE p,
lv_tabix LIKE sy-tabix,
ls_pdf_conv TYPE solisti1,
ls_xi_temp TYPE bapiqcmime,
ls_xi_pdf TYPE tline.
CLEAR : gt_xi_pdf,
gt_xi_temp.
REFRESH: gt_xi_pdf,
gt_xi_temp.
Copy the PDF file into table gt_xi_pdf
gt_xi_pdf[] = gt_pdf[].
Reformat the line to 255 characters wide (code from SAP)
CLEAR: lv_temp, lv_offset, gt_xi_temp.
DESCRIBE TABLE gt_xi_pdf LINES lv_lines.
DESCRIBE FIELD ls_xi_pdf LENGTH lv_lineslen IN CHARACTER MODE.
DESCRIBE FIELD ls_xi_temp LENGTH lv_mimelen IN CHARACTER MODE.
Go through all the lines of table gt_xi_pdf
LOOP AT gt_xi_pdf INTO ls_xi_pdf.
lv_tabix = sy-tabix.
Move ls_xi_pdf into lv_temp variable
MOVE ls_xi_pdf TO lv_temp+lv_offset.
Check if its the last line of table gt_xi_pdf
IF lv_tabix = lv_lines.
lv_lineslen = STRLEN( ls_xi_pdf ).
ENDIF.
Calculate the new offset
lv_offset = lv_offset + lv_lineslen.
Check if the new offset is equal to or greater than the length of
gt_xi_temp
IF lv_offset GE lv_mimelen.
CLEAR ls_xi_temp.
Copy the PDF data into gt_xi_temp
ls_xi_temp = lv_temp(lv_mimelen).
APPEND ls_xi_temp TO gt_xi_temp.
SHIFT lv_temp BY lv_mimelen PLACES.
Calculate the new offset
lv_offset = lv_offset - lv_mimelen.
ENDIF. "Offset GE MIMELEN
Check if its the last line of gt_xi_pdf
IF lv_tabix = lv_lines.
Check if lv_temp has some data that is not been transferred to
gt_xi_temp
IF lv_offset GT 0.
CLEAR ls_xi_temp.
Copy the PDF data into gt_xi_temp
ls_xi_temp = lv_temp(lv_offset).
APPEND ls_xi_temp TO gt_xi_temp.
ENDIF. "lv_offset GT 0
ENDIF. "lv_tabix = lv_lines
ENDLOOP.
gt_pdf_conv[] = gt_xi_temp[].
ENDFORM. " page_formatall settings in SCOT is ok ? like SMTP settings , link b/w ur Outlook server and SAP server ?
Regards
Prabhu -
Error in opening the PDF file created from the smart form output.
Hi All,
i have a simple smart form which takes 3 values like customer no, name and no of times customer called and gives an out like
Customer 0001000000 with name Ravi called 5 times today.
I have to send this output to mail as an attachment.
for this i am coding as below.
******Call the SSF Function module
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = Form name
VARIANT = ' '
DIRECT_CALL = ' '
IMPORTING
fm_name = lv_fmname
EXCEPTIONS
no_form = 1
no_function_module = 2
OTHERS = 3
lv_partner_number = '0001000000'.
lv_name_org1 = 'Ravi'.
lv_z_no_calls_day = '5'.
lw_ctrlop-getotf = 'X'.
lw_ctrlop-no_dialog = 'X'.
lw_compop-tdnoprev = 'X'.
lw_compop-tddest = 'LP01'.
*******Call the Form Function module and get the OTF of form output
CALL FUNCTION lv_fmname
EXPORTING
name_org1 = lv_name_org1
partner_number = lv_partner_number
z_no_calls_day = lv_z_no_calls_day
control_parameters = lw_ctrlop
output_options = lw_compop
user_settings = ' '
IMPORTING
job_output_info = w_return
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
OTHERS = 5.
i_otf] = w_return-otfdata[.
*********Now here if i look in to the OTF data i got in debug it has the data i aniticipated along with some other data.
the output is in the format
TDPRINTCOM(2) TDPRINTPAR(70)
ST XXXX.. customer 0001000000 with
name.....
i have my data in the above format spread in three lines of the output otf table where XXXX... is some number.
***********To convert to PDF Format
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF'
max_linewidth = 132
IMPORTING
bin_filesize = lv_len_in
BIN_FILE =
TABLES
otf = i_otf
lines = i_tline
EXCEPTIONS
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 3
err_bad_otf = 4
OTHERS = 5
*********For testing purpose i created a file on the desktop with the the data in i_tline. it created PDF file but when i tried to open it it's giving an error.
i_objtxt = 'test with pdf-Attachment!'.
APPEND i_objtxt.
DESCRIBE TABLE i_objtxt LINES v_lines_txt.
READ TABLE i_objtxt INDEX v_lines_txt.
wa_doc_chng-obj_name = 'Smart Form'.
wa_doc_chng-obj_descr = 'Frequent Caller Alert_Day'.
wa_doc_chng-doc_size = ( v_lines_txt - 1 ) * 255 + STRLEN( i_objtxt ).
*********Creating the Entry for the document
CLEAR i_objpack-transf_bin.
i_objpack-head_start = 1.
i_objpack-head_num = 0.
i_objpack-body_start = 1.
i_objpack-body_num = v_lines_txt.
i_objpack-doc_type = 'RAW'.
APPEND i_objpack.
i_objbin] = i_tline[.
DESCRIBE TABLE i_objbin LINES v_lines_bin.
READ TABLE i_objbin INDEX v_lines_bin.
i_objhead = 'Frequentcaller list_Day.pdf'.
APPEND i_objhead.
************Creating the entry for the attachment.
CLEAR : i_objpack.
i_objpack-transf_bin = 'X'.
i_objpack-head_start = 1.
i_objpack-head_num = 1.
i_objpack-body_start = 1.
i_objpack-body_num = v_lines_bin.
i_objpack-doc_type = 'PDF'.
i_objpack-obj_name = 'ATTACHMENT'.
i_objpack-obj_descr = 'FCA'.
i_objpack-doc_size = v_lines_bin * 255 .
APPEND i_objpack.
CLEAR i_reclist.
i_reclist-receiver = 'mail id'.
i_reclist-rec_type = 'U'.
APPEND i_reclist.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = wa_doc_chng
put_in_outbox = 'X'
commit_work = 'X'
TABLES
packing_list = i_objpack
object_header = i_objhead
contents_bin = i_objbin
contents_txt = i_objtxt
receivers = i_reclist
EXCEPTIONS
too_many_receivers = 1
document_not_sent = 2
operation_no_authorization = 4
OTHERS = 99.
This is all i am doing.
It is sending a mail with the attachment but we are not able to open the attachment. it's giving an error like file is damaged and couldn't be repaired.
I serched in the forum but i couldn't get the answer.
I suspect there is a problem in getting the OTF data..
Please help me in resolving this issue....
Thanks in advance.
RKCheck the sample , and see where you made the mistake.
REPORT ZPDF_MAIl.
DATA:
w_fm_name TYPE rs38l_fnam,
w_bin_filesize TYPE i,
w_filesize TYPE i,
w_lines_txt TYPE i,
w_lines_bin TYPE i.
DATA:
wa_ctrlop TYPE ssfctrlop,
wa_outopt TYPE ssfcompop,
wa_objhead TYPE soli_tab,
wa_buffer TYPE string,
wa_doc_chng TYPE sodocchgi1.
DATA:
BEGIN OF t_mail_ids OCCURS 0,
mailid TYPE ad_smtpadr,
END OF t_mail_ids,
t_otfdata TYPE ssfcrescl,
t_otf TYPE itcoo OCCURS 0 WITH HEADER LINE,
t_pdf_tab TYPE tline OCCURS 0 WITH HEADER LINE,
t_objpack LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,
t_objtxt LIKE solisti1 OCCURS 0 WITH HEADER LINE,
t_objbin LIKE solisti1 OCCURS 0 WITH HEADER LINE,
t_record LIKE solisti1 OCCURS 0 WITH HEADER LINE,
t_reclist LIKE somlreci1 OCCURS 0 WITH HEADER LINE.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = 'Z195_TEST'
IMPORTING
fm_name = w_fm_name
EXCEPTIONS
no_form = 1
no_function_module = 2
OTHERS = 3.
IF sy-subrc EQ 0.
ENDIF. " IF sy-subrc EQ 0.
wa_ctrlop-getotf = 'X'.
wa_ctrlop-no_dialog = 'X'.
wa_outopt-tdnoprev = 'X'.
CALL FUNCTION w_fm_name
EXPORTING
control_parameters = wa_ctrlop
output_options = wa_outopt
user_settings = 'X'
IMPORTING
job_output_info = t_otfdata
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
OTHERS = 5.
IF sy-subrc EQ 0.
ENDIF. " IF sy-subrc EQ 0.
t_otf[] = t_otfdata-otfdata[].
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF'
max_linewidth = 132
IMPORTING
bin_filesize = w_bin_filesize
TABLES
otf = t_otf
lines = t_pdf_tab
EXCEPTIONS
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 3
err_bad_otf = 4
OTHERS = 5.
IF sy-subrc EQ 0.
ENDIF. " IF sy-subrc EQ 0.
LOOP AT t_pdf_tab.
TRANSLATE t_pdf_tab USING '~'.
CONCATENATE wa_buffer t_pdf_tab INTO wa_buffer.
ENDLOOP.
TRANSLATE wa_buffer USING '~'.
DO.
t_record = wa_buffer.
APPEND t_record.
SHIFT wa_buffer LEFT BY 255 PLACES.
IF wa_buffer IS INITIAL.
EXIT.
ENDIF.
ENDDO.
t_objtxt = ' To Change the COR, Use the Transaction ZCOR_CHANGE'.
APPEND t_objtxt.
t_objtxt = ' Check the Attached PDF file for COR'.
APPEND t_objtxt.
DESCRIBE TABLE t_objtxt LINES w_lines_txt.
READ TABLE t_objtxt INDEX w_lines_txt.
READ TABLE t_objtxt INDEX w_lines_txt.
wa_doc_chng-obj_name = 'COR Display'.
wa_doc_chng-expiry_dat = sy-datum + 10.
CONCATENATE 'COR' "w_cornr
'-' "w_stat_descr w_action_desc
INTO wa_doc_chng-obj_descr SEPARATED BY space.
wa_doc_chng-sensitivty = 'F'.
wa_doc_chng-doc_size = w_lines_txt * 255.
CLEAR t_objpack-transf_bin.
t_objpack-head_start = 1.
t_objpack-head_num = 0.
t_objpack-body_start = 1.
t_objpack-body_num = w_lines_txt.
t_objpack-doc_type = 'RAW'.
APPEND t_objpack.
t_objpack-transf_bin = 'X'.
t_objpack-head_start = 1.
t_objpack-head_start = 1.
t_objpack-head_num = 0.
t_objpack-body_start = 1.
DESCRIBE TABLE t_objbin LINES w_lines_bin.
READ TABLE t_objbin INDEX w_lines_bin.
t_objpack-doc_size = w_lines_bin * 255 .
t_objpack-body_num = w_lines_bin.
t_objpack-doc_type = 'PDF'.
t_objpack-obj_name = 'COR'.
t_objpack-obj_descr = 'COR Test'.
* concatenate 'COR' w_cornr into t_objpack-obj_descr
* separated by space.
APPEND t_objpack.
*LOOP AT t_mail_ids.
CLEAR t_reclist.
t_reclist-receiver = 'INTENATEMAIL'.
t_reclist-rec_type = 'U'.
APPEND t_reclist.
*ENDLOOP.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = wa_doc_chng
put_in_outbox = 'X'
commit_work = 'X'
TABLES
packing_list = t_objpack
object_header = wa_objhead
contents_bin = t_objbin
contents_txt = t_objtxt
receivers = t_reclist
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 EQ 0.
ENDIF.
Maybe you are looking for
-
I've bought a ton of music, but it isn't showing up in my past purchased list
So, I have an iPhone and a Macbook air, so I exclusively use iTunes to buy and download all my music. I've purchased a good amount of songs, and they are all in my library, but when I look in my past purchases, most of my music is missing. This is an
-
Write to Text File - unflatten channel string
Hi all, This is my first post on the forums! It's been very helpful for me but I have not been able to find a solution to my (simple) problem. Operating system: Windows 7 (64-bit) Labview 2012 Full Development I'm using the DAQmx unflatten channel s
-
Trouble understanding JTable renderers
I dont properly understand how to JTable. In the application I'm writing, I have on main JFrame, with a menu. Onto this I load a jTabbed pane and then onto this a JTable , with some data loaded from a file , some coulmns are text , others integers fl
-
After update to Mavericks I can't open disc drive from keyboard
Hello After update to Mavericks I can't open disc drive from keyboard on my Mac Pro. I found the only way to do this is via disk tools , there I can eject my disc drive - seems now to be the only way - should not be like this. Any idea , Please??
-
Lightroom 2 Crashed - Please Help!
Hi, Lightroom 2 Crashed and caused a Question Mark (?) to appear on all the files I have loaded since Lightroom Crashed. For the past three (3) frustrating days I can not process any RAW files because Lightroom will not see the location of the files