FM 'SCMS_STRING_TO_FTEXT'
Hi,
Used 'SCMS_STRING_TO_FTEXT' to convert the record string to a binary table and used the output in FM to email report as an attachment.
But when I open the report I can see records more than 255 char printed in 2 lines instead of a single line.
Please suggest how to print more than 255 char record in a single line itself.
With Regards,
Gandhi Subramani
This is the code that creates the string. If I execute the FM, this is the abend error "ASSIGN_TYPE_ILLEGAL_CAST".
data: i_bin like solix occurs 0 with header line.
constants:
c_tab type c value cl_abap_char_utilities=>horizontal_tab,
c_crlf type c value cl_abap_char_utilities=>cr_lf.
data: w_string type string.
data: w_string_2 type string.
data: w_last(1) value '%'.
types: begin of t_cc, " fields in the EXCEL file
bukrs type csks-bukrs,
kostl(10),
end of t_cc.
data: it_cc type standard table of t_cc initial size 0,
wa_cc type t_cc.
*>> File header data << no crlf
concatenate 'Company' c_tab 'Cost Center'
into w_string .
concatenate w_string_2 w_string into w_string_2.
data: w_it_cc_count type i.
w_it_cc_count = lines( it_cc ).
Load internal table with DB fields
select bukrs kostl
up to 200 rows
from csks
into table it_cc.
*>> Build the string field that will be used to populate the BIN
internal table
w_string corresponds to a single line in the attachment
w_string_2 corresponds to all of the data in the attachment
loop at it_cc into wa_cc.
concatenate wa_cc-bukrs wa_cc-kostl
w_last
'>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>'
'3333333333333333333333333333333333333333333333333X'
into w_string separated by c_tab.
concatenate c_crlf w_string into w_string.
concatenate w_string_2 w_string into w_string_2.
endloop.
Convert string field that contains all of the data into the BIN table
call function 'SCMS_STRING_TO_FTEXT'
exporting
text = w_string_2
*IMPORTING
LENGTH =
tables
ftext_tab = i_bin. " the binary table in e-mail FM
Similar Messages
-
Alternative for 'SCMS_STRING_TO_FTEXT' ??
Hi...
I am using the function module SO_NEW_DOCUMENT_ATT_SEND_API1
to send email with an attachment. I need to have over 50 fields in the output. With some R&D in SDN... i found that, we can use the function module 'SCMS_STRING_TO_FTEXT' to compress the contents and then send it across as the parameter CONTENTS_HEX.
But i found out that this thing doesnt work with 4.7 !!!
In case of 4.7 we got to transfer the internal table which we need to send as attachment to CONTENTS_BIN.
So i need a function module which would do a similar work like 'SCMS_STRING_TO_FTEXT' but it should work for CONTENTS_BIN.
Need help... ...!!hi,
Try using this function module 'HR_EFI_CONVERT_STRING_TO_TABLE' .
Regards
Vasavi Kotha -
Create XML file from ABAP with SOAP Details
Hi,
I am new to XML and I am not familiar with JAVA or Web Service. I have searched in SDN and googled for a sample program for creating XML document from ABAP with SOAP details. Unfortunately I couldn't find anything.
I have a requirement for creating an XML file from ABAP with SOAP details. I have the data in the internal table. There is a Schema which the client provided and the file generated from SAP should be validating against that Schema. Schema contains SOAP details like Envelope, Header & Body.
My question is can I generate the XML file using CALL TRANSFORMATION in SAP with the SOAP details?
I have tried to create Transformation (Transaction XSLT_TOOL) in SAP with below code. Also in CALL transformation I am not able to change the encoding to UTF-8. It's always show UTF-16.
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:sap="http://www.sap.com/sapxsl" version="1.0">
<xsl:template match="/">
<SOAP:Envelope xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP:Header>
<CUNS:HeaderInfo>
<CUNS:InterfaceTypeId>10006</InterfaceTypeId>
<CUNS:BusinessPartnerID>11223344</BusinessPartnerID>
<CUNS:SchemaVersion>1.0</SchemaVersion>
<CUNS:DateTime>sy-datum</DateTime>
</CUNS:HeaderInfo>
</SOAP:Header>
<SOAP:Body>
<xsl:copy-of select="*"/>
</SOAP:Body>
</SOAP:Envelope>
</xsl:template>
</xsl:transform>
In ABAP program, I have written below code for calling above Transformation.
call transformation ('Z_ID')
source tab = im_t_output[]
result xml xml_out.
call function 'SCMS_STRING_TO_FTEXT'
exporting
text = xml_out
tables
ftext_tab = ex_t_xml_data.
Please help me how to generate XML file with SOAP details from ABAP. If anybody have a sample program, please share with me.
Is there any easy way to create the XML file in CALL Transformation. Please help.
ThanksTry ABAP forum, as it seems not to be PI related.
-
Issue while opening Excel attachment send through FM
Hi All,
I had program in which i am sending mail along with Excel attachment using FM SO_NEW_DOCUMENT_ATT_SEND_API1. Mail is going fine with data in Excel attachment. But when i try to open the Excel it gives an Info message saying that "<b>You are trying to open (attachment name),is in different format than specified file extension Verify that file is not corrupted and is from a trusted source before opening file. Do you want to open file now</b>". Then when i presses YES, Excel opens up with all data. I want to know how to avoid that info popup. Is there something has to be passed to FM or something has to be done to Excel like settings in EXCEL so that i can avoid that Info message coming.
Document type of attachment is gw_packing_list-doc_type = 'XLS'.
Thanks in advance,
ShyamHi Shyam,
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.....
<i>Reward Points</i>
Cheers,
Sagun Desai -
Send a text file using MF SO_NEW_DOCUMENT_ATT_SEND_API1
HI.
I am trying send a file text from a internal table using the MF: SO_NEW_DOCUMENT_ATT_SEND_API1, the code for tranfer the internal table is:
LOOP AT i_bultos_inex2.
mailbin-line(20) = i_bultos_inex2-cod_bulto.
mailbin-line+20(8) = i_bultos_inex2-fecha.
mailbin+254(1) = cl_abap_char_utilities=>cr_lf.
APPEND mailbin.CLEAR mailbin.
ENDLOOP.
In the file send by e-mail, the lines are not adjusted to the left and each line of the internal table not is a line in the file text.
How i can solved?
Thanks.Hi,
Try to use
call function 'SCMS_STRING_TO_FTEXT'
exporting
text = string
tables
ftext_tab = mailbin.
I think you are not working unicode system
a® -
Problem with attachment using SO_NEW_DOCUMENT_ATT_SEND_API1
Hi,
I'm using function module SO_NEW_DOCUMENT_ATT_SEND_API1 to send emails from SAP (to Outlook - but the problem can already be observed when checking the email attachment in transaction SOST) with attachments.
My attachment is a tab delimited file (so that I can open with MS Excel) with a line size of approx. 1600 characters. I mean, concatenating all fields of the output table into a 1600 character field, separated by tabstops (cl_abap_char_utilities=>horizontal_tab)
I am using function module SCMS_STRING_TO_FTEXT to convert the internal table that I want to send to the line size as accepted by function module SO_NEW_DOCUMENT_ATT_SEND_API1, tables parameter contents_bin. Due to function module SCMS_STRING_TO_FTEXT this happens line by line, using a string variable. I make sure to remove any exess blanks that appear in the process due to not completey filled character fields. And for all rows bar the first the string is prefixed with (cl_abap_char_utilities=>cr_lf). I believe that's required so that SAP knows to put the lines back together. So far so good.
When checking the email's attachment via SOST (and the same happens in Outlook) there are extra blanks in certain fields. Like:
Annual Base
92,928. 00
or
Email
First L ast
In debugging it appears that these excess spaces (sometimes 1, sometimes several) appear where the 1600 character data line is split into the 255 character pieces in 'contents_bin'. But then it happens quite randomly and cannot be observed in all data rows.
Is there a better way of splitting my internal table into 255 character chunks so that what is one field will never get split up into two rows. For the above example, the two fields would show like this in contents_bin
.... 92,928.
00
and
First_L
ast
Or where else lies the problem?
Thanks in advance!
PhilippRon,
Thank you for the suggestion. Just tried but issue remains exactly the same. The function module you have suggested builds the table in the same way.
But, after a few more rounds of debugging and scratching my head it occured to me that my problem is self inflicted. I was using the condense statement in an attempt to get rid of the trailing blanks at the end of a row causing the last column to be filled with lots of spaces at the end. But it wasn't working anyway and I have since inserted a dummy column at the end to take all those trailing blanks. What this condense statement did though was creating trailing blanks in some of those rows with 255 characters fixed length and those trailing blanks then showed up as additional blanks in some columns in the attachment that the emailing function module created by putting those lines back to it's original length of close to 1600 characters.
Problem solved!
Regards,
Philipp -
Hi everyone!
Is there a way in ABAP to output XML files? Pls. send code/ function module if any.
From ABAP programs, we are sure that we can output TEXT files, but how about XML files?
The significance of this question is related
Currently we are using XI to interface SAP and AMS, this question for ABAP to produce XML file arose, if for example, the XI server is down and we have to still send data from one system to another. IDocs can also produce XML files, pls confirm. Earlier however, we have preferred XI rather than IDocs to do this. Anyway, any idea regarding this scenario will be greatly appreciated.
Thanks and God bless!
CelesteHi,
Please check this sample codes from other thread.
1. itab --- > xml
xml ---> itab.
2. This program will do both.
(just copy paste in new program)
3.
REPORT abc.
*-------------- DATA
DATA : t001 LIKE TABLE OF t001 WITH HEADER LINE.
DATA : BEGIN OF itab OCCURS 0,
a(100) TYPE c,
END OF itab.
DATA: xml_out TYPE string .
DATA : BEGIN OF upl OCCURS 0,
f(255) TYPE c,
END OF upl.
DATA: xmlupl TYPE string .
******************************* FIRST PHASE
******************************* FIRST PHASE
******************************* FIRST PHASE
*------------------ Fetch Data
SELECT * FROM t001 INTO TABLE t001.
*------------------- XML
CALL TRANSFORMATION ('ID')
SOURCE tab = t001[]
RESULT XML xml_out.
CALL FUNCTION 'SCMS_STRING_TO_FTEXT'
EXPORTING
TEXT = xml_out
* IMPORTING
* LENGTH =
TABLES
FTEXT_TAB = itab.
*-------------- Download
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filetype = 'BIN'
filename = 'd:xx.xml'
TABLES
data_tab = itab.
******************************* SECOND PHASE
******************************* SECOND PHASE
******************************* SECOND PHASE
BREAK-POINT.
REFRESH t001.
CLEAR t001.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = 'D:XX.XML'
filetype = 'BIN'
TABLES
data_tab = upl.
LOOP AT upl.
CONCATENATE xmlupl upl-f INTO xmlupl.
ENDLOOP.
*------------------- XML
CALL TRANSFORMATION ('ID')
SOURCE XML xmlupl
RESULT tab = t001[]
BREAK-POINT.
Regards,
Ferry Lianto -
How to convert internal table data to text
data : RES_CONTEN type string.
My problem is in inernal table IT_COMM there will be 7 to 8 rows of data is there
when iam sending into Res_content it is showing only last row of IT_COMM
there after iam converting into Ftext, after that iam creating document.
what i have to do get complete data of IT_COMM
is there any standard RFC is ther to convert table to text ?
right now iam getting only last line (total 8 rows )
LOOP AT IT_COMM.
CONCATENATE IT_COMM ' ' INTO RES_CONTENT SEPARATED BY SPACE.
ENDLOOP.
CONLENGTH = STRLEN( RES_CONTENT ) .
CONLENGTHS = CONLENGTH .
CALL FUNCTION 'SCMS_STRING_TO_FTEXT'
EXPORTING
TEXT = RES_CONTENT
TABLES
FTEXT_TAB = TEXT.
TRY.
CLEAR SEND_REQUEST .
SEND_REQUEST = CL_BCS=>CREATE_PERSISTENT( ).
CLEAR DOCUMENT .
DOCUMENT = CL_DOCUMENT_BCS=>CREATE_DOCUMENT(
I_TYPE = 'RAW'
I_TEXT = TEXT
I_LENGTH = CONLENGTHS
I_SUBJECT = SUBJECT ).
Thanks in advanceHi,
Refer to the following code:
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
BIN_FILESIZE = binfile
filename = 'D:\MYFILE.txt'
FILETYPE = 'BIN'
tables
data_tab = pdftab
EXCEPTIONS
FILE_WRITE_ERROR = 1
NO_BATCH = 2
GUI_REFUSE_FILETRANSFER = 3
INVALID_TYPE = 4
NO_AUTHORITY = 5
UNKNOWN_ERROR = 6
HEADER_NOT_ALLOWED = 7
SEPARATOR_NOT_ALLOWED = 8
FILESIZE_NOT_ALLOWED = 9
HEADER_TOO_LONG = 10
DP_ERROR_CREATE = 11
DP_ERROR_SEND = 12
DP_ERROR_WRITE = 13
UNKNOWN_DP_ERROR = 14
ACCESS_DENIED = 15
DP_OUT_OF_MEMORY = 16
DISK_FULL = 17
DP_TIMEOUT = 18
FILE_NOT_FOUND = 19
DATAPROVIDER_EXCEPTION = 20
CONTROL_FLUSH_ERROR = 21
OTHERS = 22
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF. -
Hello,
We are planning to setup our SAP system to generate XML messages (from ABAP transaction/program). Then it will send this XML message in our counterparts outside our network (i.e. HQ) which is not necessarily using an SAP system. Then it will send back a response XML message to our SAP system with data that we need to save and process in our database. We are only using SAP R3 Enterprise 4.7. My question is, Is this setup is achievable in our current release of SAP? What other options do we have? Thank you in advance.
Regards,
TonyHi sri,
1. itab --- > xml
xml ---> itab.
2. This program will do both.
(just copy paste in new program)
3.
REPORT abc.
DATA
DATA : t001 LIKE TABLE OF t001 WITH HEADER LINE.
DATA : BEGIN OF itab OCCURS 0,
a(100) TYPE c,
END OF itab.
DATA: xml_out TYPE string .
DATA : BEGIN OF upl OCCURS 0,
f(255) TYPE c,
END OF upl.
DATA: xmlupl TYPE string .
FIRST PHASE
FIRST PHASE
FIRST PHASE
Fetch Data
SELECT * FROM t001 INTO TABLE t001.
XML
CALL TRANSFORMATION ('ID')
SOURCE tab = t001[]
RESULT XML xml_out.
CALL FUNCTION 'SCMS_STRING_TO_FTEXT'
EXPORTING
TEXT = xml_out
IMPORTING
LENGTH =
TABLES
FTEXT_TAB = itab.
Download
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filetype = 'BIN'
filename = 'd:\xx.xml'
TABLES
data_tab = itab.
SECOND PHASE
SECOND PHASE
SECOND PHASE
BREAK-POINT.
REFRESH t001.
CLEAR t001.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = 'D:\XX.XML'
filetype = 'BIN'
TABLES
data_tab = upl.
LOOP AT upl.
CONCATENATE xmlupl upl-f INTO xmlupl.
ENDLOOP.
XML
CALL TRANSFORMATION ('ID')
SOURCE XML xmlupl
RESULT tab = t001[]
BREAK-POINT.
regards,
amit m. -
1 extra attachment that should not be included
Hi Gurus,
I am using the SO_NEW_DOCUMENT_ATT_SEND_API1.
I can now retrieve the email sent. But the problem is, I am receiving 2 attachments namely:
MESSAGE.DAT
FILENAME.DAT.
The expected attachment is the FILENAME.DAT. Why is it that it is sending 2 files? Where did the MESSAGE.DAT came from?
BTW, MESSAGE.DAT and FILENAME.DAT has the same content.
My code is:
wa_objbin = lv_record.
APPEND wa_objbin TO it_objbin.
wa_doc_data-obj_descr = lv_title.
wa_doc_data-obj_langu = sy-langu.
wa_doc_data-skip_scren = c_x.
DESCRIBE TABLE it_objbin LINES gv_tab_lines.
READ TABLE it_objbin INTO wa_objbin INDEX gv_tab_lines.
wa_objhead = text-005. "2007_016_FR10_HFM_SFeRE
APPEND wa_objhead TO it_objhead.
Creating the entry for the compressed attachment
wa_objpack-transf_bin = c_x.
wa_objpack-head_start = 1.
wa_objpack-head_num = 1.
wa_objpack-body_start = 1.
wa_objpack-body_num = gv_tab_lines.
wa_objpack-obj_langu = sy-langu.
wa_objpack-doc_type = c_dat.
wa_objpack-obj_name = c_att.
wa_objpack-obj_descr = lv_title.
wa_objpack-doc_size = gv_tab_lines * 250.
APPEND wa_objpack TO it_objpack.
IF gv_flag2 IS INITIAL.
APPEND wa_objpack TO it_objpack.
gv_flag2 = c_x.
ELSE.
IF wa_objpack-doc_size > lv_doctemp.
REFRESH it_objpack.
APPEND wa_objpack TO it_objpack.
ENDIF.
lv_doctemp = wa_objpack-doc_size.
ENDIF.
lv_size = wa_objpack-doc_size.
Converts string to ftext format
CALL FUNCTION 'SCMS_STRING_TO_FTEXT'
EXPORTING
text = space
TABLES
ftext_tab = it_objbin.
Converts ftext to binary format
CALL FUNCTION 'SCMS_FTEXT_TO_BINARY'
EXPORTING
input_length = lv_size
TABLES
ftext_tab = it_objbin
binary_tab = it_objbin2
EXCEPTIONS
failed = 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.
Entering names in the distribution list
it_reclist-receiver = gv_email_add.
wa_reclist-receiver = '[email protected]'.
wa_reclist-express = c_x.
wa_reclist-rec_type = c_u.
APPEND wa_reclist TO it_reclist.
Sending the document
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = wa_doc_data
commit_work = c_x
TABLES
packing_list = it_objpack
object_header = it_objhead
contents_bin = it_objbin2
receivers = it_reclist
EXCEPTIONS
too_many_receivers = 1
document_not_sent = 2
operation_no_authorization = 4
OTHERS = 99.
Thanks in advance.
BenedictBenedict
Just copy paste the below code as given into a report only changing the email address of receipient to your email address to testing.
That is line:
lwa_reclist-receiver = '[email protected]'. " Email address of your receipient
A mail will be sent to your email address specified in the receipient list and a copy of it also placed in your SBWP Outbox.
Let me know if you need further help, <b>else reward neccessary points</b>.
Code
REPORT zmfv_rough_pad.
DATA :
li_attachment TYPE TABLE OF soli, " hold attachment contents
li_pdf TYPE TABLE OF tline, " hold data from spool in PDF format
li_objpack TYPE TABLE OF sopcklsti1, " hold email body, attachment details
li_objtxt TYPE TABLE OF solisti1, " hold message contents
li_reclist TYPE TABLE OF somlreci1. " hold email reciever details
DATA :
lwa_attachment LIKE LINE OF li_attachment,
lwa_pdf LIKE LINE OF li_pdf,
lwa_objpack LIKE LINE OF li_objpack,
lwa_objtxt LIKE LINE OF li_objtxt,
lwa_reclist LIKE LINE OF li_reclist,
lwa_document_data TYPE sodocchgi1. " hold document details like title, size etc.
DATA :
lv_sent_to_all TYPE c, " flag to check if mail is sent to all
l_att_lines TYPE i, " hold number of lines in attachment table
lv_spool_desc(68) TYPE c. " hold description of spool
CONSTANTS : lc_email_txt TYPE solisti1-line VALUE 'Find attached Payment Advice sent by this email.',
lc_sensitivity TYPE sodocchgi1-sensitivty VALUE 'O',
lc_raw TYPE sopcklsti1-doc_type VALUE 'RAW',
lc_pdf TYPE sopcklsti1-doc_type VALUE 'PDF',
lc_transf_bin TYPE sopcklsti1-transf_bin VALUE 'X',
lc_email TYPE sopcklsti1-obj_name VALUE 'Email',
lc_ext_id TYPE somlreci1-rec_type VALUE 'U',
lc_outbox TYPE sonv-flag VALUE 'X',
lc_obj_name TYPE sodocchgi1-obj_name VALUE 'Email Test',
lc_1 TYPE n VALUE '1',
lc_0 TYPE n VALUE '0'.
CLEAR: lwa_attachment,
lwa_pdf,
lwa_reclist,
lwa_objtxt,
lwa_objpack,
lwa_document_data.
REFRESH : li_attachment,
li_pdf,
li_reclist,
li_objtxt,
li_objpack.
Build attachment table
lwa_attachment-line = 'YOUR TEXT FROM INTERNAL TABLE LINES'.
APPEND lwa_attachment TO li_attachment.
Body of email
CLEAR lwa_objtxt.
MOVE lc_email_txt TO lwa_objtxt.
APPEND lwa_objtxt TO li_objtxt.
Title of the email
lwa_document_data-obj_descr = 'Title of email'.
lwa_document_data-sensitivty = lc_sensitivity.
lwa_document_data-expiry_dat = sy-datum + 15.
lwa_document_data-doc_size = STRLEN( lwa_objtxt ).
lwa_document_data-obj_name = lc_obj_name.
e-mail body
CLEAR lwa_objpack.
lwa_objpack-head_start = lc_1.
lwa_objpack-head_num = lc_0.
lwa_objpack-body_start = lc_1.
lwa_objpack-body_num = lc_1.
lwa_objpack-doc_type = lc_raw.
lwa_objpack-doc_size = STRLEN( lwa_objtxt ).
APPEND lwa_objpack TO li_objpack.
For e-mail attachment
DESCRIBE TABLE li_attachment LINES l_att_lines.
CLEAR lwa_attachment.
READ TABLE li_attachment INDEX l_att_lines INTO lwa_attachment.
CLEAR lwa_objpack.
lwa_objpack-transf_bin = lc_transf_bin.
lwa_objpack-head_start = lc_1.
lwa_objpack-head_num = lc_1.
lwa_objpack-body_start = lc_1.
lwa_objpack-body_num = l_att_lines.
lwa_objpack-doc_type = lc_raw.
lwa_objpack-obj_name = lc_email.
lwa_objpack-obj_descr = lv_spool_desc.
lwa_objpack-doc_size = ( 255 * ( l_att_lines - 1 ) ) + STRLEN( lwa_attachment-line ).
APPEND lwa_objpack TO li_objpack.
make recipient list
CLEAR lwa_reclist.
lwa_reclist-receiver = '[email protected]'. " Email address of your receipient
lwa_reclist-rec_type = lc_ext_id. " To external email id
lwa_reclist-COM_TYPE = 'INT'. " Internet mail
APPEND lwa_reclist TO li_reclist.
send mail with attachment
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = lwa_document_data
put_in_outbox = lc_outbox
commit_work = 'X'
IMPORTING
sent_to_all = lv_sent_to_all
TABLES
packing_list = li_objpack
contents_bin = li_attachment
contents_txt = li_objtxt
receivers = li_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.
WRITE: 'Success'.
ENDIF. -
RE: Mail sent to SAP inbox-Urgent.
Hi,
I sent mail with attachment( internal table contents) to SAP inbox using the below codw.
DATA: l_text TYPE char255. " Text
*DATA: l_text(280) TYPE c. " Text
DATA: l_lines TYPE i,
l_size TYPE sood-objlen. " Size of Attachment
Mail related
DATA: i_content TYPE soli_tab, " Mail content
i_attach TYPE soli_tab. " Attachment
DATA: l_send_request TYPE REF TO cl_bcs, " E-Mail Send Request
l_document TYPE REF TO cl_document_bcs, " E-Mail Attachment
l_recipient TYPE REF TO if_recipient_bcs, " Distribution List
l_sender TYPE REF TO if_sender_bcs, " Address of Sender
l_uname TYPE salrtdrcpt, " Sender Name(SY-UNAME)
l_bcs_exception TYPE REF TO cx_document_bcs, " BCS Exception
l_addr_exception TYPE REF TO cx_address_bcs, " Address Exception
l_send_exception TYPE REF TO cx_send_req_bcs. " E-Mail sending Exception
DATA: l_recipient_soos TYPE soos1.
*data : p_uname TYPE ad_smtpadr .
FORM send_to_sap_mail .
Preparing body of the Mail
MOVE 'Pending Delivery Documents List' TO l_text.
APPEND l_text TO i_content.
Preparing contents of attachment with Change Log
PERFORM prepare_attachment.
Creates persistent send request
TRY.
l_send_request = cl_bcs=>create_persistent( ).
Creating Document
l_document = cl_document_bcs=>create_document(
i_type = 'RAW'
i_text = i_content[]
i_subject = 'Pending Delivery Documents' ).
DESCRIBE TABLE i_mara LINES l_lines.
DESCRIBE TABLE it_output LINES l_lines.
Size to multiplied by 2 for UNICODE enabled systems
l_size = l_lines * 2 * 255.
Adding Attachment
CALL METHOD l_document->add_attachment
EXPORTING
i_attachment_type = c_ext
i_attachment_size = l_size
i_attachment_subject = 'Pending Delivery Documents'
i_att_content_text = i_attach[].
Add document to send request
CALL METHOD l_send_request->set_document( l_document ).
Get Sender Object
l_uname = sy-uname.
l_sender = cl_sapuser_bcs=>create( l_uname ).
CALL METHOD l_send_request->set_sender
EXPORTING
i_sender = l_sender.
E-Mail
TRANSLATE p_uname TO UPPER CASE.
l_recipient_soos-recesc = 'B'.
l_recipient_soos-recnam = p_uname.
Preparing recepient from SAP Logon Name
CALL METHOD cl_send_request_bcs=>create_recipient_from_soos1
EXPORTING
i_soos1 = l_recipient_soos
RECEIVING
result = l_recipient.
Add Recipient
CALL METHOD l_send_request->add_recipient
EXPORTING
i_recipient = l_recipient
i_express = 'U'
i_copy = ' '
i_blind_copy = ' '
i_no_forward = ' '.
*Trigger E-Mail immediately
l_send_request->set_send_immediately( 'X' ).
CALL METHOD l_send_request->send( ).
COMMIT WORK.
CATCH cx_document_bcs INTO l_bcs_exception.
CATCH cx_send_req_bcs INTO l_send_exception.
CATCH cx_address_bcs INTO l_addr_exception.
ENDTRY.
Refresh it_output.
clear l_text.
clear I_content.
refresh I_attach.
ENDFORM. " Send_to_sap_mail
*& Form prepare_attachment
text
--> p1 text
<-- p2 text
FORM prepare_attachment .
FIELD-SYMBOLS: <lfs_table>, " Internal table structure
<lfs_con>. " Field Content
DATA: l_text TYPE char1024. " Text content for mail attachment
DATA: l_text(1280) TYPE c. " Text content for mail attachment
DATA: l_con(50) TYPE c. " Field Content in character format
Columns to be tab delimeted
LOOP AT it_output ASSIGNING <lfs_table>.
DO.
ASSIGN COMPONENT sy-index OF STRUCTURE <lfs_table>
TO <lfs_con>.
IF sy-subrc NE 0.
CONCATENATE c_cr l_text INTO l_text.
APPEND l_text TO i_attach.
EXIT.
ELSE.
CLEAR: l_con.
MOVE <lfs_con> TO l_con.
CONDENSE l_con.
IF sy-index = 1.
CLEAR: l_text.
MOVE l_con TO l_text.
ELSE.
CONCATENATE l_text l_con INTO l_text
SEPARATED BY c_tab.
ENDIF.
ENDIF.
ENDDO.
ENDLOOP.
ENDFORM. " prepare_attachment
Here my problem is in my internal table i have 30 columns and the row output length is more than 255 char,
and the SOLI structure fields defined as CHAR255, thats why when i am opening the sap mail attachment in Excel sheet, last three fields data is not displaying can any one please let me know the answer.loop at output_table.
concatenate g_string
filed1
filed2
CL_ABAP_CHAR_UTILITIES=>CR_LF
into g_string separted by
CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
endloop.
now pass the filled string to
CALL FUNCTION 'SCMS_STRING_TO_FTEXT'
EXPORTING
text = g_string
IMPORTING
LENGTH = LENGTH
TABLES
ftext_tab = obj_bin.
pass this objbin to SO_NEW_DOCUMENT_ATT_SEND_API1
now you will get the desired excel sheet.
NOte: dont put urgent in your subject.it is arule that people should not ans question which have urgent.
Edited by: S.r.v.r.Kumar on Jun 18, 2008 10:25 PM -
Creating an e-mail with excel file attachment
Morning,
Does anyone know how to create an e-mail with a spreadsheet attachment (in foreground and background). I can create an e-mail (in foreground and background) with a text (tab delimited) file attachment with a suffix of .xls. I have created the file by writing text to a string and then putting it into a text format using the function module SCMS_STRING_TO_FTEXT.
Thanks and regards
John.See the following simple ex:
DATA: P_EMAIL TYPE SOMLRECI1-RECEIVER.
DATA: T_PACKING_LIST LIKE SOPCKLSTI1 OCCURS 0 WITH HEADER LINE,
T_CONTENTS LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
T_RECEIVERS LIKE SOMLRECI1 OCCURS 0 WITH HEADER LINE,
T_ATTACHMENT LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
T_OBJECT_HEADER LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
W_CNT TYPE I,
W_SENT_ALL(1) TYPE C,
W_DOC_DATA LIKE SODOCCHGI1,
GD_ERROR TYPE SY-SUBRC,
GD_RECIEVER TYPE SY-SUBRC.
DATA: IT_ATTACH TYPE STANDARD TABLE OF SOLISTI1 INITIAL SIZE 0
WITH HEADER LINE.
DATA: IT_MESSAGE TYPE STANDARD TABLE OF SOLISTI1 INITIAL SIZE 0
WITH HEADER LINE.
***Sending mail to the receipients
if not it_final[] is initial.
PERFORM SUB_GET_MAIL_ADDR.
Populate table with detaisl to be entered into .xls file
PERFORM BUILD_XLS_DATA_TABLE.
PERFORM POPULATE_EMAIL_MESSAGE_BODY.
Send file by email as .xls speadsheet
PERFORM SEND_FILE_AS_EMAIL_ATTACHMENT
TABLES IT_MESSAGE
IT_ATTACH
USING P_EMAIL
'Sales Register Report - Set Top Box / Accessories'
'XLS'
'SSTB'
CHANGING GD_ERROR
GD_RECIEVER.
Instructs mail send program for SAPCONNECT to send email(rsconn01)
PERFORM INITIATE_MAIL_EXECUTE_PROGRAM.
endif.
*& Form BUILD_XLS_DATA_TABLE
text
--> p1 text
<-- p2 text
FORM BUILD_XLS_DATA_TABLE .
data: wa_itab like it_final.
CONSTANTS:
CON_TAB TYPE C VALUE CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB,
CON_CRET TYPE C VALUE CL_ABAP_CHAR_UTILITIES=>CR_LF.
CONCATENATE 'Business Place' 'Region Code' 'Region' 'Branch Code'
'Branch' 'Material Desc' 'Area off Code'
'Area Name' 'Zone code' 'Zone Name' 'Cust No' 'Cust Name'
'Bill Doc No' 'Bill Date' 'Base Val' 'Total Val' 'Quantity'
INTO IT_ATTACH SEPARATED BY CON_TAB.
CONCATENATE CON_CRET IT_ATTACH INTO IT_ATTACH.
APPEND IT_ATTACH.
LOOP AT IT_FINAL INTO WA_ITAB.
CONCATENATE WA_ITAB-BUSINESS_PLACE
WA_ITAB-KVGR1
WA_ITAB-REGION
WA_ITAB-VKBUR
WA_ITAB-SALES_OFF
WA_ITAB-ARKTX
WA_ITAB-vkgrp
WA_ITAB-sales_grp
WA_ITAB-bzirk
WA_ITAB-zone
WA_ITAB-kunnr
WA_ITAB-name
WA_ITAB-vbeln
WA_ITAB-fkdat
WA_ITAB-base_value
WA_ITAB-total_value
WA_ITAB-fkimg
INTO IT_ATTACH SEPARATED BY CON_TAB.
CONCATENATE CON_CRET IT_ATTACH INTO IT_ATTACH.
APPEND IT_ATTACH.
ENDLOOP.
ENDFORM. " BUILD_XLS_DATA_TABLE
*& Form POPULATE_EMAIL_MESSAGE_BODY
text
--> p1 text
<-- p2 text
FORM POPULATE_EMAIL_MESSAGE_BODY .
REFRESH IT_MESSAGE.
CONCATENATE SY-DATUM6(2) '/' SY-DATUM4(2) '/' SY-DATUM+0(4) INTO G_DATE.
IT_MESSAGE = 'Please find attached excel sheet.'.
APPEND IT_MESSAGE.
IT_MESSAGE = 'Report'.
APPEND IT_MESSAGE.
Concatenate 'Report generated date' ':' G_Date '.' into IT_MESSAGE.
APPEND IT_MESSAGE.
clear it_message.
append it_message.
IT_MESSAGE = 'This is an autogenerated mail, please do not reply'.
APPEND IT_MESSAGE.
ENDFORM. " POPULATE_EMAIL_MESSAGE_BODY
*& Form SEND_FILE_AS_EMAIL_ATTACHMENT
Send email
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.
DATA: LD_ERROR TYPE SY-SUBRC,
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.
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.
READ TABLE IT_ATTACH INDEX W_CNT.
W_DOC_DATA-DOC_SIZE =
( W_CNT - 1 ) * 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.
T_PACKING_LIST-OBJ_NAME = 'stb'.
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-DOC_TYPE = 'XLS'.
T_PACKING_LIST-OBJ_DESCR = LD_ATTDESCRIPTION.
T_PACKING_LIST-OBJ_DESCR = 'Sales_STB'.
T_PACKING_LIST-OBJ_NAME = LD_ATTFILENAME.
T_PACKING_LIST-OBJ_NAME = 'stb'.
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 IT_RECV.
T_RECEIVERS-RECEIVER = IT_RECV-EMAIL.
T_RECEIVERS-REC_TYPE = 'U'.
T_RECEIVERS-COM_TYPE = 'INT'.
T_RECEIVERS-COPY = 'X'.
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 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 = ''
AND RETURN.
ENDFORM. " INITIATE_MAIL_EXECUTE_PROGRAM -
Sending Emails with Attachments greater than 255 chars in 4.6C
Hi,
I have a requirement in which i have to send mails with attachments greater than 255 characters. The attachment would be a tab-delimited .TXT file. Since i am working on 4.6C, i don't have the luxury of using the FM 'SCMS_STRING_TO_FTEXT'.
It's very urgent. So any help in this regards would be greatly appreciated.
Thank you.
BalajiHi,
Internal table to be passed to SOLIST1 type int, table and then compress this table using fm "table_compress" with the compressed table then call fm "table_decompress" and pass this to function module SO_NEW_DOCUMENT_ATT_SEND_API1.
Keep in mind the following variable
i_packing_list-transf_bin = 'X'.
aRs -
Querry on file to be send as an attachment to internet users
Hi,
Have a querry on how to send a file of >260 chars as an attachment. It is a TXT file.
The file needs to be send to internet addresses.
Currently tried with FM 'SO_NEW_DOCUMENT_ATT_SEND_API1'.
It sends the file as a mail attachment but the chars after 255 size getting truncated.
Thanks in advance.
Expecting prompt answers.
Regards,
Yamini.Hi Yamini
This one of the responses by Mr.Thomas Jung for a similar query, hope it helps you.
"Have you tried breaking your structure into 255 chunks? I don't know what the structure you are moving from looks like, but you should be able break it back up into the SOLI structure. The end of a line in SOLI doesn't create a Carriage Return/Line Break. You have to insert these yourself like in the following:
Create document clear mail_line. move 'This is a test E-Mail'(d01) to mail_line. concatenate mail_line cl_abap_char_utilities=>newline into mail_line. append mail_line to l_mailtext.
What kind of attachment are you wanting to create - a text tab delimited file for reading in a spreadsheet application such as excel? You might try reassembling your data table into a single string with newlines where you need them. Then use function module SCMS_STRING_TO_FTEXT to turn it back into SOLI. This is what I have done in the past. I'm afraid without knowing more about your source structure and attachment type, this is about all I can tell you."
cheers
Sameer
PS: Have a look at the following thread
Re: How to email an attachment with more than 255 characters? -
Hi,
I am trying to convert the logged changes into XML file.But the contents are not coming up correctly.Please help me in solving out this issue.
I have coded is like this :
CALL FUNCTION 'HR_INFOTYPE_LOG_GET_LIST'
EXPORTING
tclas = 'A'
begda = sy-datum
endda = sy-datum
auth_check = 'X'
USE_ARCHIVE = ' '
IMPORTING
SUBRC =
TABLES
PERNR_TAB =
INFTY_TAB =
infty_logg_key_tab = test
DATUM_TAB =
UNAME_TAB =
LOOP AT test INTO wa.
CALL FUNCTION 'HR_INFOTYPE_LOG_GET_DETAIL'
EXPORTING
logged_infotype = wa
auth_check = 'X'
USE_ARCHIVE = ' '
IMPORTING
SUBRC =
TABLES
infty_tab_before = test1
infty_tab_after = test2
fields = test3
CHECK sy-subrc = 0.
ENDLOOP.
And i am appending INFTY , PERNR from TEST1 table and FNAME ,NEWDT from TEST3 table into one new internal table called struct and converting that internal table contents into xml.
For XML conversion*********************************
CALL TRANSFORMATION ('ID')
SOURCE tab = struct[]
RESULT XML xml_out1.
CALL FUNCTION 'SCMS_STRING_TO_FTEXT'
EXPORTING
text = xml_out1
IMPORTING
LENGTH = lv_length
TABLES
ftext_tab = itab1.
CHECK sy-subrc = 0.
After downloading i am getting the xml file like this :
<?xml version="1.0" encoding="UTF-16"?>
-<asx:abap version="1.0" xmlns:asx="http://www.sap.com/abapxml">-<asx:values>-<TAB>-<item><INFTY>0002</INFTY><PERNR>00070297</PERNR><FNAME/><NEWDT/></item>-<item><INFTY/><PERNR>00000000</PERNR><FNAME>ITXEX</FNAME><NEWDT/></item>
But i want in this way:
<?xml version="1.0" encoding="UTF-8"?>
-<NewDataSet> -<PA0002> <PERNR>8000</PERNR> <TITEL>DLEM 6</TITEL> <VORNA>Raj</VORNA> <NACHN>Halli</NACHN> <NAME2>RB</NAME2> <INITS/> <RUFNM/> <SPRSL/> <GESCH/> <GBDAT/> <GBORT/> <GBLND/> <NATI0/> <GBDEP/> <NATI2/> <NATI3/> <FAMST/> <FAMDT/> <ANZKD/> <KONFE/> <BEGDA/> <AEDTM/> </PA0002>
Regards,
HelmaHi Patlolla,
Goto SPRO : Personnel Administration -> Tools -> Revision -> Set up change document.
There, add IT 0021 as an infotype to be logged.
Best Regards,
Dilek
Maybe you are looking for
-
Vector add Vector, can't get back the value
import java.util.*; public class TestingMain { public static void main(String[] args) { Vector v1 = new Vector(); Vector v2= new Vector(); v2.addElement("HH"); v2.addElement("JJ"); v1.addElement(v1); for(int i=0; i<v1.size(); i++ ){ for(int j=0; j<v2
-
Setting up a wireless network.
Hi, I'm new to this and I'm not sure which section to put this question in. My household contains an Imac (2007 model), a MacBook Pro (2012 model) , 2 Ipads (Ipad 1 & Ipad 4), 3 Iphone 4's. We also have 2 Samsung smart TV's, a Samsung 3D Blu Ray play
-
Customer account [email protected] has used the password reset and does get the emails but the passwords do not work. Had customer delete all cookies and files, shutdown all browsers and restart, still could not get in. Please email him when his acco
-
Hello, I get this error sometimes while starting a new GP Process on portal and sometimes it runs through fine : com.sap.tc.webdynpro.services.exceptions.WDRuntimeException: View container UI element frameworkComponent4 in view VerticalContainerView
-
How to delete all old stuff of net software that could disturb software from my new provider? _______ k.