2007 Oct 12 4:03 AM
Hi Friends,
we sending the ship alert as mail attachment. File type is .txt.
when seeing the file in SAP Business work Place, the contents of the text file are aligned properly in a right way.
we are using concatenate it_attach con_cret into it_attach.
But while seeing the file coming as mail attachment, the alignment is not proper.
each line is taking about 255 characters to start a second line.
To get the proper alignment in mail attachment what should i do ? kinldy help me.
Thanks in advance.
Regards,
Paul
2007 Oct 12 5:05 AM
2007 Oct 12 5:05 AM
2007 Oct 12 5:07 AM
2007 Oct 12 5:13 AM
Joseph,
Thinking that you have all the data in one internal table,now take an internal table of the below given structure,append the data as shown and then pass this as the text file.
suppose
data:begin of imakt occurs 0,
matnr like makt-matnr,
maktx like makt-maktx,
end of imakt.
data:begin of itfinal occurs 0,
data(500),
end of itfinal.
select matnr maktx from makt into table imakt where spras = sy-langu.
loop at itab1.
itfinal-data = itfinal-matnr.
itfinal-data = itfinal-maktx.
append itfinal.
endloop.
now use this itfinal to be passed to the gui_download.
Try like this.Reward only if helpful.
K.Kiran.
2007 Oct 12 5:14 AM
Hi Joseph
Use
DATA : T_MAIL_TEXT LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE.
DATA : S_MAIL_TEXT TYPE SOLISTI1.
Loop at .......
CONCATENATE it_attach con_cret into S_MAIL_TEXT-LINE SEPARATED BY SPACE.
APPEND S_MAIL_TEXT TO T_MAIL_TEXT.
CLEAR S_MAIL_TEXT.
endloop.
Then use CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'
pass OBJECT_CONTENT = T_MAIL_TEXT
Don't rewards if not helpful.
Regards
Srimanta
2007 Oct 12 5:42 AM
Hi Srimanta,
we used
CONCATENATE it_attach con_cret into it_attach
and used used FM - SO_DOCUMENT_SEND_API1 to send the mail.
when seeing the attachment in SAP Business work place the alignment is very nice. But when opening the attachment coming in the mail, the alignment is not ok. Kindly help in that part of alignment .
Thanks
Joseph
2012 May 10 10:28 PM
Hi Joseph,
look here (ignore the texts)
IF x_recipient IS NOT INITIAL.
lv_recipient = x_recipient.
ELSE.
lv_recipient = bla bla blacesbla bla blater.de'.
ENDIF.
lv_subject = 'bla bla blabla bla blabla bla bla'.
lv_tab = cl_abap_char_utilities=>horizontal_tab.
lv_cr_lf = cl_abap_char_utilities=>cr_lf.
WRITE x_lieferdatum TO lv_lieferdatum.
CONCATENATE:
'bla bla blabla bla blabla bla bla'
lv_cr_lf
`bla bla bla `
lv_cr_lf
lv_tab x_url
lv_cr_lf
`bla bla bla` x_gpart
lv_cr_lf
`bla bla bla: ` x_vkont
lv_cr_lf
`bla bla bla ` x_anlage
lv_cr_lf
`bla bla bla ` x_tariftyp
lv_cr_lf
`bla bla bla ` lv_lieferdatum
lv_cr_lf
`bla bla bla ` x_agbversion
lv_cr_lf
lv_cr_lf
`bla bla blabla bla blabla bla blabla bla bla. `
`bla bla blabla bla blabla bla blabla bla blabla bla bla`
lv_cr_lf
lv_cr_lf
`bla bla blabla bla blabla bla blabla bla blabla bla blabla bla bla`
lv_cr_lf
INTO lv_string.
TRY.
lv_size_document = STRLEN( lv_string ).
lt_soli = cl_bcs_convert=>string_to_soli( lv_string ).
lo_bcs = cl_bcs=>create_persistent( ).
lo_document = cl_document_bcs=>create_document(
i_type = 'TXT' "
* SCN Case Ahr: If you want to add lines which are longer than 255 characters
* you must use a doctype other than RAW. If you use TXT no line breaks are
* inserted after 255 characters. For TXT documents you are responsible for
* the line break
i_importance = '0'
i_length = lv_size_document
* i_hex = lt_solix
i_text = lt_soli
i_subject = lv_subject ).
* No reading confirmation required
lo_bcs->set_status_attributes(
i_requested_status = 'E'
i_status_mail = 'A' ).
* add document to send request
CALL METHOD lo_bcs->set_document( lo_document ).
* add sender
lo_sender = /item/cl_tool_static=>get_bcs_system_sender( ).
lo_bcs->set_sender( lo_sender ).
* add recioient
lo_recipient = cl_cam_address_bcs=>create_internet_address(
lv_recipient ).
lo_bcs->add_recipient(
EXPORTING
i_recipient = lo_recipient
i_express = abap_true ).
lo_bcs->set_send_immediately( abap_true ).
IF lo_bcs->send( ) IS INITIAL.
* Create a DUMP that can be analyzed
ASSERT 1 = 2.
ELSE.
IF x_commit IS NOT INITIAL.
COMMIT WORK.
ENDIF.
ENDIF.
CATCH
cx_address_bcs
cx_document_bcs
cx_send_req_bcs
cx_bcs
INTO lo_bcs_exception .
lv_string = lo_bcs_exception->get_text( ).
MESSAGE lv_string TYPE 'S'.
* Create a DUMP that can be analyzed
ASSERT 1 = 2.
ENDTRY.
Use this and never ever again func, SO_NEW_shit
Regards
Clemens
2012 May 11 11:54 AM
Ror texts longer than 255 characters you need to create a document with "TXT" like below.
If you want to add lines which are longer than 255 characters Fill the fp_it_text with the text with exactly the way you want to get aligned. Use this to get the alignment. cr_lf = cl_abap_char_utilities=>cr_lf. Use CL_BCS only.
DATA : ob_bcs TYPE REF TO cl_bcs,
ob_document TYPE REF TO cl_document_bcs,
it_recipient TYPE TABLE OF ztmm_popdf_mail,
wa_recipient TYPE ztmm_popdf_mail,
ob_recipient TYPE REF TO if_recipient_bcs,
ob_recipient_internet TYPE REF TO cl_cam_address_bcs,
lv_result TYPE os_boolean,
ob_root TYPE REF TO cx_root,
lv_att_des TYPE so_obj_des,
lv_att_name TYPE dstring,
wa_lfa1 TYPE lfa1.
DATA: lv_obj_des TYPE so_obj_des.
DATA: lt_mailid TYPE TABLE OF ztmm_popdf_mail ,
wa_mailid TYPE ztmm_popdf_mail ,
lv_mailid TYPE ad_smtpadr,
lv_ident TYPE zident.
DATA: send_request TYPE REF TO cl_send_request_bcs.
** Create BCS document
ob_bcs = cl_bcs=>create_persistent( ).
send_request = ob_bcs->send_request.
** Create Document for the body/message
ob_document = cl_document_bcs=>create_document( i_type = 'TXT'
i_subject = fp_subject
i_text = fp_it_text ).
* Add recipient
lv_mailid = gv_emailaddr."wa_mailid-emailid.
ob_recipient_internet = cl_cam_address_bcs=>create_internet_address( i_address_string = lv_mailid ).
ob_bcs->add_recipient( EXPORTING i_recipient = ob_recipient_internet ).
ob_bcs->set_document( EXPORTING i_document = ob_document ) .
ob_bcs->set_send_immediately( EXPORTING i_send_immediately = abap_true ).
CALL METHOD send_request->set_link_to_outbox( 'X' ).
** Send mail
lv_result = ob_bcs->send( ).
* CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
CATCH cx_root INTO ob_root.