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: 

Printing Archived invoice on SAP printers.

Former Member
0 Kudos

Hi experts,

I want to print SAP sales invoice from archived server.

I have used  ARCHIVOBJECT_GET_TABLE to get the binary contents

then we have concatenated the binary data  to buffer in byte mode and have coverted the buffer to binary mode through

 

SCMS_XSTRING_TO_BINARY.

Now i need to wrtie this binary data to spool request.and print on sap perter selected by user.

Can anyone please help in achiving this requirement.

Please find below code.

 

'ARCHIVOBJECT_GET_TABLE'
EXPORTING
archiv_id
= ls_connection-archiv_id
document_type
= 'PDF'
archiv_doc_id
= ls_connection-arc_doc_id
* ALL_COMPONENTS =
SIGNATURE
= 'X'
* COMPID = 'data'
IMPORTING
LENGTH
= length
BINLENGTH
= binlength
TABLES
ARCHIVOBJECT
= archivobject
BINARCHIVOBJECT
= binary_content1
EXCEPTIONS
ERROR_ARCHIV
= 1
ERROR_COMMUNICATIONTABLE
= 2
ERROR_KERNEL
= 3
OTHERS = 4 .

if binary_content1 is not INITIAL.

LOOP AT binary_content1 INTO
lw_binarchivobject
.
CONCATENATE v_buffer lw_binarchivobject-line INTO v_buffer IN BYTE MODE .
ENDLOOP.
**lv_file = lv_desc.
*lt_zipper->add( name = lv_file content = v_buffer ). CLEAR lv_zipfilehex. lv_zipfilehex = lt_zipper->save( ). CLEAR lt_binary_content
*.
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
EXPORTING
buffer = v_buffer
TABLES
binary_tab
= lt_binary_content.

how can i write lt_binary_content to spool.

regards,

Prathamesh Naik.

18 REPLIES 18

Laszlo_B
Active Contributor
0 Kudos

Hello Prathamesh,

if you implement SAP Note 1827856 - "Test program for creating composed spool requests", the new Report "RSPO_TEST_CREATE_SPOOL" will be available in SE38.

The purpose of this Report is to demonstrate how documents can be uploaded and stored in transaction SP01 in binary format.

You can see here how a binary data can be stored in the spool.

Regards,
Laszlo

Former Member
0 Kudos


Hi Laszlo,

I am able to convert the pdf file in Spool request .When we open the spool it shows binary data.Will this print as PDF when we print the spool?.

Sorry,since we don't have access to printer .we need to verify.

Regards,

Prathamesh.

Laszlo_B
Active Contributor
0 Kudos

Hello Prathamesh,

yes, the print data will be the same - the only difference is that in the case of binary spool requests transaction SP01 will not "translate" the data into print preview.

But in the case of PDF data you can print into a file on OS level (to check the result): if you create a file printer on OS level as SAP Note 576973 - "Creating a file printer on a Windows PC" shows, you can print the binary spool into a regular file.

Regards,

Laszlo

Former Member
0 Kudos

Hi Laszlo,

I tried to print the spool but it is printing similar in binary format.

I have used the below code.

'ARCHIVOBJECT_GET_TABLE'
EXPORTING
archiv_id
= ls_connection-archiv_id
document_type
= 'PDF'
archiv_doc_id
= ls_connection-arc_doc_id
* ALL_COMPONENTS =
SIGNATURE
= 'X'
* COMPID = 'data'
IMPORTING
LENGTH
= length
BINLENGTH
= binlength
TABLES
ARCHIVOBJECT
= archivobject
BINARCHIVOBJECT
= binary_content1
EXCEPTIONS
ERROR_ARCHIV
= 1
ERROR_COMMUNICATIONTABLE
= 2
ERROR_KERNEL
= 3
OTHERS = 4 .

if binary_content1 is not INITIAL.

LOOP AT binary_content1 INTO
lw_binarchivobject
.
CONCATENATE v_buffer lw_binarchivobject-line INTO v_buffer IN BYTE MODE .
ENDLOOP.

CALL FUNCTION

'SCMS_XSTRING_TO_BINARY'
EXPORTING
buffer = v_buffer
TABLES
binary_tab
= lt_binary_content.

