Wednesday, December 18, 2013

QCAPCMD another alternative to QCMDEXC

Several of you commented on Capturing QCMDEXC error codes that you preferred to use the C library function SYSTEM( ) or the API QCAPCMD.

I have to confess that I had not used the QCAPCMD API prior to writing this post. So after some playing around with it this is what I found out about using it:

Thursday, December 12, 2013

Easiest way to read all the members in a multiple member file

The idea for this post came from a discussion I saw on Facebook. Someone asked:

  1. In your RPG how can you read from a particular member of a file?
  2. By default which member is read?
  3. How can you read all the members of your PF in your RPG program?
  4. How can you find out which member is being read?

The answer for the first question is to use the EXTMBR in the File specifications. I will not go into details about this as it is covered in Useful keywords for your F-specs.

The answer for the second question is that when a program opens a file with more than one member, by default, it opens the first member, which is the oldest member as that was the one created first.

The third and fourth questions I combined into my own scenario: I want to have a program that reads all the members in a multi member file to find a particular record and identify which member this record is in.

Tuesday, December 10, 2013

SYSTEM( ) as an alternative to QCMDEXC

system qcmdexc error codes

After my post about Capturing QCMDEXC error codes Markus During sent me an alternative method to execute CL commands and retrieve any error message id that might occur.

system() is a runtime C library function that performs the same purpose as the QCMDEXC API. With system() you pass a pointer to the command string and it is executed, no need for the for the command string length.

Tuesday, December 3, 2013

Email IFS files

send ibmi as400 email sndsmtpemm

The subject matter of this post compliments the previous post Zipping files in the IFS, which describes how to copy a file to the IFS and zip it in preparation for sending it via email.

Until recently it was not possible to email a file from the IFS without using a third party tool or an API. There is the command SNDDST that I have used to send emails from an IBM i (AS400) with the contents of files or files located in the QDLS file system as attachments. But it cannot access the IFS.

A new command SNDSMTPEMM has been introduced, via PTF, to IBM i 6.1 and 7.1 that allows you to email a file from the IFS as an attachment.