Application Development 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: 

Download PDF to UNIX

Former Member
0 Kudos

Hi,

I have a sap script which I am converting to PDF using FM CONVERT_OTF_TO_PDF. Then I am transferring this converted data to UNIX in binary mode as a '.pdf' file. This file shows me hashes. If I try to download this file fromunix to pc, its not readable. Its damaged.

Is there any other way to transfer this converted pdf data to unix which will be finally readable if i download it to pc?

Thanks,

Sheetal.

1 REPLY 1

Former Member
0 Kudos

Hi,

I had the same problem: CR LF (hex 0D 0A or char 13 and char 10) are seen as normal characters instead of deviding characters. Your data are therefore devided at a fixed rate, so control words are not interpreted when reading your file.

Try:

OPEN DATASET ser_file FOR OUTPUT IN TEXT MODE MESSAGE MSG.

PERFORM save_data. " i@ps040407

CLOSE DATASET ser_file. " i@ps040407

***********************************************************************

  • S A V E _ D A T A *

***********************************************************************

FORM save_data. " i@ps040407

DATA: lv_raw TYPE xstring,

trenn TYPE i,

lv_spacetrenn(1).

  • Defining a hexstring "constant"

DATA: cc_trenn TYPE xstring. cc_trenn = '0D0A'.

CLEAR lv_spacetrenn.

LOOP AT pdf.

  • Was there a space at the end of the previous line?

IF lv_spacetrenn IS INITIAL.

CONCATENATE lv_raw pdf INTO lv_raw.

ELSE.

  • If there was, keep this space while concatenating

CONCATENATE lv_raw pdf INTO lv_raw SEPARATED BY SPACE.

ENDIF.

  • Check last character in this line

IF pdf-tdline130(1) NE SPACE AND pdf-tdline131(1) = SPACE.

lv_spacetrenn = 'X'.

ELSE.

CLEAR lv_spacetrenn.

ENDIF.

  • Separate line at CR LF (carriage return & line feed = End of Line)

FIND cc_trenn IN lv_raw MATCH OFFSET trenn.

WHILE sy-subrc = 0.

TRANSFER lv_raw(trenn) TO ser_file.

lv_raw = lv_raw+trenn.

lv_raw = lv_raw+2.

FIND cc_trenn IN lv_raw MATCH OFFSET trenn.

ENDWHILE.

ENDLOOP.

ENDFORM.

Good luck

Paul