05-07-2019 10:32 AM
Hello,
I am trying to send the table content through email,however the table has 926 rows, not all rows and columns are displayed.I am trying to convert it to xstring and all the columns are displaying now but not all the rows only half .
Can anyone help me with this?
LOOP AT lt_contents_bin.
CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
EXPORTING
text = lt_contents_bin
IMPORTING
buffer = lt_contents
EXCEPTIONS
failed = 1
OTHERS = 2.
*Converting the table contents from xstring to binary
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
EXPORTING
buffer = lt_contents
APPEND_TO_TABLE = 'X'
TABLES
binary_tab = lt_contents_hex.
LOOP AT lt_contents_hex.
APPEND lt_contents_hex TO gt_contents_hex.
ENDLOOP.
ENDLOOP.
gt_contents_text = lt_contents_text.
05-07-2019 3:04 PM
Hi
kindly used bellow program to send email with large table
DATA: lo_send_request TYPE REF TO cl_bcs,
lv_date(10),
lv_text TYPE char255, " Text
lv_subject TYPE so_obj_des,
lo_document TYPE REF TO cl_document_bcs,
lv_binary_content TYPE solix_tab,
lv_size TYPE so_obj_len,
lv_string TYPE string,
lt_main_text TYPE bcsy_text,
lo_recipient TYPE REF TO if_recipient_bcs,
lv_sent_to_all TYPE os_boolean,
lo_bcs_exception TYPE REF TO cx_bcs,
lv_email TYPE ad_smtpadr,
lv_lines TYPE i.
SELECTION-SCREEN: BEGIN OF BLOCK b2 WITH FRAME TITLE text-010.
SELECT-OPTIONS: s_ercpt FOR catsxt_sf-email NO INTERVALS .
SELECTION-SCREEN END OF BLOCK b2.
* Internal tables : move your internal table
DATA : BEGIN OF gt_up_file OCCURS 0,
line(200),
END OF gt_up_file.
*Delimiters for spreadsheet attachment
CLASS:cl_abap_char_utilities DEFINITION LOAD.
CONSTANTS: gc_tab TYPE c VALUE cl_bcs_convert=>gc_tab,
gc_crlf TYPE c VALUE cl_bcs_convert=>gc_crlf.
DATA: gv_tab TYPE c VALUE cl_abap_char_utilities=>horizontal_tab,
gv_newline TYPE c VALUE cl_abap_char_utilities=>newline,
gv_line_feed TYPE c VALUE cl_abap_char_utilities=>cr_lf.
WRITE sy-datum TO lv_date DD/MM/YYYY.
lv_lines = lines( gt_up_file ).
IF lv_lines GT 65000.
MESSAGE i000(zmm) WITH
'Report has more than 65,000 lines. Email cannot be'
'sent - Report can only be displayed.'
'In order to email report,'
'please change your selection criteria.'.
EXIT.
ENDIF.
LOOP AT gt_up_file .
CONCATENATE lv_string gt_up_file gc_crlf gv_newline
INTO lv_string.
ENDLOOP.
* --------------------------------------------------------------
* convert the text string into UTF-16LE binary data including
* byte-order-mark. Mircosoft Excel prefers these settings
* all this is done by new class cl_bcs_convert (see note 1151257)
TRY.
cl_bcs_convert=>string_to_solix(
EXPORTING
iv_string = lv_string
iv_codepage = '4103' "suitable for MS Excel, leave empty
iv_add_bom = 'X' "for other doc types
IMPORTING
et_solix = lv_binary_content
ev_size = lv_size ).
CATCH cx_bcs.
MESSAGE e445(so).
ENDTRY.
TRY.
* -------- create persistent send request ------------------------
lo_send_request = cl_bcs=>create_persistent( ).
* -------- create and set document with attachment ---------------
* create document object from internal table with text
lv_text = lv_date.
APPEND lv_text TO lt_main_text.
APPEND INITIAL LINE TO lt_main_text.
lv_text = 'Customer Price List Attached'.
APPEND lv_text TO lt_main_text.
CONCATENATE 'Customer Price List' sy-datum sy-uzeit
INTO lv_subject SEPARATED BY '_'.
lo_document = cl_document_bcs=>create_document(
i_type = 'RAW'
i_text = lt_main_text
i_subject = lv_subject ).
* add the spread sheet as attachment to document object
lo_document->add_attachment(
i_attachment_type = 'XLS' "
i_attachment_subject = lv_subject
i_attachment_size = lv_size
i_att_content_hex = lv_binary_content ).
* add document object to send request
lo_send_request->set_document( lo_document ).
* --------- add recipient (e-mail address) -----------------------
* create recipient object
LOOP AT s_ercpt.
lv_email = s_ercpt-low.
lo_recipient = cl_cam_address_bcs=>create_internet_address(
lv_email ).
* add recipient object to send request
lo_send_request->add_recipient( lo_recipient ).
ENDLOOP.
* ---------- send document ---------------------------------------
lv_sent_to_all = lo_send_request->send( i_with_error_screen = 'X' ).
COMMIT WORK.
IF lv_sent_to_all IS INITIAL.
MESSAGE s500(sbcoms) WITH ''.
ELSE.
MESSAGE s022(so).
ENDIF.
* ------------ exception handling ----------------------------------
CATCH cx_bcs INTO lo_bcs_exception.
MESSAGE i865(so) WITH lo_bcs_exception->error_type.
ENDTRY.
Regards,
Nawa
05-07-2019 10:53 AM
Hi,
You can try to use the OO option for to generate the attachement in Binary instead of the function modules. The classes to be used CL_DOCUMENT_BCS and CL_BCS. have a look at the below post on the attachement section: https://wiki.scn.sap.com/wiki/display/ABAP/Send+Emails+with+Attachments+of+any+Format
05-07-2019 11:13 AM
from the description : have kept 100 documents in a Folder on my desktop,this dude uploads files from desktop I want it from my table
05-08-2019 10:49 AM
an update I was able to send the email but still not showing all the columns using OO aproach
05-09-2019 10:38 AM
do you know what possibly can be the couse why the email are not being sent?does it need to be maintained somewhere?how can that be avoided and send the email directly?
05-07-2019 12:48 PM
Your question misses lots of information.
SCMS_STRING_TO_XSTRING converts a STRING into UTF-8 (by default).
SCMS_XSTRING_TO_BINARY splits a XSTRING into a table of X lines.
But what types are your variables?
And what number of bytes do you pass to the parameter I_ATTACHMENT_SIZE of method ADD_ATTACHMENT?
05-07-2019 1:14 PM
lt_contents TYPE STANDARD TABLE OF xstring WITH HEADER LINE,
lt_contents_bin TYPE STANDARD TABLE OF string WITH HEADER LINE,
lt_contents_hex TYPE STANDARD TABLE OF solix WITH HEADER LINE,
lt_objpack-body_num = lv_tab_lines.
lt_objpack-obj_descr = 'BoW'.
lt_objpack-doc_type = 'TXT'.
lt_objpack-doc_size = lv_tab_lines * 255.
I do not use method ADD_ATTACHMENT,In the end I simply use
FM: NEW_DOCUMENT_ATT_SEND_API1
05-07-2019 1:38 PM
05-07-2019 1:39 PM
05-07-2019 1:42 PM
about 1), I mean, how do you fill "lv_tab_lines"?
+ see the question 2 I have added in my previous comment
05-07-2019 1:45 PM
yes exatcly like that,
DESCRIBE TABLE lt_objtxt LINES lv_tab_lines.READ TABLE lt_objtxt INDEX lv_tab_lines.
t_objpack-transf_bin = 'X'.
lt_objpack-head_start = 1.
lt_objpack-head_num = 0.
lt_objpack-body_start = 1.
lt_objpack-body_num = lv_tab_lines.
lt_objpack-obj_descr = 'BoW'.
lt_objpack-doc_type = 'TXT'.
lt_objpack-doc_size = lv_tab_lines * 255.
APPEND lt_objpack.
05-07-2019 1:49 PM
05-07-2019 1:55 PM
DATA: lt_objtxt LIKE solisti1 OCCURS 10 WITH HEADER LINE.
the rest regarding lt_objtxt is above
05-07-2019 2:03 PM
05-07-2019 2:15 PM
DESCRIBETABLE lt_objtxt LINES lv_tab_lines.READTABLE lt_objtxt INDEX lv_tab_lines.
05-07-2019 2:19 PM
how do you fill it?
I'm trying to help you. Please attach the whole program in txt.ZIP format.
05-07-2019 2:27 PM
05-07-2019 2:40 PM
Is it really the right version?
Form Send_mail.
DATA: lt_objtxt LIKE solisti1 OCCURS 10 WITH HEADER LINE.
DESCRIBE TABLE lt_objtxt LINES lv_tab_lines.
lv_tab_lines will always be zero.
05-07-2019 2:43 PM
As Sandra wrote:
05-07-2019 2:49 PM
05-07-2019 2:51 PM
I feel (but difficult to be sure) that your code is more or less fine.
1) But I wonder if it's normal to have this combination, can you try RAW instead of TXT ? (because your text is UTF-8, made of bytes):
lt_objpack-transf_bin = 'X'.
lt_objpack-doc_type = 'TXT'.
2) Are you sure that LT_CONTENTS_BIN is correct at the very start of your code?
05-07-2019 2:52 PM
yes I know ,the prb is that I dont see all the rows,only some and I dont know why...
05-07-2019 2:56 PM
How would you change my code using OO.Can you help me with this one?
05-07-2019 3:14 PM
It's a very good idea to rewrite in OO, i.e. your own code + use CL_BCS, get rid of those obsolete header lines, simplify your code. You have lots of demo programs for BCS (BCS_EXAMPLE_*).
05-08-2019 9:39 AM
Can you help mw with a working one,I have tried several,but I keep receiving this message email not sent to
05-08-2019 10:49 AM
an update I was able to send the email but still not showing all the columns OO aproach
05-08-2019 11:08 AM
You mean, the issue is now "reversed": your program shows all the lines, but not all the columns (initially, it used to show all the columns, but half the lines) ?
05-09-2019 10:38 AM
do you know what possibly can be the couse why the email are not being sent?does it need to be maintained somewhere?how can that be avoided and send the email directly?
05-09-2019 1:24 PM
05-09-2019 2:53 PM
no I mean to send to multiple recipents ,somehow I am not able to send it to more than one person
05-09-2019 2:59 PM
05-07-2019 3:04 PM
Hi
kindly used bellow program to send email with large table
DATA: lo_send_request TYPE REF TO cl_bcs,
lv_date(10),
lv_text TYPE char255, " Text
lv_subject TYPE so_obj_des,
lo_document TYPE REF TO cl_document_bcs,
lv_binary_content TYPE solix_tab,
lv_size TYPE so_obj_len,
lv_string TYPE string,
lt_main_text TYPE bcsy_text,
lo_recipient TYPE REF TO if_recipient_bcs,
lv_sent_to_all TYPE os_boolean,
lo_bcs_exception TYPE REF TO cx_bcs,
lv_email TYPE ad_smtpadr,
lv_lines TYPE i.
SELECTION-SCREEN: BEGIN OF BLOCK b2 WITH FRAME TITLE text-010.
SELECT-OPTIONS: s_ercpt FOR catsxt_sf-email NO INTERVALS .
SELECTION-SCREEN END OF BLOCK b2.
* Internal tables : move your internal table
DATA : BEGIN OF gt_up_file OCCURS 0,
line(200),
END OF gt_up_file.
*Delimiters for spreadsheet attachment
CLASS:cl_abap_char_utilities DEFINITION LOAD.
CONSTANTS: gc_tab TYPE c VALUE cl_bcs_convert=>gc_tab,
gc_crlf TYPE c VALUE cl_bcs_convert=>gc_crlf.
DATA: gv_tab TYPE c VALUE cl_abap_char_utilities=>horizontal_tab,
gv_newline TYPE c VALUE cl_abap_char_utilities=>newline,
gv_line_feed TYPE c VALUE cl_abap_char_utilities=>cr_lf.
WRITE sy-datum TO lv_date DD/MM/YYYY.
lv_lines = lines( gt_up_file ).
IF lv_lines GT 65000.
MESSAGE i000(zmm) WITH
'Report has more than 65,000 lines. Email cannot be'
'sent - Report can only be displayed.'
'In order to email report,'
'please change your selection criteria.'.
EXIT.
ENDIF.
LOOP AT gt_up_file .
CONCATENATE lv_string gt_up_file gc_crlf gv_newline
INTO lv_string.
ENDLOOP.
* --------------------------------------------------------------
* convert the text string into UTF-16LE binary data including
* byte-order-mark. Mircosoft Excel prefers these settings
* all this is done by new class cl_bcs_convert (see note 1151257)
TRY.
cl_bcs_convert=>string_to_solix(
EXPORTING
iv_string = lv_string
iv_codepage = '4103' "suitable for MS Excel, leave empty
iv_add_bom = 'X' "for other doc types
IMPORTING
et_solix = lv_binary_content
ev_size = lv_size ).
CATCH cx_bcs.
MESSAGE e445(so).
ENDTRY.
TRY.
* -------- create persistent send request ------------------------
lo_send_request = cl_bcs=>create_persistent( ).
* -------- create and set document with attachment ---------------
* create document object from internal table with text
lv_text = lv_date.
APPEND lv_text TO lt_main_text.
APPEND INITIAL LINE TO lt_main_text.
lv_text = 'Customer Price List Attached'.
APPEND lv_text TO lt_main_text.
CONCATENATE 'Customer Price List' sy-datum sy-uzeit
INTO lv_subject SEPARATED BY '_'.
lo_document = cl_document_bcs=>create_document(
i_type = 'RAW'
i_text = lt_main_text
i_subject = lv_subject ).
* add the spread sheet as attachment to document object
lo_document->add_attachment(
i_attachment_type = 'XLS' "
i_attachment_subject = lv_subject
i_attachment_size = lv_size
i_att_content_hex = lv_binary_content ).
* add document object to send request
lo_send_request->set_document( lo_document ).
* --------- add recipient (e-mail address) -----------------------
* create recipient object
LOOP AT s_ercpt.
lv_email = s_ercpt-low.
lo_recipient = cl_cam_address_bcs=>create_internet_address(
lv_email ).
* add recipient object to send request
lo_send_request->add_recipient( lo_recipient ).
ENDLOOP.
* ---------- send document ---------------------------------------
lv_sent_to_all = lo_send_request->send( i_with_error_screen = 'X' ).
COMMIT WORK.
IF lv_sent_to_all IS INITIAL.
MESSAGE s500(sbcoms) WITH ''.
ELSE.
MESSAGE s022(so).
ENDIF.
* ------------ exception handling ----------------------------------
CATCH cx_bcs INTO lo_bcs_exception.
MESSAGE i865(so) WITH lo_bcs_exception->error_type.
ENDTRY.
Regards,
Nawa
05-07-2019 3:17 PM
one small question can you please tell me lt_contents_bin which is type TYPE STANDARDTABLEOF xstring WITHHEADERLINE
what should I equal it to?
05-07-2019 3:38 PM
Hi,
I assume your internal table will be with header line if its bellow code you can make it.
LOOP AT lt_contents_bin.
CONCATENATE lv_string lt_contents_bin gc_crlf gv_newline INTO lv_string.
endloop.
05-07-2019 3:59 PM
No email is comming to me ,I gave my email to and removed the loop,is this correct?No email came to me,even though the message says email sent
lv_email = 'myemail'.
lo_recipient = cl_cam_address_bcs=>create_internet_address(
lv_email ).
* add recipient object to send request
lo_send_request->add_recipient( lo_recipient ).
05-07-2019 4:22 PM
Hi,
you should provide full email address
lv_email ='myemail@gmail.com'. "or your company email
Then go to Tcode SOST and check it. your email will be there .
Regards,
Nawa
05-08-2019 8:17 AM
well I do that but still no email,very stange.
When I open lo_send_request it is empty ,even if I add my email in the debugger it still does not send it.
Should the lv_email and lo_recipient be the same?
05-08-2019 10:48 AM
an update I was alble to send the email but still not showing all the columns
05-08-2019 2:24 PM
Hi,
It can't be , using this program i send more than 40 columns.
Regards,
Nawa.
05-09-2019 10:02 AM
do you know what possibly can be the couse why the email are not being sent?does it need to be maintained somewhere?how can that be avoided and send the email directly?