Doubt in using SO_NEW_DOCUMENT_ATT_SEND_API1
Im haveing a problem in this same FM.
I want to send via e.mail the file attach of service object .
I use the fm SO_DOCUMENT_READ_API1 to to read file.
The problem is that I can not get the FM, I think I wrong to set some information, since sending is correct but the file is not readable.
Someone has to send me an example?
tanks in advance
Hi,
check out this sample code:
data: objcont like solisti1 occurs 10 with header line.
data: doc_data like sofolenti1.
call function 'SO_DOCUMENT_READ_API1'
exporting
document_id = '545645555'
importing
document_data = doc_data
tables
object_content = objcont
exceptions
others = 1.
reward appropriate points.
Regards,
mansi.
Similar Messages
-
We use SO_NEW_DOCUMENT_ATT_SEND_API1 to send e-mails to employees for various notifications. The e-mails go out through SCOT and are sent to our lotus notes.
We have a project being implemented, where the data we are sending in the note is kind of sensitive, so we'd like to see if we could send the e-mail as encrypted. Does anyone know if there is some parameter we can set upon sending that would encrypt the text in the e-mail for sending?FORM pssword_prot_encryptpdf .
DATA: BEGIN OF command_list OCCURS 0.
INCLUDE STRUCTURE sxpgcolist.
DATA: END OF command_list .
DATA: BEGIN OF exec_protocol OCCURS 0.
INCLUDE STRUCTURE btcxpm.
DATA: END OF exec_protocol.
DATA: status LIKE btcxp3-exitstat,
commandname LIKE sxpgcolist-name VALUE 'ZTEST',
sel_no LIKE sy-tabix.
* GET LIST OF EXTERNAL COMMANDS
CALL FUNCTION 'SXPG_COMMAND_LIST_GET'
EXPORTING
commandname = commandname
operatingsystem = sy-opsys
TABLES
command_list = command_list
EXCEPTIONS
OTHERS = 1.
CALL FUNCTION 'SXPG_COMMAND_CHECK'
EXPORTING
commandname = command_list-name
operatingsystem = sy-opsys
EXCEPTIONS
no_permission = 1
command_not_found = 2
parameters_too_long = 3
security_risk = 4
wrong_check_call_interface = 5
x_error = 6
too_many_parameters = 7
parameter_expected = 8
illegal_command = 9
communication_failure = 10
system_failure = 11
OTHERS = 12.
CLEAR command_list.
REFRESH command_list.
DATA: v_dir_input TYPE sxpgcolist-parameters.
DATA: v_dir_input1 TYPE sxpgcolist-parameters.
break developer.
command_list-name = 'ZTEST'.
command_list-opsystem = 'Windows NT'.
CONCATENATE 'd:\pdf\' main_dtl-vbeln '.PDF' INTO name.
CONCATENATE 'cmd /c d:\pdf\encryptpdf.exe' '-i' name '-o ' name '-u' hdr-password INTO v_dir_input SEPARATED BY space .
READ TABLE command_list INDEX sel_no.
break developer.
CONCATENATE command_list-opcommand v_dir_input INTO command_list-opcommand SEPARATED BY space.
* CHECK AUTHORIZATION
command_list-addpar = 'X'.
APPEND command_list.
CONSTANTS: c_extcom TYPE sxpgcolist-name VALUE 'ZTEST',
c_oper TYPE syopsys VALUE 'Windows NT'.
DATA: t_result TYPE STANDARD TABLE OF btcxpm.
v_dir_input = command_list-opcommand.
CALL FUNCTION 'SXPG_COMMAND_EXECUTE'
EXPORTING
commandname = c_extcom
additional_parameters = v_dir_input
operatingsystem = c_oper
TABLES
exec_protocol = t_result
EXCEPTIONS
no_permission = 1
command_not_found = 2
parameters_too_long = 3
security_risk = 4
wrong_check_call_interface = 5
program_start_error = 6
program_termination_error = 7
x_error = 8
parameter_expected = 9
too_many_parameters = 10
illegal_command = 11
wrong_asynchronous_parameters = 12
cant_enq_tbtco_entry = 13
jobcount_generation_error = 14
OTHERS = 15.
ENDFORM. " PSSWORD_PROT -
How to update the sent mail using SO_NEW_DOCUMENT_ATT_SEND_API1
I have a requirement to update/ append the sent mail like a trail.Since i am sending mails using SO_NEW_DOCUMENT_ATT_SEND_API1, how can i update new contents to sent mails using this RFC???Please help me.
you may have to store content of each time mail send then only, you can send with history.
-
Hi experts,
I m using SO_NEW_DOCUMENT_ATT_SEND_API1 function moduel for sending mails to dealers. That is, whenver i execute a Z transaction, the customer invoice details are getting displayed in report output. At the same time, the same output data is sent as mail to the respective dealers.
Now teh user is asking whether there is any possiblity for the end users to have a proof of the mail which is being sent from the Z transaction. If the mail is sent, the end user who executes the Z transaction (mail sending transaction) should have that mail in his/her SENT ITEMS. If the mail not reaches the dealer, then the user must identify the mail bounce identification.
Pls tell me how to achve the same..
Regards,
ShanthiHi,
Yes it is possible..
Just pass 'X' to the exporting parameter 'put_in_outbox'. The user can check the send mail in 'sost'. All the details of the mail will be there. This will be the proof that the mail was sent.
Reg the 2nd part of your query, if the mail is not delivered to any reciepent or to particular recipient, the details will be there in the SAP outbox, that also you can see through transaction 'sost'.
Thanks & Regards
Rocky -
Hi all,
is it possible to view mails send using SO_NEW_DOCUMENT_ATT_SEND_API1 function module to UWL?
I am receving emails in my SAP Inbox.
Please guide.
thanks.Hi,
You can only get the SAP mails into UWL notification tab with the Sonic connector (well of course with some custom development everything is possible).
One trick to get the workflow for sending "mails" to UWL is to NOT use email sending step, but instead use a decision step in the workflow and send this work item to the user. The decision step can include the same message as the email, and have onl one option "Confirm" (or whatever). These you can easily display in UWL since they are normal work items.
Regards,
Karri -
Regarding EMAIL in inbox using SO_NEW_DOCUMENT_ATT_SEND_API1
HI all,
I am using SO_NEW_DOCUMENT_ATT_SEND_API1 module to sent emails on external email IDs.Can anyone guide me if this function module also sends email to SAP inbox correspoding to email addrees on which email is sent?
Also guide me how to send doc to sap inbox of these email adrees using SO_NEW_DOCUMENT_ATT_SEND_API1.
Thanks.Hi,
Yes you can even send mails to the SAp inbox, by simply setting the receiver type as B in the RECEIVERS tables parameter.
Regards
Pavan -
Extra emails using SO_NEW_DOCUMENT_ATT_SEND_API1.
Hello,
I have a requirement to send Purchase order email to a group of people besides the vendor.
I set the configuration to send the first email to the vendor and it is working fine.
I would like to use SO_NEW_DOCUMENT_ATT_SEND_API1 to send the SAME EMAIL to a group of persons but I am not sure where to read the information of the already generated email to populate the FM.
I saw some code in the forum to read the form and send it with SO_NEW_DOCUMENT_ATT_SEND_API1, but I could not find where you enter the Purchase Order number to generate the form in base of it.
Could anybody help me to understand how to populate SO_NEW_DOCUMENT_ATT_SEND_API1 with the information of the already generated email?
Thank you.
Monica.Hi Chandra,
Thank you for your answer.
I did a little more research and realized that the email sent is not stored. This takes me to the option of emailing a SAPscript form with my PO.
I found some code in the forum to email a SAPscript but I do see where you enter the PO number or the reference to it.
Do you know?
Monica. -
E-mail functionality using so_new_document_att_send_api1
Hi
We Implemented E-mail functionality in our tool useing "so_new_document_att_send_api1" standard FM but here im unable to attach excel document .How to attach a excel document in this standard FM plz help.
Asifhi try this code
*& Report ZTEST_2 *
*& Report ZTEST_2 *
REPORT ztest_2 .
TYPES : BEGIN OF t_email_update_iw32,
aufnr LIKE viaufks-aufnr,
vornr LIKE afvc-vornr,
text(220),
END OF t_email_update_iw32.
DATA : gt_email_update_iw32 TYPE STANDARD TABLE OF t_email_update_iw32,
gw_email_update_iw32 TYPE t_email_update_iw32.
TYPES : BEGIN OF t_email_date_error,
aufnr LIKE viaufks-aufnr,
prueflos LIKE qamr-prueflos,
merknr LIKE qamr-merknr,
text(220),
END OF t_email_date_error.
DATA : gt_email_date_error TYPE STANDARD TABLE OF t_email_date_error,
gw_email_date_error TYPE t_email_date_error.
TYPES : BEGIN OF t_email_conf_doc_error,
aufnr LIKE viaufks-aufnr,
vornr LIKE afvc-vornr,
text(220),
END OF t_email_conf_doc_error.
DATA : gt_email_conf_doc_error TYPE STANDARD TABLE OF
t_email_conf_doc_error,
gw_email_conf_doc_error TYPE t_email_conf_doc_error.
SELECTION-SCREEN : BEGIN OF BLOCK b4 WITH FRAME TITLE text-004.
PARAMETERS : cb_email AS CHECKBOX DEFAULT 'X'.
*SELECTION-SCREEN BEGIN OF LINE.
*SELECTION-SCREEN COMMENT (16) text-007 FOR FIELD p_email1.
PARAMETERS : p_email LIKE somlreci1-receiver,
p_email1 LIKE adr6-smtp_addr.
PARAMETERS : p_table1 AS CHECKBOX,
p_table2 AS CHECKBOX,
p_table3 AS CHECKBOX.
SELECTION-SCREEN : END OF BLOCK b4.
CLEAR gw_email_update_iw32.
REFRESH gt_email_update_iw32.
gw_email_update_iw32-aufnr = '1234567'.
gw_email_update_iw32-vornr = '0010'.
gw_email_update_iw32-text = 'This is table1'.
APPEND gw_email_update_iw32 TO gt_email_update_iw32.
CLEAR gw_email_update_iw32.
gw_email_update_iw32-aufnr = '4564578'.
gw_email_update_iw32-vornr = '0020'.
gw_email_update_iw32-text = 'This is table1'.
APPEND gw_email_update_iw32 TO gt_email_update_iw32.
gw_email_date_error-aufnr = '222615'.
gw_email_date_error-prueflos = '1111'.
gw_email_date_error-merknr = '2222'.
gw_email_date_error-text = 'This is table2'.
APPEND gw_email_date_error TO gt_email_date_error.
gw_email_date_error-aufnr = '222615'.
gw_email_date_error-prueflos = '3333'.
gw_email_date_error-merknr = '4444'.
gw_email_date_error-text = 'This is table2'.
APPEND gw_email_date_error TO gt_email_date_error.
gw_email_conf_doc_error-aufnr = '9900107987'.
gw_email_conf_doc_error-vornr = '999999'.
gw_email_conf_doc_error-text = 'This is table3'.
APPEND gw_email_conf_doc_error TO gt_email_conf_doc_error.
gw_email_conf_doc_error-aufnr = '9900107987'.
gw_email_conf_doc_error-vornr = '999999'.
gw_email_conf_doc_error-text = 'This is table3'.
APPEND gw_email_conf_doc_error TO gt_email_conf_doc_error.
DATA : lw_space VALUE ''.
SET PARAMETER ID 'ZPDF' FIELD lw_space.
DATA : pripar LIKE pri_params.
CALL FUNCTION 'GET_PRINT_PARAMETERS'
EXPORTING
in_parameters = pripar
line_size = 255
layout = 'X_65_132'
no_dialog = 'X'
IMPORTING
out_parameters = pripar
EXCEPTIONS
archive_info_not_found = 1
invalid_print_params = 2
invalid_archive_params = 3
OTHERS = 4.
NEW-PAGE PRINT ON PARAMETERS pripar NO DIALOG .
RESERVE 5 LINES.
DATA : text1(10) TYPE c VALUE 'AUFNR',
text2(10) TYPE c VALUE 'VORNR',
text3(50) TYPE c VALUE 'TEXT'.
IF p_table1 = 'X'.
WRITE AT 10 text1. WRITE AT 30 text2 . WRITE AT 30 text3.
LOOP AT gt_email_update_iw32 INTO gw_email_update_iw32.
WRITE : / gw_email_update_iw32-aufnr , gw_email_update_iw32-vornr ,
gw_email_update_iw32-text.
ENDLOOP.
ENDIF.
WRITE : / sy-uline .
IF p_table2 = 'X'.
WRITE : / 'AUFNR' , 'PRUEFLOS' , 'MERKNR', 'TEXT' .
LOOP AT gt_email_date_error INTO gw_email_date_error.
WRITE : / gw_email_date_error-aufnr, gw_email_date_error-prueflos,
gw_email_date_error-merknr,gw_email_date_error-text.
ENDLOOP.
ENDIF.
WRITE : / sy-uline .
IF p_table3 = 'X'.
WRITE : / 'AUFNR' , 'VORNR' , 'TEXT' .
LOOP AT gt_email_conf_doc_error INTO gw_email_conf_doc_error.
WRITE : / gw_email_conf_doc_error-aufnr,
gw_email_conf_doc_error-vornr, gw_email_conf_doc_error-text.
ENDLOOP.
ENDIF.
NEW-PAGE PRINT OFF.
DATA : mtab_pdf LIKE tline OCCURS 0 WITH HEADER LINE.
DATA : rqident LIKE tsp01-rqident ,
rqcretime LIKE tsp01-rqcretime .
SELECT rqident rqcretime FROM tsp01
INTO (rqident,rqcretime)
WHERE rqowner = sy-uname
ORDER BY rqcretime DESCENDING.
EXIT.
ENDSELECT.
DATA: spool_id LIKE tsp01-rqident.
MOVE rqident TO spool_id.
DATA : p_file LIKE rlgrap-filename VALUE 'C:\file.pdf' ,
numbytes TYPE i,
cancel.
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = spool_id
NO_DIALOG =
DST_DEVICE =
PDF_DESTINATION =
IMPORTING
pdf_bytecount = numbytes
PDF_SPOOLID =
LIST_PAGECOUNT =
BTC_JOBNAME =
BTC_JOBCOUNT =
TABLES
pdf = mtab_pdf
EXCEPTIONS
err_no_abap_spooljob = 1
err_no_spooljob = 2
err_no_permission = 3
err_conv_not_possible = 4
err_bad_destdevice = 5
user_cancelled = 6
err_spoolerror = 7
err_temseerror = 8
err_btcjob_open_failed = 9
err_btcjob_submit_failed = 10
err_btcjob_close_failed = 11
OTHERS = 12
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE 'I' NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
end
DATA : w_buffer TYPE string. "To convert from 132 to 255
DATA : i_record LIKE solisti1 OCCURS 0 WITH HEADER LINE.
LOOP AT mtab_pdf.
Replacing space by ~
TRANSLATE mtab_pdf USING ' ~'.
CONCATENATE w_buffer mtab_pdf INTO w_buffer.
ENDLOOP.
Replacing ~ by space
TRANSLATE w_buffer USING '~ ' .
DO.
i_record = w_buffer.
Appending 255 characters as a record
APPEND i_record.
SHIFT w_buffer LEFT BY 255 PLACES.
IF w_buffer IS INITIAL.
EXIT.
ENDIF.
ENDDO.
*start try
DATA: objpack LIKE sopcklsti1 OCCURS 2 WITH HEADER LINE.
DATA: objhead LIKE solisti1 OCCURS 1 WITH HEADER LINE.
DATA: objbin LIKE solisti1 OCCURS 10 WITH HEADER LINE.
DATA: objtxt LIKE solisti1 OCCURS 10 WITH HEADER LINE.
DATA: reclist LIKE somlreci1 OCCURS 5 WITH HEADER LINE.
DATA: doc_chng LIKE sodocchgi1.
DATA : tab_lines TYPE c.
doc_chng-obj_name = 'TEST'.
doc_chng-obj_descr = 'Mail came successfully'.
objtxt = 'Regards'.
APPEND objtxt.
objtxt = 'Nitin'.
APPEND objtxt.
objtxt = 'hahaha'.
APPEND objtxt.
DESCRIBE TABLE objtxt LINES tab_lines.
READ TABLE objtxt INDEX tab_lines.
doc_chng-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objtxt ).
* ERSTELLEN DES EINTRAGS ZUM KOMPRIMIERTEN DOKUMENT
CLEAR objpack-transf_bin.
objpack-head_start = 1.
objpack-head_num = 0.
objpack-body_start = 1.
objpack-body_num = tab_lines.
objpack-doc_type = 'RAW'.
APPEND objpack.
* ERSTELLEN DER ANLAGE FUR DAS DOKUMENT
**OBJBIN = '\O/ '. APPEND OBJBIN.
**OBJBIN = ' '. APPEND OBJBIN.
**OBJBIN = ' / \ '. APPEND OBJBIN.
LOOP AT i_record.
objbin[] = i_record[].
ENDLOOP.
DESCRIBE TABLE objbin LINES tab_lines.
*objhead = 'picasso.txt'. APPEND objhead.
* Erstellen des Eintrags zur komprimierten Anlage
objpack-transf_bin = 'X'.
objpack-head_start = 1.
objpack-head_num = 1.
objpack-body_start = 1.
objpack-body_num = tab_lines.
objpack-doc_type = 'PDF'.
objpack-obj_name = 'PDF File received '.
objpack-obj_descr = 'PDF File received '.
*objpack-doc_size = ( tab_lines ) * 255 .
APPEND objpack.
* Fullen der Empfangerliste
refresh reclist.
reclist-rec_type = 'U'.
reclist-receiver = p_email1.
APPEND reclist.
reclist-rec_type = 'B'.
reclist-receiver = sy-uname.
APPEND reclist.
reclist-rec_type = 'U'.
reclist-receiver = p_email.
APPEND reclist.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = doc_chng
put_in_outbox = '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. -
Mails in UWL using SO_NEW_DOCUMENT_ATT_SEND_API1
Hi all,
is it possible to view mails send using SO_NEW_DOCUMENT_ATT_SEND_API1 function module to UWL?
I am receving emails in my SAP Inbox.
Please guide.
thanks.I believe you can use SONiC. You might want to do some research on that.
-
Sending Carbon Copy using SO_NEW_DOCUMENT_ATT_SEND_API1
Hello,
I am using SO_NEW_DOCUMENT_ATT_SEND_API1' to send out email letting people know a direct deposit has been posted to their bank. My problem is that the Acct department wants a carbon copy sent to their email address for each email that is sent. Looking at this function, there is a line called
RECEIVERS = IT_RECLIST. When I take this thru debug, I see IT_RECLIST defined as TYPE TABLE OF SOMLRECI1. When I see the fields in IT_RECLIST, there is a field called copy, I assume I set this flag = 'X' to let the function know I want a carbon copy, correct? Also, I am confused as to where the carbon copy email address would go, because all I see is a field called RECEIVER that is holding the recipients email. Can you guys set me straight here?u can't send a carbon copy...instead while sending the email, the same can be sent to 2 or more people at a time. Add the email address to the existing list and it will trigger same email to the department.
-
Doubt about using automation testing in mtm and vs 2012
Hi
Ive a doubt in using mtm and vs 2012. I wanna test a software by automation method
1) whether i should record the steps in visual studio and attach the recorded file to mtm and test
or
2) can i record the script(steps) in mtm and run the automation testing in mtm, if you say yes what are the step.
Plz help me out for both 1 and 2 by tell the steps.
Thank you
Reguards
Pavan kumar RHi Pavan,
It is based on the detail requirement to choose them.
Do Coded UI test in visual studio 2012, we could record the action and playback, link tests to test case that in MTM, we also could base on the detail requirement to modify the code.
Do manual or automated test in MTM 2012, we also could record the action and playback, but can’t modify the code (need do it in vs), we could do automated tests in lab environment
# System Testing Your Application Using Microsoft Test Manager
http://msdn.microsoft.com/en-us/library/jj635157(v=vs.110).aspx
For the automated test in MTM, you could refer to these steps below:
Create tests
Check in TFS
Link test methods to test case
Queue a build
Create lab environment in mtm
Do automated test
More information, please refer to:
# Essential Guide for Running Automated Tests from a Test Plan
http://msdn.microsoft.com/en-us/library/ff472576(v=vs.110).aspx
If we record the action (script/steps) in the MTM, we could
playback the test, if we want do the automated test for that recording, we could generate the code in VS and link that test to the test case, after that we could do automated tests.
# Generating a Coded UI Test from an Existing Action Recording
http://msdn.microsoft.com/en-in/library/dd286652(v=vs.110).aspx
Regards
Starain
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey. -
Attaching text file using SO_NEW_DOCUMENT_ATT_SEND_API1
hello guys, i'm a newbie here.
I'm having trouble attaching an existing text file using function 'SO_NEW_DOCUMENT_ATT_SEND_API1'. It seems i can't find the right combination of parameters that are being passed to this function.
first, i'm using WS_UPLOAD to upload the text file to an internal table then i'm creating all the neccessary internal tables that will be use by this function..
By the way, i'm trying to send mail w/ attachments to external mail and SAPids. Below is my code.
REPORT ZHR_TESTEMAIL .
TABLES: USR02, PA0105, SOSU, SOUC, RLGRAP, IBIPPARMS, DYNPREAD, RSCSEL.
DATA: FOLD_YR(2) TYPE C,
FOLD_TYPE(3) TYPE C,
G_HEADER LIKE SOOD2,
G_FOLMAM LIKE SOFM2,
METHOD1 LIKE SY-UCOMM,
G_DOCUMENT LIKE SOOD4,
G_USER LIKE SOUDNAMEI1,
FOLD_NUMBER(12) TYPE C,
G_NEW_PARENT LIKE SOODK,
G_OWNER LIKE SOUD-USRNAM,
G_REF_DOCUMENT LIKE SOOD4,
G_USER_DATA LIKE SOUDATAI1,
G_AUTHORITY LIKE SOFA-USRACC,
G_OBJCNT LIKE SOLI OCCURS 0 WITH HEADER LINE,
G_OBJHEAD LIKE SOLI OCCURS 0 WITH HEADER LINE,
G_OBJPARA LIKE SELC OCCURS 0 WITH HEADER LINE,
G_OBJPARB LIKE SOOP1 OCCURS 0 WITH HEADER LINE,
G_RECIPIENTS LIKE SOOS1 OCCURS 0 WITH HEADER LINE,
G_REFERENCES LIKE SOXRL OCCURS 0 WITH HEADER LINE,
G_ATTACHMENTS LIKE SOOD5 OCCURS 0 WITH HEADER LINE.
DATA: BEGIN OF G_FILES OCCURS 10 ,
TEXT(4096) TYPE C,
END OF G_FILES.
DATA: BEGIN OF IT_WS_FILE OCCURS 0,
WS_FILE LIKE RLGRAP-FILENAME,
END OF IT_WS_FILE.
DATA: BEGIN OF IT_SAPID OCCURS 0,
SAPID LIKE USR02-BNAME,
END OF IT_SAPID.
DATA: BEGIN OF IT_EMAIL OCCURS 0,
EMAILADD LIKE PA0105-USRID_LONG,
END OF IT_EMAIL.
DATA: BEGIN OF IT_TSP01 OCCURS 0.
INCLUDE STRUCTURE TSP01.
DATA: END OF IT_TSP01.
DATA: BEGIN OF TAB2 OCCURS 50,
TEXT(200) TYPE C,
END OF TAB2.
DATA: V_DOCDATA TYPE SODOCCHGI1,
V_OBJPACK LIKE SOPCKLSTI1 OCCURS 0 WITH HEADER LINE,
V_OBJHEAD LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
V_OBJTXT LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
V_OBJBIN LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
V_OBJHEX LIKE SOLIX OCCURS 0 WITH HEADER LINE,
IT_RECVRS TYPE SOMLRECI1 OCCURS 0 WITH HEADER LINE,
IT_CONTNT TYPE SOLISTI1 OCCURS 0 WITH HEADER LINE,
IT_BODY LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE,
V_TLIN TYPE I,
V_LINE TYPE I.
DATA: BEGIN OF IT_TEXTLINE OCCURS 500,
TEXTLINE(5000),
END OF IT_TEXTLINE.
DATA: FYL LIKE RLGRAP-FILENAME,
GV_SUBNO LIKE SOSU-SUBNO,
GV_EMAIL LIKE PA0105-USRID_LONG,
GV_NEXTDAY LIKE SY-DATUM,
YEAR(4) TYPE C,
RECFLAG TYPE C.
SELECTION-SCREEN BEGIN OF BLOCK PARAM WITH FRAME TITLE TEXT-001.
PARAMETERS: SUBJ(254) TYPE C OBLIGATORY, "Subject
DESC(254) TYPE C. "Message
SELECT-OPTIONS: SAPID FOR USR02-BNAME NO INTERVALS. "Recipient's SAP ID
SELECT-OPTIONS: EMAILADD FOR PA0105-USRID_LONG NO INTERVALS.
SELECTION-SCREEN END OF BLOCK PARAM.
SELECTION-SCREEN BEGIN OF BLOCK PARAM2 WITH FRAME TITLE TEXT-002.
SELECT-OPTIONS: WS_FILE FOR DYNPREAD-FIELDNAME NO INTERVALS.
SELECTION-SCREEN END OF BLOCK PARAM2.
SELECTION-SCREEN BEGIN OF BLOCK PARAM3 WITH FRAME TITLE TEXT-003.
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS: RBUT1 RADIOBUTTON GROUP A USER-COMMAND BUT. "Local PC
SELECTION-SCREEN COMMENT 5(20) FOR FIELD RBUT1.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS: RBUT2 RADIOBUTTON GROUP A. "Server
SELECTION-SCREEN COMMENT 5(20) FOR FIELD RBUT2.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS: RBUT3 RADIOBUTTON GROUP A. "Spool
SELECTION-SCREEN COMMENT 5(20) FOR FIELD RBUT3.
PARAMETERS: SPOOLNUM LIKE RSPOTYPE-RQNUMBER. "Spool Number
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK PARAM3.
SELECTION-SCREEN BEGIN OF BLOCK PROC WITH FRAME TITLE TEXT-004.
SELECTION-SCREEN BEGIN OF LINE.
PARAMETER: BPROC AS CHECKBOX USER-COMMAND BCK. "Background Processing
SELECTION-SCREEN COMMENT 5(50) FOR FIELD BPROC.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK PROC.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR WS_FILE-LOW.
DATA: WS_FILE_TEMP TYPE IBIPPARMS-PATH.
CLEAR: WS_FILE_TEMP.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
PROGRAM_NAME = SY-REPID
DYNPRO_NUMBER = SY-DYNNR
FIELD_NAME = 'WS_FILE'
IMPORTING
FILE_NAME = WS_FILE_TEMP.
WS_FILE-LOW = WS_FILE_TEMP.
AT SELECTION-SCREEN.
SELECT SAPNAM FROM SOUC
INTO TABLE IT_SAPID
WHERE SAPNAM IN SAPID
AND DELETED = ''.
GV_NEXTDAY = SY-DATUM + 1.
LOOP AT EMAILADD.
IT_EMAIL-EMAILADD = EMAILADD-LOW.
APPEND IT_EMAIL.
CLEAR: IT_EMAIL.
ENDLOOP.
IF NOT BPROC IS INITIAL.
CLEAR: RBUT1, RBUT3.
RBUT2 = 'X'.
ELSE.
CLEAR: RBUT2.
ENDIF.
IF NOT RBUT3 IS INITIAL.
REFRESH: WS_FILE.
ENDIF.
IF SAPID IS INITIAL AND EMAILADD IS INITIAL.
MESSAGE E000(ZZ) WITH TEXT-201.
ELSEIF NOT SAPID IS INITIAL AND EMAILADD IS INITIAL.
CLEAR IT_SAPID.
READ TABLE IT_SAPID.
SELECT SINGLE SUBNO FROM SOSU
INTO GV_SUBNO
WHERE USRNO IN ( SELECT USRNO FROM SOUC
WHERE SAPNAM = IT_SAPID-SAPID ).
IF SY-SUBRC NE 0.
MESSAGE E000(ZZ) WITH TEXT-202.
ENDIF.
CLEAR: IT_SAPID.
ELSEIF NOT SAPID IS INITIAL AND NOT EMAILADD IS INITIAL.
CLEAR: IT_SAPID, IT_EMAIL.
READ TABLE IT_SAPID.
READ TABLE IT_EMAIL.
SELECT SINGLE SUBNO FROM SOSU
INTO GV_SUBNO
WHERE USRNO IN ( SELECT USRNO FROM SOUC
WHERE SAPNAM = IT_SAPID-SAPID ).
IF SY-SUBRC NE 0.
SUBMIT RSSOADM0 WITH USRNAM EQ IT_SAPID-SAPID
WITH NEW_SUBS EQ IT_EMAIL-EMAILADD
WITH SUB_ESC EQ 'U'
WITH EDAT EQ SY-DATUM
WITH BDAT EQ SY-DATUM
WITH BDAT EQ GV_NEXTDAY
WITH EDAT EQ '99991231'
WITH BTIM EQ SY-UZEIT
WITH ETIM EQ '240000'
WITH FORW_ALL EQ 'X'
WITH PSTHR2 EQ ''
AND RETURN.
ENDIF.
CLEAR: IT_SAPID.
ELSEIF NOT EMAILADD IS INITIAL AND SAPID IS INITIAL.
RECFLAG = 'X'.
ENDIF.
START-OF-SELECTION.
PERFORM B_SENDMAIL.
FORM B_SENDMAIL.
YEAR = SY-DATUM+0(4).
LOOP AT WS_FILE.
CLEAR: FYL.
FYL = WS_FILE-LOW.
REFRESH: TAB2.
CALL FUNCTION 'WS_UPLOAD'
EXPORTING
FILENAME = FYL
FILETYPE = 'BIN'
TABLES
DATA_TAB = TAB2.
IT_TEXTLINE[] = TAB2[].
DOCUMENT_DATA (SUBJECT OF MAIL)
V_DOCDATA-OBJ_NAME = DESC.
V_DOCDATA-OBJ_DESCR = SUBJ.
V_DOCDATA-OBJ_LANGU = SY-LANGU.
V_DOCDATA-SENSITIVTY = 'C'.
V_DOCDATA-OBJ_PRIO = '1'.
BODY OF MAIL
IT_BODY-LINE = 'Collection Report'.
APPEND IT_BODY.
CONTENTS_TXT (Attachments)
IT_CONTNT[] = IT_TEXTLINE[].
DESCRIBE TABLE IT_CONTNT LINES V_LINE.
READ TABLE IT_CONTNT INDEX V_LINE.
PACKING_LIST
V_OBJPACK-DOC_SIZE = ( V_LINE - 1 ) * 255 + STRLEN( IT_CONTNT ).
V_OBJPACK-TRANSF_BIN = 'X'.
V_OBJPACK-HEAD_START = 1.
V_OBJPACK-HEAD_NUM = 0.
V_OBJPACK-BODY_START = 1.
V_OBJPACK-BODY_NUM = V_LINE.
V_OBJPACK-DOC_TYPE = 'TXT'.
V_OBJPACK-OBJ_NAME = 'ATTACHMENT'.
V_OBJPACK-OBJ_DESCR = 'Attached Document'.
APPEND V_OBJPACK.
CLEAR V_OBJPACK.
RECEIVERS of mail
IF RECFLAG IS INITIAL.
LOOP AT IT_SAPID.
IT_RECVRS-RECEIVER = IT_SAPID-SAPID.
IT_RECVRS-REC_TYPE = 'B'.
IT_RECVRS-COM_TYPE = ''.
IT_RECVRS-EXPRESS = 'X'.
IT_RECVRS-NO_FORWARD = ''.
IT_RECVRS-NO_PRINT = ''.
APPEND IT_RECVRS.
CLEAR IT_RECVRS.
ENDLOOP.
ELSE.
LOOP AT EMAILADD.
IT_RECVRS-RECEIVER = EMAILADD-LOW.
IT_RECVRS-REC_TYPE = 'U'.
IT_RECVRS-COM_TYPE = 'INT'.
IT_RECVRS-EXPRESS = 'X'.
APPEND IT_RECVRS.
CLEAR IT_RECVRS.
ENDLOOP.
ENDIF.
OBJECT_HEADER (Filename)
CONCATENATE 'Collection Report' '_'
SY-DATUM+4(4) YEAR '.TXT'
INTO V_OBJHEAD-LINE.
V_OBJHEAD-LINE = FYL+16(25).
APPEND V_OBJHEAD.
CLEAR V_OBJHEAD.
Function Module For Sending Mail with Attachment
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
DOCUMENT_DATA = V_DOCDATA
TABLES
PACKING_LIST = V_OBJPACK
OBJECT_HEADER = V_OBJHEAD
CONTENTS_HEX = IT_CONTNT
CONTENTS_TXT = IT_BODY
RECEIVERS = IT_RECVRS
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 S000(ZZ) WITH TEXT-005.
ELSE.
MESSAGE S000(ZZ) WITH TEXT-006.
ENDIF.
ENDLOOP.
end of my code *
please help me guys... when i run this program, DOCUMENT_NOT_SENT is what i always get..
waiting for ur reply... thank you vey much and godbless.Hi,
Try this sample code.
FORM SEND_TO_EMAIL USING zFName.
DATA: OBJPACK LIKE SOPCKLSTI1 OCCURS 2 WITH HEADER LINE.
DATA: OBJHEAD LIKE SOLISTI1 OCCURS 1 WITH HEADER LINE.
DATA: OBJBIN LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.
DATA: OBJTXT LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.
DATA: RECLIST LIKE SOMLRECI1 OCCURS 5 WITH HEADER LINE.
DATA: DOC_CHNG LIKE SODOCCHGI1.
DATA: TAB_LINES LIKE SY-TABIX.
DATA: ctmp(50) TYPE C.
Creation of the document to be sent
DOC_CHNG-OBJ_NAME = 'JOURNAL'.
CONCATENATE 'SAP Payroll Journal file Period' pybegda INTO ctmp
SEPARATED BY SPACE.
DOC_CHNG-OBJ_DESCR = cTmp.
OBJTXT = 'SAP Payroll Journal'.
APPEND OBJTXT.
CONCATENATE 'For Period' pybegda INTO ctmp
SEPARATED BY SPACE.
OBJTXT = ctmp.
APPEND OBJTXT.
CONCATENATE 'Attached File :' zFname INTO ctmp
SEPARATED BY SPACE.
OBJTXT = ctmp.
APPEND OBJTXT.
OBJTXT = 'Please find the attachment.'.
APPEND OBJTXT.
DESCRIBE TABLE OBJTXT LINES TAB_LINES.
READ TABLE OBJTXT INDEX TAB_LINES.
DOC_CHNG-DOC_SIZE = ( TAB_LINES - 1 ) * 255 + STRLEN( OBJTXT ).
Creation of 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_LINES.
OBJPACK-DOC_TYPE = 'RAW'.
APPEND OBJPACK.
Creation of the document attachment
<b>LOOP AT xMail.
CONDENSE xMail-aline.
OBJBIN = xMail-aline.
APPEND OBJBIN.
CLEAR OBJBIN.
ENDLOOP.</b>
DESCRIBE TABLE OBJBIN LINES TAB_LINES.
OBJHEAD = zFname. APPEND OBJHEAD.
Creation of the entry for the compressed attachment
OBJPACK-TRANSF_BIN = 'X'.
OBJPACK-HEAD_START = 1.
OBJPACK-HEAD_NUM = 1.
OBJPACK-BODY_START = 1.
OBJPACK-BODY_NUM = TAB_LINES.
OBJPACK-DOC_TYPE = 'RAW'.
OBJPACK-OBJ_NAME = 'DATA'.
OBJPACK-OBJ_DESCR = 'SAP Payroll File'.
OBJPACK-DOC_SIZE = TAB_LINES * 255.
APPEND OBJPACK.
Completing the recipient list
LOOP AT PENERIMA.
CONDENSE PENERIMA-PNRM.
RECLIST-RECEIVER = PENERIMA-PNRM.
RECLIST-REC_TYPE = 'U'.
APPEND RECLIST.
ENDLOOP.
Sending the document
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
DOCUMENT_DATA = DOC_CHNG
PUT_IN_OUTBOX = ' '
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.
CASE SY-SUBRC.
WHEN 0.
WRITE: / 'Result of the send process:'.
LOOP AT RECLIST.
WRITE: / RECLIST-RECEIVER(48), ':'.
IF RECLIST-RETRN_CODE = 0.
WRITE / 'The document was sent'.
ELSE.
WRITE / 'The document could not be sent'.
ENDIF.
ENDLOOP.
WHEN 1.
WRITE: / 'Too many receiver'.
WHEN 2.
WRITE: / 'Document could not be sent to any recipient'.
WHEN 4.
WRITE: / 'No send authorization'.
WHEN OTHERS.
WRITE: / 'Error occurred while sending'.
ENDCASE.
ENDFORM. -
Hi,
I am triggering a mail using the function module SO_NEW_DOCUMENT_ATT_SEND_API1, where in the subject of the mail is passed using the DOC_CHNG-OBJ_DESCR, here the object_descr can only accomadate 50 characters.
But requirement is to have more than 50 characters may be 100 to 150 in the subject line.Please help me to extend.
Thanks in advance.Hi,
Searched in the forum for the above requirement but didnt find the required info..
Please help me in finding a solution to this
Thanks in advance -
Hi ALL,
I HAVE THE REQUIREMENT AS SEND A REPORT AS A MAIL. IAM USING FM 'SO_NEW_DOCUMENT_ATT_SEND_API1' WHILE EXECUTING ITS NOT SHOWING ANY ERROR. BUT IAM NOT GETTING ANY MAIL. I CHECKED IN 'SOST' TCODE. THERE I SEE A MESSAGE LIKE 'CANNOT PROCESS THE MSG TYPE IN SAP SYSTEM'. PLS TELL ME THE WHAT IS THE PROBLE.Hi
Please dont write in Capital letters, it considered as shouting. Hope you are aware of the forum rules.
You can check if you have made anything wrong in coding by referring wiki link.
[Sending Mails |http://wiki.sdn.sap.com/wiki/display/ABAP/SendingMails-HomePage]
Regards
Abhii -
Good Afternoon,
I'm using the following code to send e-Mails:
LOOP AT t_z3emailusr INTO w_z3emailusr.
t_receivers-receiver = w_z3emailusr-email.
t_receivers-rec_type = 'U'.
t_receivers-express = 'X'.
APPEND t_receivers.
ENDLOOP.
MOVE text-003 TO t_mailtxt-line.
APPEND t_mailtxt.
CLEAR t_mailtxt-line.
APPEND t_mailtxt.
MOVE text-001 TO t_mailtxt-line.
APPEND t_mailtxt.
CLEAR t_mailtxt-line.
APPEND t_mailtxt.
LOOP AT t_apqi INTO w_apqi.
MOVE w_apqi-groupid TO t_mailtxt-line.
APPEND t_mailtxt.
ENDLOOP.
MOVE text-002 TO t_mailtxt-line.
APPEND t_mailtxt.
CLEAR t_mailtxt-line.
APPEND t_mailtxt.
MOVE text-003 TO t_mailtxt-line.
APPEND t_mailtxt.
MOVE text-004 TO t_mailtxt-line.
APPEND t_mailtxt.
CLEAR t_mailtxt.
DESCRIBE TABLE t_mailtxt LINES mailtxt_size.
MOVE text-000 TO t_doc_att-obj_descr.
MOVE sy-langu TO t_doc_att-obj_langu.
MOVE 'O' TO t_doc_att-sensitivty.
t_doc_att-doc_size = mailtxt_size * 255.
CLEAR t_mailpack-transf_bin.
MOVE 1 TO t_mailpack-head_start.
CLEAR t_mailpack-head_num.
MOVE 1 TO t_mailpack-body_start.
MOVE mailtxt_size TO t_mailpack-body_num.
MOVE 'HTM' TO t_mailpack-doc_type.
MOVE sy-langu TO t_mailpack-obj_langu.
APPEND t_mailpack.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = t_doc_att
put_in_outbox = 'X'
TABLES
packing_list = t_mailpack
contents_txt = t_mailtxt
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.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
Everything is ok except for the text...
Although i'm appending lines in t_mailtxt the text of the e-mail is continuous...
How to display text with "line breaks"? Do i need to change the doc_type of t_mailpack?
Regards,
Pedro GasparYes .. change the doc_type.
Maybe you are looking for
-
Hello I am having trouble making a working installation of CUPS-PDF to be shared through SAMBA. Windows XP can't find the shared printers, the archbox can find it's own printer shares but can not use cups-pdf through SAMBA because of "Idle - Tree con
-
Dear Experts, THis is regarding form for LD00. I am from EH&S module. For getting DG data on form, there is one std form in sap which is RVDELNOTE. The respective print program is RVADDN01 I have replaced this LE_SHP_DELNOTE with RVDELNOTE then I am
-
Duplicate Contact/Address Book entries on iPhone
why do I have duplicate contact and address books entries on my iPhone? I never had this problem until I upgraded to iCloud. I have an iPhone 4 and it is upgraded to the current OS.
-
Unable to create dimensions in schemas that use synonyms
I have three schemas (s1, s2 and s3) that use synonyms to reference different tables. S1 and S2 have all tables, equally distributed in their schema. S3 is an end user who has just synonyms. I tried creating dimensions in any of them, table or view n
-
My iPod now turns off after failing to turn off.
When my iPod couldn't turn off and the battery drained, I deleted "the song" when the problem came, full-charged it via the computer and it haven't occurred again. I occurs to me: 1-Sometimes certain files get corrupted, for example word files, and g