‎2013 May 31 9:35 AM
Hi Experts,
My requirement was to convert internal table data to pdf format and download to unix/PC. I have written the content to spool and then converted it to pdf. below is my code. It is working perfectly. i am able to view pdf.
TYPES: BEGIN OF gs_file_unix,
data TYPE c LENGTH 500,
END OF gs_file_unix.
*/..Local data declaration
DATA: li_file_unix TYPE STANDARD TABLE OF gs_file_unix,
lw_file TYPE gs_file_data,
lw_file_unix TYPE gs_file_unix,
lv_amount TYPE c LENGTH 14,
lc_tab TYPE c VALUE cl_abap_char_utilities=>horizontal_tab.
DATA: li_mstr_print_params TYPE pri_params,
lv_mc_valid(1) TYPE c,
ls_data TYPE tline.
DATA: lv_spoolid TYPE tsp01-rqident,
li_data_otf TYPE ehsw_tt_tline.
"Fui_file is internal table , it is populating perfectly
LOOP AT fui_file INTO lw_file.
lv_amount = lw_file-amount.
CONCATENATE lw_file-doc_date
lw_file-account
lw_file-cost_center
lw_file-debit_credit
lv_amount
lw_file-currency
lw_file-item_desc
lw_file-assignment
INTO lw_file_unix-data
SEPARATED BY lc_tab.
APPEND lw_file_unix TO li_file_unix.
CLEAR lv_amount.
ENDLOOP.
*/..call FM to Setup the Print Parmaters
CALL FUNCTION 'GET_PRINT_PARAMETERS'
EXPORTING
authority = space
copies = '1'
cover_page = space
data_set = space
department = space
destination = space
expiration = '1'
immediately = space
new_list_id = 'X'
no_dialog = 'X'
user = sy-uname
IMPORTING
out_parameters = li_mstr_print_params
valid = lv_mc_valid
EXCEPTIONS
archive_info_not_found = 1
invalid_print_params = 2
invalid_archive_params = 3
OTHERS = 4.
*/..Make sure that a printer destination has been set up.
*/.. If this is not done the PDF function module ABENDS
IF li_mstr_print_params-pdest = space.
li_mstr_print_params-pdest = gc_locl.
ENDIF.
*/.. Explicitly set line width, and output format so that the PDF
*/..conversion comes out OK
li_mstr_print_params-linsz = gc_132.
li_mstr_print_params-paart = gc_format.
*/..Generating the SPOOL with the Internal Table Data
NEW-PAGE PRINT ON PARAMETERS li_mstr_print_params
NO DIALOG NO-TITLE NO-HEADING.
LOOP AT li_file_unix INTO lw_file_unix.
WRITE:/ lw_file_unix-data.
ENDLOOP.
lv_spoolid = sy-spono.
NEW-PAGE PRINT OFF.
*/..Generating the PDF from the SPOOL Request
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = lv_spoolid
dst_device = li_mstr_print_params-pdest
TABLES
pdf = li_data_otf.
IF sy-subrc <> 0.
MESSAGE 'Error in converting PDF format'(e04) TYPE gc_error.
ENDIF.
*******************Test Download*******************************
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = 'D:/Test1File.pdf'
filetype = 'BIN'
TABLES
data_tab = li_data_otf.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
When i test this in my development server i can see the format ,this is perfect :
But in testing server same code generates the file having some un-necessary gaps:
I am unable to understand why it is happening if code is working in one server perfectly then it should work in other one also.
Please Reply experts.
Regards,
Ashish
‎2013 May 31 9:53 AM
Hi Ashish,
Check both the Server "Output Devices" , "Device Type" are same using SPAD T-code .
Regard's
Smruti
‎2013 May 31 9:43 AM
There can be different printer settings.Contact your basis team and confirm.
Thanks
Akankshi
‎2013 May 31 9:45 AM
Hi,
Just a wild guess, Check your user settings in both servers. Also debug and see the values in li_data_otf in both the servers.
Thanks.
Ankit.
‎2013 May 31 10:11 AM
‎2013 May 31 9:53 AM
Hi Ashish,
Check both the Server "Output Devices" , "Device Type" are same using SPAD T-code .
Regard's
Smruti
‎2013 May 31 10:10 AM
‎2013 May 31 10:50 AM
Hi Ashish,
Before going to Note can you check below Note is Implemented in your Development Server,(i.e. check with Basis team ) previously ? Check this Note 1645945 - PDF conversion: Incorrect character widths.
is any other program available in your both server whose download PDF Document's , is it same issue for other program or only issue with current program .
Regard's
Smruti
‎2013 May 31 3:37 PM