Sunteți pe pagina 1din 7

Print to Text File at OS Level

Print to Text File at OS Level


Applies to:
All SAP products based on ABAP stack

Summary
A tutorial on how to print to text file at OS Level from SAP. The tutorial provides detailed step-by-step
configuration details to create a printer which prints to text file at OS level in designated File System.
Example configuration is done for SAP products installed on HP-UX 11i.
Author(s): Harpreet Singh
Company: Accenture (Bangalore India)
Created on: 29 September 2006

Author Bio
I am working as SAP-BASIS Team Lead at Accenture. I have around 6Yrs in SAP-BASIS
experience which include two implementation projects.
Certifications:

WAS 640 certified technology consultant

OCP (Oracle Certified professional DBA Track)

SAP DEVELOPER NETWORK | sdn.sap.com


2006 SAP AG

BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com


1

Print to Text File at OS Level

Table of Contents
Applies to: ........................................................................................................................................ 1
Summary.......................................................................................................................................... 1
Author Bio ........................................................................................................................................ 1
Business Requirement..................................................................................................................... 2
Procedure ........................................................................................................................................ 2
Example ........................................................................................................................................... 5
Disclaimer and Liability Notice......................................................................................................... 7

Business Requirement
You want to redirect the spool output to a text file at OS Level rather than the Real Printer.

Procedure

Execute transaction SPAD

Click output devices and switch to change mode

Click Create

SAP DEVELOPER NETWORK | sdn.sap.com


2006 SAP AG

BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com


2

Print to Text File at OS Level

On Device Attribute tab Provide necessary details like


o

Output Device name

Short Name

Device type as ASCIIPRI : Some generic ASCII printer

Spool Server provide name of the app server running spool work process and whose file
system you would like to use for print files.

Provide other details as required.

On Access method tab provide details such as


o

Host Spool Access method as L : Print Locally Using LP/LPR

Host printer any name you would like to have this is just a dummy name.

Click Edit Command Set

You will get one more box in Access tab named Command Set ID as show below

SAP DEVELOPER NETWORK | sdn.sap.com


2006 SAP AG

BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com


3

Print to Text File at OS Level

Provide one character name and double click on that. Following screen will popup

Provide the necessary details as described below

Description : Any description for command set ID

Command to transfer print data : Here (in below Fig)


/usr/bin/cp &F <File System Path>
This will copy the contents of output to file system you specified in place of <File
System Path>
&F is the file name with default storage path and default storage path is data
directory for instance i.e. /usr/sap/<SID>/<instance>/data and default file name is
<OUTPUT_ID>.<SID>
Second part after semicolon is the script at OS level you would like to execute after
completing the first step, this would be required to rename the file to understandable
file name. You can pass on parameter to this scripts following parameter are allowed
&P : output device
&F : transfer file
&f : name of transfer file without path name share (as of 4.0A)
&p : path name of transfer file (as of 4.0A)
&C : number of copies
&I : job name of SAP spooler
&J : job name of SAP spooler with database name
&L : layout
&M : client of owner
&O : owner
&m : printing client

SAP DEVELOPER NETWORK | sdn.sap.com


2006 SAP AG

BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com


4

Print to Text File at OS Level

&o : printing user


&t : phone number (FAX)
&T : title
&R : recipient (cover sheet)
&D : department (cover sheet)
&S : SAP name of output device
&Y : priority
&U : UNIX cover sheet requested? ('N'=No, 'X'=Yes, 'D'=Default)
&N: number of the spool request (as of Release 4.5A)
&n: number of the output request (as of Release 4.5A)
c: number of pages (as of Release 4.0A)
&s: field 'Suffix2' of the spool request (as of Release 4.0A)
Command to query job status : This is required to know the status of the output at
OS level, if this not that much important you can provide echo ok but dont leave it
blank.

Click Enter and Save the printer definition

Its done

Example
For example if you would like to create the file to /intf/rq1/outb/mm/pending and rename the file to
<CREATOR>-<TITLE>-<SPOOL ID>_<YYYYMMDDHHMMSS>.done
Create the following script (say name spool_output_to_os.sh and placed at /var/adm/scripts/BASIS/general )

SAP DEVELOPER NETWORK | sdn.sap.com


2006 SAP AG

BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com


5

Print to Text File at OS Level

J=$1
N=$2
O=$3
T=$4
E=".done"
d=`date '+20%y%m%d%H%M%S'`
FN=`echo $J | awk -F/ '{printf("%s",$7)}'`
FN1=${O}-${T}-${N}_${d}${E}
mv /intf/rq1/outb/mm/pending/${FN} /intf/rq1/outb/mm/pending/${FN1}

and in Command to transfer print data enter


/usr/bin/cp &F /intf/rq1/outb/mm/pending/ ; /var/adm/scripts/BASIS/general/spool_output_to_os.sh &F &N &O
&T
Here parameter &F &N &O &T are passed to scripts.

SAP DEVELOPER NETWORK | sdn.sap.com


2006 SAP AG

BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com


6

Print to Text File at OS Level

Disclaimer and Liability Notice


This document may discuss sample coding or other information that does not include SAP official interfaces
and therefore is not supported by SAP. Changes made based on this information are not supported and can
be overwritten during an upgrade.
SAP will not be held liable for any damages caused by using or misusing the information, code or methods
suggested in this document, and anyone using these methods does so at his/her own risk.
SAP offers no guarantees and assumes no responsibility or liability of any type with respect to the content of
this technical article or code sample, including any liability resulting from incompatibility between the content
within this document and the materials and services offered by SAP. You agree that you will not hold, or seek
to hold, SAP responsible or liable with respect to the content of this document.

SAP DEVELOPER NETWORK | sdn.sap.com


2006 SAP AG

BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com


7

S-ar putea să vă placă și