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

Problem with function modules 'TABLE_COMPRESS' and 'TABLE_DECOMPRESS'

Former Member
0 Likes
1,631

hi guys,

I have a requirement such that i have to compress the POs which are processed and then store it in a system such that user will be able to see the POs at a later stage also.

POs are to be converted to PDF format and then compressed before saving so as to save the disk space and hence they have to be decompressed before viewing.

Currently I am using fucntion module FUNCTION 'CONVERT_OTF_2_PDF' to conver PO to PDF format, 'TABLE_COMPRESS' to compress and 'TABLE_DECOMPRESS' to decompress.

The issue is that :- These function modules are working fine for english text but in my PO i have chinese characters also and these function modules give wierd characters in place of chinese characters. Please help me with some other function modules which can even compress chinese characters properly.

thanks

Rahul

11 REPLIES 11
Read only

Former Member
0 Likes
1,351

Hi Rahul,

I guess the problem is not in the function 'TABLE_COMPRESS'.

The problem occured when you generate OTF.

To prove my guess is correct. You can try to download your PDF internal table into a PDF file in the presentation by using FM: GUI_DOWNLOAD.

I guess you will see wierd characters instead of chines characters...in the PDF file.

My suggestion that you have to use printer which support chinese characters when generating the OTF.

Regards,

Hendy

Read only

0 Likes
1,351

Hi Hendy,

Thanks for the reply. Can you please elaborate your statement " use printer which support chinese characters when generating the OTF." because I am unable to find the connection between Function module 'CONVERT_OTF_2_PDF' and printer.

Presently I am using the following code:-

<u>For converting OTF to PDF and compressing:-</u>

CALL FUNCTION 'CONVERT_OTF_2_PDF'

IMPORTING

bin_filesize = v_numbytes

TABLES

otf = in_otf

doctab_archive = i_doc_archive

lines = i_pdf

EXCEPTIONS

err_conv_not_possible = 1

err_otf_mc_noendmarker = 2

OTHERS = 3.

IF sy-subrc <> 0.

MESSAGE e000(zzg_all01_general) WITH l_ebeln

'Unable to create PDF through OTF'.

EXIT.

ENDIF.

  • Compress PDF

CALL FUNCTION 'TABLE_COMPRESS'

IMPORTING

compressed_size = v_numbytes2

TABLES

in = i_pdf

out = i_pdf_out

EXCEPTIONS

compress_error = 1

OTHERS = 2.

IF sy-subrc <> 0.

MESSAGE e000(zzg_all01_general) WITH l_dest_po_num

' Compression and Storage'

'Failed'.

EXIT.

ENDIF.

<u>For Decompressing and viewing the PDF:-</u>

  • Decompress table

CALL FUNCTION 'TABLE_DECOMPRESS'

TABLES

in = i_clines

out = i_pdf

EXCEPTIONS

compress_error = 1

table_not_compressed = 2

OTHERS = 3.

IF sy-subrc NE 0.

MESSAGE i000(zzg_all01_general) WITH

'Table decompression failed'.

EXIT.

ENDIF.

  • Download file to presentation server

CALL FUNCTION 'WS_DOWNLOAD'

EXPORTING

bin_filesize = in_table-filesize

filename = l_filedest

filetype = 'BIN'

IMPORTING

filelength = v_numbytes

TABLES

data_tab = i_pdf

EXCEPTIONS

file_open_error = 1

file_write_error = 2

invalid_filesize = 3

invalid_type = 4

no_batch = 5

unknown_error = 6

invalid_table_width = 7

gui_refuse_filetransfer = 8

customer_error = 9

OTHERS = 10.

IF sy-subrc NE 0.

IF sy-subrc EQ 2.

MESSAGE i000(zzg_all01_general) WITH 'Download error.'

'Please close the file if already opened.'.

ELSE.

MESSAGE i000(zzg_all01_general) WITH 'Download error.'.

ENDIF.

EXIT.

ENDIF.

  • Display PDF file

CALL FUNCTION 'WS_EXECUTE'

EXPORTING

  • DOCUMENT = ' '

  • CD = ' '

commandline = l_filedest

  • INFORM = ' '

program = 'ACRORD32'

  • STAT = ' '

  • WINID = ' '

  • OSMAC_SCRIPT = ' '

  • OSMAC_CREATOR = ' '

  • WIN16_EXT = ' '

  • EXEC_RC = ' '

  • IMPORTING

  • RBUFF =

EXCEPTIONS

frontend_error = 1

no_batch = 2

prog_not_found = 3

illegal_option = 4

gui_refuse_execute = 5

OTHERS = 6.

After that a PDF file a generated, which shows something else in place of chinese characters.

Read only

0 Likes
1,351

Hi Rahul,

"use printer which support chinese characters when generating the OTF."

You can set the printer name when calling FM for SMARTFORMS/SAPSCRIPT to generate OTF intenal table.

(I assume you generate the OTF internal table from SMARTFORMS/SAPSCRIPT)

e.g. : in SMARTFORMS

DATA fs_ssfcompop TYPE ssfcompop.

