IBM Support

Example of RPG Opening a .pdf File Using STRPCO Using QCMDEXC

Troubleshooting


Problem

This document shows how you can use QCMDEXC from within an RPG program to open a file that exists on your PC. The concept can be extended to open other file types, and the files can be stored in the Integrated File System if the PC has a drive mapped to it.

Resolving The Problem

The following code, when compiled and run, opens a file named a.pdf that is stored on your PC in the root of the C: drive. The concept can be extended to open other file types, such as .htm or .txt, and the path provided can be a mapped drive to the Integrated File System.

Disclaimer: This code is provided as an example only. There are no warranties of any kind, expressed or implied.

Example:
D QCMDEXC PR ExtPgm('QCMDEXC')
D cmd 32702A const options(*varsize)
D len 15P 5 const
D cmd s 200A varying
/free
monitor;
cmd = 'STRPCO';
QCMDEXC(cmd: %len(cmd));
on-error;
endmon;
cmd = 'STRPCCMD PCCMD(''start C:a.pdf'') -
PAUSE(*NO)';
QCMDEXC(cmd: %len(cmd));
*inlr = *on;
/end-free

Note: You will want to make sure that you have a PDF file called A.PDF in your C drive for this to run. You can only run the STRPCO and STRPCCMD commands interactive or by calling a program interactive.

[{"Type":"MASTER","Line of Business":{"code":"LOB57","label":"Power"},"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Product":{"code":"SWG60","label":"IBM i"},"Platform":[{"code":"PF012","label":"IBM i"}],"Version":"6.1.0"}]

Historical Number

422500832

Document Information

Modified date:
18 December 2019

UID

nas8N1014847