Skip to Content

Problem in file format

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

1.PNG (8.5 kB)
2.PNG (9.8 kB)
Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on May 31, 2013 at 08:53 AM

    Hi Ashish,

    Check both the Server "Output Devices" , "Device Type" are same using SPAD T-code .

    Regard's

    Smruti

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 31, 2013 at 08:43 AM

    There can be different printer settings.Contact your basis team and confirm.

    Thanks

    Akankshi

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 31, 2013 at 08: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.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.