0

I have a field called FNAME which contains the first name of an employee. For my output I want to show only the first letter of their name.

For example, if their name is "Frederic" I want it to output "F" for their first name.

How would I manipulate this to get only the first letter? Do I do it with EDTWRD in my PRTF file?

mike
  • 1,233
  • 1
  • 15
  • 36
Arnatuile
  • 185
  • 1
  • 1
  • 5
  • Is the field in the PRTF defined as CHAR(1)? If it is, then you don't have to "do" anything in RPG except assign the value to the output field. It'll truncate to a single left-most character anyway. – user2338816 Dec 09 '15 at 06:15

1 Answers1

2

EDTWRD and EDTCDE for that matter only work on numeric fields.

You'd need to substring the value.

fname = %subst(fname:1:1);
Charles
  • 21,637
  • 1
  • 20
  • 44
  • 2
    If your data is not always great, you might want to trim it first to get the first non-blank character like this `%subst(%triml(fname): 1: 1)` – jmarkmurphy Oct 02 '15 at 02:15