Error In emailing smartforms
I am trying to email my smartform output to a specified email address, but I am getting an error messege as mail could not me send as in the function module 'SO_NEW_DOCUMENT_SEND_API1'
Below is the code. The smartform contains a logo only.
Pls see the code and tell me what isn that I am missing!
*& Report ZKHA_SMARTFORM
REPORT zkha_smartform.
TYPE-POOLS: slis,
abap.
DATA : BEGIN OF it_mara OCCURS 0,
matnr LIKE mara-matnr,
END OF it_mara.
DATA: wa_ctrlop TYPE ssfctrlop, "Smart Forms: Control structure
wa_outopt TYPE ssfcompop, " SAP Smart Forms: Smart Composer (transfer)
t_otfdata TYPE ssfcrescl, "Smart Forms: Return value at end of form Printing
t_pdf_tab LIKE tline OCCURS 0 WITH HEADER LINE, "#EC *
t_otf TYPE itcoo OCCURS 100 WITH HEADER LINE,"#EC * "itcoo is OTF Struct
w_filesize TYPE i, "#EC *
w_bin_filesize TYPE i, "#EC NEEDED
fm_name TYPE rs38l_fnam.
DATA : fullpath TYPE string, "#EC *
filename TYPE string, "#EC *
path TYPE string, "#EC *
user_action TYPE i, "#EC *
encoding TYPE abap_encoding. "#EC *
PARAMETERS: p_file TYPE rlgrap-filename NO-DISPLAY.
DATA: numbytes TYPE i,
cancel.
*wa_outopt-tddest = ' '.
wa_ctrlop-getotf = 'X'.
wa_ctrlop-no_dialog = 'X'.
*wa_outopt-tdnoprev = 'X'.
*wa_outopt-tdnoprint = 'X'. " CHANGED HERE
*wa_ctrlop-device = 'MAIL'.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = 'Z_KHATEST1'
VARIANT = ' '
DIRECT_CALL = ' '
IMPORTING
fm_name = fm_name
EXCEPTIONS
NO_FORM = 1
NO_FUNCTION_MODULE = 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.
CALL FUNCTION fm_name
EXPORTING
ARCHIVE_INDEX =
ARCHIVE_INDEX_TAB =
ARCHIVE_PARAMETERS =
control_parameters = wa_ctrlop " CHANGED HERE
MAIL_APPL_OBJ =
MAIL_RECIPIENT =
MAIL_SENDER =
output_options = wa_outopt " CHANGED HERE
user_settings = 'X'
IMPORTING
DOCUMENT_OUTPUT_INFO =
job_output_info = t_otfdata
JOB_OUTPUT_OPTIONS =
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
OTHERS = 5
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
*CASE sy-ucomm.
WHEN 'PRNT'. " ADDED HERE
t_otf[] = t_otfdata-otfdata[].
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF'
max_linewidth = 132
ARCHIVE_INDEX = ' '
COPYNUMBER = 0
ASCII_BIDI_VIS2LOG = ' '
PDF_DELETE_OTFTAB = ' '
IMPORTING
bin_filesize = w_bin_filesize
BIN_FILE =
TABLES
otf = t_otf
lines = t_pdf_tab
EXCEPTIONS
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 3
err_bad_otf = 4
OTHERS = 5
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Data: t_objbin type standard table of SOLISTI1 with header line.
Converted to length of 255 Char
CALL FUNCTION 'SX_TABLE_LINE_WIDTH_CHANGE'
EXPORTING
LINE_WIDTH_SRC =
LINE_WIDTH_DST = '255'
TRANSFER_BIN = ' '
TABLES
content_in = t_pdf_tab
content_out = t_objbin
EXCEPTIONS
ERR_LINE_WIDTH_SRC_TOO_LONG = 1
ERR_LINE_WIDTH_DST_TOO_LONG = 2
ERR_CONV_FAILED = 3
OTHERS = 4
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
PERFORM download_w_ext(rstxpdft) TABLES t_pdf_tab
USING p_file
'.pdf'
'BIN'
numbytes
cancel. "#EC *
CLEAR: wa_outopt, wa_ctrlop.
*ENDCASE.
DATA:
t_tline TYPE TABLE OF tline,
t_reclist TYPE TABLE OF somlreci1,
wa_doc_chng TYPE sodocchgi1,
wa_reclist TYPE somlreci1,
wa_return TYPE ssfcrescl,
v_descr TYPE so_obj_des,
v_mailid TYPE ad_smtpadr,
v_adrnr TYPE ad_addrnum ,
v_len_in TYPE string.
wa_doc_chng-obj_name = 'SMARTFORM'.
wa_doc_chng-expiry_dat = sy-datum + 10.
wa_doc_chng-obj_descr = v_descr.
wa_doc_chng-sensitivty = 'F'.
wa_doc_chng-obj_langu = sy-langu.
wa_doc_chng-no_change = 'X' .
Selecting email address depending on
address no.from ADR6 Table
SELECT smtp_addr "E-Mail Address
FROM adr6 UP TO 1 ROWS
INTO v_mailid
WHERE addrnumber = v_adrnr.
ENDSELECT .
wa_reclist-receiver = v_mailid.
wa_reclist-receiver = '[email protected]'.
" I have hard coded the mail address. It is automatically populating the adr6 table, I donno why???
Pls give immediate resolution!!!!
wa_reclist-rec_type = 'U'.
APPEND wa_reclist TO t_reclist.
break-point.
CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'
EXPORTING
document_data = wa_doc_chng
DOCUMENT_TYPE = 'PDF'
PUT_IN_OUTBOX = 'X'
COMMIT_WORK = 'X'
IMPORTING
SENT_TO_ALL =
NEW_OBJECT_ID =
tables
OBJECT_HEADER =
OBJECT_CONTENT = t_objbin
CONTENTS_HEX =
OBJECT_PARA =
OBJECT_PARB =
receivers = t_reclist
EXCEPTIONS
TOO_MANY_RECEIVERS = 1
DOCUMENT_NOT_SENT = 2
DOCUMENT_TYPE_NOT_EXIST = 3
OPERATION_NO_AUTHORIZATION = 4
PARAMETER_ERROR = 5
X_ERROR = 6
ENQUEUE_ERROR = 7
OTHERS = 8
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Use the following steps for doing the same. These steps are tested succesfully.
1. Get the Function Module Name for the Smart form
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = c_fmname
VARIANT = ' '
DIRECT_CALL = ' '
IMPORTING
FM_NAME = w_fmname
EXCEPTIONS
NO_FORM = 1
NO_FUNCTION_MODULE = 2
OTHERS = 3
2. Set the values to be passed in the Function Module to get the output of the Smart form in OTF format.
Set the call for OTF format.
t_control_parameters-no_dialog = c_x.
t_control_parameters-getotf = c_x.
3. Call the function Module for the smartform.
CALL FUNCTION w_fmname
EXPORTING
ARCHIVE_INDEX = H_ARCHIVE_INDEX
ARCHIVE_INDEX_TAB =
ARCHIVE_PARAMETERS = H_ARCHIVE_PARAMS
CONTROL_PARAMETERS = t_control_parameters
MAIL_APPL_OBJ =
MAIL_RECIPIENT =
MAIL_SENDER =
OUTPUT_OPTIONS =
USER_SETTINGS = 'X'
Variable = v_flag
IMPORTING
DOCUMENT_OUTPUT_INFO =
JOB_OUTPUT_INFO = w_job_output_info
JOB_OUTPUT_OPTIONS =
TABLES
I_table = t_itab
EXCEPTIONS
FORMATTING_ERROR = 1
INTERNAL_ERROR = 2
SEND_ERROR = 3
USER_CANCELED = 4
OTHERS = 5
4. Convert the OTF format to PDF format using the w_job_output_info-otfdata
DATA: l_filesize TYPE i,
t_lines LIKE tline OCCURS 0,
t_objbin TYPE ty_tab_objbin.
**/ Get the PDF version of the OTF
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF'
IMPORTING
bin_filesize = l_filesize
bin_file = bin_file
TABLES
otf = w_job_output_info-otfdata
lines = t_lines
EXCEPTIONS
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 3
OTHERS = 4.
5. Convert the PDF format to format required for attachment.
**/ Convert the PDF format to the table type required for the attachment.
CALL FUNCTION 'QCE1_CONVERT'
TABLES
t_source_tab = t_lines
t_target_tab = t_objbin
EXCEPTIONS
convert_not_possible = 1
OTHERS = 2.
6. Create the document to be sent by e-mail
Creation of the document to be sent
File Name: Name of the file to be attached
w_doc_chng-obj_name = Flename.
Mail Subject
w_doc_chng-obj_descr = Test E-mail(em1).
Completing the recipient list
t_reclist-receiver = t_rec. e-mail id of the recipient
t_reclist-rec_type = 'U'.
APPEND t_reclist.
Mail Contents
t_objtxt = 'Line 1'(bd1).
APPEND t_objtxt.
CLEAR t_objtxt.
APPEND t_objtxt. " to put in a blank line
t_objtxt = 'Line 2'(bd2).
APPEND t_objtxt.
CLEAR t_objtxt.
t_objtxt = Line 3'(bd3).
APPEND t_objtxt.
CLEAR t_objtxt.
APPEND t_objtxt. " to put in a blank line
t_objtxt = Line 4(bd3).
APPEND t_objtxt.
Calculate email size in bytes
DESCRIBE TABLE t_objtxt LINES w_tab_lines.
READ TABLE t_objtxt INDEX w_tab_lines.
w_doc_chng-doc_size = ( w_tab_lines - 1 ) * 255 + STRLEN( t_objtxt ).
Creation of the entry for the compressed document
for the email text
CLEAR t_objpack-transf_bin.
t_objpack-head_start = 1.
t_objpack-head_num = 0.
t_objpack-body_start = 1.
t_objpack-body_num = w_tab_lines.
t_objpack-doc_type = 'RAW'.
APPEND t_objpack.
Creation of the document attachment
(Assume that the data in OBJBIN is in BMP format)
DESCRIBE TABLE p_objbin LINES w_tab_lines.
t_objhead = Fielname.PDF'(em5).
APPEND t_objhead.
CLEAR t_objpack.
**/ Creation of the entry for the compressed/attached document
t_objpack-transf_bin = c_x.
t_objpack-head_start = 1.
t_objpack-head_num = 1.
t_objpack-body_start = 1.
t_objpack-body_num = w_tab_lines.
t_objpack-doc_type = 'PDF'.
t_objpack-obj_name = 'Possibly hover name'.
t_objpack-obj_descr = Mail Description'(em6).
t_objpack-doc_size = w_tab_lines * 255.
APPEND t_objpack.
7. Send the document by e-mail
Sending the document
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = w_doc_chng
put_in_outbox = c_x
TABLES
packing_list = t_objpack
object_header = t_objhead
contents_bin = t_objbin
contents_txt = t_objtxt
receivers = t_reclist
EXCEPTIONS
too_many_receivers = 1
document_not_sent = 2
operation_no_authorization = 4
OTHERS = 99.
IF sy-subrc <> 0.
WRITE: / text-014, sy-subrc.
ELSE.
WRITE: / text-015.
ENDIF.
8. Commit work: this step is important to send the email to transaction SOST.
Once the email has reached the transaction SOST then its the job of the basis to do the configuration to send it to the specified e-mail id by internet.
**commit work for the email to go into transaction SOST.
COMMIT WORK.
9. In transaction SOST the mail will appear.
Similar Messages
-
Error while activating smartforms:'itab' is neither specified under table.
Hi,
I got an error while activating smartforms,
'ITAB' is not specified under tables nor defined as an internal table.
This comes under loop - Data tab.
itab into wa.
Please rectify this error.Hi Jana,
I already declared itab in global definitions as follows,
Variable Type Associated type
T_VBAP TYPE TYPES_VBAP
(itab) (type) (str - structure)
But still i m getting the error.
Can u suggest some other soln.
thanks for ur reply. -
Error while activating smartforms - 'OCCURS N' specification missing
Hi,
I had a error while activating smartforms,
'T_VBAP' is not an internal table - the 'OCCURS N' specification is missing.
Solve this error.Hi,
u might have used the internal table directly without creating work area.
pls create work area ur problem will be solved.
Thankyou,
Regards,
Pavani -
Error when email enabling a document library
Hi - I've checked through other threads re errors when email enabling a doc library, but our scenario is a bit different. We have some custom code that creates sites based on a site template and uses data from a 3rd party system to define the site
name, permissions etc. I don't think that the process for creating the sites is relevant to the issue, but mentioning that anyway to be complete. As part of the site creation workflow, one of the document libraries is email enabled. However, on one specific
site, the document library was not email enabled. When I try and do this manually, I get the following error:
Error in the application. at
Microsoft.SharePoint.SPList.UpdateDirectoryManagementService(String oldAlias,
String newAlias)
at Microsoft.SharePoint.SPList.Update(Boolean
bFromMigration)
at Microsoft.SharePoint.SPList.Update()
at
Microsoft.SharePoint.ApplicationPages.EmailSettingsPage.SubmitButton_Click(Object
sender, EventArgs args)
at
System.Web.UI.WebControls.Button.OnClick(EventArgs e)
at
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument)
at
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint,
Boolean includeStagesAfterAsyncPoint)
Other tests/observations:
On the problem site, I get the same error when trying to email enable other document libraries
Other sites on the same site collection have been created using the same process/site template, and the appropriate document library was email enabled automatically (sites created both before and subsequent to this problem site)
I have successfully managed to manually email enable a document library on an different existing site
I have manually created a new site using the same site template and successfully managed to manually email enable a document library on that site
So I am fairly certain that it is nothing to do with permissions as other posts relating to this issue have suggested. Does anyone have any ideas on what is happening, how to resolve or further checks I can make? Many thanksHi qaaweb,
based on my experience, the issue itself may be caused by some triggers,
the permission is one of them only,
to narrow down usually, we try to update credential first, that at some environment may less impact.
example:
based on: http://technet.microsoft.com/en-us/library/cc262947.aspx, to configure email, if already configured then skip.
make sure that application pool account that is used for central admin to be the same for central admin, site and the web application.
make sure SQL server and granted DBCreator , Serveradmin, Setupadmin on service account.
remove old database and sync:
C:\program files\common files\Microsoft shared\web server extensions\12\bin>stsadm -o sync -listolddatabases 0
C:\program files\common files\Microsoft shared\web server extensions\12\bin>stsadm -o sync -deleteolddatabases 0
Update farm credentials, http://support.microsoft.com/kb/934838
if needed: central administration > Operation > Authentication provider and changed Kerberos to NTLM on central admin site.
Login service account on the SharePoint server and enable IncomingEmail settings on the web application
please let us know if the workaround is not applicable
Regards,
Aries
Microsoft Online Community Support
Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread. -
Hello Guys,,,,
When i am trying to see the previw of the quotation it opens in a new wondow and says "Error occuers in smartform". Rest of the screen is blank. i checked this from standard SAP Bsuiness roles. it does the same.
I checked from GUI and it works fine.
can anyone help us understand what to check on this issue?
Thanks and regards,
lata
Edited by: latha reddy on Jun 22, 2010 4:12 PMHi Latha,
Usually in Web UI this could be because of the import structure IS_CONTROL_PARAMETERS in exec_smartform methods. [This thread|Re: Print Preview not working in CRM Web UI; should solve your problem.
Regards,
Amar -
Hi,
I am trying to run PO Smartform but i am getting an error ' Table %Template 1 does'nt fit into window '. The Smartform is succesfully compiled but when i tried to print preview i am getting this message in result screen. Can i know the possible reasons for this error. Whether Smartform dynamically manage the size of all windows.
Suggest me possible solutions for the error.
Thankshi ben,
Dont increase the size of all windows.
If the error u r facing is regarding <b>WIDTH</b> adjust the width of template as per the width of window.
If it is with the <b>HEIGHT</b> , give the exact height for template that u gave for that particular window ( u can give less height for template than window but u cann't do the other ....)
To check which one is that particular template that is showing error :
select the page --> expand then search for %TEMPLATE1 that will be unique in the whole smartform. -
[CUP 5.3] Error while email validation
Hello all,
Anyone seen this before in CUP 5.3 SP15?
I have an access request form in which I allow user lookup. The user lookup is linked with an SAP HR system.
When I search users on name, only the users that have an emailaddress filled in in the infotypes show up in my list. Users without an emailaddress are not shown. I can only get them in my search results when I specifically search for them on user ID.
When I then select the user without emailaddress and insert him/her into my access request form, I always receive the "error creating request" message. The log tells me:
2011-09-20 15:29:28,326 [SAPEngine_Application_Thread[impl:3]_24] ERROR EUCreateRequestAction.java@224:loadHandler() : Error while email validation = E-mail address
Users with an emailaddress are no problem.
Even when I fill in an emailaddress manually, CUP apparently keeps using the emailaddress from the infotype.
Anyone know how to resolve this?
Thanks in advance,
Edited by: Lanssens Tom on Sep 20, 2011 6:09 PM (spelling)Hello Srihari,
User Email Address is a Mandatory field which cannot be changed. The only option to change is to turn off "Editable". However, if I do that I receive the warning "It is better to make the field editable, because the end user cannot submit the request, if the field value is not available in the user's data source".
I know that the best solution/workaround is to make sure that all users in the HR list have an emailaddress, so we are going to follow up on this with a script. Still, I would like to know why I can't find nor work with users that don't have an emailaddress, and why I can't update their emailaddress myself manually via the CUP.
Best regards,
Tom -
Error in Calling Smartforms-During FAX output
Hi experts
I am getting the following error while processing the FAX output type.....
Can you please advice how to proceed on this..
Error message
Error in Calling Smartforms
Processing log of the Output type
Object 0130001210
Output type: Delivery Note
Processing log for program RVADDN01 routine ENTRY
Error during reading T001G (Return code
Cannot process message, no route from userID to fax number
Advance thanks for your support
regards
RajaHi experts
I am getting the following error while processing the FAX output type.....
Can you please advice how to proceed on this..
Error message
Error in Calling Smartforms
Processing log of the Output type
Object 0130001210
Output type: Delivery Note
Processing log for program RVADDN01 routine ENTRY
Error during reading T001G (Return code
Cannot process message, no route from userID to fax number
Advance thanks for your support
regards
Raja -
ePrint Error The email was sent to multiple printers or recipients, (It was not)
Using new HP Photosmart 5510
Vista 32 bitYou can get this error is you have more than the printer email in the "To" field or any entries in the "CC" field of the email. If that is not the case, you can try these troubleshooting steps:
http://h30434.www3.hp.com/t5/ePrint-Print-Apps-Mobile/ePrint-Apps-Connectivity-Troubleshooting-Pleas...d=reg_r1002_usen
I am an HP employee -
SCOT: When email status error, send email to sender
Hello everyone
I would like to know if it is possible to configure SCOT to send an email to the sender when an email ending as error.
Here is the scenario.
1. An email is sent through scot.
2. SCOT process the email and comeback with an error. Example msg 841 (message too long)
3. So, when the email status is an error, an email should be sent to the sender to advise him of the problem.
So, the sender will be able to act quickly and perform corrective action.
Any idea on how to configure this?
Regards
dstjHello Volkoale
Sorry, it is in project plan at the moment. I didn't have time to do it.
Here is some speudo code:
Select all record from SOST table where MSGTY = 'E' " Message type Error
and entry_date = sy-datlo
and entry_time is between now and 15 minutes ago.
select al record from SOOS where corresponding to SOST.
field SOOS-sndnam correspond to the sender of the message.
The table SOOD contain the title of the email (Field "OBJDES" )
When you have all those records.
you can send an email to the sender.
I hope that can help you. -
Error while emailing pdf Smartform- help needed
Hi All,
I have successsully saved smartform as pdf on my local machine and while trying to send the same as an attachment.i am encountering a run time error in SCOT transaction on pressing send message.
Error details are as follows:-
CPIC-CALL: THE SAPECMINIT UNABLE TO DETERMINE HOST ADDRESS
Source Code: SAPMSSY1
CALL RFCIMPORT
The program is given below. Kindly reply me the solution.
All helpful answers will b rewarded.
Regards,
Eureka.
*& Report Z24436_SMARTFORM2 *
REPORT Z24436_SMARTFORM2 .
Global Variables Declarations
DATA: MAt_id TYPE MATNR VALUE '1%',
fm_name TYPE rs38l_fnam.
DATA: ITAB_MAkt TYPE STANDARD TABLE OF MAkt.
DATA: p_form TYPE tdsfname VALUE 'ZUDAY_SMARTFORMS1'.
All Database Selections are here
*Getting Materials belonging to the given plant
SELECT * FROM MAkt INTO TABLE ITAB_MAkt
WHERE MATNR LIKE MAT_id.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = p_form
VARIANT = ' '
DIRECT_CALL = ' '
IMPORTING
fm_name = fm_name
EXCEPTIONS
no_form = 1
no_function_module = 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.
EXIT.
ENDIF.
DATA : gw_ssfcrescl TYPE ssfcrescl.
DATA: gt_otf TYPE STANDARD TABLE OF itcoo ,
gt_tline TYPE STANDARD TABLE OF tline,
gt_pdf TYPE STANDARD TABLE OF tline,
gv_len LIKE sood-objlen,
gw_ssfctrlop TYPE ssfctrlop, "for CONTROL_PARAMETERS
gw_ssfcompop TYPE ssfcompop. "for OUTPUT_OPTIONS
gw_ssfctrlop-getotf = 'X'.
gw_ssfctrlop-no_dialog = 'X'.
gw_ssfcompop-tdnoprev = 'X'.
**Calling the generated function module
CALL FUNCTION fm_name
EXPORTING
ARCHIVE_INDEX =
ARCHIVE_INDEX_TAB =
ARCHIVE_PARAMETERS =
CONTROL_PARAMETERS = gw_ssfctrlop
MAIL_APPL_OBJ =
MAIL_RECIPIENT =
MAIL_SENDER =
OUTPUT_OPTIONS = gw_ssfcompop
USER_SETTINGS = 'X'
customer_info = customer
IMPORTING
DOCUMENT_OUTPUT_INFO =
JOB_OUTPUT_INFO = gw_ssfcrescl
JOB_OUTPUT_OPTIONS =
TABLES
it_makt = itab_makt
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
OTHERS = 5
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
gt_otf[] = gw_ssfcrescl-otfdata[].
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF'
max_linewidth = 132
IMPORTING
bin_filesize = gv_len
TABLES
otf = gt_otf
lines = gt_pdf
EXCEPTIONS
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 3
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
DATA:
gt_pdf TYPE TABLE OF tline,
gt_xi_pdf TYPE TABLE OF tline,
gt_pdf_conv TYPE TABLE OF solisti1,
gt_xi_temp TYPE TABLE OF bapiqcmime.
CONSTANTS:
lc_x(1) TYPE c VALUE 'X',
lc_raw(3) TYPE c VALUE 'RAW',
lc_pdf(3) TYPE c VALUE 'PDF',
lc_attach(12) TYPE c VALUE 'ATTACHMENT'.
DATA:
lv_spool TYPE rspoid, "Spool Number
lv_pdf_size TYPE i, "PDF Size
lv_subject(40) TYPE c, "Email subject
lv_tab_lines TYPE sytabix, "Table Lines
lv_date(10) TYPE c, "Variable for date
lv_time(8) TYPE c. "Variable for Time
DATA:
For Compressing document
ls_objpack TYPE sopcklsti1,
lt_objpack TYPE STANDARD TABLE OF sopcklsti1,
To specify subject
lt_objhead TYPE STANDARD TABLE OF solisti1,
ls_objhead TYPE solisti1,
To send the PDF
lt_objbin TYPE STANDARD TABLE OF solisti1,
ls_objbin TYPE solisti1,
Email body
lt_objtxt TYPE STANDARD TABLE OF solisti1,
ls_objtxt TYPE solisti1,
To specify Receivers
lt_reclist TYPE STANDARD TABLE OF somlreci1,
ls_reclist TYPE somlreci1,
Documenting Data
ls_doc_chng TYPE sodocchgi1,
ls_pdf_conv TYPE solisti1.
CONSTANTS: lc_under(1) TYPE c VALUE '_'.
**Copy the Spool request to a Local Variable
lv_spool = sy-spono.
Convert spool job to PDF
***************this is normal report spool to pdf.
but your case it will be smartform to pdf
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = lv_spool
no_dialog = lc_x
IMPORTING
pdf_bytecount = lv_pdf_size
TABLES
pdf = gt_pdf
EXCEPTIONS
OTHERS = 0.
To Format the PDF file so as each row contains 255 characters
PERFORM page_format .
Transfer the file to objbin table
LOOP AT gt_pdf_conv INTO ls_pdf_conv.
ls_objbin-line = ls_pdf_conv-line.
APPEND ls_objbin TO lt_objbin.
CLEAR ls_objbin.
ENDLOOP.
*// Creating the document to be sent - Mail subject creation
ls_doc_chng-obj_name = sy-repid.
lv_subject = text-008. "Mail subject
WRITE sy-datum TO lv_date USING EDIT MASK '__/__/____'.
WRITE sy-uzeit TO lv_time USING EDIT MASK '__:__:__'.
CONCATENATE lv_subject lc_under lv_date lc_under lv_time
INTO ls_doc_chng-obj_descr.
*// Email body
PDF attachment of Product Allocation for Open orders
ls_objtxt = text-009.
APPEND ls_objtxt TO lt_objtxt.
Write Date when the mail was sent in the email body
CONCATENATE text-010 lv_date INTO ls_objtxt.
APPEND ls_objtxt TO lt_objtxt.
Write Time when the mail was sent in the email body
CONCATENATE text-011 lv_time INTO ls_objtxt.
APPEND ls_objtxt TO lt_objtxt.
DESCRIBE TABLE lt_objtxt LINES lv_tab_lines.
READ TABLE lt_objtxt INTO ls_objtxt INDEX lv_tab_lines.
Calculate the document size
ls_doc_chng-doc_size = ( lv_tab_lines - 1 ) * 255 +
STRLEN( ls_objtxt ).
*// Creating the entry for the compressed document
CLEAR ls_objpack-transf_bin.
ls_objpack-head_start = 1.
ls_objpack-head_num = 0.
ls_objpack-body_start = 1.
ls_objpack-body_num = lv_tab_lines.
ls_objpack-doc_type = 'RAW' . "RAW
APPEND ls_objpack TO lt_objpack.
CLEAR lv_tab_lines.
DESCRIBE TABLE lt_objbin LINES lv_tab_lines.
ls_objhead = ls_doc_chng-obj_descr.
APPEND ls_objhead TO lt_objhead.
*// Creating the entry for the compressed attachment
ls_objpack-transf_bin = lc_x.
ls_objpack-head_start = 1.
ls_objpack-head_num = 1.
ls_objpack-body_start = 1.
ls_objpack-body_num = lv_tab_lines.
ls_objpack-doc_type = 'PDF'. "PDF
ls_objpack-obj_name = 'ATTACHMENT'. "ATTACHMENT
CONCATENATE lv_subject lc_under lv_date lc_under lv_time
INTO ls_objpack-obj_descr.
CLEAR: ls_objbin.
READ TABLE lt_objbin INTO ls_objbin INDEX lv_tab_lines.
ls_objpack-doc_size = ( lv_tab_lines - 1 ) * 255 +
STRLEN( ls_objbin ).
APPEND ls_objpack TO lt_objpack.
ls_reclist-receiver = '[email protected]'.
ls_reclist-receiver = gv_email_addr.
ls_reclist-rec_type = 'U'.
APPEND ls_reclist TO lt_reclist.
IF ls_reclist-receiver IS INITIAL.
MESSAGE i175.
ELSE.
*// Send EMail
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = ls_doc_chng
put_in_outbox = lc_x
commit_work = lc_x
TABLES
packing_list = lt_objpack
object_header = lt_objhead
contents_bin = lt_objbin
contents_txt = lt_objtxt
receivers = lt_reclist
EXCEPTIONS
too_many_receivers = 1
document_not_sent = 2
operation_no_authorization = 3
OTHERS = 99.
CASE sy-subrc.
WHEN 0.
Mail successfully delivered
*// Do nothing
WHEN 1.
This will never occur as at any point of time mail will be
sent to one processor only.
*// Do nothing
WHEN 2.
MESSAGE i175.
WHEN 3.
MESSAGE i175.
*// Do nothing
ENDCASE.
ENDIF.
REFRESH: lt_objpack,
lt_objbin,
lt_objtxt,
lt_objhead,
lt_reclist.
CLEAR: ls_reclist,
ls_doc_chng,
ls_objpack,
ls_objhead,
ls_objtxt.
DATA : gv_filename LIKE rlgrap-filename VALUE 'C:\Udaya4.pdf'.
CALL FUNCTION 'DOWNLOAD'
EXPORTING
bin_filesize = gv_len
filename = gv_filename
filetype = 'BIN'
filetype_no_show = 'X'
IMPORTING
act_filename = gv_filename
filesize = gv_len
cancel = ''
TABLES
data_tab = gt_pdf.
FORM page_format .
Local data
DATA : lv_lines TYPE i,
lv_temp(500) TYPE c,
lv_offset TYPE p,
lv_lineslen(2) TYPE p,
lv_mimelen(2) TYPE p,
lv_tabix LIKE sy-tabix,
ls_pdf_conv TYPE solisti1,
ls_xi_temp TYPE bapiqcmime,
ls_xi_pdf TYPE tline.
CLEAR : gt_xi_pdf,
gt_xi_temp.
REFRESH: gt_xi_pdf,
gt_xi_temp.
Copy the PDF file into table gt_xi_pdf
gt_xi_pdf[] = gt_pdf[].
Reformat the line to 255 characters wide (code from SAP)
CLEAR: lv_temp, lv_offset, gt_xi_temp.
DESCRIBE TABLE gt_xi_pdf LINES lv_lines.
DESCRIBE FIELD ls_xi_pdf LENGTH lv_lineslen IN CHARACTER MODE.
DESCRIBE FIELD ls_xi_temp LENGTH lv_mimelen IN CHARACTER MODE.
Go through all the lines of table gt_xi_pdf
LOOP AT gt_xi_pdf INTO ls_xi_pdf.
lv_tabix = sy-tabix.
Move ls_xi_pdf into lv_temp variable
MOVE ls_xi_pdf TO lv_temp+lv_offset.
Check if its the last line of table gt_xi_pdf
IF lv_tabix = lv_lines.
lv_lineslen = STRLEN( ls_xi_pdf ).
ENDIF.
Calculate the new offset
lv_offset = lv_offset + lv_lineslen.
Check if the new offset is equal to or greater than the length of
gt_xi_temp
IF lv_offset GE lv_mimelen.
CLEAR ls_xi_temp.
Copy the PDF data into gt_xi_temp
ls_xi_temp = lv_temp(lv_mimelen).
APPEND ls_xi_temp TO gt_xi_temp.
SHIFT lv_temp BY lv_mimelen PLACES.
Calculate the new offset
lv_offset = lv_offset - lv_mimelen.
ENDIF. "Offset GE MIMELEN
Check if its the last line of gt_xi_pdf
IF lv_tabix = lv_lines.
Check if lv_temp has some data that is not been transferred to
gt_xi_temp
IF lv_offset GT 0.
CLEAR ls_xi_temp.
Copy the PDF data into gt_xi_temp
ls_xi_temp = lv_temp(lv_offset).
APPEND ls_xi_temp TO gt_xi_temp.
ENDIF. "lv_offset GT 0
ENDIF. "lv_tabix = lv_lines
ENDLOOP.
gt_pdf_conv[] = gt_xi_temp[].
ENDFORM. " page_formatall settings in SCOT is ok ? like SMTP settings , link b/w ur Outlook server and SAP server ?
Regards
Prabhu -
Error - While converting Smartform to PDF and send in Email
HI all,
I am getting error while opening the PDF file. i searched in SDN but I am not able to figure out what is the correct issues.
Please find the piece of code.
* Assigning the OTFDATA to OTF Structure table
CLEAR gt_otf.
gt_otf[] = ls_jobout_info-otfdata[].
* Convert the OTF DATA to SAP Script Text lines
CLEAR gt_pdf_tab.
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF'
** max_linewidth = 134
max_linewidth = 132
IMPORTING
** bin_file = ts_file
bin_filesize = gv_bin_filesize
TABLES
otf = gt_otf
lines = gt_pdf_tab
EXCEPTIONS
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 3
OTHERS = 4.
* Passing the SAP Script text lines to SAPoffice: Single List with Column Length 255 table
DATA:
* gv_bin_filesize TYPE i, " Store the file size
gv_pos TYPE i,
gv_len TYPE i,
gv_tab_lines TYPE i.
CLEAR : gs_objbin, gs_pdf_tab.
LOOP AT gt_pdf_tab INTO gs_pdf_tab.
gv_pos = 255 - gv_len.
IF gv_pos > 134. "length of pdf_table
gv_pos = 134.
ENDIF.
gs_objbin+gv_len = gs_pdf_tab(gv_pos).
gv_len = gv_len + gv_pos.
IF gv_len = 255. "length of out (contents_bin)
APPEND gs_objbin TO gt_objbin.
CLEAR: gs_objbin, gv_len.
IF gv_pos < 134.
gs_objbin = gs_pdf_tab+gv_pos.
gv_len = 134 - gv_pos.
ENDIF.
ENDIF.
ENDLOOP.
IF gv_len > 0.
APPEND gs_objbin TO gt_objbin.
ENDIF.
* Filling the details in SAPoffice: Description of Imported Object Components table
DESCRIBE TABLE gt_objbin LINES gv_tab_lines.
CLEAR gs_objbin.
READ TABLE gt_objbin INTO gs_objbin INDEX gv_tab_lines.
IF sy-subrc = 0.
gs_objpack-doc_size = ( gv_tab_lines - 1 ) * 255 + STRLEN( gs_objbin ).
gs_objpack-transf_bin = 'X'.
gs_objpack-head_start = 1.
gs_objpack-head_num = 0.
gs_objpack-body_start = 1.
gs_objpack-body_num = gv_tab_lines.
gs_objpack-doc_type = 'PDF'.
gs_objpack-obj_name = l_title.
gs_objpack-obj_descr = w_output-tdtitle.
APPEND gs_objpack TO gt_objpack.
ENDIF.
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
document_data = p_doc_chng
put_in_outbox = 'X'
sender_address = p_w_sender
sender_address_type = 'INT'
TABLES
packing_list = p_objpack
** object_header = p_objhead
contents_bin = p_objbin
** contents_txt = p_objtxt
* CONTENTS_HEX =
* OBJECT_PARA =
* OBJECT_PARB =
receivers = p_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
kindly help...email is coming but when i tried to open the PDF file, error saying, " There is error opening a file. thie file is damages and cannot be opened'
thanksHI all,
I am getting error while opening the PDF file. i searched in SDN but I am not able to figure out what is the correct issues.
Please find the piece of code.
* Assigning the OTFDATA to OTF Structure table
CLEAR gt_otf.
gt_otf[] = ls_jobout_info-otfdata[].
* Convert the OTF DATA to SAP Script Text lines
CLEAR gt_pdf_tab.
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF'
** max_linewidth = 134
max_linewidth = 132
IMPORTING
** bin_file = ts_file
bin_filesize = gv_bin_filesize
TABLES
otf = gt_otf
lines = gt_pdf_tab
EXCEPTIONS
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 3
OTHERS = 4.
* Passing the SAP Script text lines to SAPoffice: Single List with Column Length 255 table
DATA:
* gv_bin_filesize TYPE i, " Store the file size
gv_pos TYPE i,
gv_len TYPE i,
gv_tab_lines TYPE i.
CLEAR : gs_objbin, gs_pdf_tab.
LOOP AT gt_pdf_tab INTO gs_pdf_tab.
gv_pos = 255 - gv_len.
IF gv_pos > 134. "length of pdf_table
gv_pos = 134.
ENDIF.
gs_objbin+gv_len = gs_pdf_tab(gv_pos).
gv_len = gv_len + gv_pos.
IF gv_len = 255. "length of out (contents_bin)
APPEND gs_objbin TO gt_objbin.
CLEAR: gs_objbin, gv_len.
IF gv_pos < 134.
gs_objbin = gs_pdf_tab+gv_pos.
gv_len = 134 - gv_pos.
ENDIF.
ENDIF.
ENDLOOP.
IF gv_len > 0.
APPEND gs_objbin TO gt_objbin.
ENDIF.
* Filling the details in SAPoffice: Description of Imported Object Components table
DESCRIBE TABLE gt_objbin LINES gv_tab_lines.
CLEAR gs_objbin.
READ TABLE gt_objbin INTO gs_objbin INDEX gv_tab_lines.
IF sy-subrc = 0.
gs_objpack-doc_size = ( gv_tab_lines - 1 ) * 255 + STRLEN( gs_objbin ).
gs_objpack-transf_bin = 'X'.
gs_objpack-head_start = 1.
gs_objpack-head_num = 0.
gs_objpack-body_start = 1.
gs_objpack-body_num = gv_tab_lines.
gs_objpack-doc_type = 'PDF'.
gs_objpack-obj_name = l_title.
gs_objpack-obj_descr = w_output-tdtitle.
APPEND gs_objpack TO gt_objpack.
ENDIF.
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
document_data = p_doc_chng
put_in_outbox = 'X'
sender_address = p_w_sender
sender_address_type = 'INT'
TABLES
packing_list = p_objpack
** object_header = p_objhead
contents_bin = p_objbin
** contents_txt = p_objtxt
* CONTENTS_HEX =
* OBJECT_PARA =
* OBJECT_PARB =
receivers = p_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
kindly help...email is coming but when i tried to open the PDF file, error saying, " There is error opening a file. thie file is damages and cannot be opened'
thanks -
Error send a smartform PDF by Email to Vendor
Hi Expert,
Please help me.........................
I want to send a PO (Smartform) as Email to Vendor.
In SAPScript the PO send by Email is working fine, but in Smartforms it is not working.
Normally, I will use via Smartforms the Program = YBAA_FM06P, FORM routine = ENTRY_NEU, PDF/Smartform Form = ZYBAA_MMPO1.
A communication strategy has communication type as INT has been defined.
This communication strategy has been set as default in the output type ZNEU. The transmission medium has been set to 5 (External Send) and the partner function as VN (Vendor).
The e-mail address of the vendor has also been maintained.
In transaction MN04, i have also made an entry for output type ZNEU and set the document type as NB.
But message output do not create.
How to send a smartform PDF by Email to vendor?
Thanks,Hi,
I can convert the PO output in to PDF from SOST I can sent it to external vendor using the Mail triggering configuration settings but meassage output do not create.
Please tell me how can I do.
Thank, -
Error in opening smartform generated PDF attachments
Hi every one,
my smartforms generate multiple emails based on the widely used code as shown below.
The emails are successfully being sent to different locations, but the problem is the first PDF file is opening, but the others followed by it are not opening. It's giving an error ' File damaged and cannot be opened!'
Pls see the below code and help me out.
Points would be awarded.
Thanks to all in advance!!
Arnab
REPORT zvenkat_smartform_via_mai.
*& Structures and Infotype Internal tables.
TABLES pernr.
INFOTYPES:
0000,
0001,
0002,
0006,
0022,
0023.
INCLUDE dbpnpmac.
*& Declaration part
Types
TYPES:
BEGIN OF t_emp_info,
pernr TYPE pa0001-pernr,
ename TYPE pa0001-ename,
bukrs TYPE pa0001-bukrs,
persk TYPE pa0001-persk,
stell TYPE pa0001-stell,
gblnd TYPE pa0002-gblnd,
END OF t_emp_info,
BEGIN OF t_mard,
matnr TYPE mard-matnr,
werks TYPE mard-werks,
labst TYPE mard-labst,
meins TYPE mara-meins,
END OF t_mard.
Work areas
DATA:
w_emp_info TYPE t_emp_info.
Internal tables
DATA:
i_emp_info TYPE STANDARD TABLE OF t_emp_info,
i_mard TYPE STANDARD TABLE OF t_mard.
" Mai related declarations
"Variables
DATA :
g_sent_to_all TYPE sonv-flag,
g_tab_lines TYPE i.
"Types
TYPES:
t_document_data TYPE sodocchgi1,
t_packing_list TYPE sopcklsti1,
t_attachment TYPE solisti1,
t_body_msg TYPE solisti1,
t_receivers TYPE somlreci1,
t_pdf TYPE tline.
"Workareas
DATA :
w_document_data TYPE t_document_data,
w_packing_list TYPE t_packing_list,
w_attachment TYPE t_attachment,
w_body_msg TYPE t_body_msg,
w_receivers TYPE t_receivers,
w_pdf TYPE t_pdf.
"Internal Tables
DATA :
i_document_data TYPE STANDARD TABLE OF t_document_data,
i_packing_list TYPE STANDARD TABLE OF t_packing_list,
i_attachment TYPE STANDARD TABLE OF t_attachment,
i_body_msg TYPE STANDARD TABLE OF t_body_msg,
i_receivers TYPE STANDARD TABLE OF t_receivers,
i_pdf TYPE STANDARD TABLE OF t_pdf.
PARAMETERS:
p_mai_id(99) TYPE c.
*& Start-of-selection.
START-OF-SELECTION.
GET pernr.
PERFORM get_data.
PERFORM show_smartform.
*& End-of-selection.
END-OF-SELECTION.
*& Form get_data
FORM get_data .
rp-provide-from-last p0000 space pn-begda pn-endda.
rp-provide-from-last p0001 space pn-begda pn-endda.
rp-provide-from-last p0002 space pn-begda pn-endda.
MOVE-CORRESPONDING: p0000 TO w_emp_info,
p0001 TO w_emp_info,
p0002 TO w_emp_info.
SELECT matnr werks labst
FROM mard
INTO CORRESPONDING FIELDS OF TABLE i_mard.
ENDFORM. " get_data
*& Form show_smartform
FORM show_smartform .
DATA :
l_sform_name TYPE tdsfname,
l_fm_name TYPE rs38l_fnam.
DATA :
l_sf_control TYPE ssfctrlop,
l_sf_options TYPE ssfcompop.
DATA: i_otf LIKE itcoo OCCURS 100 WITH HEADER LINE.
i_pdf LIKE tline OCCURS 100 WITH HEADER LINE.
DATA: op_option TYPE ssfctrlop,
job_output TYPE ssfcrescl.
op_option-getotf = 'X'.
l_sform_name = 'ZVENKAT_SMARTFORM'.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = l_sform_name
IMPORTING
fm_name = l_fm_name
EXCEPTIONS
no_form = 1
no_function_module = 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.
ELSE.
CALL FUNCTION l_fm_name
EXPORTING
control_parameters = op_option
output_options = l_sf_options
w_emp_info = w_emp_info
IMPORTING
DOCUMENT_OUTPUT_INFO =
job_output_info = job_output
TABLES
p0006 = p0006
p0022 = p0022
p0023 = p0023
i_mard = i_mard.
IF sy-subrc 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF'
TABLES
otf = job_output-otfdata
lines = i_pdf.
IF sy-subrc 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
PERFORM send_mai.
ENDIF.
ENDFORM. " show_smartform
*& Form send_mai
FORM send_mail .
"Subject of the mai.
w_document_data-obj_name = 'MAI_TO_HEAD'.
w_document_data-obj_descr = 'Regarding Mai Program by SAP ABAP'.
"Body of the mai
PERFORM build_body_of_mai
USING:space,
'Hi,',
'I am fine. How are you? How are you doing ? ',
'This program has been created to send simple mai',
'with Subject,Body with Address of the sender. ',
'Regards,',
'Venkat.O,',
'SAP HR Technical Consultant.'.
"Write Packing List for Body
DESCRIBE TABLE i_body_msg LINES g_tab_lines.
w_packing_list-head_start = 1.
w_packing_list-head_num = 0.
w_packing_list-body_start = 1.
w_packing_list-body_num = g_tab_lines.
w_packing_list-doc_type = 'RAW'.
APPEND w_packing_list TO i_packing_list.
CLEAR w_packing_list.
"Write Packing List for Attachment
w_packing_list-transf_bin = 'X'.
w_packing_list-head_start = 1.
w_packing_list-head_num = 1.
w_packing_list-body_start = 1.
DESCRIBE TABLE i_attachment LINES w_packing_list-body_num.
w_packing_list-doc_type = 'PDF'.
w_packing_list-obj_descr = 'PDF Attachment'.
w_packing_list-obj_name = 'PDF_ATTACHMENT'.
w_packing_list-doc_size = w_packing_list-body_num * 255.
APPEND w_packing_list TO i_packing_list.
CLEAR w_packing_list.
"Fill the document data and get size of attachment
w_document_data-obj_langu = sy-langu.
READ TABLE i_attachment INTO w_attachment INDEX g_tab_lines.
w_document_data-doc_size = ( g_tab_lines - 1 ) * 255 + STRLEN( w_attachment ).
"Receivers List.
w_receivers-rec_type = 'U'. "Internet address
w_receivers-receiver = p_mai_id. "here mai Id should be given
w_receivers-com_type = 'INT'.
w_receivers-notif_del = 'X'.
w_receivers-notif_ndel = 'X'.
APPEND w_receivers TO i_receivers .
CLEAR:w_receivers.
"Function module to send mai to Recipients
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = w_document_data
put_in_outbox = 'X'
commit_work = 'X'
IMPORTING
sent_to_all = g_sent_to_all
TABLES
packing_list = i_packing_list
contents_bin = i_attachment
contents_txt = i_body_msg
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 i303(me) WITH 'Mai has been Successfully Sent.'.
ELSE.
WAIT UP TO 2 SECONDS.
"This program starts the SAPconnect send process.
SUBMIT rsconn01 WITH mode = 'INT'
WITH output = 'X'
AND RETURN.
ENDIF.
ENDFORM. " send_mai
*& Form build_body_of_mai
text
-->L_MESSAGE text
FORM build_body_of_mai USING l_message.
w_body_msg = l_message.
APPEND w_body_msg TO i_body_msg.
CLEAR w_body_msg.
ENDFORM. " build_body_of_maiHi,
Check the code below
1.converting smartform to PDF
Summury: Converting the smartfrom to PDF is process of 3 simple steps.
Calling the Smart form, then it returns the OTF data in Return.
Converting the OTF data into required format using the Function Module CONVERT_OTF_2_PDF.
Download the File
*& Report ZTEST_NREDDY_PDF
REPORT ZTEST_NREDDY_PDF.
DATA: it_otf TYPE STANDARD TABLE OF itcoo,
it_docs TYPE STANDARD TABLE OF docs,
it_lines TYPE STANDARD TABLE OF tline,
st_job_output_info TYPE ssfcrescl,
st_document_output_info TYPE ssfcrespd,
st_job_output_options TYPE ssfcresop,
st_output_options TYPE ssfcompop,
st_control_parameters TYPE ssfctrlop,
v_len_in TYPE so_obj_len,
v_language TYPE sflangu VALUE 'E',
v_e_devtype TYPE rspoptype,
v_bin_filesize TYPE i,
v_name TYPE string,
v_path TYPE string,
v_fullpath TYPE string,
v_filter TYPE string,
v_uact TYPE i,
v_guiobj TYPE REF TO cl_gui_frontend_services,
v_filename TYPE string,
v_fm_name TYPE rs38l_fnam.
CONSTANTS c_formname TYPE tdsfname VALUE 'ZTEST'.
CALL FUNCTION 'SSF_GET_DEVICE_TYPE'
EXPORTING
i_language = v_language
i_application = 'SAPDEFAULT'
IMPORTING
e_devtype = v_e_devtype.
st_output_options-tdprinter = v_e_devtype.
*st_output_options-tdprinter = 'locl'.
st_control_parameters-no_dialog = 'X'.
st_control_parameters-getotf = 'X'.
.................GET SMARTFORM FUNCTION MODULE NAME.................
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = c_formname
IMPORTING
fm_name = v_fm_name
EXCEPTIONS
no_form = 1
no_function_module = 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.
...........................CALL SMARTFORM............................
CALL FUNCTION v_fm_name
EXPORTING
control_parameters = st_control_parameters
output_options = st_output_options
IMPORTING
document_output_info = st_document_output_info
job_output_info = st_job_output_info
job_output_options = st_job_output_options
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
OTHERS = 5.
IF sy-subrc 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ELSE.
.........................CONVERT TO OTF TO PDF.......................
CALL FUNCTION 'CONVERT_OTF_2_PDF'
IMPORTING
bin_filesize = v_bin_filesize
TABLES
otf = st_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 THE FILE NAME TO STORE....................
CONCATENATE 'smrt' '.pdf' INTO v_name.
CREATE OBJECT v_guiobj.
CALL METHOD v_guiobj->file_save_dialog
EXPORTING
default_extension = 'pdf'
default_file_name = v_name
file_filter = v_filter
CHANGING
filename = v_name
path = v_path
fullpath = v_fullpath
user_action = v_uact.
IF v_uact = v_guiobj->action_cancel.
EXIT.
ENDIF.
..................................DOWNLOAD AS FILE....................
MOVE v_fullpath TO v_filename.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
bin_filesize = v_bin_filesize
filename = v_filename
filetype = 'BIN'
TABLES
data_tab = it_lines
EXCEPTIONS
file_write_error = 1
no_batch = 2
gui_refuse_filetransfer = 3
invalid_type = 4
no_authority = 5
unknown_error = 6
header_not_allowed = 7
separator_not_allowed = 8
filesize_not_allowed = 9
header_too_long = 10
dp_error_create = 11
dp_error_send = 12
dp_error_write = 13
unknown_dp_error = 14
access_denied = 15
dp_out_of_memory = 16
disk_full = 17
dp_timeout = 18
file_not_found = 19
dataprovider_exception = 20
control_flush_error = 21
OTHERS = 22.
IF sy-subrc 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDIF.
Regards,
Raj. -
Error in Email PDF of purchase order
In the purchase order, we have set up a message(output) type as
external send for sending the email to the buyer. It has been working
good for the past 1 year and suddenly for the past few weeks we started
noticing errors.
The error is that we cannot see any data in one of the pages of the PO
output(PDF attachment). For example, if a PO has 5 pages, the 2nd page
will be blank and all the other pages would have come out fine. This
does not happen in every PO and also it is not the same page which is
missing in all the error PO PDFs. But when we print the output with
the Print medium it always looks fine. Both uses the same smartform
and the program.
Even in the same PO, the first time they email it does not work
correctly and if they repeat the output after a few minutes all pages
look fine.
This error happens sporadically and it does not have any connection
with the number of pages a PO prints or it is not the same page that is
missing always. I beleive it does not have anything to do with the
special characters in the PO. The language we are trying to print is
English.
We use CONVERT_OTF function module to convert from OTF to PDF. This
was working good always before and suddenly we see problems every now
and then. I will also attach a screen shot of the error when the PDF
is opened(this shows a page in PO which is blank & error of PDF). Can
you please look into this and direct us in the right path
to solve the issue?
ThanksHi,
As mentioned the pdf missing page error is sporadic, I would recommend you to check the following:
1. Add a delay 'WAIT' Function Module before 'CONVERT_OTF'. Maybe, due to some change in hardware, patch upgrade or increased user load, the pdf is not getting generated the first time. Hence, it works fine the next time.
2. Ask your BASIS Team to monitor the dialog processes when you run this activity. You can also use SQL Trace to get any leads with reference to bandwidth issues.
Regards,
Pranav.
Maybe you are looking for
-
AppleScript to make All-Day Events?
I'm new at this, so forgive the question if it's obvious. I routinely import a calendar using Outlook2Cal from a Windows machine to iCal 2.0.3 on my PowerBook. It works fine, but All-Day events in Outlook show up in iCal as starting at 12:00 AM the f
-
Create Table/View with Validity Date Control?
Hi, does anyone know the easiest way for me to create a custom view that uses validity dates to control records by time periods, similar to time constraint 1 infotypes in HR? For instance, if I define a table to store entries like so Client (Key): 10
-
Pausing and restarting closed caption and audio
Can anyone help me with this issue - I have 2 sets of closed captions on one slide with audio that spans the both closed captions. I pause the audio at the end of closed caption one using a click box, when I restart it by clicking on the click box th
-
System is not configured for WS Securitylogon
Greetings, I've created and attempted to begin transport of my first provider service. I'm having some issues in our QA system The SE80 objects attached to a transport & transported no problem. I had to manually add the ICF objects onto a transport
-
Revision: 10214 Author: [email protected] Date: 2009-09-13 07:33:58 -0700 (Sun, 13 Sep 2009) Log Message: This fixes the problem that if two text components share the same textFlow there is an infinite loop involving updateDisplayList -> damage