on 04-10-2007 3:11 PM
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 = 'udayabhaskar_p@infosys.com'.
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_format
all settings in SCOT is ok ? like SMTP settings , link b/w ur Outlook server and SAP server ?
Regards
Prabhu
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
95 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.