Note:
Source:
HNOMAIN * MTHNAME: Sample User Written Routine in RPG * Converts month number to month name * This is an IBM i RPG version of the standard mthname.c * sub routine supplied with IBI products.
* This a no main dll service type program with a lowercase * exported symbol ... which is what is needed to integrate * with programs that typically use lower or mixed case * symbols in there dlls (ie. C).
* This routine is stored for z/OS PDS Deployment purposes * as MTHNAMRP so it does not conflict with any of the * other MTHNAME samples. Gencpgm on z/OS doesn't support * RPG so building there is a non issue.
* Declare procedure parameter prototype. * EXTPROC needed for lower case symbol ... very important! D mthname PR EXTPROC('mthname') D MTH 8F D MTHNAME 11A
* Procedure begin with external symbol export declaration. P mthname B EXPORT
* Declare procedure parameter interface. D mthname PI D MTH 8F D MTHNAME 11A * Error Cases ... check if below 1 or above 12 C IF MTH < 1 OR MTH > 12 C MOVE '** Error **' MTHNAME C ENDIF
* Look up by month ... * (Using LOOKUP would be better, but lets keep it simple) C IF MTH = 1 C MOVE 'January ' MTHNAME C ENDIF C IF MTH = 2 C MOVE 'February ' MTHNAME C ENDIF C IF MTH = 3 C MOVE 'March ' MTHNAME C ENDIF C IF MTH = 4 C MOVE 'April ' MTHNAME C ENDIF C IF MTH = 5 C MOVE 'May ' MTHNAME C ENDIF C IF MTH = 6 C MOVE 'June ' MTHNAME C ENDIF C IF MTH = 7 C MOVE 'July ' MTHNAME C ENDIF C IF MTH = 8 C MOVE 'August ' MTHNAME C ENDIF C IF MTH = 9 C MOVE 'September ' MTHNAME C ENDIF C IF MTH = 10 C MOVE 'October ' MTHNAME C ENDIF C IF MTH = 11 C MOVE 'November ' MTHNAME C ENDIF C IF MTH = 12 C MOVE 'December ' MTHNAME C ENDIF * Done; return to caller. C RETURN * Procedure End P E
iWay Software |