on 08-07-2008 1:04 PM
Hi ABAP Gurus,
I am creating print program wherein calling the smartforms and converting to a pdf file, and mailing the pdf file to an internet address.
When i execute the pgm, the print screen is poping up....i am not able to disable it though i am passing right control parameters( lwa_ctrlop-no_dialog = 'X').
Attaching my code..please see and tell me where i have to make changes..
TABLES: USR01.
Internal table declarations
DATA lit_mseg TYPE STANDARD TABLE OF mseg INITIAL SIZE 0.
DATA lit_temp TYPE STANDARD TABLE OF gty_gr_creat INITIAL SIZE 0.
DATA lit_otf TYPE itcoo OCCURS 0 WITH HEADER LINE.
DATA lit_tline TYPE TABLE OF tline WITH HEADER LINE.
DATA lit_objtxt TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0.
DATA lit_objpack TYPE STANDARD TABLE OF sopcklsti1 INITIAL SIZE 0.
DATA lit_objbin TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0.
DATA lit_receiver TYPE STANDARD TABLE OF somlreci1 INITIAL SIZE 0.
Workarea declarations
DATA lwa_ctrlop TYPE ssfctrlop .
DATA lwa_compop TYPE ssfcompop .
DATA lwa_return TYPE ssfcrescl .
DATA lwa_tline TYPE tline .
DATA lwa_objtxt TYPE solisti1 .
DATA lwa_objpack TYPE sopcklsti1.
DATA lwa_doc_data TYPE sodocchgi1.
DATA lwa_objbin TYPE solisti1 .
DATA lwa_receiver TYPE somlreci1 .
DATA lwa_temp TYPE gty_gr_creat.
Variable declarations
DATA lv_form_name TYPE tdsfname VALUE 'YTEST4'.
DATA lv_dlist TYPE so_obj_nam VALUE 'ZPTS446'.
DATA lv_func_mod TYPE rs38l_fnam .
DATA lv_len_in LIKE sood-objlen.
DATA lv_time TYPE syuzeit .
DATA lv_time2 TYPE char8 .
DATA lv_date2 TYPE char10 .
DATA lv_info TYPE so_text255 .
DATA lv_lines TYPE i .
DATA lv_buffer TYPE string .
Constants declarations
CONSTANTS lc_x TYPE char1 VALUE 'X' .
CONSTANTS lc_c TYPE so_escape VALUE 'U'. "'C' .
CONSTANTS lc_locl TYPE rspopname VALUE 'SAP'. "'LOCL' .
CONSTANTS lc_printer TYPE tddevice VALUE 'PRINTER'. "'MAIL' .
CONSTANTS lc_raw TYPE so_obj_tp VALUE 'RAW' .
CONSTANTS lc_pdf TYPE so_obj_tp VALUE 'PDF' .
CONSTANTS lc_colon TYPE char1 VALUE ':' .
CONSTANTS lc_slash TYPE char1 VALUE '/' .
CONSTANTS lc_int TYPE char3 VALUE 'INT' .
data: content type BCSY_TEXT.
*data: content1 type SOLI_TAB.
data: it_attach type standard table of soli.
parameters: mailid type AD_SMTPADR DEFAULT 'emailid',
subject type SOOD-OBJDES,
ext type SOODK-OBJTP,
ATTACH type SOOD-OBJDES.
APPEND 'THIS IS AN AUTO GENERATED MAIL' TO CONTENT.
APPEND 'THIS IS AN AUTO GENERATED MAIL CONTENT' TO IT_ATTACH.
*---- Get name of the function module for smartform 'YTEST4'
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = lv_form_name
IMPORTING
fm_name = lv_func_mod
EXCEPTIONS
no_form = 1
no_function_module = 2
OTHERS = 3.
*---- Check function module name is not initial.
IF NOT lv_func_mod IS INITIAL.
*------ Select default printer based on User settings
SELECT SINGLE spld
FROM usr01
INTO usr01-spld
WHERE bname = sy-uname.
IF sy-subrc IS INITIAL.
lwa_compop-tddest = usr01-spld. "Device type
ELSE.
lwa_compop-tddest = lc_locl. "Device type
ENDIF.
lwa_compop-tdnoprev = 'X'. "lc_x. "No print preview
lwa_compop-tdnoprint = 'X'. "lc_x. "No printing from print preview
lwa_compop-tdiexit = lc_x.
lwa_compop-tddelete = 'X'.
*------ Setting control parameters
lwa_ctrlop-getotf = lc_x.
lwa_ctrlop-no_dialog = 'X'.
lwa_ctrlop-device = lc_printer.
lwa_ctrlop-PREVIEW = space.
*------ Call smartform function module
CALL FUNCTION lv_func_mod
EXPORTING
control_parameters = lwa_ctrlop
output_options = lwa_compop
user_settings = 'X'
IMPORTING
job_output_info = lwa_return
TABLES
CONTENT = CONTENT[]
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
OTHERS = 5.
*------ If smartform function module successful
IF sy-subrc EQ 0.
*----
Transfer OTF data to internal table LIT_OTF
lit_otf[] = lwa_return-otfdata[].
*----
Convert to PDF
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF'
max_linewidth = 132
IMPORTING
bin_filesize = lv_len_in
TABLES
otf = lit_otf
lines = lit_tline
EXCEPTIONS
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 3
OTHERS = 4.
*----
If above function module is successful
IF sy-subrc EQ 0.
APPEND lwa_objtxt TO lit_objtxt.
MOVE CONTENT[] TO LIT_OBJTXT[]. "----THE MAIL CONTENT IS SAME AS THE INTERNAL TABLE ATTACHMENT CONTENT
*----
Document size
CLEAR: lv_lines, lwa_objtxt.
DESCRIBE TABLE lit_objtxt LINES lv_lines.
READ TABLE lit_objtxt INTO lwa_objtxt INDEX lv_lines.
*----
Populate packing list for body text
CLEAR lwa_objpack.
lwa_objpack-head_start = 1.
lwa_objpack-head_num = 0.
lwa_objpack-body_start = 1.
lwa_objpack-body_num = lv_lines.
lwa_objpack-doc_type = lc_raw.
APPEND lwa_objpack TO lit_objpack.
CLEAR lwa_objpack.
*----
Mail subject line
CLEAR lwa_doc_data.
lwa_doc_data-obj_name = subject .
lwa_doc_data-obj_descr = subject .
lwa_doc_data-doc_size = ( lv_lines - 1 ) * 255 + STRLEN( lwa_objtxt ).
*----
Populating internal table LIT_OBJBIN
LOOP AT lit_tline INTO lwa_tline.
TRANSLATE lwa_tline USING ' ~'.
CONCATENATE lv_buffer lwa_tline INTO lv_buffer.
ENDLOOP.
TRANSLATE lv_buffer USING '~ '.
DO.
APPEND lv_buffer TO lit_objbin.
SHIFT lv_buffer LEFT BY 255 PLACES.
IF lv_buffer IS INITIAL.
EXIT.
ENDIF.
ENDDO.
*----
Get total no.of lines of Object table(attachment)
CLEAR lv_lines.
DESCRIBE TABLE lit_objbin LINES lv_lines.
*----
Packing list for attachment
lwa_objpack-transf_bin = lc_x .
lwa_objpack-head_start = 1 .
lwa_objpack-head_num = 1 .
lwa_objpack-body_start = 1 .
lwa_objpack-body_num = lv_lines.
lwa_objpack-doc_type = lc_pdf .
lwa_objpack-obj_name = ATTACH.
lwa_objpack-obj_descr = ATTACH.
lwa_objpack-doc_size = lv_lines * 255.
APPEND lwa_objpack TO lit_objpack.
CLEAR lwa_objpack.
*----
Giving the receiver email-id
CLEAR lwa_receiver.
lwa_receiver-receiver = MAILID.
lwa_receiver-rec_type = lc_c.
APPEND lwa_receiver TO lit_receiver.
*----
Calling the function module to sending email
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = lwa_doc_data
put_in_outbox = lc_x
commit_work = lc_x
TABLES
packing_list = lit_objpack
contents_bin = lit_objbin
contents_txt = lit_objtxt
receivers = lit_receiver
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 EQ 0.
*----
Wait upto 2 secounds
WAIT UP TO 2 SECONDS.
*----
Call the RSCONN01 (SAPconnect: Start Send Process)
SUBMIT rsconn01 WITH mode = lc_int
WITH output = 'X'
AND RETURN.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
REFRESH: lit_otf , lit_tline ,
lit_objtxt , lit_objpack, lit_objbin , lit_receiver.
CLEAR: lwa_ctrlop , lwa_compop , lwa_return , lwa_tline ,
lwa_objtxt , lwa_objpack, lwa_doc_data, lwa_objbin ,
lwa_receiver.
CLEAR: lv_func_mod , lv_len_in , lv_time , lv_time2 ,
lv_date2 , lv_info , lv_lines , lv_buffer .
Well here is the solution...
For PRINTING DIRECTLY
ST_CONTROL_PARAMETERS-PREVIEW = ' '.
ST_CONTROL_PARAMETERS-NO_DIALOG = 'X'.
ST_OUTPUT_OPTIONS-TDIMMED = 'X'.
CALL FUNCTION v_fm_name
EXPORTING
ARCHIVE_INDEX =
ARCHIVE_INDEX_TAB =
ARCHIVE_PARAMETERS =
CONTROL_PARAMETERS = st_control_parameters
MAIL_APPL_OBJ =
MAIL_RECIPIENT =
MAIL_SENDER =
OUTPUT_OPTIONS = st_output_options
USER_SETTINGS = 'X'
IMPORTING
DOCUMENT_OUTPUT_INFO = st_document_output_info
JOB_OUTPUT_INFO = st_job_output_info
JOB_OUTPUT_OPTIONS = st_job_output_options
TABLES
IS_LABELS = IS_LABELS
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.
In case u do not have the printer settings maintained for teh user then u have to supply the printer name yourself..otherwise it will pop up again..U have to fill up these parametrs also
ST_OUTPUT_OPTIONS-TDDEST
ST_OUTPUT_OPTIONS-TDPRINTER
and make the USER_SETTINGS = space
st_control_parameter type SSFCTRLOP
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello,
1.Check value of lwa_compop-TDDEST.
Put break-point and chk. Pass some value to lwa_compop-TDDEST.
If it wil empty then dialog will appear even if you have pass
no_dialog = 'X'.
Please check value of lwa_compop-TDDEST and pass some output device to it.
2.Pass value of
user_settings = ' '. U have passed it as 'X'.
Pass space thr.
Edited by: Anil Mane on Aug 7, 2008 3:25 PM
Edited by: Anil Mane on Aug 7, 2008 3:29 PM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Check the below which creates the PDF from OTF, but use this format to mail in your program. It may help you.
The below program is set to the default printer, no dialog, no preview. So this helps you.
Variable declarations
DATA:
w_form_name TYPE tdsfname VALUE 'ZTEST_R1',
w_fmodule TYPE rs38l_fnam,
w_cparam TYPE ssfctrlop,
w_outoptions TYPE ssfcompop,
w_bin_filesize TYPE i, " Binary File Size
w_file_name TYPE string,
w_file_path TYPE string,
w_full_path TYPE string.
Internal tables declaration
Internal table to hold the OTF data
DATA:
t_otf TYPE itcoo OCCURS 0 WITH HEADER LINE,
Internal table to hold OTF data recd from the SMARTFORM
t_otf_from_fm TYPE ssfcrescl,
Internal table to hold the data from the FM CONVERT_OTF
t_pdf_tab LIKE tline OCCURS 0 WITH HEADER LINE.
This function module call is used to retrieve the name of the Function
module generated when the SMARTFORM is activated
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = w_form_name
IMPORTING
fm_name = w_fmodule
EXCEPTIONS
no_form = 1
no_function_module = 2
OTHERS = 3.
IF sy-subrc NE 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
Calling the SMARTFORM using the function module retrieved above
GET_OTF parameter in the CONTROL_PARAMETERS is set to get the OTF
format of the output
w_cparam-no_dialog = 'X'.
w_cparam-preview = space. " Suppressing the dialog box
" for print preview
w_cparam-getotf = 'X'.
Printer name to be used is provided in the export parameter
OUTPUT_OPTIONS
w_outoptions-tddest = 'LP01'.
CALL FUNCTION w_fmodule
EXPORTING
control_parameters = w_cparam
output_options = w_outoptions
IMPORTING
job_output_info = t_otf_from_fm
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
OTHERS = 5.
IF sy-subrc NE 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
t_otf[ ] = t_otf_from_fm-otfdata[ ].
Function Module CONVERT_OTF is used to convert the OTF format to PDF
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF'
max_linewidth = 132
IMPORTING
bin_filesize = w_bin_filesize
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 NE 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
--> Mail this t_pdf_tab which is the converted PDF from OTF.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
81 | |
10 | |
10 | |
9 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.