ALV Report to be send as a mail as an Excel sheet attachment
Hi,
I have designed a Report that has the mailing functionality by attaching the ALV report output in the Excel sheet.
1. I am using SUBMITT PROGRAM....EXPORTING MEMORY ID.
Here I am retrieving the required ALV report.
2. I am passing of ALV Report output to internal table, say XLS_TAB using FM LIST_TO_ASCI.
I can see the data in the internal table. But the problem is when the report output has many columns (i.e) greater than 255 Char, the columns get truncated(data is missed).
So, how to prevent the missing of the columns. I don't want split each record into new line. Because, when it is passed to Excel, each record should be in a single line without missing any column.
If you say the FM can be valid upto 255 Char, what can be the alternative solution?
Immediate response is appreciated.
Thanks for your help.
Sravan.
Hi deepan
DESCRIBE TABLE objtxt LINES tab_lines.
READ TABLE objtxt INDEX tab_lines.
docdata-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objtxt ) . <---- make it 1024 instead of 255
CLEAR objpack-transf_bin.
objpack-head_start = 1.
objpack-head_num = 0.
objpack-body_start = 1.
objpack-body_num = gv_tab_lines.
objpack-doc_type = RAW
APPEND objpack
then looping contents of the final table to OBJBIN1.
DESCRIBE TABLE objbin1 LINES tab_lines.
objpack-doc_size = tab_lines * 255 . <-------- make it has 1024 instead of 255
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
APPEND objpack.
Regards
vijay
Similar Messages
-
Urgent: Sending an Email with Excel sheet attachment
Hi All,
I am preparing a report and has to send mail with excel sheet attachement. In report i am getting everything fine. But in the mail i am not getting the data, data is passing to the FM succesfully. But in the mail, excel is not having full data.
the below mentioned is my code.
i_texts-line = c_stern.
i_texts-line+254(1) = c_newline.
APPEND i_texts.
LOOP AT i_texc.
i_att_line-line = i_texc.
APPEND i_att_line.
ENDLOOP.
DATA: wa_doc_chng LIKE sodocchgi1.
DATA: w_tab_lines LIKE sy-tabix.
STATICS: c_body_start TYPE i VALUE '1'.
CONSTANTS: lc_filename(10) TYPE c VALUE 'Attachment',
lc_atthead(30) TYPE c VALUE 'Manually released invoices'.
DATA: i_objpack LIKE sopcklsti1 OCCURS 2 WITH HEADER LINE.
DATA: w_doc_name(30) TYPE c.
DATA: l_text1(15),
l_text2(12),
l_text3(15),
l_text4(15),
l_text5(14),
l_text6(17),
l_text7(10),
l_text8(20),
l_text9(19),
l_text10(19),
l_text11(19),
l_text12(16),
l_text13(20),
l_text14(19),
l_text15(19),
l_text16(30).
DATA: DATE(10),
DT(2),
MON(3),
YR(4),
lc_final(50).
CLEAR: i_texts, i_reci,i_att_line. "i_bname,
REFRESH: i_texts, i_reci,i_att_line. "i_bname,
WRITE sy-datum TO w_datex.
WRITE sy-uzeit TO w_timex.
l_text1 = text-003.
l_text2 = text-004.
l_text3 = text-005.
l_text4 = text-006.
l_text5 = text-007.
l_text6 = text-008.
l_text7 = text-009.
l_text8 = text-010.
l_text9 = text-011.
l_text10 = text-012.
l_text11 = text-013.
l_text12 = text-014.
l_text13 = text-015.
l_text14 = text-016.
l_text15 = text-017.
l_text16 = text-026.
CONCATENATE
l_text1
l_text2
l_text3
l_text4
l_text5
l_text6
l_text7
l_text8
l_text9
l_text10
l_text11
l_text12
l_text13
l_text14
l_text15
l_text16
INTO i_texts SEPARATED BY
c_horz_tab.
i_texts-line+254(1) = c_newline.
APPEND i_texts.
CLEAR i_texts.
LOOP AT i_texc.
i_att_line-line = i_texc.
APPEND i_att_line.
ENDLOOP.
LOOP AT so_rec.
i_reci-receiver = so_rec-low.
i_reci-express = 'X'.
i_reci-rec_type = 'U'.
APPEND i_reci.
ENDLOOP.
DESCRIBE TABLE i_texts LINES w_tab_lines.
READ TABLE i_texts INDEX w_tab_lines.
wa_doc_chng-doc_size = ( w_tab_lines - 1 ) * 255 + STRLEN( i_texts ).
wa_obj_name = 'ZFI_XX_REL_BLOCKED_INVOICE_01'.
DT = SY-DATUM+6(2).
MON = SY-DATUM+4(2).
YR = SY-DATUM+0(4).
CONCATENATE DT MON YR INTO DATE SEPARATED BY '-'.
CONCATENATE lc_atthead date into lc_final separated by ' '.
MOVE lc_final
TO wa_obj_descr .
wa_doc_chng-obj_name = wa_obj_name.
wa_doc_chng-obj_descr = wa_obj_descr.
CLEAR i_objpack-transf_bin.
i_objpack-head_start = 1.
i_objpack-head_num = 0.
i_objpack-body_start = 0.
i_objpack-body_num = w_tab_lines.
i_objpack-doc_type = 'RAW'.
APPEND i_objpack.
APPEND LINES OF i_att_line TO i_texts.
LOOP AT i_arseg INTO wa_arseg.
i_xmplt_d-belnr = wa_arseg-belnr.
i_xmplt_d-budat = wa_arseg-budat.
i_xmplt_d-bukrs = wa_arseg-bukrs.
i_xmplt_d-lifnr = wa_arseg-lifnr.
i_xmplt_d-name1_lifnr = wa_arseg-name1_lifnr.
i_xmplt_d-wrbtr = wa_arseg-wrbtr.
i_xmplt_d-waers = wa_arseg-waers.
i_xmplt_d-ebeln = wa_arseg-ebeln.
i_xmplt_d-ebelp = wa_arseg-ebelp.
i_xmplt_d-reason = wa_arseg-reason.
i_xmplt_d-dmeng = wa_arseg-dmeng.
i_xmplt_d-dwert = wa_arseg-dwert.
i_xmplt_d-bname = wa_arseg-bname.
i_xmplt_d-name_text = wa_arseg-name_text.
i_xmplt_d-udate = wa_arseg-udate.
i_xmplt_d-comment = wa_arseg-comment.
APPEND i_xmplt_d.
ENDLOOP.
LOOP AT i_xmplt_d.
CONCATENATE i_xmplt_d-belnr
i_xmplt_d-budat
i_xmplt_d-bukrs
i_xmplt_d-lifnr
i_xmplt_d-name1_lifnr
i_xmplt_d-wrbtr
i_xmplt_d-waers
i_xmplt_d-ebeln
i_xmplt_d-ebelp
i_xmplt_d-reason
i_xmplt_d-dmeng
i_xmplt_d-dwert
i_xmplt_d-bname
i_xmplt_d-name_text
i_xmplt_d-udate
i_xmplt_d-comment
INTO i_texts SEPARATED
BY c_horz_tab.
i_texts-line+254(1) = c_newline.
APPEND i_texts.
CLEAR i_texts.
ENDLOOP.
DESCRIBE TABLE i_texts LINES w_tab_lines.
READ TABLE i_texts INDEX w_tab_lines.
wa_doc_chng-doc_size = ( w_tab_lines - 1 ) * 255 + STRLEN( i_texts ).
DESCRIBE TABLE i_texts LINES w_tab_lines.
i_objpack-transf_bin = ' '.
i_objpack-head_start = 0.
i_objpack-head_num = 0.
i_objpack-body_start = 1.
i_objpack-body_num = w_tab_lines.
i_objpack-doc_type = 'XLS'.
i_objpack-obj_name = 'Attachment'.
i_objpack-obj_descr = w_doc_name.
i_objpack-obj_descr = lc_filename.
i_objpack-doc_size = w_tab_lines * 255.
APPEND i_objpack.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = wa_doc_chng
TABLES
packing_list = i_objpack
contents_txt = i_texts
receivers = i_reci
EXCEPTIONS
too_many_receivers = 1
document_not_sent = 2
operation_no_authorization = 4
OTHERS = 99.
IF sy-subrc = 0.
COMMIT WORK.
ELSE.
WRITE: / 'Error in send E-Mail' .
ENDIF.
please revert me asap. It is very urgent to me. thanks in advance.
ByehI
Have you build your Excel Data table to get attachement in Mail? If no then please find the Eg. code for your reference to send Excel attachment..
* End of Selection Event : Displaying the selected data *
END-OF-SELECTION.
PERFORM EMAIL_EXCEL_ATTACHMENT.
******///form
FORM EMAIL_EXCEL_ATTACHMENT .
* Populate table with detaisl to be entered into .xls file
PERFORM BUILD_XLS_DATA_TABLE.
* Populate message body text
PERFORM POPULATE_EMAIL_MESSAGE_BODY.
* Send file by email as .xls speadsheet
PERFORM SEND_FILE_AS_EMAIL_ATTACHMENT
TABLES IT_MESSAGE
IT_ATTACH
USING S_EMAIL
TEXT-042
C_XLS
'filename'
CHANGING GD_ERROR
GD_RECIEVER.
* Instructs mail send program for SAPCONNECT to send email(rsconn01)
PERFORM INITIATE_MAIL_EXECUTE_PROGRAM.
ENDFORM. " EMAIL_EXCEL_ATTACHMENT
********///form BUILD_XLS_DATA_TABLE
FORM BUILD_XLS_DATA_TABLE .
DATA : LV_NETWR(20) TYPE C,
LV_BOL_DATE(20) TYPE C,
LV_KAWRT(20) TYPE C,
LV_FKDAT(20) TYPE C,
LV_WAERK(20) TYPE C,
LV_KURRF(20) TYPE C,
LV_SHIPDATE(20) TYPE C,
LV_DEPTDATE(20) TYPE C.
CONSTANTS:
CON_TAB TYPE C VALUE CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB,
CON_CRET TYPE C VALUE CL_ABAP_CHAR_UTILITIES=>CR_LF. "#EC *
DATA STR TYPE STRING.
**********/ this parameter concatenate to get headers
CONCATENATE STR
'SLNO'
'OWNER'
'SERIAL NO'
'FROM'
'DESTINATION'
'INVOICE VALUE'
'DESCRIPTION'
'CUSTOMER NAME'
'BL NUMBER'
'BL DATE'
'VESSEL NAME/AIRLINE DETAILS'
'MODE OF TRANSIT'
'SHIPPING MARKS'
'DUTY SUM INSURED'
'FLAG'
'OPEN COVERNO'
'INVOICE DATE'
'INVOICE NO'
'LC WORDING'
'QUANTITY'
'PACKAGING DETAILS'
'BASIS OF VALUATION'
'EXCLUDE WAR SRCC'
'CURRENCY'
'EXCHANGE RATE'
'ADDRESS'
'VESSEL BUILT YEAR'
'VESSEL FLAG'
'VOYAGE NO'
'SHIPMENT DATE'
'DEPARTURE DATE'
'SURVEYOR COUNTRY'
'SURVEYOR CITY'
'SURVEYOR AGENT'
'SURVEYOR ADDRESS'
'EXPORT CONSIGNMENT'
'CONTAINER DETAILS'
CL_ABAP_CHAR_UTILITIES=>CR_LF INTO STR SEPARATED BY CON_TAB.
LOOP AT IT_FINAL.
*******/ this is to pass body / row data
WRITE : IT_FINAL-NETWR TO LV_NETWR, "#EC UOM_IN_MES
IT_FINAL-BOL_DATE TO LV_BOL_DATE,
IT_FINAL-KAWRT TO LV_KAWRT, "#EC UOM_IN_MES
IT_FINAL-FKDAT TO LV_FKDAT,
IT_FINAL-WAERK TO LV_WAERK,
IT_FINAL-KURRF TO LV_KURRF,
IT_FINAL-SHIPDATE TO LV_SHIPDATE,
IT_FINAL-DEPTDATE TO LV_DEPTDATE.
CONCATENATE
STR
IT_FINAL-SLNO
IT_FINAL-OWNER
IT_FINAL-SRNO
IT_FINAL-PORT_LOAD
IT_FINAL-PORT_DSCHR
LV_NETWR
IT_FINAL-DESCRIP
IT_FINAL-CUSTNAME
IT_FINAL-BOL_NUM
LV_BOL_DATE
IT_FINAL-VESSELNAME
IT_FINAL-SHP_TYPE
IT_FINAL-SHP_MARK
LV_KAWRT
IT_FINAL-FLAG
IT_FINAL-OPEN_CONO
LV_FKDAT
IT_FINAL-VBELN
IT_FINAL-LC_WORD
IT_FINAL-QUANT
IT_FINAL-PACKDETL
IT_FINAL-INCO1
IT_FINAL-EXCWSR
LV_WAERK
LV_KURRF
IT_FINAL-ADDPAY
IT_FINAL-VESSBYR
IT_FINAL-VESSFLG
IT_FINAL-VOY_FLY_NO
LV_SHIPDATE
LV_DEPTDATE
IT_FINAL-SURCOUNT
IT_FINAL-INCO2
IT_FINAL-EXPORT_CON
IT_FINAL-SURAGT
IT_FINAL-SURADD
IT_FINAL-CONTRNO
CL_ABAP_CHAR_UTILITIES=>CR_LF INTO STR SEPARATED BY CON_TAB.
ENDLOOP.
CALL FUNCTION 'SCMS_STRING_TO_FTEXT'
EXPORTING
TEXT = STR
TABLES
FTEXT_TAB = IT_ATTACH.
ENDFORM. " BUILD_XLS_DATA_TABLE
******// form POPULATE_EMAIL_MESSAGE_BODY
FORM POPULATE_EMAIL_MESSAGE_BODY .
REFRESH IT_MESSAGE.
IT_MESSAGE = TEXT-043. " Please find attached Insurance Certificate details
APPEND IT_MESSAGE.
ENDFORM. " POPULATE_EMAIL_MESSAGE_BODY
*******'/ form SEND_FILE_AS_EMAIL_ATTACHMENT
*& Form SEND_FILE_AS_EMAIL_ATTACHMENT
* text
* -->PIT_MESSAGE text
* -->PIT_ATTACH text
* -->P_EMAIL text
* -->P_MTITLE text
* -->P_FORMAT text
* -->P_FILENAME text
* -->P_ATTDESCRIPTION text
* -->P_SENDER_ADDRESS text
* -->P_SENDER_ADDRES_TYPE text
* -->P_ERROR text
* -->P_RECIEVER text
FORM SEND_FILE_AS_EMAIL_ATTACHMENT TABLES PIT_MESSAGE
PIT_ATTACH
USING P_EMAIL
P_MTITLE
P_FORMAT
P_FILENAME
P_ATTDESCRIPTION
P_SENDER_ADDRESS
P_SENDER_ADDRES_TYPE
CHANGING P_ERROR
P_RECIEVER. "#EC *
DATA: LD_ERROR TYPE SY-SUBRC, "#EC *
* LD_RECIEVER TYPE SY-SUBRC,
LD_MTITLE LIKE SODOCCHGI1-OBJ_DESCR,
* LD_EMAIL LIKE SOMLRECI1-RECEIVER,
LD_FORMAT TYPE SO_OBJ_TP ,
LD_ATTDESCRIPTION TYPE SO_OBJ_NAM ,
LD_ATTFILENAME TYPE SO_OBJ_DES ,
LD_SENDER_ADDRESS LIKE SOEXTRECI1-RECEIVER,
LD_SENDER_ADDRESS_TYPE LIKE SOEXTRECI1-ADR_TYP,
LD_RECEIVER LIKE SY-SUBRC. "#EC *
* ld_email = p_email.
LD_MTITLE = P_MTITLE.
LD_FORMAT = P_FORMAT.
LD_ATTDESCRIPTION = P_ATTDESCRIPTION.
LD_ATTFILENAME = P_FILENAME.
LD_SENDER_ADDRESS = P_SENDER_ADDRESS.
LD_SENDER_ADDRESS_TYPE = P_SENDER_ADDRES_TYPE.
* Fill the document data.
W_DOC_DATA-DOC_SIZE = 1.
* Populate the subject/generic message attributes
W_DOC_DATA-OBJ_LANGU = SY-LANGU.
W_DOC_DATA-OBJ_NAME = 'SAPRPT'.
W_DOC_DATA-OBJ_DESCR = LD_MTITLE .
W_DOC_DATA-SENSITIVTY = 'F'.
* Fill the document data and get size of attachment
CLEAR W_DOC_DATA.
DESCRIBE TABLE IT_ATTACH LINES W_CNT.
READ TABLE IT_ATTACH INDEX W_CNT.
W_DOC_DATA-DOC_SIZE =
W_CNT * 255 + STRLEN( IT_ATTACH ).
W_DOC_DATA-OBJ_LANGU = SY-LANGU.
W_DOC_DATA-OBJ_NAME = 'SAPRPT'.
W_DOC_DATA-OBJ_DESCR = LD_MTITLE.
W_DOC_DATA-SENSITIVTY = 'F'.
CLEAR T_ATTACHMENT.
REFRESH T_ATTACHMENT.
T_ATTACHMENT[] = PIT_ATTACH[].
* Describe the body of the message
CLEAR T_PACKING_LIST.
REFRESH T_PACKING_LIST.
T_PACKING_LIST-TRANSF_BIN = SPACE.
T_PACKING_LIST-HEAD_START = 1.
T_PACKING_LIST-HEAD_NUM = 0.
T_PACKING_LIST-BODY_START = 1.
DESCRIBE TABLE IT_MESSAGE LINES T_PACKING_LIST-BODY_NUM.
T_PACKING_LIST-DOC_TYPE = 'raw'.
APPEND T_PACKING_LIST.
* Create attachment notification
T_PACKING_LIST-TRANSF_BIN = 'X'.
T_PACKING_LIST-HEAD_START = 1.
T_PACKING_LIST-HEAD_NUM = 1.
T_PACKING_LIST-BODY_START = 1.
DESCRIBE TABLE T_ATTACHMENT LINES T_PACKING_LIST-BODY_NUM.
T_PACKING_LIST-DOC_TYPE = LD_FORMAT.
T_PACKING_LIST-OBJ_DESCR = LD_ATTDESCRIPTION.
T_PACKING_LIST-OBJ_NAME = LD_ATTFILENAME.
T_PACKING_LIST-DOC_SIZE = T_PACKING_LIST-BODY_NUM * 255.
APPEND T_PACKING_LIST.
* Add the recipients email address
CLEAR T_RECEIVERS.
REFRESH T_RECEIVERS.
LOOP AT S_EMAIL.
T_RECEIVERS-RECEIVER = S_EMAIL-LOW.
T_RECEIVERS-REC_TYPE = 'U'.
T_RECEIVERS-COM_TYPE = 'INT'.
T_RECEIVERS-NOTIF_DEL = 'X'.
T_RECEIVERS-NOTIF_NDEL = 'X'.
APPEND T_RECEIVERS.
ENDLOOP.
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
DOCUMENT_DATA = W_DOC_DATA
PUT_IN_OUTBOX = 'X'
SENDER_ADDRESS = LD_SENDER_ADDRESS
SENDER_ADDRESS_TYPE = LD_SENDER_ADDRESS_TYPE
COMMIT_WORK = 'X'
IMPORTING
SENT_TO_ALL = W_SENT_ALL
TABLES
PACKING_LIST = T_PACKING_LIST
CONTENTS_BIN = T_ATTACHMENT
CONTENTS_TXT = IT_MESSAGE
RECEIVERS = T_RECEIVERS
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.
* Populate zerror return code
LD_ERROR = SY-SUBRC.
* Populate zreceiver return code
LOOP AT T_RECEIVERS.
LD_RECEIVER = T_RECEIVERS-RETRN_CODE.
ENDLOOP.
ENDFORM. " SEND_FILE_AS_EMAIL_ATTACHMENT
*******/form
*& Form INITIATE_MAIL_EXECUTE_PROGRAM
* text
* --> p1 text
* <-- p2 text
FORM INITIATE_MAIL_EXECUTE_PROGRAM .
WAIT UP TO 2 SECONDS.
SUBMIT RSCONN01 WITH MODE = 'INT'
WITH OUTPUT = 'X'
AND RETURN.
ENDFORM. " INITIATE_MAIL_EXECUTE_PROGRAM
*********end of code to trigger mail in excel format....
If any other help please let me know......
I am sure this example code will help you to resolve your problem...
please analyse above code for your requirement...
In my scenario the message you said is not displaying.....
Reward Points -
How to send huge no. of excel sheet attachment to a mail ID
HI ,
I have mail functionality program which send mail to a mail id with multiple excel sheet attchment. I have done all these things. When it sends small number of excel attchment then it's ok. But when it sends huge number of excel attchment (ex.- 1000 excel attchment) then it showing error message to the mail id -
'This message is larger than the size limit for messages. Please make it smaller and try sending it again.'
I have used cl_bcs, cl_document_bcs these class. I have seen all related post in sdn but unable to get my requirement.
i need your suggestion.Hi,
Try this code::
FORM MAIL_SEND .
*Mail Body
MOVE text-004 TO wa_text. "Space
APPEND wa_text TO wt_text.
CLEAR wa_text.
MOVE TEXT-003 TO wa_text.
APPEND wa_text TO wt_text.
CLEAR wa_text.
MOVE text-005 TO wa_text.
APPEND wa_text TO wt_text.
CLEAR wa_text.
MOVE TEXT-003 TO wa_text.
APPEND wa_text TO wt_text.
CLEAR wa_text.
MOVE text-011 TO wa_text.
APPEND wa_text TO wt_text.
CLEAR wa_text.
tl_contents[] = wt_text.
TRY.
TRY.
**-- Create persistent send request
l_send_request = cl_bcs=>create_persistent( ).
CATCH CX_SEND_REQ_BCS.
ENDTRY.
*-- Get the length of the Document
DESCRIBE TABLE tl_contents LINES l_cnt.
READ TABLE tl_contents INTO wa_contents INDEX l_cnt.
l_doc_len = ( l_cnt - 1 ) * 255 + STRLEN( wa_contents ).
*-- Subject of the mail
l_sub = 'TEST1'.
I_SUBJECT = 'BP assignment report for Credit analyst and CrSeg'.
**-- Create Document
l_document = cl_document_bcs=>create_document(
i_type = c_htm
i_text = tl_contents
i_length = l_doc_len
i_subject = I_SUBJECT "'BP assignment report for Credit analyst and CrSeg
i_language = sy-langu
i_importance = '1' ).
CATCH CX_DOCUMENT_BCS.
**-- Subject of the mail
MOVE l_sub TO l_subj.
ENDTRY.
TRY.
*-- Set the Message Subject
CALL METHOD l_send_request->set_message_subject
EXPORTING
ip_subject = l_subj.
CATCH CX_SEND_REQ_BCS.
ENDTRY.
**-- Add document to send request
try.
CALL METHOD l_send_request->set_document( l_document ).
CATCH CX_SEND_REQ_BCS.
endtry.
CALL FUNCTION 'SPLIT_FILENAME'
EXPORTING
long_filename = 'C:\BP_DETAILS.XLS'
IMPORTING
pure_filename = p_name
pure_extension = p_ext.
TRANSLATE p_ext TO UPPER CASE.
elpath = 'C:\BP_DETAILS.XLS'.
*Upload the file
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = elpath
filetype = 'BIN'
TABLES
data_tab = t_ann
EXCEPTIONS
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
OTHERS = 17.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
try.
IF t_ann[] IS NOT INITIAL.
*-- File name of the Attachment
l_subject = p_name.
*-- Extension of the Attachment
l_att_type = p_ext.
TRY.
w_document = l_document.
*-- Add Attachment to the Document
CALL METHOD L_document->add_attachment
EXPORTING
i_attachment_type = l_att_type
i_attachment_subject = l_subject
i_att_content_hex = t_ann. "t_mailhex.
CATCH cx_document_bcs.
ENDTRY.
ENDIF.
*-- Do send delivery info for successful mails
lv_msg = 'E'.
CALL METHOD l_send_request->set_status_attributes
EXPORTING
i_requested_status = lv_msg "Error status
i_status_mail = lv_msg. "Error status
TRY.
send_request = l_send_request->send_request.
CATCH cx_bcs.
ENDTRY.
set outbox flag
TRY.
CALL METHOD send_request->set_link_to_outbox( 'X' ).
CATCH cx_bcs.
ENDTRY.
request error status
TRY.
CALL METHOD send_request->setu_requested_status( req_stat ).
CATCH cx_bcs INTO l_bcs_exception.
ENDTRY.
*-- Set sender
l_sender = cl_sapuser_bcs=>create( sy-uname ).
CALL METHOD l_send_request->set_sender
EXPORTING
i_sender = l_sender.
gs_mail-e_mail = 'mail ID1'.
APPEND gs_mail TO gt_mail.
CLEAR gs_mail.
gs_mail-e_mail = 'mail ID2'.
APPEND gs_mail TO gt_mail.
CLEAR gs_mail.
gs_mail-e_mail = 'mail ID3'.
APPEND gs_mail TO gt_mail.
CLEAR gs_mail.
loop at gt_mail into gs_mail.
try.
l_recipient = cl_cam_address_bcs=>create_internet_address(
gs_mail-e_mail ).
catch cx_address_bcs.
endtry.
CALL METHOD l_send_request->add_recipient
EXPORTING
i_recipient = l_recipient
i_express = 'X'
i_copy = 'X'.
endloop.
*-- Send Email
CALL METHOD l_send_request->send(
EXPORTING
i_with_error_screen = 'X'
RECEIVING
result = l_result ).
CATCH cx_bcs INTO l_bcs_exception.
ENDTRY.
COMMIT WORK.
ENDFORM.
Thanks -
I used Internet explorer but was having difficulties reading "sky's" e-mails, I was recommended by Sky to use Firefox. I can now read the e-mails but when I send an e-mail and an attachment, to 4 addressees (which I have done every week for about 5 years, using internet explorer) they don't arrive at any of the intended destination, can anyone give me a solution to my problem. Thanks
Hi thanks for the response,
I haven't tried to send an attachment to myself, not sure exactly how to do that but I'll have a look Friday/Saturday when I get home.
As to the mail system, I use Sky's e-mail, as I said it use to work perfect on Internet explorer until Sky changed the format of their e-mail page, then I was unable to scroll up or down the page. So I was advised by Sky to use Firefox -
my company is using microsoft exchange server for the mails. When ever i send my mail, having even one single attachment, whole of the mail is converted into the attachment and the reciver receive the mail in the form of attachments.
HI,
I get following? when run the test? user is login to Domain A but accessing exchange in Domain B? -
Excel sheet attached mail when opened shows a error message
hi all,
i have created a report for sending the output to the sap inbox as excel attachment . my problem is ;it always shows an error message when ever the attachment is opened.
I have used the function 'SO_NEW_DOCUMENT_ATT_SEND_API1' and in the table parameters, TABLES
packing_list =
passing the .XLS format and excel sheet name.
please provide me a solution to stop the display of this error message having the contents 'this file is not in a recognizable format'.
thanks and regards\
Thomas
Coding :
FORM sub_output_timeadm USING lv_usrid TYPE gty_timhours-usrid.
DATA : lv_emp1(10) TYPE c,
lv_ename(40) TYPE c,
lv_hour(10) ,
lv_lgart(15),
lv_scc(10),
lv_rcc(10),
lv_order(15),
lv_ordtext(40),
lv_act(10).
DATA : lwa_content TYPE solisti1.
DATA : lit_objpack LIKE sopcklsti1 OCCURS 2 WITH HEADER LINE,"#EC *
lit_objbin LIKE solisti1 OCCURS 0 WITH HEADER LINE,
lit_objtxt LIKE solisti1 OCCURS 2 WITH HEADER LINE,
lit_reclist LIKE somlreci1 OCCURS 2 WITH HEADER LINE,
lwa_docdat LIKE sodocchgi1 OCCURS 1 WITH HEADER LINE,
lv_tab_lines LIKE sy-tabix.
DATA : lv_file LIKE rlgrap-filename,
lv_line LIKE solisti1-line,
lv_vt TYPE c VALUE cl_abap_char_utilities=>horizontal_tab.
DATA : lwa_receivers TYPE somlreci1 .
*Object text details
PERFORM sub_objtxt_data TABLES lit_objtxt
lit_objpack
USING lv_tab_lines.
*Document data details
PERFORM sub_document_data TABLES lwa_docdat
lit_objtxt
USING lv_file
lv_tab_lines.
PERFORM sub_topofpage TABLES lit_objbin
USING lv_line
lv_vt.
PERFORM sub_fill_columnhead TABLES lit_objbin.
LOOP AT git_content INTO lwa_content.
lv_emp1 = lwa_content+2(10).
CONDENSE lv_emp1.
lv_ename = lwa_content+15(40).
SHIFT lv_ename LEFT.
* CONDENSE lv_ename.
IF lv_ename+0(7) = text-024.
WRITE lv_ename TO lv_ename RIGHT-JUSTIFIED.
ELSE.
CONDENSE lv_ename.
ENDIF.
lv_hour = lwa_content+58(10).
CONDENSE lv_hour.
lv_lgart = lwa_content+70(15).
CONDENSE lv_lgart.
lv_scc = lwa_content+90(10).
CONDENSE lv_scc.
lv_rcc = lwa_content+103(10).
CONDENSE lv_rcc.
lv_order = lwa_content+115(15).
CONDENSE lv_order.
lv_ordtext = lwa_content+132(40).
CONDENSE lv_ordtext.
lv_act = lwa_content+174(10).
CONDENSE lv_act.
CONCATENATE lv_emp1
lv_ename
lv_hour
lv_lgart
lv_scc
lv_rcc
lv_order
lv_ordtext
lv_act INTO lv_line SEPARATED BY lv_vt.
CONCATENATE gc_add lv_line lv_vt INTO lv_line.
APPEND lv_line TO lit_objbin.
CLEAR :lv_emp1,
lv_ename,
lv_hour,
lv_lgart,
lv_scc,
lv_rcc,
lv_order,
lv_ordtext,
lv_act ,lv_line,lwa_content.
ENDLOOP.
DESCRIBE TABLE lit_objbin LINES lv_tab_lines.
lv_tab_lines = lv_tab_lines + 1.
* Object pack details
PERFORM sub_objpack_data TABLES lit_objbin
lit_objpack
USING lv_tab_lines
lv_file.
*Receiver list details
PERFORM sub_reclist_timeadm TABLES lit_reclist
USING lv_usrid.
READ TABLE lit_reclist INDEX 1.
IF sy-subrc = 0.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = lwa_docdat
put_in_outbox = gc_x
commit_work = gc_x
TABLES
packing_list = lit_objpack
contents_bin = lit_objbin
contents_txt = lit_objtxt
receivers = lit_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 i014.
* WHEN 1.
* MESSAGE i016.
* WHEN 2.
* MESSAGE i016.
* WHEN 4.
* MESSAGE i015.
* WHEN OTHERS.
* MESSAGE i017.
ENDCASE.
ENDIF.
REFRESH git_content.
CLEAR gwa_content.
FORM sub_objtxt_data TABLES xt_objtxt STRUCTURE solisti1
xt_objpack STRUCTURE sopcklsti1
USING xv_tab_lines .
DATA : lv_zdat(10) TYPE c,
lv_zdat2(10) TYPE c.
CONSTANTS: lc_hiphen(1) TYPE c VALUE '-'.
* write sy-datum to lv_zdat mm/dd/yyyy.
* concatenate text-022 lv_zdat into xt_objtxt separated by space.
* APPEND xt_objtxt.clear xt_objtxt.
WRITE pnpbegda TO lv_zdat MM/DD/YYYY.
WRITE pnpendda TO lv_zdat2 MM/DD/YYYY.
CONCATENATE text-080
lv_zdat
lc_hiphen
lv_zdat2 INTO xt_objtxt SEPARATED BY space.
APPEND xt_objtxt.CLEAR xt_objtxt.
xt_objtxt = text-067.
APPEND xt_objtxt.CLEAR xt_objtxt.
CLEAR: lv_zdat,
lv_zdat2.
DESCRIBE TABLE xt_objtxt LINES xv_tab_lines.
READ TABLE xt_objtxt INDEX xv_tab_lines.
CLEAR xt_objpack-transf_bin.
xt_objpack-head_start = 1.
xt_objpack-head_num = 0.
xt_objpack-body_start = 1.
xt_objpack-body_num = xv_tab_lines.
xt_objpack-doc_type = gc_raw.
APPEND xt_objpack.
CLEAR xt_objpack.
ENDFORM. " sub_objtxt_data
*& Form sub_document_data
*To fix the size of the document
* -->XT_DOCDAT
* -->XT_OBJTXT
* -->XV_LV_FILE
* -->XV_TAB_LINES
FORM sub_document_data TABLES xt_docdat STRUCTURE sodocchgi1
xt_objtxt STRUCTURE solisti1
USING xv_lv_file
xv_tab_lines. "#EC *
DATA : lv_subject TYPE string,
lv_open TYPE c VALUE '(',
lv_close TYPE c VALUE ')',
lv_slash TYPE c VALUE '/'.
xt_docdat-obj_name = xv_lv_file.
CONCATENATE lv_open sy-sysid
lv_slash sy-mandt lv_close INTO lv_subject.
xt_docdat-obj_descr = lv_subject.
xt_docdat-doc_size
= ( xv_tab_lines - 1 ) * 255 + STRLEN( xt_objtxt ).
ENDFORM. " sub_document_data
*& Form sub_topofpage
* text
* -->P_LIT_OBJBIN text
FORM sub_topofpage TABLES xt_objbin STRUCTURE solisti1
USING xv_lv_line
xv_vt.
DATA: lwa_line TYPE slis_listheader.
LOOP AT git_header INTO lwa_line.
CONCATENATE lwa_line-key lwa_line-info
INTO xv_lv_line SEPARATED BY xv_vt.
CONCATENATE gc_add xv_lv_line xv_vt
xv_vt "TAB space
xv_vt
xv_vt
xv_vt
xv_vt
xv_vt
* xv_vt
* xv_vt
* xv_vt
* xv_vt
* xv_vt
* xv_vt
* xv_vt
INTO xv_lv_line.
APPEND xv_lv_line TO xt_objbin.
ENDLOOP.
ENDFORM. " sub_topofpage
*& Form sub_fill_columnhead
* text
* --> p1 text
* <-- p2 text
FORM sub_fill_columnhead TABLES xt_objbin STRUCTURE solisti1.
DATA: lv_line LIKE solisti1-line,
lv_vt TYPE c VALUE cl_abap_char_utilities=>horizontal_tab,
lv_zdat(10).
DATA : lv_line1(40),
lv_line2(10),
lv_line3(10),
lv_line4(3),
lv_line5(40).
lv_line1 = text-008.
WRITE sy-datum TO lv_zdat MM/DD/YYYY.
lv_line2 = lv_zdat.
CONCATENATE lv_vt
lv_line1
lv_vt
lv_vt
lv_line2
lv_vt
lv_vt
lv_vt
lv_vt
* lv_vt
INTO lv_line.
CONCATENATE gc_add lv_line lv_vt INTO lv_line.
APPEND lv_line TO xt_objbin.
CLEAR : lv_line, lv_line1, lv_line2, lv_zdat.
lv_line1 = text-009.
lv_line2 = text-010.
WRITE pnpbegda TO lv_zdat MM/DD/YYYY.
lv_line3 = lv_zdat.
CLEAR lv_zdat.
lv_line4 = ' - '.
WRITE pnpendda TO lv_zdat MM/DD/YYYY.
lv_line5 = lv_zdat.
CONCATENATE lv_vt
lv_line1
lv_vt
lv_vt
lv_line2
lv_vt
lv_line3
lv_line4
lv_line5
lv_vt
lv_vt
lv_vt
lv_vt
INTO lv_line.
CONCATENATE gc_add lv_line lv_vt INTO lv_line.
APPEND lv_line TO xt_objbin.
CLEAR : lv_line, lv_line1,
lv_line2,lv_line3,
lv_line4, lv_line5, lv_zdat.
CONCATENATE lv_vt
lv_vt
lv_vt
lv_vt
lv_vt
lv_vt
lv_vt
lv_vt
lv_vt
INTO lv_line.
CONCATENATE gc_add lv_line lv_vt INTO lv_line.
APPEND lv_line TO xt_objbin.
CLEAR lv_line.
CONCATENATE text-013
text-014
text-015
text-016
text-017
text-018
text-019
text-026
text-020
INTO lv_line
SEPARATED BY lv_vt.
CONCATENATE gc_add lv_line
lv_vt "TAB space
INTO lv_line.
APPEND lv_line TO xt_objbin.
ENDFORM. " sub_fill_columnhead
*& Form sub_objpack_data
*To fix the actual document size
* -->XT_OBJBIN
* -->XT_OBJPACK
* -->XV_TAB_LINES
* -->XV_LV_FILE
FORM sub_objpack_data TABLES xt_objbin STRUCTURE solisti1
xt_objpack STRUCTURE sopcklsti1
USING xv_tab_lines
xv_lv_file. "#EC *
DATA : lwa_objpack TYPE sopcklsti1.
lwa_objpack-transf_bin = gc_x.
lwa_objpack-head_start = 1.
lwa_objpack-head_num = 0.
lwa_objpack-body_start = 1.
lwa_objpack-body_num = xv_tab_lines.
lwa_objpack-doc_type = gc_xls.
lwa_objpack-obj_name = xv_lv_file.
lwa_objpack-obj_descr = gc_descr.
lwa_objpack-doc_size
= ( xv_tab_lines - 1 ) * 255 + STRLEN( xt_objbin ).
APPEND lwa_objpack TO xt_objpack.
CLEAR lwa_objpack.
ENDFORM. " sub_objpack_data
*& Form sub_reclist_timeadm
* text
* -->P_LIT_RECLIST text
* -->P_LV_USRID text
FORM sub_reclist_timeadm TABLES xt_reclist STRUCTURE somlreci1
USING lp_usrid TYPE gty_timhours-usrid."#EC *
*local constant
CONSTANTS : lc_b TYPE c VALUE 'B'.
*local workarea.
DATA : lwa_receivers TYPE somlreci1 ,
lwa_usrid TYPE gty_usrid ,
lwa_docdata TYPE sodocchgi1.
REFRESH : git_receivers.":, LIT_DOCDATA .
CLEAR : lwa_receivers,lwa_docdata.
IF p_timadm EQ 'X'.
MOVE: lp_usrid TO lwa_receivers-receiver,
text-002 TO lwa_receivers-express,
lc_b TO lwa_receivers-rec_type.
APPEND lwa_receivers TO xt_reclist.
ELSEIF p_manger EQ 'X'.
READ TABLE git_usrid INTO lwa_usrid WITH KEY pernr = gwa_emphours-magpernr
usrty = '0001' BINARY SEARCH.
IF sy-subrc EQ 0.
MOVE: lwa_usrid-usrid TO lwa_receivers-receiver,
text-002 TO lwa_receivers-express,
lc_b TO lwa_receivers-rec_type.
APPEND lwa_receivers TO xt_reclist.
ENDIF.
CLEAR : lwa_usrid .
ENDIF.Hi Tona,
Please go through the code and cross check....
REPORT zcyborg_5 NO STANDARD PAGE HEADING.
TABLES : eket.
DATA : p_date TYPE d.
DATA : w_lines TYPE sy-tabix.
TYPES : BEGIN OF types_eket,
ebeln TYPE eket-ebeln,
ebelp TYPE eket-ebelp,
eindt TYPE eket-eindt,
END OF types_eket.
DATA : t_eket TYPE STANDARD TABLE OF types_eket.
Declaration for ALV display *********************
DATA : w_grid TYPE REF TO cl_gui_alv_grid,
w_custom_container TYPE REF TO cl_gui_custom_container.
RANGES : r_eindt FOR eket-eindt.
FIELD-SYMBOLS: <fs_eket> TYPE types_eket.
INITIALIZATION.
CALL FUNCTION 'CALCULATE_DATE'
EXPORTING
days = '60-'
months = '0'
start_date = sy-datum
IMPORTING
result_date = p_date.
r_eindt-low = p_date.
r_eindt-high = sy-datum.
r_eindt-sign = 'I'.
r_eindt-option = 'BT'.
APPEND r_eindt.
START-OF-SELECTION.
PERFORM get_data.
PERFORM disp_data.
PERFORM email_data.
perform disp_alv.
*& Form get_data
text
--> p1 text
<-- p2 text
FORM get_data.
SELECT ebeln
ebelp
eindt
FROM eket
INTO TABLE t_eket
WHERE eindt IN r_eindt.
ENDFORM. " get_data
*& Form disp_data
text
--> p1 text
<-- p2 text
FORM disp_data.
DESCRIBE TABLE t_eket LINES w_lines.
WRITE :/5 'No of rows : ', w_lines.
WRITE :/5 'EBELN', 30 'EBELP', 50 'EINDT'.
SORT t_eket DESCENDING BY eindt.
LOOP AT t_eket ASSIGNING <fs_eket>.
AT NEW ebeln.
ULINE.
ENDAT.
WRITE : /5 <fs_eket>-ebeln, 30 <fs_eket>-ebelp, 50 <fs_eket>-eindt.
ENDLOOP.
ENDFORM. " disp_data
call function 'SEND_TABLE_TO_EXCEL'
exporting
structure_name = 'EKET'
tables
exceltab = t_eket
FORM email_data.
*Structures and internal table used to send data vai mail
DATA : objpack LIKE sopcklsti1 OCCURS 2 WITH HEADER LINE,
objhead LIKE solisti1 OCCURS 1 WITH HEADER LINE,
objbin LIKE solisti1 OCCURS 0 WITH HEADER LINE,
objtxt LIKE solisti1 OCCURS 10 WITH HEADER LINE,
reclist LIKE somlreci1 OCCURS 5 WITH HEADER LINE,
tab_lines LIKE sy-tabix,
doc_chng LIKE sodocchgi1.
DATA : it_attach TYPE STANDARD TABLE OF solisti1,
w_attach TYPE solisti1.
CONSTANTS : c_car TYPE x VALUE '0D',
c_tab TYPE x VALUE '09'.
CONCATENATE 'EBELN'
c_tab
'EBELP'
c_tab
'EINDT'
c_car INTO w_attach.
APPEND w_attach TO it_attach.
LOOP AT t_eket INTO <fs_eket>.
CONCATENATE <fs_eket>-ebeln
c_tab
<fs_eket>-ebelp
c_tab
<fs_eket>-eindt
c_car INTO w_attach.
APPEND w_attach TO it_attach.
ENDLOOP.
MOVE it_attach[] TO objbin[].
*assign a name to the email document
doc_chng-obj_name = 'Output'.
doc_chng-obj_descr = 'Old Scheduling lines'."gives the subject line
objtxt-line = 'Regards'.
APPEND objtxt.
objtxt-line = 'Shivaji'.
APPEND objtxt.
*determine the size of the body of the email
DESCRIBE TABLE objtxt LINES tab_lines.
READ TABLE objtxt INDEX tab_lines.
doc_chng-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objtxt ).
*fill the fields of the packing list for the body of the email
*doc needs no header
objpack-head_start = 1.
objpack-head_num = 0.
*but it has a body
objpack-body_start = 1.
objpack-body_num = tab_lines.
objpack-doc_type = 'RAW'.
APPEND objpack.
*************fill the fields for packing list ***
for attachment ********
DESCRIBE TABLE objbin LINES tab_lines.
*************if it has no header ****************
objpack-transf_bin = 'X'.
objpack-head_start = 1.
objpack-head_num = 1.
*************if it has a body ********
objpack-body_start = 1.
objpack-body_num = tab_lines.
objpack-doc_type = 'XLS'.
objpack-obj_name = 'Attachement'.
objpack-obj_descr = 'file'.
objpack-doc_size = tab_lines * 255.
APPEND objpack.
************fill the mail recipient list*******
reclist-receiver = sy-uname.
**rec_type 'B' indicates sap user ,rec_type 'U' indicates internet user
reclist-rec_type = 'B'.
reclist-express = 'X'.
APPEND reclist.
Function Module to send the data as an excel attachement ****
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = doc_chng
put_in_outbox = 'X'
IMPORTING
SENT_TO_ALL =
NEW_OBJECT_ID =
TABLES
packing_list = objpack
OBJECT_HEADER =
contents_bin = objbin
contents_txt = objtxt
CONTENTS_HEX =
OBJECT_PARA =
OBJECT_PARB =
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
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. -
ALV List header shifting to next coloumn when transfer to excel sheet
Hi,
When i am transferring the data to excel sheet like
After Executing click LOCAL FILE then click on spreadsheet RADIO BUTTON. My header is shifting one right colomn.
I tried with COL_len but my issued is not resolved
REPORT ZTEST_AMIT no standard page heading line-size 350. .
TYPE-POOLS: SLIS.
DATA: X_FIELDCAT TYPE SLIS_FIELDCAT_ALV,
IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
L_LAYOUT type slis_layout_alv,
x_events type slis_alv_event,
it_events type SLIS_T_EVENT.
DATA: BEGIN OF ITAB OCCURS 0,
VBELN LIKE VBAK-VBELN,
POSNR LIKE VBAP-POSNR,
MALE(40) type c,
female(20) type c,
END OF ITAB.
SELECT VBELN
POSNR
FROM VBAP
UP TO 20 ROWS
INTO TABLE ITAB.
X_FIELDCAT-FIELDNAME = 'VBELN'.
X_FIELDCAT-SELTEXT_L = 'VBELN'.
X_FIELDCAT-TABNAME = 'ITAB'.
X_FIELDCAT-COL_POS = 1.
APPEND X_FIELDCAT TO IT_FIELDCAT.
CLEAR X_FIELDCAT.
X_FIELDCAT-FIELDNAME = 'POSNR'.
X_FIELDCAT-SELTEXT_L = 'POSNR'.
X_FIELDCAT-TABNAME = 'ITAB'.
X_FIELDCAT-COL_POS = 2.
APPEND X_FIELDCAT TO IT_FIELDCAT.
CLEAR X_FIELDCAT.
X_FIELDCAT-FIELDNAME = 'MALE'.
X_FIELDCAT-SELTEXT_L = 'MALE'.
X_FIELDCAT-TABNAME = 'ITAB'.
X_FIELDCAT-COL_POS = 3.
x_fieldcat-outputlen = 10.
APPEND X_FIELDCAT TO IT_FIELDCAT.
CLEAR X_FIELDCAT.
X_FIELDCAT-FIELDNAME = 'FEMALE'.
X_FIELDCAT-SELTEXT_L = 'FEMALE'.
X_FIELDCAT-TABNAME = 'ITAB'.
X_FIELDCAT-COL_POS = 4.
x_fieldcat-just = 'C'.
APPEND X_FIELDCAT TO IT_FIELDCAT.
CLEAR X_FIELDCAT.
x_events-NAME = SLIS_EV_TOP_OF_PAGE.
x_events-FORM = 'TOP_OF_PAGE'.
APPEND x_events TO iT_EVENTS.
CLEAR x_events .
L_LAYOUT-NO_COLHEAD = 'X'.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = sy-repid
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = ' '
I_STRUCTURE_NAME =
IS_LAYOUT = l_layout
IT_FIELDCAT = it_fieldcat
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = ' '
IS_VARIANT =
IT_EVENTS = it_events
IT_EVENT_EXIT =
IS_PRINT =
IS_REPREP_ID =
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
t_outtab = itab
EXCEPTIONS
PROGRAM_ERROR = 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.
FORM TOP_OF_PAGE.
*-To display the headers for main list
FORMAT COLOR COL_HEADING.
WRITE: / SY-ULINE(45).
WRITE: / SY-VLINE,
(8) ' ' ,
SY-VLINE,
(8) ' ' ,
SY-VLINE,
(19) '***'(015) centered,
sy-vline.
WRITE: / SY-VLINE,
(8) 'VBELN' ,
SY-VLINE,
(8) 'POSNR'(014) ,
SY-VLINE,
(8) 'MALE'(020) ,
sy-vline,
(8) 'FMALE'(015) ,
sy-vline.
FORMAT COLOR OFF.
ENDFORM.
Message was edited by: amit teja
Message was edited by: amit teja
Message was edited by: amit teja
Message was edited by: amit tejafor sorting
for the para meter: IT_SORT in FM
take that type as: SLIS_SORTINFO_ALV
and for the fileds give d valus as per ur requirement...
fileds r: SPOS
FIELDNAME
TABNAME
UP
DOWN
GROUP
SUBTOT
COMP
EXPA
OBLIGATORY
ramesh. -
How to send data to an already open excel sheet
I have a simple VI that opens a closed excel file, writes data to it and closes it.
I want to modify it to write data, unconcerned of whether the file is open or closed.
how to do it..
I have attached the VI here..
thanks..
Attachments:
Save to Excel.vi 11 KBWhen you open a file you make a copy of the data on disc and put it in memory somewhere the application that opened it knows about.
In your case a spreadsheet open in Excel will have its file locked for its exclusive use. This prevents the file from getting updates by more than one application which would most assuradly cause unintended consequences (the file would get corupted.)
In other words You only think you want to write data from LabVIEW to a file open for editing in Excel - You really don't want to do this
Jeff -
How to find the OBIEE report (Catelogue) path from BI enabled excel sheet
Dear All,
I have an excel sheet where the data is coming from BI server. How can I find the BI report name and path from the excel sheet.
Regards
MustafaSorry Friends,
May be I am not conveying the message properly.
Let me try to do it again.
I have an excel sheet which is created by somebody else and send me by mail.
This excel sheet is having connectivity to the BI server and pulling data from BI.
What I want to know is to get the BI report and view name from the excel sheet so that I can do some modification in the report.
Please not the owner of the excel file is un-reachable.
Let say I have uploaded the sample Excel in the following URL http://www.fileflyer.com/view/VSHtOA8.
This excel file is pulling data from our BI Server
Could anybody tell me the report path, name and view name from the excel file
Regards
Mustafa -
Send ALV report as email attachment but in background scheduling mode
Hi All,
I have ALV report which runs fine in the foreground.
But i need to display it in the spool that is by scheduling in the background.
can i send an excel attachement as e-mail in the background scheduling? my report contains
10 columns and i need them in proper format on excel sheet attachment? plz help me out?if possible
give me abap code..HI,
Use the below link
Sending Mail to the schedular of Background Job
Thanks -
Running a ALV Report in bakcground and sending it to Email/FAX
Hi,
I am designing a ALV report to send a email/fax/Printer which has to be run in background or foreground according to selection screen inputs.
I am doing the following
1. After generating ALV report, converting it to pdf
2. Sending Email or Fax or Print from selection screen value.
3. after that scheduling in background using JOB_OPEN and JOB_SUBMIT FM's.
Can I use SO_DOCUMENT_SEND_API1 FM for both Email and Fax.
When I schedule the report in the background using JOB_OPEN, at which point I have to code it inside the report. Is it after I generate the ALV Report and Email sending code or before it..
ThanksHi
How did you end up doing the emailing? I have the same task..... -
How to Convert Report into Excel Sheet when Sending Mail.
Dear Friends,
i want to send mail to HOD of Product with an Excel Sheet .
i want to send Pending Issue details to HOD in Excel Sheet attachment .
here i have pending issue report now i need to send it in Excel Sheet attachment .
i have table where i have manage Product ID and HOD OF PRODUCT.
CREATE TABLE "MAP_USER_PRODUCT_DTL"
( "ID" NUMBER NOT NULL ENABLE,
"PRODUCT_ID"NUMBER,
"USER_ID" VARCHAR2(5) NOT NULL ENABLE,
"HOD_PROD" VARCHAR2(100)========================================Value is Y OR N IF HOD then Y else N
CONSTRAINT "MAP_USER_PRODUCT_DTL_PK" PRIMARY KEY ("ID") ENABLE
/i have one more table where all complete issue detail insert.
CREATE TABLE "CRM_ISSUE_PROBLEM"
( "ID" NUMBER,
"SUBJECT" VARCHAR2(255) NOT NULL ENABLE,
"CLIENT_ID" NUMBER,
"ASSIGNED_TO_ID" VARCHAR2(100),
"ASSIGNED_ON" DATE,
"DESCRIPTION" VARCHAR2(4000),
"PRODUCT_ID" NUMBER NOT NULL ENABLE,
"STATUS_ID" NUMBER NOT NULL ENABLE,
CONSTRAINT "CRM_ISSUE_PROBLEM_PK" PRIMARY KEY ("ID") ENABLE
Here STATUS_ID is Like Pending ISsue,Open Issue and Close Issue .i want to send mail to HOD with Pending Issue Report convert into Excel Sheet and send to HOD?
How can i do this.
Thanks
Edited by: Vedant on Oct 12, 2011 12:36 AM
Edited by: Vedant on Oct 12, 2011 2:22 AMHello Vedant,
Would it suffice if you send a CSV file?
If yes, then see following code.. run the code under APEX > Home > SQL Workshop > SQL Commands
DECLARE
ln_id NUMBER;
lc_clob CLOB;
lb_blob BLOB;
li_in PLS_INTEGER := 1;
li_out PLS_INTEGER := 1;
li_lang PLS_INTEGER := 0;
li_warning PLS_INTEGER := 0;
lv_mail_rcpts VARCHAR2(2000) := '[email protected]';
lv_mail_from VARCHAR2(100) := '[email protected]';
lv_clmn_separator VARCHAR2(1) := ',';
BEGIN
-- Build file content as CLOB
-- Replace with your query
FOR i IN (select object_id A, object_name B, object_type C, status D, temporary E, generated F, secondary G,namespace H from user_objects where rownum < 10)
LOOP
IF lc_clob IS NULL THEN
lc_clob := i.A||lv_clmn_separator||i.B||lv_clmn_separator||i.C||lv_clmn_separator||i.D||lv_clmn_separator||i.E||lv_clmn_separator||i.F||lv_clmn_separator||i.G||lv_clmn_separator||i.H;
ELSE
lc_clob := lc_clob||CHR(10)||i.A||lv_clmn_separator||i.B||lv_clmn_separator||i.C||lv_clmn_separator||i.D||lv_clmn_separator||i.E||lv_clmn_separator||i.F||lv_clmn_separator||i.G||lv_clmn_separator||i.H;
END IF;
END LOOP;
-- Convert CLOB to BLOB
DBMS_LOB.CREATETEMPORARY(lb_blob,TRUE);
DBMS_LOB.convertToBlob(lb_blob,lc_clob,DBMS_LOB.LOBMAXSIZE,li_in,li_out,DBMS_LOB.DEFAULT_CSID,li_lang,li_warning);
-- Send mail
ln_id:= APEX_MAIL.SEND(
p_to => lv_mail_rcpts,
p_from => lv_mail_from,
p_subj => 'Subject Goes here',
p_body => 'Body goes here'
-- add CSV file as attachment
APEX_MAIL.ADD_ATTACHMENT
p_mail_id => ln_id,
p_attachment => lb_blob,
p_filename => 'filename.csv',
p_mime_type => 'application/csv'
-- push mail queue
APEX_MAIL.PUSH_QUEUE;
-- empty temporary space
DBMS_LOB.FREETEMPORARY ( lob_loc => lb_blob);
COMMIT;
END;Regards,
Hari -
How to zip report output and send via mail from application
Hello,
I want to know how to zip the report output and send it by mail to concerned person from application
I want this as the report is having more than 70000s of records.
Also the XLS has the limitation of 2^16 records and the report is having more than this
Any help is very much appreciated
Regards,
Vani1: Make a Dummy report. From some post parameter form trigger, run your original report with "srw.runreport" call. The original report can generate output to a file.
2: Then withing this dummy report run, call a user exit to zip the
original reports output. You need to write this user exit and attach them
with reports.
3: Now use Report 9i distribution for this dummy report to sent this external zip file through mail.
With Regards
Reports Team -
Error while sending excel sheet as attachment to Mail Receiver
Hi everyone,
I am facing the below error when I am trying to send data to Mail receiver adapter. The attachment is excel sheet.
Delivery of the message to the application using connection Mail_http://sap.com/xi/XI/System failed, due to: com.sap.aii.af.ra.ms.api.RecoverableException: Object not found in lookup of MessageTransformBean.: com.sap.engine.services.jndi.persistent.exceptions.NameNotFoundException: Object not found in lookup of MessageTransformBean..
I don't understand where the problem is. This has been running since long time and last month we have changed our web dispatcher details. I hope everything is fine. But not sure the root cause for this issue.
Please help me in resolving this.
Thank you.
Regards
Bhanu T.Check if this helps: MessageTransformBean module
Confirm that you have configured the MessagetransformationBean properly.
Are you trying to convert some payload into Excel and send it as an attachment in the Mail CC? If yes, then I hope that you have included the correct Content_type value.
Check this for more info on Content_type: /people/community.user/blog/2006/09/08/email-report-as-attachment-excelword
Regards,
Abhishek. -
Download the ALV Report output into excel sheet or notepad
Hi,
how to downlaod the alv report out into excel sheet or notepad in a proper manner. program contain large number records....
Thanks in advance!!!!
Regards,
kranthi.Hi
Download a report to excel with format (border, color cell, etc)
Try this program...it may help you to change the font ..etc.
Code:
REPORT ZSIRI NO STANDARD PAGE HEADING.
this report demonstrates how to send some ABAP data to an
EXCEL sheet using OLE automation.
INCLUDE OLE2INCL.
handles for OLE objects
DATA: H_EXCEL TYPE OLE2_OBJECT, " Excel object
H_MAPL TYPE OLE2_OBJECT, " list of workbooks
H_MAP TYPE OLE2_OBJECT, " workbook
H_ZL TYPE OLE2_OBJECT, " cell
H_F TYPE OLE2_OBJECT. " font
TABLES: SPFLI.
DATA H TYPE I.
table of flights
DATA: IT_SPFLI LIKE SPFLI OCCURS 10 WITH HEADER LINE.
*& Event START-OF-SELECTION
START-OF-SELECTION.
read flights
SELECT * FROM SPFLI INTO TABLE IT_SPFLI UP TO 10 ROWS.
display header
ULINE (61).
WRITE: / SY-VLINE NO-GAP,
(3) 'Flg'(001) COLOR COL_HEADING NO-GAP, SY-VLINE NO-GAP,
(4) 'Nr'(002) COLOR COL_HEADING NO-GAP, SY-VLINE NO-GAP,
(20) 'Von'(003) COLOR COL_HEADING NO-GAP, SY-VLINE NO-GAP,
(20) 'Nach'(004) COLOR COL_HEADING NO-GAP, SY-VLINE NO-GAP,
(8) 'Zeit'(005) COLOR COL_HEADING NO-GAP, SY-VLINE NO-GAP.
ULINE /(61).
display flights
LOOP AT IT_SPFLI.
WRITE: / SY-VLINE NO-GAP,
IT_SPFLI-CARRID COLOR COL_KEY NO-GAP, SY-VLINE NO-GAP,
IT_SPFLI-CONNID COLOR COL_NORMAL NO-GAP, SY-VLINE NO-GAP,
IT_SPFLI-CITYFROM COLOR COL_NORMAL NO-GAP, SY-VLINE NO-GAP,
IT_SPFLI-CITYTO COLOR COL_NORMAL NO-GAP, SY-VLINE NO-GAP,
IT_SPFLI-DEPTIME COLOR COL_NORMAL NO-GAP, SY-VLINE NO-GAP.
ENDLOOP.
ULINE /(61).
tell user what is going on
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING
PERCENTAGE = 0
TEXT = TEXT-007
EXCEPTIONS
OTHERS = 1.
start Excel
CREATE OBJECT H_EXCEL 'EXCEL.APPLICATION'.
PERFORM ERR_HDL.
SET PROPERTY OF H_EXCEL 'Visible' = 1.
CALL METHOD OF H_EXCEL 'FILESAVEAS' EXPORTING #1 = 'c:\kis_excel.xls'
PERFORM ERR_HDL.
tell user what is going on
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING
PERCENTAGE = 0
TEXT = TEXT-008
EXCEPTIONS
OTHERS = 1.
get list of workbooks, initially empty
CALL METHOD OF H_EXCEL 'Workbooks' = H_MAPL.
PERFORM ERR_HDL.
add a new workbook
CALL METHOD OF H_MAPL 'Add' = H_MAP.
PERFORM ERR_HDL.
tell user what is going on
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING
PERCENTAGE = 0
TEXT = TEXT-009
EXCEPTIONS
OTHERS = 1.
output column headings to active Excel sheet
PERFORM FILL_CELL USING 1 1 1 'Flug'(001).
PERFORM FILL_CELL USING 1 2 0 'Nr'(002).
PERFORM FILL_CELL USING 1 3 1 'Von'(003).
PERFORM FILL_CELL USING 1 4 1 'Nach'(004).
PERFORM FILL_CELL USING 1 5 1 'Zeit'(005).
LOOP AT IT_SPFLI.
copy flights to active EXCEL sheet
H = SY-TABIX + 1.
PERFORM FILL_CELL USING H 1 0 IT_SPFLI-CARRID.
PERFORM FILL_CELL USING H 2 0 IT_SPFLI-CONNID.
PERFORM FILL_CELL USING H 3 0 IT_SPFLI-CITYFROM.
PERFORM FILL_CELL USING H 4 0 IT_SPFLI-CITYTO.
PERFORM FILL_CELL USING H 5 0 IT_SPFLI-DEPTIME.
ENDLOOP.
changes by Kishore - start
CALL METHOD OF H_EXCEL 'Workbooks' = H_MAPL.
CALL METHOD OF H_EXCEL 'Worksheets' = H_MAPL." EXPORTING #1 = 2.
PERFORM ERR_HDL.
add a new workbook
CALL METHOD OF H_MAPL 'Add' = H_MAP EXPORTING #1 = 2.
PERFORM ERR_HDL.
tell user what is going on
SET PROPERTY OF H_MAP 'NAME' = 'COPY'.
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING
PERCENTAGE = 0
TEXT = TEXT-009
EXCEPTIONS
OTHERS = 1.
output column headings to active Excel sheet
PERFORM FILL_CELL USING 1 1 1 'Flug'(001).
PERFORM FILL_CELL USING 1 2 0 'Nr'(002).
PERFORM FILL_CELL USING 1 3 1 'Von'(003).
PERFORM FILL_CELL USING 1 4 1 'Nach'(004).
PERFORM FILL_CELL USING 1 5 1 'Zeit'(005).
LOOP AT IT_SPFLI.
copy flights to active EXCEL sheet
H = SY-TABIX + 1.
PERFORM FILL_CELL USING H 1 0 IT_SPFLI-CARRID.
PERFORM FILL_CELL USING H 2 0 IT_SPFLI-CONNID.
PERFORM FILL_CELL USING H 3 0 IT_SPFLI-CITYFROM.
PERFORM FILL_CELL USING H 4 0 IT_SPFLI-CITYTO.
PERFORM FILL_CELL USING H 5 0 IT_SPFLI-DEPTIME.
ENDLOOP.
changes by Kishore - end
disconnect from Excel
CALL METHOD OF H_EXCEL 'FILESAVEAS' EXPORTING #1 = 'C:\SKV.XLS'.
FREE OBJECT H_EXCEL.
PERFORM ERR_HDL.
FORM FILL_CELL *
sets cell at coordinates i,j to value val boldtype bold *
FORM FILL_CELL USING I J BOLD VAL.
CALL METHOD OF H_EXCEL 'Cells' = H_ZL EXPORTING #1 = I #2 = J.
PERFORM ERR_HDL.
SET PROPERTY OF H_ZL 'Value' = VAL .
PERFORM ERR_HDL.
GET PROPERTY OF H_ZL 'Font' = H_F.
PERFORM ERR_HDL.
SET PROPERTY OF H_F 'Bold' = BOLD .
PERFORM ERR_HDL.
ENDFORM.
*& Form ERR_HDL
outputs OLE error if any *
--> p1 text
<-- p2 text
FORM ERR_HDL.
IF SY-SUBRC <> 0.
WRITE: / 'Fehler bei OLE-Automation:'(010), SY-SUBRC.
STOP.
ENDIF.
ENDFORM. " ERR_HDL
Please note that this example maybe slow at filling the excel table
(perhaps four fields per second on a 900 MHz machine - almost 30 seconds
for a short example).
To get the data on properties and methods - there is a bit of smoke and mirrors
going on here; they are EXCEL properties and methods, not sap ones - so you need
to look at excel help to determine how a particular function is structured. then
build the block in sap, as shown in the example.
If you only want to transfer the data to Excel like when you transfer the data from
ALV to Excel simply use the Function Modules:
XXL_SIMPLE_API
If you want more modifications when you transfer it to Excel use:
XXL_FULL_API
Maybe you are looking for
-
A better way to do this without scriptlets?
I have an object passed to the JSP through the request.setAttribute(). I have to get a Collection from that object and use it in my custom tag. The problem is that it isn't elegant as I would like it (still too much scriptlets). The scriptlet code be
-
How Can I Keep Embedded Documents in a PDF Conversion of a Word Document?
I am running XP and using Word 2010. I have a document that contains embedded Word documents. I can convert the document to PDF but I loose the embedded documents when I do. Is there a way to keep them available in the PDF version? I can "attach"
-
Flash drive failure? Help
I have been using a macbook air (mid 2012) for a while, it gave me some warnings for the last 3 days that my start up memory is low but I did not know what to do although I had 8GB free. Yesterday i finished my work normally and closed the lid. Today
-
I have a hp photosmart estation C510 series and the screen on the tablet broke a few months ago, as it was still connected to me internet i had no problems still pronting and scanning. However I have just moved to a new house with new internet, how c
-
Who uses Dreamweaver CS3 on Mac OS X?
Howdy, I'm curious to know how many of you here use Dreamweaver CS3 on the Mac? Not bothered bout you Windows users, I've used it on there and it's fine (although bulky and slow). I made the switch to mac a long while back, and coming from Windows an