CLEAR: fs_ssfcompop.

fs_ssfcompop-tddest = '????'. "Printer which support chinese characters

CALL FUNCTION fm_smartforms

EXPORTING

output_options = fs_ssfcompop

To find the correct printer you can ask your basis guys or goto tcode SPAD.

To find out which printer/ouput devices that support chinese characters, in the tcode SPAD you can search printer that using device type which support chinese characters, for example device type CNHPLJ4(HP LaserJet PCL-5 Simp.Chinese).

Regards,

Hendy

Read only

0 Likes
1,351

Hi Hendy,

I tried changing the printer to a printer with type CNHPLJ4.

This time the PDF that is generated after using 'WS_DOWNLOAD' is BLANK.

During debugg is found that the OTF internal table has some value (783 records) and after decompression by TABLE_DECOMPRESS i_pdf (internal table to store PDF) has 6483 records.

But after running WS_DOWNLOAD and WS_EXECUTE (which calls ACRORD32), a PDF file is shown and a pop-up appears "No updated at this time"

And ultimately a blank PDF is generated. Where as in ME23N i can see the extected output.

Please suggest on this.Can there be any prob with WS_DOWNLOAD that can be solved by GUI_DOWNLOAD or is this something else now?

Thanks

Rahul

Read only

0 Likes
1,351

Hi Rahul,

I suggest you to use GUI_DOWNLOAD... since WS_DOWNLOAD is obsolete.

You can try the following code (these codes are working fine in my system).

note: dont forget to change SMARTFORMS and Printer Name accordingly..

DATA in_otf LIKE itcoo OCCURS 0 WITH HEADER LINE.

DATA i_doc_archive LIKE docs OCCURS 0 WITH HEADER LINE.

DATA i_pdf LIKE tline OCCURS 0 WITH HEADER LINE.

DATA i_pdf_out LIKE tline OCCURS 0 WITH HEADER LINE.

DATA fs_ssfctrlop LIKE ssfctrlop.

DATA fs_ssfcompop TYPE ssfcompop.

DATA wa_ssfcresop TYPE ssfcresop .

DATA output_data TYPE ssfcrescl.

CLEAR: fs_ssfcompop, fs_ssfctrlop.

fs_ssfcompop-tdnewid = 'X'.

fs_ssfcompop-tdimmed = space .

fs_ssfcompop-tddest = 'HPLJ'. "Printer Name

fs_ssfctrlop-no_dialog = 'X'.

fs_ssfctrlop-getotf = 'X'.

CALL FUNCTION '/1BCDWB/SF00000117'

EXPORTING

control_parameters = fs_ssfctrlop

output_options = fs_ssfcompop

user_settings = space

IMPORTING

job_output_info = output_data

EXCEPTIONS

formatting_error = 1

internal_error = 2

send_error = 3

user_canceled = 4

OTHERS = 5.

in_otf[] = output_data-otfdata[].

CALL FUNCTION 'CONVERT_OTF_2_PDF'

TABLES

otf = in_otf

doctab_archive = i_doc_archive

lines = i_pdf

EXCEPTIONS

err_conv_not_possible = 1

err_otf_mc_noendmarker = 2

OTHERS = 3.

IF sy-subrc <> 0.

MESSAGE e000(zzg_all01_general) WITH

'Unable to create PDF through OTF'.

EXIT.

ENDIF.

  • Compress PDF

CALL FUNCTION 'TABLE_COMPRESS'

TABLES

in = i_pdf

out = i_pdf_out

EXCEPTIONS

compress_error = 1

OTHERS = 2.

IF sy-subrc <> 0.

MESSAGE e000(zzg_all01_general) WITH

' Compression and Storage'

'Failed'.

EXIT.

ENDIF.

*for decompressing and viewing the pdf:-

  • Decompress table

CLEAR i_pdf[].

CALL FUNCTION 'TABLE_DECOMPRESS'

TABLES

in = i_pdf_out

out = i_pdf

EXCEPTIONS

compress_error = 1

table_not_compressed = 2

OTHERS = 3.

IF sy-subrc NE 0.

MESSAGE i000(zzg_all01_general) WITH

'Table decompression failed'.

EXIT.

ENDIF.

  • Download file to presentation server

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

filename = 'C:\test.pdf'

filetype = 'BIN'

TABLES

data_tab = i_pdf

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.

  • Display PDF file

CALL FUNCTION 'WS_EXECUTE'

EXPORTING

commandline = 'C:\test.pdf'

program = 'ACRORD32'

EXCEPTIONS

frontend_error = 1

no_batch = 2

prog_not_found = 3

illegal_option = 4

gui_refuse_execute = 5

OTHERS = 6.

Read only

0 Likes
1,351

Hi Hendy,

sorry to disturb u again

Actually in my case I am using SAPCRIPT and not SMART-FORM and I am generating the OTF from spool-request.

So i could not use :-

fs_ssfcompop-tdnewid = 'X'.

fs_ssfcompop-tdimmed = space .

fs_ssfcompop-tddest = 'HPLJ'. "Printer Name

fs_ssfctrlop-no_dialog = 'X'.

