Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Easiest way to execute a CLPFM from within an RPG program

Easiest way to execute a CLPFM from within an RPG program

Easiest way to execute a CLPFM from within an RPG program


I have a quick question that I hope will have an equally quick answer. I have an RPG program that is used to run part of our payroll process. The RPG program populates a data file that gets transmitted to the company that maintains our retirement. The vendor process for our regular payroll cycles that runs this program has the ability to execute a series of commands prior to running executing the RPG program. One of the commands that I execute is CLRPFM I403B as the RPG program populates this file with new data for our retirement vendor with each payroll run.

Unfortunately, the vendor process functionality only works for payroll runs which are batch, (ie our standard payroll process). However, now I need to setup this program to run for on-demand check processing, which is interactive not batch. The result is that I now need to execute the CLPRM IT403B from within the RPG program itself.

Is there a quick and easy way to accomplish this? I have seen references to using the QCMDEXC API, using the SYSTEM API etc. I was hoping someone could tell/show me the simplest way to accomplish this.

I believe the code is RPG III or IV (not sure how to tell), since I do very little RPG related stuff, mainly just making small changes to existing programs. The system is running V6R1M0.

Any help would be appreciated.

RE: Easiest way to execute a CLPFM from within an RPG program

I have seen two ways to do this.

One is the QCMDEXEC API. That is pretty simple to use: (Off the top of my head, but it should be close).

The important thing is that the field LENGTH which is the second parameter on the call needs to be defined as 15 long with 5 decimal places. The LENGTH parameter holds the value of the length of the command - 'CLRPFM I403B' is 12 long.


C                   Z-Add     12            LENGTH           15 5
C                   EVAL      CLRPFM = 'CLRPFM I403B'
C                   Call      'QCMDEXC'           
C                   Parm                    CLRPFM   
C                   Parm                    LENGTH 

The other way is to create a CL program that clears the file and call it. This code assumes you have created a CL program called CLEARCL.


C                   Call      'CLEARCL' 


I keep trying to do something about my procrastination but I keep putting it off until tomorrow.

RE: Easiest way to execute a CLPFM from within an RPG program

You will have to make the file USROPN and open it only after you've cleared it.


CODE --> FileSpec

FI403B     IF   E           K Disk    Usropn 

And here'se the initialization subroutine (which gets executed before anything else):


     C     *INZSR        BEGSR                                        
     C                   EVAL      CLRPFM = 'CLRPFM I403B'            
     C                   Call      'QCMDEXC'                          
     C                   Parm                    CLRPFM           12  
     C                   Parm      12            LENGTH           15 5
     C                   Open      I403B                              
     C                   ENDSR 

-- Francis
Francisus ego, sed non sum papa.

RE: Easiest way to execute a CLPFM from within an RPG program

Tom and Francis,

Excellent. That's exactly what I was looking for. I really appreciate your taking the time to help me out.

Take care.


Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close