Hello SDN members,
I have a technical question about printing. Because of a very special project I need to send data to label printers via SAP spool. Smartforms or Adobe Interactive forms are not a possible alternative for us at this moments. We want to embed dynamically some bitmaps. That means, that I have to send data directly in printers language. For this I use a procedure like
NEW-PAGE PRINT ON DESTINATION ...
WRITE ....
WRITE ....
NEW-PAGE PRINT OFF.
This report runs for several years. Now we must implenet new fuctionality of printing bitmaps. While implementing this, I recognized that the WRITE command will cut longer data or add a line feed (0x0A) automatically to the output stream if data exeeds a special line length. The new functionality is to print bitmaps, embetted by transaction SE78. For this I have to send the full bitmap data to the printer. Unfortunatly WRITE damages this data stream by inserting line feed.
Example: this is a section of the spool data, copied by CTRL+Y and CTRL+C.
{RC004;Bitmap test ...}{SG;0300,0500,0000,0000,2,
424D52000000000000003E00000028000000050000
0005000000010001000000000000000000232E0000
232E00000000000000000000FFFFFF000000000087}
{XS;I,0001,0002C5100}{U1;0120}
But I need a "longer" stream without line feeds like this:
{RC004;Bitmap test ...}{SG;0300,0500,0000,0000,2,424D52000000000000003E000000280000000500000005000000010001000000000000000000232E0000232E00000000000000000000FFFFFF000000000087}
{XS;I,0001,0002C5100}{U1;0120}
I think this is because SAP spool inserts a line feed because of the paper (or list) size.
How can I prevent this ? Other possibilities ?
Here you can see the code snippet
DATA: lv_sg TYPE string,
lxstr_data TYPE xstring,
lstr_data TYPE string,
lv_max TYPE i,
lstr_line TYPE string,
lv_pos TYPE i,
lv_line_cnt TYPE i.
......
......
* get the bitmap data stream
CALL METHOD cl_ssf_xsf_utilities=>get_bds_graphic_as_bmp
EXPORTING
p_object = 'GRAPHICS'
p_name = iv_bitmap_name
p_id = 'BMAP'
p_btype = 'BMON'
RECEIVING
p_bmp = lxstr_data
EXCEPTIONS
not_found = 1
internal_error = 2
OTHERS = 3.
* convert to string
lstr_data = lxstr_data.
......
......
CONCATENATE '{SG;' lv_offx ',' lv_offy ',' lv_sizex ',' lv_sizey ',2,'
INTO lv_sg.
* send to printer
write lv_sg.
* send bitmap data
write lstr_data.
* send terminator to printer
write '|}'.
The Result was a single but cutted data line, like:
{RC004;Bitmap test ...}{SG;0300,0500,0000,0000,2,424D52000000000000003E0000002800
The cutted part of the stream is lost then. So I tried to separate the data into smaller parts, like this:
******************************
* create header
******************************
CONCATENATE '{SG;' lv_offx ',' lv_offy ',' lv_sizex ',' lv_sizey ',2,'
INTO lv_sg.
* send to printer
write lv_sg.
*******************************
* loop for bitmap data
*******************************
* convert to string
lstr_data = lxstr_data.
* get length of data
lv_max = STRLEN( lstr_data ).
* loop about the length <=this workaround is made to part the full stream into smaller data streams
DO lv_max TIMES.
lv_pos = sy-index - 1. "fix the line counter
* add character to line buffer
CONCATENATE lstr_line lstr_data+lv_pos(1) INTO lstr_line.
* if line buffer > 40
IF lv_line_cnt > 40.
lv_line_cnt = 0. "reset line buffer
write lstr_line . "send line buffer to printer
CLEAR lstr_line. "clear line buffer
ELSE.
* increase line buffer counter
lv_line_cnt = lv_line_cnt + 1.
ENDIF.
ENDDO.
*******************************
* create terminator
*******************************
* send terminator to printer
write '|}'.
This leads to the effect, that SAP inserts line feed.
Any idea ?!
Thank you for helping me ...
Regards,
Markus