Hi All.

I am at my wit's end trying to get an example of code I found, to work.

I am trying to rename a file in the IFS, but it is not working.

We are on V5r4 and PTFs are up to date.

I'm confident in it's function, but I cant figure out what i'm doing wrong.

I want to use the .ifs directory '\\as400\dir1\dir2\filea.dat'
and rename it to '\\as400\dir1\dir2\fileb.dat'

Please help.

D rename PR 10I 0 ExtProc('Qp0lRenameKeep')
D old * Value options(*string)
D new * Value options(*string)

D ReportError PR

D Source s 100A
D Target s 100A

c eval Source='/home/klemscot/editest.txt'
c eval Target='/tmp/editest.txt'

* Note that if Source and Target are in different filesystems,
* this will fail with "CPE3405: Improper Link"

c if rename(%trimr(source):
c %trimr(target)) < 0
c callp ReportError
c endif

c eval *inlr = *on

P ReportError B
D ReportError PI

D sys_errno PR * ExtProc('__errno')
D p_errno s *
D errno s 10I 0 based(p_errno)

D MessageID 7A Const
D QualMsgF 20A Const
D MsgData 1A Const
D MsgDtaLen 10I 0 Const
D MsgType 10A Const
D CallStkEnt 10A Const
D CallStkCnt 10I 0 Const
D MessageKey 4A
D ErrorCode 8192A options(*varsize)

D BytesProv 1 4I 0 inz(0)
D BytesAvail 5 8I 0 inz(0)

D MsgKey S 4A
D MsgNo s 4P 0
c eval p_errno = sys_errno
c eval msgno = errno
c callp QMHSNDPM( 'CPE' + %editc(msgno:'X')
c : ' ': 0: '*ESCAPE': '*': 3
c : MsgKey: dsEC)