1.11.11

SAP Note 28800 - Interface R/3, remote UNIX printing command

Symptom:

How does R/3 communicate with a UNIX print command ?
Additional key words

popen, print command
Cause and prerequisites

Request for separate print program called up by SAP and supplied by SAP with the correct status of the print request.
Solution

The UNIX print command call, which is to be found in rspo/host_spool/print, is performed using the C library command popen.
The command popen has a UNIX command as its argument and returns the standard output of this UNIX command. You can then evaluate this value.
Please refer to the sample print program below. It needs to be compiled using the standard C compiler.
command her contains the UNIX print command, which is to be found in the R/3 profile parameter rspo/hostspool/print. A while loop is called up. In the while loop the standard output of the UNIX print command is issued, which is now contained in the variable buf. The standard output usually is "REQUEST ID IS".
To work with this program, you have to use, for example, rspo/hostspool/print = mydruck $d $c $f in the profile parameter rspo/hostspool/print. mydruck could be the name of the executable.

#include
#include
main(int argc, char **argv)
char command[70], buf[100];
int copies;
FILE *ptr;

sprintf(command, "/usr/bin/lp -d%s -n%s %s",argv[1],argv[2],argv[3]);
sprintf(buf, "host spool error");
ptr= popen(command, "r");
if (ptr)
fgets(buf, 100, ptr);
pclose(ptr);
printf("%s", buf);
}

No comments:

Post a Comment