on 07-01-2015 1:40 PM
Hi,
I am able to create a smart form layout and able to upload the smart form output into pdf by calling the FM 'Convert OTF'.
This FM converts the smart form output into pdf format and then by calling open dataset i am able to upload it into application server.
But i don't know how to convert smart form output into post script format and upload postscript file in application server.
Can any body please tell me.
Hi,
There is also SAPConnect conversion function module SX_OBJECT_CONVERT_OTF_TO_PRT, which is used to convert attachments to Postscript during sending of E-mails from SAP system. It works similarly to the one Juwin found, in that it uses spooler and creates (temporary) file on AS, but it encapsulates spool processing - takes in OTF returned by smartform/sapscript and returns Postscript content (in binary form).
Since there is lots of spool and file handling overhead, IMO it's ill suited for mass processing. Juwin's approach cuts down on some of the overhead since permanent AS file is being created straight away, instead of creating temporary spool system file, which needs to be read back and written to the desired location on AS.
The test programm adapted from SF_EXAMPLE_02 illustrates the use:
Edit in: there was a couplel bugs in the code - I had neglected to pass the file length to gui_download and to check whether user had canceled downloading.
*----------------------------------------------------------------------*
* Report SF_EXAMPLE_01
*----------------------------------------------------------------------*
* Printing of documents using Smart Forms
*----------------------------------------------------------------------*
REPORT zsf_example_01.
DATA: carr_id TYPE sbook-carrid,
fm_name TYPE rs38l_fnam.
PARAMETER: p_custid TYPE scustom-id DEFAULT 1.
SELECT-OPTIONS: s_carrid FOR carr_id DEFAULT 'LH' TO 'LH'.
PARAMETER: p_form TYPE tdsfname DEFAULT 'SF_EXAMPLE_01' obligatory.
DATA: customer TYPE scustom,
bookings TYPE ty_bookings,
connections TYPE ty_connections.
DATA: gs_control_parameters TYPE ssfctrlop,
gs_job_output_info TYPE ssfcrescl,
gt_content_txt TYPE soli_tab ,
gt_content_bin TYPE solix_tab,
gt_objhead TYPE soli_tab,
g_len TYPE so_obj_len,
g_bin_filesize TYPE i,
gf_transfer_bin TYPE abap_bool,
g_filename TYPE string,
g_path TYPE string,
g_fullpath TYPE string,
g_user_action LIKE cl_gui_frontend_services=>action_cancel .
* get data
SELECT SINGLE * FROM scustom INTO customer WHERE id = p_custid.
CHECK sy-subrc = 0.
SELECT * FROM sbook INTO TABLE bookings
WHERE customid = p_custid
AND carrid IN s_carrid
ORDER BY PRIMARY KEY.
SELECT * FROM spfli INTO TABLE connections
FOR ALL ENTRIES IN bookings
WHERE carrid = bookings-carrid
AND connid = bookings-connid
ORDER BY PRIMARY KEY.
* print data
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = p_form
IMPORTING
fm_name = fm_name
EXCEPTIONS
no_form = 1
no_function_module = 2
OTHERS = 3.
IF sy-subrc <> 0.
* error handling
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
EXIT.
ENDIF.
gs_control_parameters-getotf = 'X'.
* now call the generated function module
CALL FUNCTION fm_name
EXPORTING
control_parameters = gs_control_parameters
customer = customer
bookings = bookings
connections = connections
IMPORTING
job_output_info = gs_job_output_info
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
OTHERS = 5.
IF sy-subrc <> 0.
* error handling
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSE .
gt_content_txt[] = gs_job_output_info-otfdata[] .
CALL FUNCTION 'SX_OBJECT_CONVERT_OTF_PRT'
EXPORTING
format_src = 'OTF'
format_dst = 'PS'
devtype = 'POST2'
CHANGING
transfer_bin = gf_transfer_bin
content_txt = gt_content_txt
content_bin = gt_content_bin
objhead = gt_objhead
len = g_len
EXCEPTIONS
err_conv_failed = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSE.
cl_gui_frontend_services=>file_save_dialog(
EXPORTING
default_extension = 'ps'
CHANGING
filename = g_filename
path = g_path
fullpath = g_fullpath
user_action = g_user_action
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.
CHECK g_user_action NE cl_gui_frontend_services=>action_cancel .
g_bin_filesize = g_len.
cl_gui_frontend_services=>gui_download(
EXPORTING
bin_filesize = g_bin_filesize
filename = g_fullpath
filetype = 'BIN'
CHANGING
data_tab = gt_content_bin
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
not_supported_by_gui = 22
error_no_gui = 23
OTHERS = 24
).
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.
ENDIF.
cheers
Jānis
Message was edited by: Jānis B
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Can you please explain why do you need a PS file for?
Thanks
Juwin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Actually they want to migrate from one system to another and add some lines or comments in the post script file and print file...Can you please tell me how to convert the smart form output to post script format and then upload in application server..i think we can upload it by using open dataset and close dataset.
Hi Sushant,
If you analysis the CG3Z t-code, which is used for upload file from local system to application system.
you will get below function module to, which has been used by SAP to store the files in application system.
C13Z_FILE_UPLOAD_ASCII
C13Z_FILE_UPLOAD_BINARY
You can use any one of them to upload the PDF file.You have to convert the OTF data to Bindary format and the use C13Z_FILE_UPLOAD_BINARY FM to save the same in Application server.
Regards,
Praveer.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
there is a way to convert the output to PostScript (Level 2 only). You would need to implement GHOSTSCRIPT on the application servers and implement an external command with SM49. From your ABAP coding you can first create the PDF File and then convert it from PDF to PostScript with the ps2ps2 tool (which is part of the ghostscript package). You can find GHOSTSCRIPT here.
Regards
Oliver
Thanks Oliver.for the answer..Actually what i need is to create a letter in smart form and to upload in pdf format and postscript format in application server.i searched the forum and heard of some fm like OTF_POSTSCRIPT..so is there any way round to convert smart form letter into post script format..or the way you described above through ghost script is the only way..so do we have to purchase ghost script package for application server.
I'm not aware of a function module or a class method that converts OTF to Postscript. That's why I suggested to use an external converter for PDF to Postscript conversion. GHOSTSCRIPT can be used free of charge. If you are on a Plattform other than Windows or Linux you have to compile the sources on your plattform (or try to find the right binaries of maybe an older version via google ,,,).
Regards
Oliver
I looked through the function OTF_POSTSCRIPT, which Sushant mentioned. It has comment saying "use RSPO_PROCESS_DIALOG_JOB to use spooler and device type POSTSCPT to convert OTF to PostScript." I tried calling this new FM, passing the spool request number and it correctly generated the Postscript file.
So, I guess you can use this FM, to generate PS file.
Thanks,
Juwin
It doesn't matter whether its from Smartform or SAPScript. The spool should be of OTF type. Both Smartform and SAPScript, creates OTF spools.
This function needs 3 parameters:
PJIDENT - Spool request number
PJNUMMER - Output request number
DEVICETYPE - POSTSCPT
Spool request number is visible in SP01.
Select the spool request number and open the output requests.
And now you will see the output request number
If you pass all these to the function, it creates a PS file in the application server.
Thanks
Juwin
User | Count |
---|---|
75 | |
9 | |
8 | |
7 | |
6 | |
5 | |
5 | |
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.