2009 Apr 02 8:05 PM
hello all,
I am using SO_NEW_DOCUMENT_ATT_SEND_API1 function to send email as an excel attachment but when i recieve the email in my out look in the first column lot of space is comming and if i download the excel sheet and modify it and save it is working fine, but for users it is a problem i want to send this email excel attachment so that the excel should not have any unwanted space in the columns could you please check the below code and let me know what needs to be added for resolving the issue,
CLEAR: OBJBIN,TAB_LINES,OBJHEAD,OBJPACK,RECLIST.
REFRESH:OBJBIN,OBJHEAD,OBJPACK,RECLIST.
CONCATENATE 'Delivery' 'Created on' 'Time' 'Goods issue date'
'Route' 'Ship-to-party' 'Name of ship-to-party' 'Sold-to-party'
'Name of sold-to-party' 'Delivery type'
INTO OBJBIN-LINE SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
APPEND OBJBIN.
CLEAR OBJBIN.
CONCATENATE OBJBIN CL_ABAP_CHAR_UTILITIES=>NEWLINE INTO OBJBIN.
APPEND OBJBIN.
CLEAR OBJBIN.
LOOP AT GT_OUTTAB WHERE VSTEL = P_VSTEL-LOW.
CONCATENATE GT_OUTTAB-VBELN GT_OUTTAB-ERDAT GT_OUTTAB-ERZET GT_OUTTAB-WADAT
GT_OUTTAB-ROUTE GT_OUTTAB-KUNNR GT_OUTTAB-NAME_WE GT_OUTTAB-KUNAG
GT_OUTTAB-NAME_AG GT_OUTTAB-LFART
INTO OBJBIN-LINE SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
APPEND OBJBIN.
CLEAR OBJBIN.
CONCATENATE OBJBIN CL_ABAP_CHAR_UTILITIES=>NEWLINE INTO OBJBIN.
APPEND OBJBIN.
CLEAR OBJBIN.
CLEAR GT_OUTTAB.
ENDLOOP.
DESCRIBE TABLE OBJBIN LINES TAB_LINES.
IF TAB_LINES > 1.
DELETE OBJBIN INDEX TAB_LINES.
ENDIF.
CLEAR TAB_LINES.
DESCRIBE TABLE OBJBIN LINES TAB_LINES.
IF TAB_LINES > 1.
CLEAR:DOC_CHNG,OBJTXT.
REFRESH:OBJTXT.
DOC_CHNG-OBJ_NAME = 'OFFER'.
CONCATENATE 'Goods issue for Outbound deliveries as of' SY-DATUM
INTO DOC_CHNG-OBJ_DESCR SEPARATED BY SPACE.
CONCATENATE 'Excel sheet with Deliveries for shipping-point' P_VSTEL-LOW INTO OBJTXT SEPARATED BY SPACE.
APPEND OBJTXT.
OBJTXT = 'is enclosed as an attachment.'.
APPEND OBJTXT.
CONCATENATE 'Created time:' SY-UZEIT INTO OBJTXT SEPARATED BY SPACE.
APPEND OBJTXT.
CLEAR TAB_LINES1.
DESCRIBE TABLE OBJTXT LINES TAB_LINES1.
READ TABLE OBJTXT INDEX TAB_LINES1.
DOC_CHNG-DOC_SIZE = ( TAB_LINES1 - 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_LINES1.
OBJPACK-DOC_TYPE = 'RAW'.
APPEND OBJPACK.
CONCATENATE 'Deliveries_' P_VSTEL-LOW '.xls' INTO OBJHEAD.
APPEND OBJHEAD.
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 = 'XLS'.
CONCATENATE 'Deliveries_' P_VSTEL-LOW INTO OBJPACK-OBJ_DESCR .
OBJPACK-DOC_SIZE = TAB_LINES * 255.
APPEND OBJPACK..
LOOP AT T_EMAIL WHERE VSTEL = P_VSTEL-LOW.
RECLIST-RECEIVER = T_EMAIL-EMAIL.
RECLIST-REC_TYPE = 'U'.
TRANSLATE RECLIST-RECEIVER TO LOWER CASE.
APPEND RECLIST.
CLEAR:T_EMAIL,RECLIST.
ENDLOOP.
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
RECEIVERS = RECLIST
EXCEPTIONS
TOO_MANY_RECEIVERS = 1
DOCUMENT_NOT_SENT = 2
OPERATION_NO_AUTHORIZATION = 4
OTHERS = 99.
2009 Apr 02 8:10 PM
HI,
Try to pass the contents_hex instead of contents_bin...
DATA :
l_hex LIKE solix,
lt_contents_hex LIKE STANDARD TABLE OF solix ,
conv TYPE REF TO cl_abap_conv_out_ce,
l_buffer TYPE xstring,
l_hexa(510) TYPE x.
* APPEND object_header.
CALL FUNCTION 'SO_RAW_TO_RTF'
TABLES
objcont_old = lt_objbin
objcont_new = lt_objbin.
LOOP AT lt_objbin INTO l_line.
conv = cl_abap_conv_out_ce=>create( encoding = 'UTF-8' endian = 'B').
CALL METHOD conv->write( data = l_line ).
l_buffer = conv->get_buffer( ).
MOVE l_buffer TO l_hexa.
MOVE l_hexa TO l_hex-line.
APPEND l_hex TO lt_contents_hex.
ENDLOOP.
2014 Jan 11 6:59 PM
Hi Avinash,
Could you please suggest me what i can do in the following case.
I am gettign a blank space before the value of the first column as above KK KK got .
I am trying to change as you suggested above, but program is going to dump
conv = cl_abap_conv_out_ce=>create( encoding = 'UTF-8' endian = 'B') after execution of this line and saying
The current ABAP program 'CL_ABAP_CONV_OUT_CE===========CP' had to be
interrupted because the
parameter 'DATA' had the illegal type 'u'.
please share the complete coding and declarations if any reg the code you specified.
@kk kk: please let me know how you solved the same.
appreciate your help.
Thanks,
Smriti
2009 Apr 02 8:31 PM
Hi KK,
Try this and check this if it works
CONCATENATE 'Delivery' 'Created on' 'Time' 'Goods issue date'
'Route' 'Ship-to-party' 'Name of ship-to-party' 'Sold-to-party'
'Name of sold-to-party' 'Delivery type'
INTO OBJBIN-LINE SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
CONCATENATE cl_abap_char_utilities=>CR_LF OBJBIN-LINE into OBJBIN-LINE. " ++
APPEND OBJBIN.
CLEAR OBJBIN.
CONCATENATE OBJBIN CL_ABAP_CHAR_UTILITIES=>NEWLINE INTO OBJBIN.
CONCATENATE cl_abap_char_utilities=>CR_LF OBJBIN-LINE into OBJBIN-LINE. " ++
APPEND OBJBIN.
CLEAR OBJBIN.
LOOP AT GT_OUTTAB WHERE VSTEL = P_VSTEL-LOW.
CONCATENATE GT_OUTTAB-VBELN GT_OUTTAB-ERDAT GT_OUTTAB-ERZET GT_OUTTAB-WADAT
GT_OUTTAB-ROUTE GT_OUTTAB-KUNNR GT_OUTTAB-NAME_WE GT_OUTTAB-KUNAG
GT_OUTTAB-NAME_AG GT_OUTTAB-LFART
INTO OBJBIN-LINE SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
CONCATENATE cl_abap_char_utilities=>CR_LF OBJBIN-LINE into OBJBIN-LINE. " ++
APPEND OBJBIN.
CLEAR OBJBIN.
CONCATENATE OBJBIN CL_ABAP_CHAR_UTILITIES=>NEWLINE INTO OBJBIN.
CONCATENATE cl_abap_char_utilities=>CR_LF OBJBIN-LINE into OBJBIN-LINE. " ++
APPEND OBJBIN.
CLEAR OBJBIN.
CLEAR GT_OUTTAB.
ENDLOOP.
Thanks
Naresh
2015 Apr 23 10:50 PM
Hi,
Concatenate cl_abap_char_utilities=>cr_lf before every line/record of the file.
This should resolve the issue.
Thanks,
Anupam