if lt_binary_content is not INITIAL.

data: i type i value 0, j type i, pages type i.
data: size type i.
data: handle like sy-tabix.
data: spoolid like tsp01-rqident.
data: partname type adspart.
data: cancel type c.
data: adstype type string.


CALL FUNCTION 'RSPO_SR_OPEN'
EXPORTING
dest
= p_print
layout
= 'G_RAW'
* name = sponame
suffix1
= 'BIN'
suffix2
= sy-uname
immediate_print
= ' '
auto_delete
= ' '
doctype
= 'BIN'
IMPORTING
handle
= handle
spoolid
= spoolid
EXCEPTIONS
OTHERS = 1.
* check_rc.
CALL FUNCTION 'RSPO_SR_TABLE_WRITE_BINARY'
EXPORTING
handle
= handle
* CODEPAGE =
* total = bin_filesize
TABLES
lines = lt_binary_content
EXCEPTIONS
handle_not_valid
= 1.
* check_rc.
CALL FUNCTION 'RSPO_SR_CLOSE'
EXPORTING
handle
= handle
final
= 'X'
EXCEPTIONS
handle_not_valid
= 1
operation_failed
= 2.

Can you pelase let me know if there is nay issue.

Regards,

Prathamesh Naik.

0 Kudos

Hi,

I can confirm that a pdf 1.3 created by CONVERT_OTF FM and added to spool using RSPO_TEST_CREATE_SPOOL BIN option prints almost fine on an output device (Xerox WorkCenter 7346) using Berkeley-protocol. Almost, because the contents are zoomed out somewhat (compared to the output via normal OTF spool)... I speculate at the moment that it may have something to do with the margins/printable area - either with what we do or don't do in the custom Postscript device type, or even the default settings of the physical printer itself.

cheers

Janis

Message was edited by: Jānis B

Laszlo_B
Active Contributor
0 Kudos

Hello Prathamesh,

does the printout start with a code like:

%PDF-1.3

<<

/Filter 3 0 R

...etc.?

Regards,

Laszlo

Former Member
0 Kudos

Hi laszlo,

the print is something like that only.Please find the details below.

Please let me know if we can chnage anything.Also it printed 2 lines on every page causing print to 26 pages.

Regards,

Prathamesh.

Laszlo_B
Active Contributor
0 Kudos

Hello Prathamesh,

this looks like the source code of a PDF file. This means: the PDF is stored correctly in R/3, and there seems to be no issues (yet) with the file itself.

The reason why the source code is printed: only a few printers can print "natively" PDF files. If you open a PDF in Adobe Reader, then Reader will convert the file into a print data which will be understood by the printer. But in this scenario there is no Adober Reader, and the PDF data will be sent directly to the printer - which can not "understand" the source code of the PDF, thus it simply prints the commands uninterpreted.

As a solution: if you can print these spools into files, follow the description of SAP Note 576973 - "Creating a file printer on a Windows PC", and print them into regular PDF files. Then you can open these with Adobe Reader, which will handle the actual printing part.

Alternatively: if Access Method G or S is used for printing, you can install and test SAPPDFPrint, which should be able to help printing PDFs. A description of SAPPDFPrint is in the SAP Note 1444342 - "Device type-independent printing of ADS forms".

Regards,

Laszlo

Former Member
0 Kudos

Hi Laszlo,

is there any other way round to convert the binary data into PDF spool.

0 Kudos

Hi Laszlo,

Thank you very much for your valuable informations about SAP printing - keep up the good work!

I'm afraid my question is too generic, but... assuming I have an archived pdf, the "information" regarding the pages the pdf contains (simplex/duplex/no mode chang mode and the input tray) and a printer that supports pdf printing "natively" (Xerox Workcenter or Phaser 7760) - how would you go about trying to "retrofit" tray control to the binary SAP spool for pdf... I guess, my question is: can you advise if the tray control would be achievable by adding PJL commands on top of pdf? Or something else...?

Thank you and best regards,

Janis

Edit in: ok, I think I found the info myself and feel it's worth a try in case of Xerox... for printing single pdf documents at least... According to HP PJL manual, it should be possible to instruct printer to print only a range of pages using:


