on 09-13-2007 4:55 AM
Dear All,
Requirement: PO sapscript layout after some modifications (say, ZMEDRUCK) has to be converted to pdf. Through me9f user will be able to give ranges of PO numbers and can view the print preview for the po. After that on clicking the print button we get the printout of the pos one after another based on the user input of PO numbers.
Our requirement is that when the user will click on the "Print Preview" of po (rather than pressing the print button) it i.e. PO sapscript layout has to get converted to pdf.
If you have already encountered this scenario, could you please send me the source code regarding this at the earliest. If you want to email it to my personal id, please let me know so that I can give it to you. Thank you.
It will be very beneficial for mine if you can send me some source code in this regard. (FYI. We want only Print output of PO sapscript. So, Print Program /SMB40/FM06P [after copying it to our ZSMB40/FM06P program] need to be modified for downloading the PO into PDF where there is no FMs like OPEN_FORM, WRITE_FORM, CLOSE_FORM. So already available source code in SAP forums can not help me.)). Kindly help me at the earliest. Its VERY URGENT
Thank you.
Thanks & Regards
Sudipta
yes.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Try this, also go through this useful link with code https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/49e15474-0e01-0010-9cba-e62df824...
Rough idea
**Set printer parameters
control_param-no_dialog = 'X'.
control_param-preview = ''.
control_param-getotf = 'X'.
output_opt-tddest = 'LOCL'.
output_opt-tdimmed = ''.
output_opt-tdnewid = ''.
output_opt-tdnoprint = ''.
output_opt-tdnoprev = 'X'.
Get smartform name
call function 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = formname
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 smartform
call function fm_name
EXPORTING
control_parameters = control_param
output_options = output_opt
user_settings = ' '
wa_head = wa_head
IMPORTING
job_output_info = job_info
TABLES
int_detail = int_detail
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
others = 5.
Note pass the job info file you got from above function module
data: int_docs type standard table of docs,
int_line type standard table of tline.
call function 'CONVERT_OTF_2_PDF'
IMPORTING
bin_filesize = filesize
TABLES
otf = job_info-otfdata
doctab_archive = int_docs
lines = int_line
EXCEPTIONS
err_conv_not_possible = 1
err_otf_mc_noendmarker = 2
others = 3.
USE below function module
all method cl_gui_frontend_services=>gui_download
exporting
bin_filesize = filesize
filename = filename
filetype = 'BIN'
changing
data_tab = int_line
Regards,
Sairam
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
check code with temp script and check
REPORT ztestprg MESSAGE-ID zoar.
TYPES : BEGIN OF ty_itab,
kunnr TYPE kna1-kunnr,
name1 TYPE kna1-name1,
land1 TYPE kna1-land1,
END OF ty_itab.
***Start New
DATA : struct TYPE itcpo,
pdftab TYPE TABLE OF tline WITH HEADER LINE,
datab TYPE TABLE OF itcoo WITH HEADER LINE.
DATA : binfilesize TYPE i,
file_name TYPE string,
file_path TYPE string,
full_path TYPE string.
To specify Printer name
struct-tddest = 'LP01'.
To specify no Print Preview
struct-tdnoprev = 'X'.
To access the SAP Script output in OTF format
struct-tdgetotf = 'X'.
struct-tdnewid = 'X'.
***End New
DATA : gt_itab TYPE STANDARD TABLE OF ty_itab,
wa_itab LIKE LINE OF gt_itab.
SELECT kunnr name1 land1 FROM kna1 INTO TABLE gt_itab
UP TO 20 ROWS.
CALL FUNCTION 'OPEN_FORM'
EXPORTING
application = 'TX'
ARCHIVE_INDEX =
ARCHIVE_PARAMS =
device = 'PRINTER'
dialog = ' '
<b>form = 'ZPDF'</b>
language = sy-langu
OPTIONS = struct
MAIL_SENDER =
MAIL_RECIPIENT =
MAIL_APPL_OBJECT =
raw_data_interface = '*'
SPONUMIV =
IMPORTING
LANGUAGE =
NEW_ARCHIVE_PARAMS =
RESULT =
EXCEPTIONS
canceled = 1
device = 2
form = 3
OPTIONS = 4
unclosed = 5
mail_options = 6
archive_error = 7
invalid_fax_number = 8
more_params_needed_in_batch = 9
spool_error = 10
codepage = 11
OTHERS = 12
.
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 'START_FORM'
EXPORTING
<b>form = 'ZPDF'</b>
language = sy-langu
startpage = 'PAGE_01'
<b>program = 'ZTESTPRG'</b>.
LOOP AT gt_itab INTO wa_itab.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'ABAP'
window = 'MAIN'.
ENDLOOP.
CALL FUNCTION 'END_FORM'.
*
*
CALL FUNCTION 'CLOSE_FORM'
IMPORTING
RESULT =
RDI_RESULT =
TABLES
otfdata = datab[]
EXCEPTIONS
unopened = 1
bad_pageformat_for_print = 2
send_error = 3
spool_error = 4
codepage = 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.
*
*----
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF'
MAX_LINEWIDTH = 132
ARCHIVE_INDEX = ' '
COPYNUMBER = 0
ASCII_BIDI_VIS2LOG = ' '
PDF_DELETE_OTFTAB = ' '
IMPORTING
bin_filesize = binfilesize
BIN_FILE =
TABLES
otf = datab[]
lines = pdftab[]
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.
----
CALL METHOD cl_gui_frontend_services=>file_save_dialog
EXPORTING
WINDOW_TITLE =
DEFAULT_EXTENSION =
DEFAULT_FILE_NAME =
FILE_FILTER =
INITIAL_DIRECTORY =
WITH_ENCODING =
PROMPT_ON_OVERWRITE = 'X'
CHANGING
filename = file_name
path = file_path
fullpath = full_path
USER_ACTION =
FILE_ENCODING =
EXCEPTIONS
CNTL_ERROR = 1
ERROR_NO_GUI = 2
NOT_SUPPORTED_BY_GUI = 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.
----
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
bin_filesize = binfilesize
filename = full_path
filetype = 'BIN'
APPEND = ' '
WRITE_FIELD_SEPARATOR = ' '
HEADER = '00'
TRUNC_TRAILING_BLANKS = ' '
WRITE_LF = 'X'
COL_SELECT = ' '
COL_SELECT_MASK = ' '
DAT_MODE = ' '
CONFIRM_OVERWRITE = ' '
NO_AUTH_CHECK = ' '
CODEPAGE = ' '
IGNORE_CERR = ABAP_TRUE
REPLACEMENT = '#'
WRITE_BOM = ' '
TRUNC_TRAILING_BLANKS_EOL = 'X'
WK1_N_FORMAT = ' '
WK1_N_SIZE = ' '
WK1_T_FORMAT = ' '
WK1_T_SIZE = ' '
IMPORTING
FILELENGTH =
TABLES
data_tab = pdftab[]
FIELDNAMES =
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.
Rewards if useful...................
Minal
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
92 | |
11 | |
10 | |
9 | |
9 | |
7 | |
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.