Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

ALV to PDF conversion problem

Former Member
0 Likes
515

Hi Gurus,

I have 17 fields in ALV output ,which is to be converted into PDF report,

in normal layout it is converting only 5 fields into pdf (truncating rest of the fields )

while in landscape layout data is splliting into 2 lines ,and as a result pdf is not coming properly.

is there any way of doing this ,so that all fields can come in single line of PDF without truncating the data.

Please Respond,

Points will be rewarded ,

Regards

Talwinder

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
482

Hi

try by using this FM 'CONVERT_OTF'

CALL FUNCTION 'CONVERT_OTF'

EXPORTING

format = 'PDF'

max_linewidth = 132

ARCHIVE_INDEX = ' '

COPYNUMBER = 0

ASCII_BIDI_VIS2LOG = ' '

IMPORTING

bin_filesize = bin_filesize

BIN_FILE =

TABLES

otf = tab_otf_final

lines = pdf_tab

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.

************downloading the converted PDF data to your local PC*******

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

bin_filesize = bin_filesize

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'

IMPORTING

filelength = file_size

TABLES

data_tab = pdf_tab

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.

ENDIF.

3 REPLIES 3
Read only

Former Member
0 Likes
483

Hi

try by using this FM 'CONVERT_OTF'

CALL FUNCTION 'CONVERT_OTF'

EXPORTING

format = 'PDF'

max_linewidth = 132

ARCHIVE_INDEX = ' '

COPYNUMBER = 0

ASCII_BIDI_VIS2LOG = ' '

IMPORTING

bin_filesize = bin_filesize

BIN_FILE =

TABLES

otf = tab_otf_final

lines = pdf_tab

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.

************downloading the converted PDF data to your local PC*******

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

bin_filesize = bin_filesize

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'

IMPORTING

filelength = file_size

TABLES

data_tab = pdf_tab

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.

ENDIF.

Read only

0 Likes
482

Try with this standard report

RSTXPDFT4

Check this sample code

http://www.erpgenie.com/abap/code/abap51.htm

Regards

Nanda

Read only

former_member404244
Active Contributor
0 Likes
482