@PJL JOB ["job name"] [START=first page] [END = last page][PASSWORD = number] [DISPLAY = "display text"][<CR>]<LF>


command, and the XEROXes should support:

@PJL XMEDIASOURCE=value; where value is ANY or TRAYx

@PJL XMEDIATYPE=value, vhere value is media type


The obvious con: if I don't find the commands to "cache" the file on the printer and reuse it, I'd need to need to send it multiple times... I'll try to find the time to try this out; your inputs would nevertheless be very welcome


Message was edited by: Jānis B

Laszlo_B
Active Contributor
0 Kudos

Hello Prathamesh,

the spool already contains PDF data.

The problem is: the printer can not interpret this PDF data. Therefore such a solution is needed which converts the PDF data, so the printer can understand it. Please see my previous answer for possible solutions.

Alternatively, you need to aquire a printer which can print PDF natively - but of course this would mean additional vendor search, expenses, etc.

Regards,

Laszlo

Laszlo_B
Active Contributor
0 Kudos

Hello Jānis,

thanks for watching.

The problem with already stored spool data is that R/3 can't interfere with the source code - therefore it's not possible to directly edit it.

Therefore adding the tray/duplex commands at the beginning of the spool data might be useful, but I'm afraid that would mean the mixing of print languages, and not all printers are capable to understand that.

For example: I have downloaded a simple PDF file from R/3, then I have uploaded it into SP01 with RSPO_TEST_CREATE_SPOOL. In the next step I printed this (binary) spool request with Device Type KOC360A1 (I know this is a Konica Device Type instead of Xerox, but I could replicate my issue this way).

Now the beginning of the print data looks like this:

%-12345X@PJL

@PJL SET USERNAME ="..."

@PJL SET JOBNAME ="..."

@PJL ENTER LANGUAGE=PCL

E (0N &l0L%PDF-1.3

%âăĎÓ

<...>

What happens here is: KOC360A1 starts a regular PCL language, then "suddenly" the PDF source code will start.

I'm not sure whether a printer can handle that: the printer expects PCL source code, so I would guess the (uninterpreted) PDF source code will be printed, as a simple text.

Theoretically it is possible to mix different languages in one print data (with command PJL ENTER LANGUAGE), in practice I'm not sure how that would work out...

So unfortunately I don't see many options here. If the document server/archiving program makes it possible to print via R/3 Output Device (and therefore Device Type), the POSS-options/Print Tickets can be tested.

However, other than that... I can't recall much possibilities.

Regards,

Laszlo

0 Kudos

*sigh* Yes, you are right - the devices can "autosense" pdfs, but trying to wrap the pdf in PJL just leads to errors.

I guess there must be very good reasons the printer manufacturers (and Adobe too) do the things the way they do them (besides having to make more money), but by now I've come to detest those ways . I want to be able to quickly build my own tiny-mini "solution" for something as simple sounding as printing a pdf on a direct pdf printing capable printer while controlling the input trays...

Oh, well... I'll ask Xerox if something like that is feasible at all - the technical contacts I have dealt with were very capable and helpful folks indeed and sooner or later solved everything we threw at them.

Thanks again and cheers,

Janis

Former Member
0 Kudos

Hi Laszlo,

I have found the below link

https://help.sap.com/saphelp_nwmobile711/helpdata/en/4b/7bd20dcc3537f4e10000000a42189b/content.htm

which says :

Note that SAPPDFPRINT only works with Interactive Forms generated by Adobe Document Services (ADS). Other spool requests (such as ABAP lists or SAPscript forms) that were generated with the device type PDF1, or binary spool requests that contain a PDF document cannot be printed using SAPPDFPRINT.

Can you please suggest any other alternative if applicable?

regards,

Prathamesh

kabil_g
Active Participant
0 Kudos

Hi Prathamesh,

You can customize your nace transaction to print archieve invoice also.....................

Former Member
0 Kudos

Hi Kabil,

I need to print archived invoice through custom report

kabil_g
Active Participant
0 Kudos

Customize tat output type in nace to print archeive invoices also...............

Former Member
0 Kudos

Hi kabil,

But we need to print range of invoices through report.

I think we can't print multiple archive doucment through nace without user intervension.

regards,

Prathamesh Naik.