fs_ssfctrlop-getotf = 'X'.

In my case i am getting the output from spool and then converting this otf to pdf.

my code is :-

i_otftmp-tdprintcom = 'MT'.

i_otftmp-tdprintpar = '0477300353'.

APPEND i_otftmp.

i_otftmp-tdprintcom = 'FC'.

i_otftmp-tdprintpar = 'HELVE 080 00067XSF005SF005110000044EX'.

  • i_otftmp-tdprintpar = 'CNHEI 080 00067XSF005SF005110000044EX'.

APPEND i_otftmp.

i_otftmp-tdprintcom = 'SW'.

i_otftmp-tdprintpar = '00044'.

APPEND i_otftmp.

i_otftmp-tdprintcom = 'ST' .

IF l_cus_ekorg IS INITIAL. "Ins by ACC027 RT #18330-D16K994829

i_otftmp-tdprintpar = '0196325***** ARCHIVE COPY *****'.

ENDIF. " "Ins by ACC027 RT #18330-D16K994829

APPEND i_otftmp.

CALL FUNCTION 'RSPO_RETURN_SPOOLJOB'

EXPORTING

rqident = l_spoolid

TABLES

buffer = i_buffer_otf

EXCEPTIONS

no_such_job = 1

job_contains_no_data = 2

selection_empty = 3

no_permission = 4

can_not_access = 5

read_error = 6

type_no_match = 7

OTHERS = 8.

in_otf[] = i_buffer_otf[].

CALL FUNCTION 'CONVERT_OTF_2_PDF'

IMPORTING

bin_filesize = v_numbytes

TABLES

otf = in_otf

doctab_archive = i_doc_archive

lines = i_pdf

EXCEPTIONS

err_conv_not_possible = 1

err_otf_mc_noendmarker = 2

OTHERS = 3.

IF sy-subrc <> 0.

MESSAGE e000(zzg_all01_general) WITH l_ebeln

'Unable to create PDF through OTF'.

EXIT.

ENDIF.

  • Compress PDF

CALL FUNCTION 'TABLE_COMPRESS'

IMPORTING

compressed_size = v_numbytes2

TABLES

in = i_pdf

out = i_pdf_out

EXCEPTIONS

compress_error = 1

OTHERS = 2.

IF sy-subrc <> 0.

MESSAGE e000(zzg_all01_general) WITH l_dest_po_num

' Compression and Storage'

'Failed'.

EXIT.

ENDIF.

I have even tried changing the printer in SAPCRIPT (setting it to chinese type) ,in that case i get a blank PDF.

I have changed my function module from WS_DOWNLOAD to GUI_DOWNLOAD.

I have changed the font from HELVE to CNHEI (below given is the code)

i_otftmp-tdprintpar = 'HELVE 080 00067XSF005SF005110000044EX'.

  • i_otftmp-tdprintpar = 'CNHEI 080 00067XSF005SF005110000044EX'.

After changing all this , I am still not getting the desired output.

Please suggest what else can i try.

Thanks a lot

Rahul

Read only

Former Member
0 Likes
1,351

Hi rahul,

1. converting to pdf -


> compresss

2. Before compressing,

3. just save the pdf data

in a file on the local computer using some code.

Then try to open that .pdf file.

4. If the chinese characters are coming here itself,

then it means, the conversion is not working properly!

regards,

amit m.

Read only

0 Likes
1,351

Hi Amit,

I have already tried by removing the codes for compression/decompression....

Still i was not getting the chinese characters printed..

Till now i have tried the following things:-

I have replaced the function module ‘WS_DOWNLOAD’ with ‘GUI_DOWNLOAD’, as ‘WS_DOWNLOAD’ is obsolete now. But still there wasn’t any change in the output. Chinese characters are not getting printed.

I tried changing the font from HELVE to CNHEI in the code.

i_otftmp-tdprintpar = 'HELVE 080 00067XSF005SF005110000044EX'.

  • i_otftmp-tdprintpar = 'CNHEI 080 00067XSF005SF005110000044EX'.

I tried setting a CHINESE type printer in ME23N.

In all the cases there was not any change in the output.

I also tried by removing the codes for COMPRESSION/ DECOMPRESSION to confirm if error was in generation of OTF or because of compression and decompression.

I found that even after removing the compression/ decompression code there was not any change in the output i.e. Chinese characters were still not getting printed.

This confirms that problem is not because of compression and decompression.

Now i want to know wots the problem in the conversion ??

thanks a lot

Rahul

Read only

0 Likes
1,351

Hi rahul,

1. by using some standard tcodes,

if possible,

we should see the output of the purchase order, on screen.

2. Is that coming ok on screen?

regards,

amit m.

Read only

0 Likes
1,351

Hi Amit,

Yes we can see the PO output thru tcode - ME23N directly or by checking the spool request by SP01.... output is perfect there

i.e. both english and chinese characters are getting printed in standard SAP output (ME23N)...

but the same doesnot work in my code...

Thanks

Rahul

Read only

Former Member
0 Likes
1,351

I think the problem was with the version of ACROBAT and now with the functional modules.