Go4AS400-Image

The Web Ask Go4AS400
Share  
 
Homepage
See Sitemap
as400_FAQ
See Videos here
Contact me



Ü  %SUBST (String name: String position: length)

·         This partially extracts the string from any position. Below example extract year, month, day etc. from the timestamp.

Example –%subst built-in function in rpgle

 

 

0072.00  * CALCULATE THE TIME FOR THE CURRENT SYSTEM DATE

0073.00 C                   EVAL      TIMESTP=%TIMESTAMP()

0074.00 C                   EVAL      TIME_IS=%TIMESTAMP()

0075.00 C                   EVAL      TIME_ISO=%char(TIME_IS:*iso0)

0076.00 C                   EVAL      CURRYEAR=%dec(%SUBST(TIMe_ISO:1:4):4:0)

0077.00 C                   EVAL      CURRMONTH=%dec(%SUBST(TIMe_ISO:5:2):2:0)

0078.00 C                   EVAL      CURRDAY=%dec(%SUBST(TIMe_ISO:7:2):2:0)

0079.00 C                   EVAL      CURRHRS=%dec(%SUBST(TIMe_ISO:9:2):2:0)

0080.00 C                   EVAL      CURRMINS=%dec(%SUBST(TIMe_ISO:11:2):2:0)

0081.00 C                   EVAL      CURRSECS=%dec(%SUBST(TIMe_ISO:13:4):4:0)

 

 

OUTPUT

 

 

TIME_IS = '2012-05-18-07.11.00.926000'             

TIME_ISO = '20120518071100926000'

CURRYEAR=2012

CURRMONTH=05

CURRDAY=18

CURRHRS=07

CURRMINS=11

CURRSECS=00

 

 



Comments:

Copyright © Go4as400.com, 2014. Copyright notice