DOCUMENT_NOT_SENT = 2
hi,
I have problem with sending the mail trough FM SO_DOCUMENT_SEND_API1in PRD server, while i am trying to send mail it is giving me exception DOCUMENT_NOT_SENT = 2, while in DEV & QAS server it is working fine.
please help me.
waiting for reply.
Hi,
Check whether configuration required for sending mails is done or not.
The tcodes SCOT and SOST should be configured .Just check with your BASIS person whether this has been done in your PRD server or not.
Regards,
Lakshman.
Similar Messages
-
Document_not_sent exception in SO_DOCUMENT_SEND_API1
Hi SAP Experts,
I would just like to ask what causes this exception. When I try to run my program I am able to send an e-mail successfully, but when my client was using the program. Exception document_not_sent was raised. Thanks in advance.Things to check...has a valid email address in user settings for the failing user? Can't say for ECC6.0, but I think that is a requirement.
In transaction SO12 (from memory, I can't see this in my current system), is the internet switch turned on (if going to internet)?
There may be an auth object, but in a prior life, I worked in an installation where only a particular batch user (background job ID) could send email from production...that was controlled via S012, which users couldn't change. -
Hello Experts,
I am using the said FM to send e-mail with Excel attachment but it always give me the error
DOCUMENT_NOT_SENT. What maybe the cause of this error? hope you could help me out here guys.
Thank you and take care!Hi
Try using this class <b>CL_BCS</b> for mailing with attachments.
Checkout this thread
Class CL_BCS Query for body part of mail
Regards,
Raj -
DOCUMENT_NOT_SENT error in Mail Triggerring
Hello All,
I got a requirement wherein i have to covert a program output to spool and from spool i should convert that into a PDF attachment and trigger a mail to Outlook...
I could do the above one [everything is going fine, right spoolid i chosen and the data is compressed and packed in right way]
But when i try to trigger that as mail using FM SO_DOCUMENT_SEND_API1..
I am getting error as DOCUMENT_NOT_SENT [My NEW_OBJECT_ID in FM SO_DOCUMENT_SEND_API1 is blank will it make FM SX_SEND_DISPATCHER to fail?? Hence results in no mail triggering] ...
To find out the problem i have even checked SCOT and SOST transaction, But no log was found....
Also i made a background schedule of my program and saw the results in SM37 [Here also i could not see any error and i could see my desired output]..
I have even enabled PUT_IN_OUTBOX as 'X' and COMMIT_WORK as 'X'.....
My coding is as follows:
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
DOCUMENT_DATA = LA_DOC "W_DOC_DATA
PUT_IN_OUTBOX = 'X'
COMMIT_WORK = 'X'
IMPORTING
NEW_OBJECT_ID = OBJID
TABLES
PACKING_LIST = IT_PACKING_LIST
OBJECT_HEADER = HEADLIST
CONTENTS_BIN = IT_ATTACHMENT
CONTENTS_TXT = IT_MAILBODY[]
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.
Waiting for your replies.....Hi Jayanthi,
I want to send email to internet address and not to SAP user. Like for example can I send the attachment to my yahoo id??
If I change to
i_reclist-receiver = give sap user id
i_reclist-express = 'X'.
i_reclist-rec_type = 'B'.
this will surely work but it comes to my SAP Office Inbox but I need to send it to any address on the internet. Is it possible?
Please do reply.
Thanks in advance,
Rashmi -
Smartform Mail -DOCUMENT_NOT_SENT Exception
Hi ,
We are using the FM - SO_NEW_DOCUMENT_ATT_SEND_API1 to send a smartform mail with PDF attachement, we are able to acheive this in the Developement system, where as in Quality system this FM is raising exception DOCUMENT_NOT_SENT (sy-subrc = 2).
The same code exists in both the systems, I read in SDN that the SU01 settings should be checked, I checked it and made it similar to the developement system.
Can anyone let me what may be the root cause of the issue ?
Thanks in advance.Hi Jay,
Thanks for your quick reply.
commit_work = 'X' is in the code in both the systems.
Logged off and logged in again for SU01 settings to be effective.
But still the same exception. -
Hi Experts,
plz help me on this issue . i am using the function module SO_NEW_DOCUMENT_SEND_API1 which is throwing the exception DOC_NOT_SENT...Please suggest what it is about..
when i am giving i/p's in different server it is reflecting in SCOT, when i am giving i/p's for my client server
it's not reflecting in SCOT.....
is it configuration problems? if it is plz suggest me which configurations are missing ...because we are not getting which config is missed..
ThanksHi
Please check this thread as it deals with the same issue
DOCUMENT_NOT_SENT means Document not sent to any recipients
its unable to send emails i think you need to add the email in SCOT for the server
Not able to send mail using FM SO_NEW_DOCUMENT_SEND_API1 -
To add number of senders mail addresses
in the following code how there is one sender address how do i make it to 3 senders i mean add the number of senders
REPORT ZSPOOL5 NO STANDARD PAGE HEADING.
PARAMETER: P_EMAIL1 LIKE SOMLRECI1-RECEIVER,
P_SENDER LIKE SOMLRECI1-RECEIVER,
P_DELSPL AS CHECKBOX.
*ranges:
*DATA DECLARATION
DATA: GD_RECSIZE TYPE I.
Spool IDs
TYPES: BEGIN OF T_TBTCP.
INCLUDE STRUCTURE TBTCP.
TYPES: END OF T_TBTCP.
DATA: IT_TBTCP TYPE STANDARD TABLE OF T_TBTCP INITIAL SIZE 0,
WA_TBTCP TYPE T_TBTCP.
Job Runtime Parameters
DATA: GD_EVENTID LIKE TBTCM-EVENTID,
GD_EVENTPARM LIKE TBTCM-EVENTPARM,
GD_EXTERNAL_PROGRAM_ACTIVE LIKE TBTCM-XPGACTIVE,
GD_JOBCOUNT LIKE TBTCM-JOBCOUNT,
GD_JOBNAME LIKE TBTCM-JOBNAME,
GD_STEPCOUNT LIKE TBTCM-STEPCOUNT,
GD_ERROR TYPE SY-SUBRC,
GD_RECIEVER TYPE SY-SUBRC.
DATA: W_RECSIZE TYPE I.
DATA: GD_SUBJECT LIKE SODOCCHGI1-OBJ_DESCR,
IT_MESS_BOD LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
IT_MESS_ATT LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
GD_SENDER_TYPE LIKE SOEXTRECI1-ADR_TYP,
GD_ATTACHMENT_DESC TYPE SO_OBJ_NAM,
GD_ATTACHMENT_NAME TYPE SO_OBJ_DES.
Spool to PDF conversions
DATA: GD_SPOOL_NR LIKE TSP01-RQIDENT,
GD_DESTINATION LIKE RLGRAP-FILENAME,
GD_BYTECOUNT LIKE TST01-DSIZE,
GD_BUFFER TYPE STRING.
Binary store for PDF
DATA: BEGIN OF IT_PDF_OUTPUT OCCURS 0.
INCLUDE STRUCTURE TLINE.
DATA: END OF IT_PDF_OUTPUT.
CONSTANTS:C_DEV LIKE SY-SYSID VALUE 'DEV',
C_NO(1) TYPE C VALUE ' ',
C_DEVICE(4) TYPE C VALUE 'LOCL'.
*START-OF-SELECTION.
START-OF-SELECTION.
Write statement to represent report output. Spool request is created
if write statement is executed in background. This could also be an
ALV grid which would be converted to PDF without any extra effort
WRITE 'Hello World'.
NEW-PAGE.
COMMIT WORK.
NEW-PAGE PRINT OFF.
IF SY-BATCH EQ 'X'.
PERFORM GET_JOB_DETAILS.
PERFORM OBTAIN_SPOOL_ID.
Alternative way could be to submit another program and store spool
id into memory.
*submit ZSPOOLTOPDF2
to sap-spool
spool parameters %_print
archive parameters %_print
without spool dynpro
and return.
Get spool id from program called above
IMPORT w_spool_nr FROM MEMORY ID 'SPOOLTOPDF'.
PERFORM CONVERT_SPOOL_TO_PDF.
PERFORM PROCESS_EMAIL.
IF P_DELSPL EQ 'X'.
PERFORM DELETE_SPOOL.
ENDIF.
IF SY-SYSID = C_DEV.
WAIT UP TO 5 SECONDS.
SUBMIT RSCONN01 WITH MODE = 'INT'
WITH OUTPUT = 'X'
AND RETURN.
ENDIF.
ELSE.
SKIP.
WRITE:/ 'Program must be executed in background in-order for spool',
'request to be created.'.
ENDIF.
FORM obtain_spool_id *
FORM OBTAIN_SPOOL_ID.
CHECK NOT ( GD_JOBNAME IS INITIAL ).
CHECK NOT ( GD_JOBCOUNT IS INITIAL ).
SELECT * FROM TBTCP
INTO TABLE IT_TBTCP
WHERE JOBNAME = GD_JOBNAME
AND JOBCOUNT = GD_JOBCOUNT
AND STEPCOUNT = GD_STEPCOUNT
AND LISTIDENT <> '0000000000'
ORDER BY JOBNAME
JOBCOUNT
STEPCOUNT.
READ TABLE IT_TBTCP INTO WA_TBTCP INDEX 1.
IF SY-SUBRC = 0.
MESSAGE S004(ZDD) WITH GD_SPOOL_NR.
GD_SPOOL_NR = WA_TBTCP-LISTIDENT.
MESSAGE S004(ZDD) WITH GD_SPOOL_NR.
ELSE.
MESSAGE S005(ZDD).
ENDIF.
ENDFORM. "obtain_spool_id
FORM get_job_details *
FORM GET_JOB_DETAILS.
Get current job details
CALL FUNCTION 'GET_JOB_RUNTIME_INFO'
IMPORTING
EVENTID = GD_EVENTID
EVENTPARM = GD_EVENTPARM
EXTERNAL_PROGRAM_ACTIVE = GD_EXTERNAL_PROGRAM_ACTIVE
JOBCOUNT = GD_JOBCOUNT
JOBNAME = GD_JOBNAME
STEPCOUNT = GD_STEPCOUNT
EXCEPTIONS
NO_RUNTIME_INFO = 1
OTHERS = 2.
ENDFORM. "get_job_details
FORM convert_spool_to_pdf *
FORM CONVERT_SPOOL_TO_PDF.
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
SRC_SPOOLID = GD_SPOOL_NR
NO_DIALOG = C_NO
DST_DEVICE = C_DEVICE
IMPORTING
PDF_BYTECOUNT = GD_BYTECOUNT
TABLES
PDF = IT_PDF_OUTPUT
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.
CHECK SY-SUBRC = 0.
Transfer the 132-long strings to 255-long strings
LOOP AT IT_PDF_OUTPUT.
TRANSLATE IT_PDF_OUTPUT USING ' ~'.
CONCATENATE GD_BUFFER IT_PDF_OUTPUT INTO GD_BUFFER.
ENDLOOP.
TRANSLATE GD_BUFFER USING '~ '.
DO.
IT_MESS_ATT = GD_BUFFER.
APPEND IT_MESS_ATT.
SHIFT GD_BUFFER LEFT BY 255 PLACES.
IF GD_BUFFER IS INITIAL.
EXIT.
ENDIF.
ENDDO.
ENDFORM. "convert_spool_to_pdf
FORM process_email *
FORM PROCESS_EMAIL.
DESCRIBE TABLE IT_MESS_ATT LINES GD_RECSIZE.
CHECK GD_RECSIZE > 0.
PERFORM SEND_EMAIL USING P_EMAIL1.
perform send_email using p_email2.
ENDFORM. "process_email
FORM send_email *
--> p_email *
FORM SEND_EMAIL USING P_EMAIL.
CHECK NOT ( P_EMAIL IS INITIAL ).
REFRESH IT_MESS_BOD.
Default subject matter
GD_SUBJECT = 'Subject'.
GD_ATTACHMENT_DESC = 'Attachname'.
CONCATENATE 'attach_name' ' ' INTO gd_attachment_name.
IT_MESS_BOD = 'Message Body text, line 1'.
APPEND IT_MESS_BOD.
IT_MESS_BOD = 'Message Body text, line 2...'.
APPEND IT_MESS_BOD.
If no sender specified - default blank
IF P_SENDER EQ SPACE.
GD_SENDER_TYPE = SPACE.
ELSE.
GD_SENDER_TYPE = 'INT'.
ENDIF.
Send file by email as .xls speadsheet
PERFORM SEND_FILE_AS_EMAIL_ATTACHMENT
TABLES IT_MESS_BOD
IT_MESS_ATT
USING P_EMAIL
'Example .xls documnet attachment'
'PDF'
GD_ATTACHMENT_NAME
GD_ATTACHMENT_DESC
P_SENDER
GD_SENDER_TYPE
CHANGING GD_ERROR
GD_RECIEVER.
ENDFORM. "send_email
FORM delete_spool *
FORM DELETE_SPOOL.
DATA: LD_SPOOL_NR TYPE TSP01_SP0R-RQID_CHAR.
LD_SPOOL_NR = GD_SPOOL_NR.
CHECK P_DELSPL <> C_NO.
CALL FUNCTION 'RSPO_R_RDELETE_SPOOLREQ'
EXPORTING
SPOOLID = LD_SPOOL_NR.
ENDFORM. "delete_spool
*& Form SEND_FILE_AS_EMAIL_ATTACHMENT
Send email
FORM SEND_FILE_AS_EMAIL_ATTACHMENT TABLES IT_MESSAGE
IT_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.
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.
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[] = IT_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.
T_RECEIVERS-RECEIVER = LD_EMAIL.
T_RECEIVERS-REC_TYPE = 'U'.
T_RECEIVERS-COM_TYPE = 'INT'.
T_RECEIVERS-NOTIF_DEL = 'X'.
T_RECEIVERS-NOTIF_NDEL = 'X'.
APPEND T_RECEIVERS.
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_attachmenthi ,
just loop at LD_SENDER_ADDRESS which is there in fm
'SO_DOCUMENT_SEND_API1' -
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. -
Error while sendinf pdf file as attachment
hi all.,
am trying to send the pdf file of a smartform as attachment thru mail .. but its getting failed am getting error (sy-subrc = 6 ) after calling the fm so_new_document_att_send_api1 .. pls. suggest the possible cause of errors.
CALL FUNCTION 'CONVERT_OTF_2_PDF'
IMPORTING
bin_filesize = lv_bin_filesize
TABLES
otf = ls_job_output_info-otfdata
doctab_archive = it_docs
lines = it_lines
EXCEPTIONS
err_conv_not_possible = 1
err_otf_mc_noendmarker = 2
OTHERS = 3.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
*--- Get filename to store DYNAMIC
IF p_lsdir IS NOT INITIAL.
MOVE p_lsdir TO lv_path.
ENDIF.
CONDENSE wa_kna1-kunnr.
CONCATENATE 'SOA' wa_kna1-kunnr '.pdf' INTO lv_name.
CONCATENATE lv_path lv_name INTO lv_fullpath.
break ibm_prasad.
CLEAR wa_buffer.
LOOP AT it_lines.
TRANSLATE it_lines USING '~'.
CONCATENATE wa_buffer it_lines INTO wa_buffer.
ENDLOOP.
TRANSLATE wa_buffer USING '~'.
DO.
i_record = wa_buffer.
APPEND i_record.
SHIFT wa_buffer LEFT BY 255 PLACES.
IF wa_buffer IS INITIAL.
EXIT.
ENDIF.
ENDDO.
REFRESH: i_reclist,
i_objtxt,
i_objbin,
i_objpack.
CLEAR wa_objhead.
i_objbin[] = i_record[].
i_objtxt = 'SOA test with pdf-Attachment!'.
APPEND i_objtxt.
DESCRIBE TABLE i_objtxt LINES v_lines_txt.
READ TABLE i_objtxt INDEX v_lines_txt.
wa_doc_chng-obj_name = 'SOA'.
wa_doc_chng-expiry_dat = sy-datum + 10.
wa_doc_chng-obj_descr = 'SOA'.
wa_doc_chng-sensitivty = 'F'.
wa_doc_chng-doc_size = v_lines_txt * 255.
* Maint Text
CLEAR i_objpack-transf_bin.
i_objpack-head_start = 1.
i_objpack-head_num = 0.
i_objpack-body_start = 1.
i_objpack-body_num = v_lines_txt.
i_objpack-doc_type = 'RAW'.
APPEND i_objpack.
* Attachment (pdf-Attachment)
i_objpack-transf_bin = 'X'.
i_objpack-head_start = 1.
i_objpack-head_num = 0.
i_objpack-body_start = 1.
DESCRIBE TABLE i_objbin LINES v_lines_bin.
READ TABLE i_objbin INDEX v_lines_bin.
i_objpack-doc_size = v_lines_bin * 255 .
i_objpack-body_num = v_lines_bin.
i_objpack-doc_type = 'PDF'.
i_objpack-obj_name = 'SOA Eail'.
i_objpack-obj_descr = 'test'.
APPEND i_objpack.
CLEAR i_reclist.
i_reclist-receiver = <mail id>
i_reclist-rec_type = 'U'.
APPEND i_reclist.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = wa_doc_chng
put_in_outbox = 'X'
commit_work = 'X'
TABLES
packing_list = i_objpack
object_header = wa_objhead
contents_bin = i_objbin
contents_txt = i_objtxt
receivers = i_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.
thanks
sureshu need to use this SO_NEW_DOCUMENT_ATT_SEND_API1
check this code tutorial on how to add pdf file as an attachment
u need to modify the code to read the pdf from directory then rest of code is same
https://www.sdn.sap.com/irj/scn/wiki?path=/display/snippets/mailsendthroughoutputcontrols
кu03B1ятu03B9к
Edited by: kartik tarla on Mar 9, 2009 7:31 PM -
Sending mail with multiple attachment
hi.
i want to send mail with multiple attachment.
i m succeed in sending multiple attachment but the second pdf is not open.
its given error like "This file is damaged and could not be open.
pls check my code. and
give the solution....
point should be assured...........
hope all u r understand my problem..
& tell me where is i m missing something.
REPORT YSDPASALE1_MAIL LINE-SIZE 110.
data : year_month(6) type c.
data : from_date like sy-datum,to_date like sy-datum.
INITIALIZATION.
year_month = sy-datum+0(6).
CONCATENATE year_month '01' into from_date.
to_date = sy-datum.
ranges : temp for mkpf-budat.
temp-low = from_date.
temp-high = to_date.
append temp to temp.
DATA: P_JOBCNT LIKE TBTCJOB-JOBCOUNT,
jobname like TBTCJOB-JOBNAME,
L_RELEASE(1) TYPE c.
CONSTANTS : l_c_device(4) VALUE 'LOCL'.
DATA : t type i value 0.
DATA : p_email1 like somlreci1-receiver,
p_sender LIKE somlreci1-receiver.
Data Declaration
DATA: gd_recsize TYPE i,gd_recsize1 TYPE i.
Spool IDs
TYPES: BEGIN OF t_tbtcp.
INCLUDE STRUCTURE tbtcp.
TYPES: END OF t_tbtcp.
DATA: it_tbtcp TYPE STANDARD TABLE OF t_tbtcp INITIAL SIZE 0,
wa_tbtcp TYPE t_tbtcp.
Job Runtime Parameters
DATA: gd_eventid LIKE tbtcm-eventid,
gd_eventparm LIKE tbtcm-eventparm,
gd_external_program_active LIKE tbtcm-xpgactive,
gd_jobcount LIKE tbtcm-jobcount,
gd_jobname LIKE tbtcm-jobname,
gd_stepcount LIKE tbtcm-stepcount,
gd_error TYPE sy-subrc,
gd_reciever TYPE sy-subrc.
DATA: w_recsize TYPE i.
DATA: gd_subject LIKE sodocchgi1-obj_descr,
it_mess_bod LIKE solisti1 OCCURS 0 WITH HEADER LINE,
it_mess_att LIKE solisti1 OCCURS 0 WITH HEADER LINE,
it_mess_att1 LIKE solisti1 OCCURS 0 WITH HEADER LINE,
it_mess_att2 LIKE solisti1 OCCURS 0 WITH HEADER LINE,
gd_sender_type LIKE soextreci1-adr_typ,
gd_attachment_desc TYPE so_obj_nam,
gd_attachment_desc1 TYPE so_obj_nam,
gd_attachment_name TYPE so_obj_des,
gd_mtitle LIKE sodocchgi1-obj_descr.
Spool to PDF conversions
DATA: gd_spool_nr LIKE tsp01-rqident,
gd_destination LIKE rlgrap-filename,
gd_bytecount LIKE tst01-dsize,
gd_buffer TYPE string.
CONSTANTS: c_dev LIKE sy-sysid VALUE 'DEV',
c_no(1) TYPE c VALUE ' ',
c_device(4) TYPE c VALUE 'LOCL'.
Binary store for PDF
DATA: BEGIN OF it_pdf_output OCCURS 0.
INCLUDE STRUCTURE tline.
DATA: END OF it_pdf_output.
DATA: BEGIN OF mailstr OCCURS 0,
p_email like somlreci1-receiver,
END OF mailstr.
DATA: mailtab like STANDARD TABLE OF mailstr WITH HEADER LINE.
DATA: ypp18tab like STANDARD TABLE OF mailstr WITH HEADER LINE,
ymis008tab like STANDARD TABLE OF mailstr WITH HEADER LINE,
ysd15tab like STANDARD TABLE OF mailstr WITH HEADER LINE,
ymis10tab like STANDARD TABLE OF mailstr WITH HEADER LINE.
SUBMIT YSDPASALE1 with bdt in temp
to sap-spool
with line-size = '255'
with KEEP_IN_SPOOL = 'X'
with IMMEDIATELY = ' '
WITHOUT SPOOL DYNPRO
AND RETURN
NEW-PAGE PRINT ON
DESTINATION l_c_device
IMMEDIATELY ' '
KEEP IN SPOOL 'X'
NEW LIST IDENTIFICATION 'X'
NO DIALOG.
new-page print off.
IF sy-batch EQ 'X'.
PERFORM get_job_details.
PERFORM obtain_spool_id.
PERFORM convert_spool_to_pdf.
select yemail as p_email into CORRESPONDING FIELDS OF TABLE ymis008tab
from ymail
where ytcode = 'YMIS008'.
ELSE.
SKIP.
WRITE:/ 'Program must be executed in background in-order for spool & mail sending',
'request to be created.'.
ENDIF.
wait up to 3 seconds.
submit YSD_MONTHLY_SALES
USING SELECTION-SET 'MAIL'
to sap-spool
with KEEP_IN_SPOOL = 'X'
with IMMEDIATELY = ' ' "SPACE
WITHOUT SPOOL DYNPRO
AND RETURN
NEW-PAGE PRINT ON
DESTINATION l_c_device
IMMEDIATELY ' '
KEEP IN SPOOL 'X'
NEW LIST IDENTIFICATION 'X'
NO DIALOG.
new-page print off.
IF sy-batch EQ 'X'.
gd_attachment_desc1 = 'YMIS10'.
gd_mtitle = 'Monthly Sales Report'.
PERFORM get_job_details.
PERFORM obtain_spool_id.
PERFORM convert_spool_to_pdf1.
loop at it_mess_att.
move it_mess_att1 to it_mess_att.
APPEND it_mess_att.
endloop.
APPEND LINES OF it_mess_att1 to it_mess_att.
free it_mess_att1.
it_mess_att[] = it_mess_att1[].
insert LINES OF it_mess_att1 into it_mess_att.
APPEND LINES OF it_mess_att2 to it_mess_att .
insert LINES OF it_mess_att1 into it_mess_att.
insert LINES OF it_mess_att2 into it_mess_att.
loop at ymis008tab into mailstr.
p_email1 = mailstr-p_email.
p_email1 = '[email protected]'.
PERFORM process_email.
endloop.
clear mailstr.
wait up to 5 seconds.
SUBMIT rsconn01 WITH mode = 'INT'
WITH output = 'X'
AND RETURN.
ELSE.
SKIP.
ENDIF.
FORM obtain_spool_id *
FORM obtain_spool_id.
CHECK NOT ( gd_jobname IS INITIAL ).
CHECK NOT ( gd_jobcount IS INITIAL ).
SELECT * FROM tbtcp
INTO TABLE it_tbtcp
WHERE jobname = gd_jobname
AND jobcount = gd_jobcount
AND stepcount = gd_stepcount
AND listident <> '0000000000'
ORDER BY jobname
jobcount
stepcount.
READ TABLE it_tbtcp INTO wa_tbtcp INDEX 1.
IF sy-subrc = 0.
message s004(zdd) with gd_spool_nr.
gd_spool_nr = wa_tbtcp-listident.
MESSAGE s004(zdd) WITH gd_spool_nr.
ELSE.
MESSAGE s005(zdd).
ENDIF.
ENDFORM.
FORM get_job_details *
FORM get_job_details.
Get current job details
CALL FUNCTION 'GET_JOB_RUNTIME_INFO'
IMPORTING
eventid = gd_eventid
eventparm = gd_eventparm
external_program_active = gd_external_program_active
jobcount = gd_jobcount
jobname = gd_jobname
stepcount = gd_stepcount
EXCEPTIONS
no_runtime_info = 1
OTHERS = 2.
ENDFORM.
FORM convert_spool_to_pdf *
FORM convert_spool_to_pdf.
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = gd_spool_nr
no_dialog = c_no
dst_device = c_device
IMPORTING
pdf_bytecount = gd_bytecount
TABLES
pdf = it_pdf_output
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.
CHECK sy-subrc = 0.
Transfer the 132-long strings to 255-long strings
LOOP AT it_pdf_output.
TRANSLATE it_pdf_output USING ' ~'.
CONCATENATE gd_buffer it_pdf_output INTO gd_buffer.
ENDLOOP.
TRANSLATE gd_buffer USING '~ '.
DO.
it_mess_att = gd_buffer.
APPEND it_mess_att.
SHIFT gd_buffer LEFT BY 255 PLACES.
IF gd_buffer IS INITIAL.
EXIT.
ENDIF.
ENDDO.
ENDFORM.
FORM convert_spool_to_pdf1.
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = gd_spool_nr
no_dialog = c_no
dst_device = c_device
IMPORTING
pdf_bytecount = gd_bytecount
TABLES
pdf = it_pdf_output
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.
CHECK sy-subrc = 0.
Transfer the 132-long strings to 255-long strings
LOOP AT it_pdf_output.
TRANSLATE it_pdf_output USING ' ~'.
CONCATENATE gd_buffer it_pdf_output INTO gd_buffer.
ENDLOOP.
TRANSLATE gd_buffer USING '~ '.
DO.
it_mess_att1 = gd_buffer.
APPEND it_mess_att1.
SHIFT gd_buffer LEFT BY 255 PLACES.
IF gd_buffer IS INITIAL.
EXIT.
ENDIF.
ENDDO.
ENDFORM.
FORM process_email *
FORM process_email.
DESCRIBE TABLE it_mess_att LINES gd_recsize.
DESCRIBE TABLE it_mess_att1 LINES gd_recsize1.
CHECK gd_recsize > 0 or gd_recsize1 > 0.
PERFORM send_email." USING p_email1.
perform send_email using p_email2.
ENDFORM.
FORM send_email *
--> p_email *
FORM send_email." USING p_email.
CHECK NOT ( p_email IS INITIAL ).
REFRESH it_mess_bod.
Default subject matter
gd_subject = 'Subject'.
gd_attachment_desc = gd_attachment_desc1 .
gd_attachment_desc = 'YPP18 - Daily Highlights'.
CONCATENATE 'attach_name' ' ' INTO gd_attachment_name.
it_mess_bod = 'Dear Sir,'.
APPEND it_mess_bod.
it_mess_bod = ' '.
APPEND it_mess_bod.
it_mess_bod = ' '.
APPEND it_mess_bod.
it_mess_bod = 'kindly find the attached document'.
APPEND it_mess_bod.
it_mess_bod = ' '.
APPEND it_mess_bod.
it_mess_bod = 'Do not reply on this mail, It is generated from SAP'.
APPEND it_mess_bod.
it_mess_bod = ' '.
APPEND it_mess_bod.
it_mess_bod = ' '.
APPEND it_mess_bod.
it_mess_bod = 'Regards,'.
APPEND it_mess_bod.
it_mess_bod = 'Arpit Shah'.
APPEND it_mess_bod.
If no sender specified - default blank
IF p_sender EQ space.
gd_sender_type = space.
ELSE.
gd_sender_type = 'INT'.
ENDIF.
Send file by email as .xls speadsheet
PERFORM send_file_as_email_attachment
tables it_mess_bod
it_mess_att
it_mess_att1
using "p_email
gd_mtitle
'Testing mail generated from SAP'
'Daily Highlights Abstract Report - YPP18'
'PDF'
gd_attachment_name
gd_attachment_desc
p_sender
gd_sender_type
changing gd_error
gd_reciever.
ENDFORM.
*& Form SEND_FILE_AS_EMAIL_ATTACHMENT
Send email
FORM send_file_as_email_attachment tables it_message
it_attach
it_attach1
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.
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,w_doc_data1 like sodocchgi1.
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_data1-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[] = it_attach[].
For 2nd Attachments
* Fill the document data and get size of attachment
CLEAR w_doc_data.
READ TABLE it_attach1 INDEX w_cnt.
w_doc_data-doc_size = w_doc_data1-doc_size +
( w_cnt - 1 ) * 255 + STRLEN( it_attach1 ).
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.
APPEND LINES OF it_attach1 to t_attachment.
t_attachment[] = it_attach1[].
APPEND LINES OF it_attach1 to t_attachment.
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 = 0.
t_packing_list-body_start = 1.
DESCRIBE TABLE t_attachment LINES t_packing_list-body_num.
DESCRIBE TABLE it_mess_att LINES t_packing_list-body_num.
DESCRIBE TABLE it_attach LINES t_packing_list-body_num.
t_packing_list-doc_type = ld_format.
t_packing_list-obj_descr = 'YMIS008'."ld_attdescription.
t_packing_list-obj_name = 'YMIS008'."ld_attfilename.
t_packing_list-doc_size = t_packing_list-body_num * 255.
APPEND t_packing_list.
clear t_packing_list.
for 2 attachments
data : a type i,b type i.
a = t_packing_list-body_num.
t_packing_list-transf_bin = 'X'.
t_packing_list-head_start = 1.
t_packing_list-head_num = 0.
t_packing_list-body_start = a + 1. "1
DESCRIBE TABLE it_mess_att1 LINES t_packing_list-body_num.
DESCRIBE TABLE it_attach1 LINES t_packing_list-body_num.
t_packing_list-doc_type = ld_format.
t_packing_list-obj_descr = 'YMIS10'."ld_attdescription.
t_packing_list-obj_name = 'YMIS10'."ld_attfilename.
t_packing_list-doc_size = t_packing_list-body_num * 255.
APPEND t_packing_list.
a = t_packing_list-body_num.
clear 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 = a + 1.
t_packing_list-body_num = t_packing_list-body_num + 1.
DESCRIBE TABLE it_mess_att1 LINES t_packing_list-body_num.
t_packing_list-body_num = a + t_packing_list-body_num .
t_packing_list-doc_type = ld_format.
t_packing_list-obj_descr = 'YMIS10'."ld_attdescription.
t_packing_list-obj_name = 'YMIS10'."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 ymis008tab into mailstr.
t_receivers-receiver = mailstr-p_email. "ld_email.
t_receivers-receiver = p_email1.
t_receivers-rec_type = 'U'.
t_receivers-com_type = 'INT'.
t_receivers-notif_del = 'X'. "X "Read Acknoledgement
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.
Rgds.
ArpitHi Arpit,
Take a look at the documentation of FM 'SO_DOCUMENT_SEND_API1' for parameter PACKING_LIST. I think you should set t_packing_list-head_num to a different value than 0 for the second attachment.
Regards,
John. -
When sending email PO in a PDF attachment, the attachment can not be openen
Hi all,
We are trying to send an email with the PO in PDF format. We got the email but the attachment can not be opened.
Error reads: Adobe could not open test.pdf because it is either not a supported file type or because the file has been damaged (for example , it was send as a email attachemnet and was not correctly decoded).
Could any body bring some light? We know that everything in SCOT is fine because we can email the PO through configuration to the vendor without problem. It is just these extra copies that do not work.
a) We are modifying our custom Print program to add the code below after closing the form.
in few words:
a) We are getting the OTF from closing the form.
b) Converting the OTF to PDF
c) Sending the PDF as attachment.
data: lt_docs TYPE TABLE OF docs.
data: pdf_bytecount TYPE i.
data: begin of pdfout occurs 0,
tline type tline,
end of pdfout.
Ende Formulardruck --------------------------------------------------*
CALL FUNCTION 'CLOSE_FORM'
IMPORTING
result = result
tables
otfdata = otf.
IF RESULT-TDSPOOLID NE SPACE.
SPOOLID = RESULT-TDSPOOLID.
PERFORM PROTOCOL_UPDATE USING '320' SPOOLID SPACE SPACE SPACE.
ENDIF.
if result-userexit eq 'C' or
result-userexit eq 'E'.
retco = '9'.
endif.
CALL FUNCTION 'CONVERT_OTF_2_PDF'
IMPORTING
bin_filesize = pdf_bytecount
TABLES
otf = otf
doctab_archive = lt_docs
lines = pdfout
EXCEPTIONS
err_conv_not_possible = 1
err_otf_mc_noendmarker = 2
OTHERS = 3.
Creation of the document to be sent File Name
maildata-obj_name = 'TEST'.
Mail Subject
maildata-obj_descr = 'Subject'.
Mail Contents
append mailtxt.
describe table mailtxt lines tab_lines.
read table mailtxt index tab_lines.
maildata-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( mailtxt ).
Creation of the entry for the compressed document
clear mailpack-transf_bin.
mailpack-head_start = 1.
mailpack-head_num = 0.
mailpack-body_start = 1.
mailpack-body_num = tab_lines.
mailpack-doc_type = 'RAW'.
append mailpack.
Move OTF code to structure SOLI form email
CLEAR solisti1. REFRESH solisti1.
LOOP AT otf.
solisti1-line = otf.
APPEND solisti1.
ENDLOOP.
Move pdf code to structure soli form email
clear solisti1. refresh solisti1.
loop at pdfout.
solisti1-line = pdfout.
append solisti1.
endloop.
loop at solisti1.
move-corresponding solisti1 to mailbin.
append mailbin.
endloop.
describe table mailbin lines tab_lines.
mailhead = 'TEST.OTF'.
mailhead = 'TEST.PDF'.
append mailhead.
Creation of the entry for the compressed attachment
mailpack-transf_bin = 'X'.
mailpack-head_start = 1.
mailpack-head_num = 1.
mailpack-body_start = 1.
mailpack-body_num = tab_lines.
mailpack-doc_type = 'OTF'.
mailpack-doc_type = 'PDF'.
mailpack-obj_name = 'TEST'.
mailpack-obj_descr = 'Subject'.
mailpack-doc_size = tab_lines * 255.
append mailpack.
mailrec-receiver = '[email protected]'.
mailrec-rec_type = 'U'.
append mailrec.
mailrec-receiver = '[email protected]'.
mailrec-rec_type = 'U'.
append mailrec.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
DOCUMENT_DATA = maildata
TABLES
PACKING_LIST = mailpack
OBJECT_HEADER = mailhead
CONTENTS_TXT = mailtxt
RECEIVERS = mailrec
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.
ENDFORM.Dear Monica,
You need to configure the system with respect to functional point of view and need to write the following code in print program. i have done this and solution is as follows.
<b> Reward me for this solution.</b>
Process 11 (MM) Sending RFQs and POs to vendors directly from the system instead of sending thru Courier or Fax
Existing Process (AS-IS) Presently system is not supporting this requirement
Business Requirements RFQs to be linked with vendor master with e-mail to send enquiries directly through system instead of courier/fax. Vice versa P.Os. Specifications, drawings should also go to vendor along with mail.
To-Be
Configuration Settings:
1) Spro Materials management Purchasing Messages Output control Message types Define message types for RFQ/ PO
Created ZEK1,ZMI and ZEK2 for RFQs
Created ZIK,ZOC,ZOK,ZOM,ZSI, ZSK2 and ZSM for Pos
The above New output types Included with existing Print Forms and Programs but modified with External send(5) medium, and added companys letter head thru ABAP developments (details provided below)
The above new output types also maintained for Fine- tuned control (thru same navigation) for New(1) and Change(2) operations
2) Spro Materials management Purchasing Messages Output control Message determination schemas Define message schema for RFQ/ PO
Maintained the new output types in the control data
3) Maintain Condition records for the New out put types (copied same document types from the existing old output types)
Easy access Logistics Materials management Purchasing Master data Messages MN01 (for RFQs)/ MN04 (for Pos)
4) Maintain Email id of Vendor in Vendor master.
Developments (ABAP):
1) Copied the existing print programs and forms of the corresponding out types.
2) Addition of header window in each corresponding form (HEADER window). Uploaded the HEADER3 graphics in the header window.
INCLUDE HEADER3 OBJECT GRAPHICS ID BCOL LANGUAGE EN
3) Added the the following code in TOP includes
TYPE-POOLs szadr.
INCLUDE: LMEDRUCKF09.
data: intnast LIKE snast,
lvs_recipient LIKE swotobjid, "Internet
lvs_sender LIKE swotobjid, "Internet
lvs_comm_type TYPE ad_comm,
lvs_comm_values TYPE szadr_comm_values,
p_retco TYPE i.
5) Addition of the perform to SOS include for header window display
PERFORM WRITE_FORM_HEADER.
*& Form WRITE_FORM_HEADER
text
--> p1 text
<-- p2 text
FORM WRITE_FORM_HEADER.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'HE1'
FUNCTION = 'SET'
TYPE = 'BODY'
WINDOW = 'HEADER'
IMPORTING
PENDING_LINES =
EXCEPTIONS
ELEMENT = 1
FUNCTION = 2
TYPE = 3
UNOPENED = 4
UNSTARTED = 5
WINDOW = 6
BAD_PAGEFORMAT_FOR_PRINT = 7
SPOOL_ERROR = 8
CODEPAGE = 9
OTHERS = 10
ENDFORM.
6) In the corresponding FORM include the following code has been added.
DATA: lvs_comm_type TYPE ad_comm,
lvs_comm_values TYPE szadr_comm_values,
xprogramm type sy-repid.
... use stratagy to get communication type
CALL FUNCTION 'ADDR_GET_NEXT_COMM_TYPE'
EXPORTING
strategy = nast-tcode
address_number = lfa1-adrnr
IMPORTING
comm_type = lvs_comm_type
comm_values = lvs_comm_values
EXCEPTIONS
address_not_exist = 1
person_not_exist = 2
no_comm_type_found = 3
internal_error = 4
parameter_error = 5
OTHERS = 6.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
convert communication data
MOVE-CORRESPONDING nast TO intnast.
MOVE sy-repid TO xprogramm.
7) By using the function module we can get sender and reciepient mail ids to variables lvs_recipient lvs_sender
CALL FUNCTION 'CONVERT_COMM_TYPE_DATA'
EXPORTING
pi_comm_type = lvs_comm_type
pi_comm_values = lvs_comm_values
pi_country = lfa1-land1
pi_repid = xprogramm
pi_snast = intnast
IMPORTING
pe_itcpo = itcpo
pe_device = xdevice
pe_mail_recipient = lvs_recipient
pe_mail_sender = lvs_sender
EXCEPTIONS
comm_type_not_supported = 1
recipient_creation_failed = 2
sender_creation_failed = 3
OTHERS = 4.
IF sy-subrc <> 0.
Avoids cancellation with message TD421
p_retco = '1'. "831984
PERFORM protocol_update USING '740' space space space space.
dummy message to make the message appear in the where-used list
IF 1 = 2.
MESSAGE S740(me).
ENDIF.
EXIT.
ENDIF.
IF xdevice = 'MAIL'. "885787
Check validity of email address to avoid cancellation with TD463
CALL FUNCTION 'SX_ADDRESS_TO_DEVTYPE' "831984
EXPORTING
recipient_id = lvs_recipient
sender_id = lvs_sender
EXCEPTIONS
err_invalid_route = 1
err_system = 2
OTHERS = 3.
IF SY-SUBRC <> 0.
p_retco = '1'.
PERFORM protocol_update USING '740' space space space space.
dummy message to make the message appear in the where-used list
IF 1 = 2.
MESSAGE S740(me).
ENDIF.
EXIT.
ENDIF.
ENDIF.
8) Attaching the new print program and form in NACE transaction.
Steps for End user:
1) Creating the Purchase Order or RFQ with suitable document type through ME21N or ME41 .
2) Executing the transaction ME9F and in selecting the suitable output type.
3) Executing the transaction ZSEND_PDOC using INT as input.
4) With above steps we can able to send purchase order or RFQ to vendor as an attachment through e-mail in PDF format.
Regards
Badari -
How to place a Logo, Picture ..etc in the main body of an email.
My requirement is to send an email having a logo as the header. The logo must be placed in the main body of the email and NOT as an attachment.
I have tried out the following but it gives garbage:
REPORT ztest_pratik01.
INTERNAL TABLES
DATA:
i_objpack TYPE STANDARD TABLE OF sopcklsti1,
i_objtext TYPE STANDARD TABLE OF solisti1,
i_objbin TYPE STANDARD TABLE OF solisti1,
i_hex TYPE STANDARD TABLE OF solix,
i_receivers TYPE STANDARD TABLE OF somlreci1.
WORK AREAS
DATA: wa_email_doc TYPE sodocchgi1,
wa_objpack TYPE sopcklsti1,
wa_objtext TYPE solisti1,
wa_hex TYPE solix,
wa_receivers TYPE somlreci1.
CONSTANTS
CONSTANTS: c_x TYPE flag VALUE 'X',
c_u TYPE char1 VALUE 'U'.
DATA: v_body TYPE i.
START-OF-SELECTION
START-OF-SELECTION.
PERFORM sub_get_logo.
END-OF-SELECTION
END-OF-SELECTION.
wa_email_doc-obj_name = 'TEST Mail'.
"Mail Subject
wa_email_doc-obj_descr
= 'TEST'.
v_body = LINES( i_hex ).
Creating the entry for the compressed document
*--(1): Creating entry for the Main Mail body text in itab i_objtext
wa_objpack-transf_bin = 'X'.
" Starting index(row) For header information in the itab i_objpack
wa_objpack-head_start = 1.
" No of lines for the header information in itab i_objpack
wa_objpack-head_num = 1.
" The row(index) of the itab i_objtext from where the Mail Body starts
wa_objpack-body_start = 1. "Skipped the first Line
" The number of lines in the Mail body
wa_objpack-body_num = v_body. "We have two lines from the 2nd row
" Document type. There are also whole lot of other options
wa_objpack-doc_type = 'RAW'.
wa_objpack-obj_name = 'LOGO.BMP'.
wa_objpack-obj_descr = 'MAIL BODY'.
wa_objpack-obj_langu = ' '.
" In this case one can skip this. Normally ist calculated as
" no of linex * 255
wa_objpack-doc_size = v_body * 255.
APPEND wa_objpack TO i_objpack.
CLEAR wa_objpack.
*Building the recepient list
Receipient information
wa_receivers-receiver = sy-uname.
wa_receivers-rec_type = 'B'. "To SAP Inbox
APPEND wa_receivers TO i_receivers.
CLEAR wa_receivers.
wa_receivers-receiver = mail id.
wa_receivers-rec_type = c_u.
APPEND wa_receivers TO i_receivers.
CLEAR wa_receivers.
Finally Send the Document
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = wa_email_doc
put_in_outbox = 'X'
commit_work = 'X'
TABLES
packing_list = i_objpack
contents_bin = i_objbin
contents_txt = i_objtext
contents_hex = i_hex
receivers = i_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.
*& Form SUB_GET_LOGO
text
--> p1 text
<-- p2 text
FORM sub_get_logo .
DATA: graphic_url(255),
graphic_refresh(1).
DATA: graphic_size TYPE i.
DATA: l_graphic_xstr TYPE xstring,
l_graphic_conv TYPE i,
l_graphic_offs TYPE i.
DATA: BEGIN OF graphic_table OCCURS 0,
line(255) TYPE x,
END OF graphic_table.
CLEAR: graphic_url,
graphic_table[].
CALL METHOD cl_ssf_xsf_utilities=>get_bds_graphic_as_bmp
EXPORTING
p_object = 'GRAPHICS'
p_name = 'Z_LOGO'
p_id = 'BMAP'
p_btype = 'BMON'
RECEIVING
p_bmp = l_graphic_xstr
EXCEPTIONS
not_found = 1
OTHERS = 2.
if sy-subrc = 1.
message e287 with g_stxbitmaps-tdname.
elseif sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
exit.
endif.
graphic_size = XSTRLEN( l_graphic_xstr ).
CHECK graphic_size > 0.
l_graphic_conv = graphic_size.
l_graphic_offs = 0.
WHILE l_graphic_conv > 255.
graphic_table-line = l_graphic_xstr+l_graphic_offs(255).
APPEND graphic_table.
l_graphic_offs = l_graphic_offs + 255.
l_graphic_conv = l_graphic_conv - 255.
ENDWHILE.
graphic_table-line = l_graphic_xstr+l_graphic_offs(l_graphic_conv).
APPEND graphic_table.
LOOP AT graphic_table.
wa_hex = graphic_table.
APPEND wa_hex TO i_hex.
ENDLOOP.
ENDFORM. " SUB_GET_LOGO
Any Ideas how to do the same???Hi ,
I advice you to raise a OSS Note so that SAP Can suggest what needs to be done in this case .
Hope my suggestion is helpful.
Thanks & Regards
Pradeep Akula . -
Convert an already created pdf to otf
i made an report that takes some pdf from sapscript and takes the otf's and send them as email attachement.
Now i want to incude one more pdf to the same email that is already created and i store it to my fileserver . How can i do this ?
REPORT YDP_SEND_ALL_DOCS_EMAIL.
DATA: ITCPO LIKE ITCPO,
TAB_LINES LIKE SY-TABIX.
Variables for EMAIL functionality
DATA: MAILDATA LIKE SODOCCHGI1.
DATA: MAILPACK LIKE SOPCKLSTI1 OCCURS 2 WITH HEADER LINE.
DATA: MAILHEAD LIKE SOLISTI1 OCCURS 1 WITH HEADER LINE.
DATA: MAILBIN LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.
DATA: MAILTXT LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.
DATA: MAILREC LIKE SOMLREC90 OCCURS 0 WITH HEADER LINE.
DATA: SOLISTI1 LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE.
TABLES: LIPS,
LIKP,
LFA1,
KNA1,
ADR6,
VBKD,
VBPA,
VBAK,
VBRK,
VBRP,
MARA,
T005T,
VBFA.
DATA : BEGIN OF ITAB OCCURS 0,
VBELN LIKE VBRK-VBELN, "billing doc
NAME1 LIKE KNA1-NAME1, "Customer name
SMTP_ADDR LIKE ADR6-SMTP_ADDR,
END OF ITAB.
DATA: MY_OPTIONS TYPE ITCPO.
SELECTION-SCREEN BEGIN OF BLOCK B0 WITH FRAME TITLE TEXT-001.
PARAMETERS: SVBELN TYPE VBRK-VBELN.
PARAMETERS: SNAME TYPE KNA1-NAME1.
PARAMETERS: S_EMAIL TYPE ADR6-SMTP_ADDR.
SELECTION-SCREEN SKIP 2.
PARAMETERS: SUBJ(30) TYPE C.
SELECTION-SCREEN SKIP 2.
PARAMETERS: LINE1 LIKE MAILTXT-LINE.
PARAMETERS: LINE2 LIKE MAILTXT-LINE.
PARAMETERS: LINE3 LIKE MAILTXT-LINE.
PARAMETERS: LINE4 LIKE MAILTXT-LINE.
PARAMETERS: LINE5 LIKE MAILTXT-LINE.
PARAMETERS: LINE6 LIKE MAILTXT-LINE DEFAULT 'The following PDF are produced by SAP and are digitally signed .'.
SELECTION-SCREEN END OF BLOCK B0.
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-002.
PARAMETERS: YHSD AS CHECKBOX DEFAULT 'X'.
PARAMETERS: ZHAG AS CHECKBOX DEFAULT 'X'.
PARAMETERS: ZPHL AS CHECKBOX DEFAULT 'X'.
SELECTION-SCREEN END OF BLOCK B1.
AT SELECTION-SCREEN OUTPUT.
LOOP AT SCREEN.
IF SCREEN-NAME = 'S_EMAIL'.
SCREEN-INPUT = 0.
SCREEN-INTENSIFIED = 0.
MODIFY SCREEN.
EXIT.
ENDIF.
ENDLOOP.
LOOP AT SCREEN.
IF SCREEN-NAME = 'SNAME'.
SCREEN-INPUT = 0.
SCREEN-INTENSIFIED = 0.
MODIFY SCREEN.
EXIT.
ENDIF.
ENDLOOP.
AT SELECTION-SCREEN.
SELECT SINGLE * FROM VBRK WHERE VBELN = SVBELN.
IF SY-SUBRC = 0.
SELECT SINGLE * FROM KNA1 WHERE KUNNR = VBRK-KUNRG.
SNAME = KNA1-NAME1.
SELECT SINGLE * FROM ADR6 WHERE ADDRNUMBER = KNA1-ADRNR.
IF SY-SUBRC = 0 .
S_EMAIL = ADR6-SMTP_ADDR.
ELSE.
S_EMAIL = 'No Email Address !!!!'.
ENDIF.
ELSE.
S_EMAIL = 'No Email Address !!!!'.
ENDIF.
START-OF-SELECTION.
PERFORM SEND_FORM_VIA_EMAIL.
*& Form WRITE_FORM
text
-->P_WIN text
-->P_TYPE text
-->P_EL text
-->P_FUN text
FORM WRITE_FORM USING P_WIN P_TYPE P_EL P_FUN.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = P_EL
FUNCTION = P_FUN
TYPE = P_TYPE
WINDOW = P_WIN
IMPORTING
PENDING_LINES =
EXCEPTIONS
ELEMENT = 1
FUNCTION = 2
TYPE = 3
UNOPENED = 4
UNSTARTED = 5
WINDOW = 6
BAD_PAGEFORMAT_FOR_PRINT = 7
SPOOL_ERROR = 8
CODEPAGE = 9
OTHERS = 10.
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. "WRITE_FORM
*& Form CLOSE_FORM
text
FORM CLOSE_FORM.
CALL FUNCTION 'CLOSE_FORM'
IMPORTING
RESULT = ITCPP
RDI_RESULT =
TABLES
OTFDATA = OTF
EXCEPTIONS
UNOPENED = 1
BAD_PAGEFORMAT_FOR_PRINT = 2
SEND_ERROR = 3
OTHERS = 4.
ENDFORM. " CLOSE_LAYOUT_DSS
*& Form GET_DATA
text
FORM GET_DATA.
DATA: BEGIN OF OTF OCCURS 0.
INCLUDE STRUCTURE ITCOO .
DATA: END OF OTF.
DATA: ITCPO LIKE ITCPO.
DATA: ITCPP LIKE ITCPP.
CLEAR ITCPO.
ITCPO-TDGETOTF = 'X'.
PERFORM COLLECT_DATA(YHAL_SHIPPING_DETAILS) USING SVBELN."VBRK-VBELN.
CALL FUNCTION 'OPEN_FORM'
EXPORTING
FORM = 'YHAL_SHIP_DETAIL'
LANGUAGE = SY-LANGU
OPTIONS = ITCPO
DIALOG = ' '
EXCEPTIONS
OTHERS = 1.
PERFORM DISPLAY_DATA(YHAL_SHIPPING_DETAILS) USING SVBELN." VBRK-VBELN.
Close up Form and get OTF code
CALL FUNCTION 'END_FORM'
EXCEPTIONS
ERROR_MESSAGE = 01
OTHERS = 02.
MOVE-CORRESPONDING ITCPO TO ITCPP.
CALL FUNCTION 'CLOSE_FORM'
IMPORTING
RESULT = ITCPP
TABLES
OTFDATA = OTF
EXCEPTIONS
OTHERS = 1.
Move OTF code to structure SOLI form email
CLEAR SOLISTI1. REFRESH SOLISTI1.
LOOP AT OTF.
SOLISTI1-LINE = OTF.
APPEND SOLISTI1.
ENDLOOP.
ENDFORM. "GET_DATA
*& Form GET_DATA1
text
FORM GET_DATA1.
DATA: BEGIN OF OTF OCCURS 0.
INCLUDE STRUCTURE ITCOO .
DATA: END OF OTF.
DATA: ITCPO LIKE ITCPO.
DATA: ITCPP LIKE ITCPP.
CLEAR OTF.
CLEAR ITCPO.
ITCPO-TDGETOTF = 'X'.
PERFORM COLLECT_DATA(Z111_PACKING_LIST) USING SVBELN."VBRK-VBELN.
CALL FUNCTION 'OPEN_FORM'
EXPORTING
FORM = 'Z1111_PACKING'
LANGUAGE = SY-LANGU
OPTIONS = ITCPO
DIALOG = ' '
EXCEPTIONS
OTHERS = 1.
PERFORM DISPLAY_DATA(Z111_PACKING_LIST). "USING SVBELN." VBRK-VBELN.
Close up Form and get OTF code
CALL FUNCTION 'END_FORM'
EXCEPTIONS
ERROR_MESSAGE = 01
OTHERS = 02.
MOVE-CORRESPONDING ITCPO TO ITCPP.
CALL FUNCTION 'CLOSE_FORM'
IMPORTING
RESULT = ITCPP
TABLES
OTFDATA = OTF
EXCEPTIONS
OTHERS = 1.
Move OTF code to structure SOLI form email
CLEAR SOLISTI1. REFRESH SOLISTI1.
LOOP AT OTF.
SOLISTI1-LINE = OTF.
APPEND SOLISTI1.
ENDLOOP.
ENDFORM. "GET_DATA1
*& Form GET_DATA2
text
FORM GET_DATA2.
DATA: BEGIN OF OTF OCCURS 0.
INCLUDE STRUCTURE ITCOO .
DATA: END OF OTF.
DATA: ITCPO LIKE ITCPO.
DATA: ITCPP LIKE ITCPP.
CLEAR OTF.
CLEAR ITCPO.
ITCPO-TDGETOTF = 'X'.
PERFORM COLLECT_DATA(Z111_AGENCY_NOTE) USING SVBELN."VBRK-VBELN.
CALL FUNCTION 'OPEN_FORM'
EXPORTING
FORM = 'Z1111_AGENCY'
LANGUAGE = SY-LANGU
OPTIONS = ITCPO
DIALOG = ' '
EXCEPTIONS
OTHERS = 1.
PERFORM DISPLAY_DATA(Z111_AGENCY_NOTE) USING SVBELN." VBRK-VBELN.
Close up Form and get OTF code
CALL FUNCTION 'END_FORM'
EXCEPTIONS
ERROR_MESSAGE = 01
OTHERS = 02.
MOVE-CORRESPONDING ITCPO TO ITCPP.
CALL FUNCTION 'CLOSE_FORM'
IMPORTING
RESULT = ITCPP
TABLES
OTFDATA = OTF
EXCEPTIONS
OTHERS = 1.
Move OTF code to structure SOLI form email
CLEAR SOLISTI1. REFRESH SOLISTI1.
LOOP AT OTF.
SOLISTI1-LINE = OTF.
APPEND SOLISTI1.
ENDLOOP.
ENDFORM. "GET_DATA2
FORM SEND_FORM_VIA_EMAIL *
FORM SEND_FORM_VIA_EMAIL.
CLEAR: MAILDATA, MAILTXT, MAILBIN, MAILPACK, MAILHEAD, MAILREC.
REFRESH: MAILTXT, MAILBIN, MAILPACK, MAILHEAD, MAILREC.
Creation of the document to be sent File Name
MAILDATA-OBJ_NAME = 'TEST'.
Mail Subject
MAILDATA-OBJ_DESCR = SUBJ ."'EGGRAFA BIBLOY'.
Mail Contents
MAILTXT-LINE = LINE1.
APPEND MAILTXT.
MAILTXT-LINE = LINE2.
APPEND MAILTXT.
MAILTXT-LINE = LINE3.
APPEND MAILTXT.
MAILTXT-LINE = LINE4.
APPEND MAILTXT.
MAILTXT-LINE = LINE5.
APPEND MAILTXT.
MAILTXT-LINE = LINE6.
APPEND MAILTXT.
Prepare Packing List
PERFORM PREPARE_PACKING_LIST.
Set recipient - email address here!!!
MAILREC-RECEIVER = '[email protected]'.
MAILREC-REC_TYPE = 'U'.
APPEND MAILREC.
Sending the document
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
DOCUMENT_DATA = MAILDATA
PUT_IN_OUTBOX = ' '
TABLES
PACKING_LIST = MAILPACK
OBJECT_HEADER = MAILHEAD
CONTENTS_BIN = MAILBIN
CONTENTS_TXT = MAILTXT
RECEIVERS = MAILREC
EXCEPTIONS
TOO_MANY_RECEIVERS = 1
DOCUMENT_NOT_SENT = 2
OPERATION_NO_AUTHORIZATION = 4
OTHERS = 99.
COMMIT WORK.
ENDFORM. "SEND_FORM_VIA_EMAIL
Form PREPARE_PACKING_LIST
FORM PREPARE_PACKING_LIST.
CLEAR: MAILPACK, MAILBIN, MAILHEAD.
REFRESH: MAILPACK, MAILBIN, MAILHEAD.
DESCRIBE TABLE MAILTXT LINES TAB_LINES.
READ TABLE MAILTXT INDEX TAB_LINES.
MAILDATA-DOC_SIZE = ( TAB_LINES - 1 ) * 255 + STRLEN( MAILTXT ).
Creation of the entry for the compressed document
CLEAR MAILPACK-TRANSF_BIN.
MAILPACK-HEAD_START = 1.
MAILPACK-HEAD_NUM = 0.
MAILPACK-BODY_START = 1.
MAILPACK-BODY_NUM = TAB_LINES.
MAILPACK-DOC_TYPE = 'RAW'.
APPEND MAILPACK.
Creation of the document attachment
This form gets the OTF code from the SAPscript form.
If you already have your OTF code, I believe that you may
be able to skip this form. just do the following code, looping thru
your SOLISTI1 and updating MAILBIN.
IF YHSD = 'X' .
PERFORM GET_OTF_CODE. "----
LOOP AT SOLISTI1.
MOVE-CORRESPONDING SOLISTI1 TO MAILBIN.
APPEND MAILBIN.
ENDLOOP.
DESCRIBE TABLE MAILBIN LINES TAB_LINES.
MAILHEAD = 'TEST.OTF'.
APPEND MAILHEAD.
ENDIF.
Creation of the entry for the compressed attachment
MAILPACK-TRANSF_BIN = 'X'.
MAILPACK-HEAD_START = 1.
MAILPACK-HEAD_NUM = 1.
MAILPACK-BODY_START = 1.
MAILPACK-BODY_NUM = TAB_LINES.
MAILPACK-DOC_TYPE = 'OTF'.
MAILPACK-OBJ_NAME = 'TEST01'.
MAILPACK-OBJ_DESCR = 'Subject01'.
MAILPACK-DOC_SIZE = TAB_LINES * 255.
APPEND MAILPACK.
IF ZHAG = 'X'.
PERFORM GET_OTF_CODE1. "----
LOOP AT SOLISTI1.
MOVE-CORRESPONDING SOLISTI1 TO MAILBIN.
APPEND MAILBIN.
ENDLOOP.
DESCRIBE TABLE MAILBIN LINES TAB_LINES.
MAILHEAD = 'TEST1.OTF'.
APPEND MAILHEAD.
ENDIF.
Creation of the entry for the compressed attachment
MAILPACK-TRANSF_BIN = 'X'.
MAILPACK-HEAD_START = 1.
MAILPACK-HEAD_NUM = 1.
MAILPACK-BODY_START = 1.
MAILPACK-BODY_NUM = TAB_LINES.
MAILPACK-DOC_TYPE = 'OTF'.
MAILPACK-OBJ_NAME = 'TEST02'.
MAILPACK-OBJ_DESCR = 'Subject02'.
MAILPACK-DOC_SIZE = TAB_LINES * 255.
APPEND MAILPACK.
IF ZPHL = 'X'.
PERFORM GET_OTF_CODE2. "----
LOOP AT SOLISTI1.
MOVE-CORRESPONDING SOLISTI1 TO MAILBIN.
APPEND MAILBIN.
ENDLOOP.
DESCRIBE TABLE MAILBIN LINES TAB_LINES.
MAILHEAD = 'TEST2.OTF'.
APPEND MAILHEAD.
ENDIF.
Creation of the entry for the compressed attachment
MAILPACK-TRANSF_BIN = 'X'.
MAILPACK-HEAD_START = 1.
MAILPACK-HEAD_NUM = 1.
MAILPACK-BODY_START = 1.
MAILPACK-BODY_NUM = TAB_LINES.
MAILPACK-DOC_TYPE = 'OTF'.
MAILPACK-OBJ_NAME = 'TEST03'.
MAILPACK-OBJ_DESCR = 'Ship.details-Agency.report-Packing.list'.
MAILPACK-DOC_SIZE = TAB_LINES * 255.
APPEND MAILPACK.
ENDFORM. "PREPARE_PACKING_LIST
Form GET_OTF_CODE
FORM GET_OTF_CODE.
PERFORM GET_DATA.
ENDFORM. "GET_OTF_CODE
Form GET_OTF_CODE1
FORM GET_OTF_CODE1.
PERFORM GET_DATA1.
ENDFORM. "GET_OTF_CODE1
Form GET_OTF_CODE2
FORM GET_OTF_CODE2.
PERFORM GET_DATA2.
ENDFORM. "GET_OTF_CODE2
END-OF-SELECTION.Hi Dimath,
Try the following FM:
CONVERT_OTF Convert SAP documents (SAPScript) to other types.
Example:
CALL FUNCTION "CONVERT_OTF"
EXPORTING FORMAT = "PDF"
IMPORTING BIN_FILESIZE = FILE_LEN
TABLES OTF = OTFDATA
LINES = PDFDATA
EXCEPTIONS ERR_MAX_LINEWIDTH = 1
ERR_FORMAT = 2
ERR_CONV_NOT_POSSIBLE = 3
OTHERS = 4.
Hope this helps.
Reward if helpful.
Regards,
Sipra -
Send email from PA30 user exit
When I try to send an email from user exit in ZXPADU02 it never makes it to SOST. WIll always go to SBWP outbox if I set the flag but never gets sent to receiver address.
If I paste the following code into a report it works fine. Is there some other parameter for this FM or some additional process needed to send email from a user exit?
DATA: maildata TYPE sodocchgi1.
DATA: mailtxt TYPE TABLE OF solisti1 WITH HEADER LINE.
DATA: mailrec TYPE TABLE OF somlrec90 WITH HEADER LINE.
CLEAR maildata.
REFRESH: mailtxt, mailrec.
maildata-obj_name = 'SRVC_EMAIL'.
maildata-obj_descr = 'Email test'.
maildata-obj_langu = sy-langu.
mailtxt-line = 'Test line from user exit'.
APPEND mailtxt.
mailrec-receiver = '[email protected]'.
mailrec-rec_type = 'U'.
APPEND mailrec.
CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'
EXPORTING
document_data = maildata
document_type = 'RAW'
put_in_outbox = 'X'
commit_work = 'X'
TABLES
object_header = mailtxt
object_content = mailtxt
receivers = mailrec
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.Put the function call 'SO_NEW_DOCUMENT_SEND_API1'
in a report Program & SUBMIT that report from ZXPADU02.
Arya -
SO_DOCUMENT_SEND_API1 and Business Workplace
Hello gurus,
I'm using the FM SO_DOCUMENT_SEND_API1 to send emails (massively) with a pdf file as attachment. Unfortunately, I can't see the email in the outbox of my business workplace . Nevertheless all the recipients get the emails without problems. The sy-subrc after calling the FM is 0. Everything seems to go fine except for the missing entries in my outbox .
Any help will be appreciated.
Thank you,
Jaime
P.D. This is the way how I'm calling the FM:
call function 'SO_DOCUMENT_SEND_API1'
exporting
document_data = wa_doc_data
put_in_outbox = 'X'
sender_address = in_sender_address
sender_address_type = in_sender_addres_type
commit_work = 'X'
importing
sent_to_all = w_sent_all
tables
packing_list = it_packing_list
contents_bin = it_attachment_int
contents_txt = it_message_body_int
receivers = it_email_receivers_int
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.
* Todo bien!
when 1.
raise too_many_receivers.
when 2.
raise document_not_sent.
when 3.
raise document_type_not_exist.
when 4.
raise operation_no_authorization.
when 5.
raise parameter_error.
when 6.
raise x_error.
when 7.
raise enqueue_error.
when others.
raise unknown_error.
endcase.Hello.
please find the code below it will be more help ful to you
DATA :
IT_PACKING_LIST TYPE TABLE OF SOPCKLSTI1,
IT_CONTENTS_TXT TYPE TABLE OF SOLISTI1,
IT_RECEIVERS TYPE TABLE OF SOMLRECI1,
WA_DOCUMENT TYPE SODOCCHGI1,
WA_PACKING_LIST TYPE SOPCKLSTI1,
WA_RECEIVERS TYPE SOMLRECI1,
WA_CONTENTS_TXT TYPE SOLISTI1,
IT_OTF TYPE table of ITCOO,
T_html_raw type table of ITCOO,
T_SENDER TYPE SO_REC_EXT,
T_ADSMTP_LINE TYPE SZADR_ADSMTP_LINE,
T_SENDER_TYP TYPE SOEXTRECI1-ADR_TYP,
T_pdf_xstring type xstring,
Tt_lines type table of tline,
wa_lines type tline,
T_pdf_len type i,
it_docs TYPE STANDARD TABLE OF docs,
L_SMTP_ADDR type AD_SMTPADR,
MID(20) type c,
wa_buffer TYPE string.
*Importing the MAil Address from the Memory id
*Pass the OTF data to the Internal Table
IT_OTF = job_output_info-OTFDATA.
If not IT_OTF is INITIAL.
*Convert the OTF data to ASCII
Call function 'CONVERT_OTF'
exporting
format = 'ASCII'
importing
bin_filesize = T_pdf_len
bin_file = T_pdf_xstring " binary file
tables
otf = IT_OTF
lines = tt_lines
exceptions
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 3
err_bad_otf = 4
others = 5.
if sy-subrc = 0.
*PAss the ASCII data to the Body Of the Mail
loop at tt_lines into wa_lines.
wa_CONTENTS_TXT = wa_lines-tdline.
append wa_contents_txt to it_contents_txt.
clear wa_contents_txt.
endloop.
*Mail headder information **
WA_DOCUMENT-OBJ_NAME = 'SMARTFORM'.
WA_DOCUMENT-OBJ_LANGU = SY-LANGU.
WA_DOCUMENT-OBJ_DESCR = 'Interest Calculation' .
WA_DOCUMENT-SENSITIVTY = 'F'.
If email exist.
WA_RECEIVERS-RECEIVER = ur email addrees
WA_RECEIVERS-REC_TYPE = 'U'.
WA_RECEIVERS-COM_TYPE = 'INT'.
WA_RECEIVERS-NOTIF_DEL = 'X'.
WA_RECEIVERS-NOTIF_NDEL = 'X'.
APPEND WA_RECEIVERS TO IT_RECEIVERS.
T_SENDER = SY-UNAME.
T_SENDER_TYP = 'INT'.
*Passing the data to the Context Table
Document Attachement information **
CLEAR WA_PACKING_LIST-TRANSF_BIN.
WA_PACKING_LIST-TRANSF_BIN = SPACE.
WA_PACKING_LIST-HEAD_START = 1.
WA_PACKING_LIST-HEAD_NUM = 0.
WA_PACKING_LIST-BODY_START = 1.
WA_PACKING_LIST-obj_name = 'Interest Calculation Letter'.
DESCRIBE TABLE IT_CONTENTS_TXT LINES WA_PACKING_LIST-BODY_NUM.
WA_PACKING_LIST-DOC_size = WA_PACKING_LIST-BODY_NUM * 255.
WA_PACKING_LIST-BODY_NUM = WA_PACKING_LIST-BODY_NUM.
WA_PACKING_LIST-DOC_TYPE = 'RAW'.
APPEND WA_PACKING_LIST TO IT_PACKING_LIST.
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
DOCUMENT_DATA = WA_DOCUMENT
PUT_IN_OUTBOX = 'X'.
SENDER_ADDRESS = T_SENDER
SENDER_ADDRESS_TYPE = 'B'
COMMIT_WORK = 'X'
TABLES
PACKING_LIST = IT_PACKING_LIST
CONTENTS_TXT = IT_CONTENTS_TXT
RECEIVERS = IT_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.
Thanks,
Maybe you are looking for
-
Trouble managing multiple libraries
If I option+launch iTunes, I can choose from whatever libraries I've created, or choose "New" to create a new one. If I quit iTunes, then relaunch (without option key), iTunes opens the last library I had open. Okay so far, BUT: If I'm in iTunes, and
-
Error while posting document in FB01
Hello All, While creating a document I encounter th below error: Please specify LBZ code Kindly help me what the meaning of this. Thanks in advance, Jhero
-
Download data into a local file from PCUI
Hi, i need to export items from 'quotation' into a local file (on presentation server) with CRM4.0 and using the fileupload field type. I used the MF 'GUI_DOWNLOAD' but i had an exception error 'CONTROL_FLUSH_ERROR'. Effectively it was expected since
-
I had old home movies that were filmed on 8mm and were then converted to DVD. I am now trying to edit them on iMovie, but cannot import the files. When I try to import, it says "filtering unusable files" and nothing appears in my clips. The files are
-
Purchase order in Disposal Processing (WAE01)
Hi experts, I have a problem: When i create a disposal processing (WAE01) y do the flow, but when i push the botton "purchase order" a screen appears, where i have to put: Document type Item Category Acct. assignment cat. This values are always the s