|
At 05:34 PM 6/30/98 -0400, VENU YAMAJALA wrote: > I have a question - Is there anyway, we can output the 26 char timestamp from >an ILE RPG? My requirement is that I have a date in a certain format and I want >to convert this to *ISO Time Stamp format to send to some other module. From >the format, I want to build a 30 char fiel in *ISO TimeStamp field. I have a >format table which tells me that a particular format has the atomic values YY, >MM, DD, HH, SS, MN and separators. It gives me the positions of each atomic >value in that format. For example we have a format called YMD with '/' >separators which has > >Format AtomicValue >FromPos Length >YMD YY >1 2 >YMD >/ >3 1 >YMD MM >4 2 >YMD >/ >6 1 >YMD DD >7 2 > > So from this table, I will split my date value into YY, MM, DD, ... pieces by >using SUBSTRING with FromPos and >Length from the above table. Then from the pieces I collected, I want to build >a 30 char field which is in *ISO TimeStamp format (with extra positions as >zeros). I have a logic to get the century value (if it is not there in the >original date I received). Venu, You can move the timestamp to a date field with the appropriate format and then if necessary, move that to an alpha field. This would give you a result with the appropriate separators already in place. You could also move the timestamp to an alpha field (the data structure name) and then reference the subfields. What you cannot do is substring the timestamp. You can only substring alpha variables. I haven't tried it, but you might even be able to get away with defining a single data structure with multiple date fields as subfields, each beginning at position 1. If RPG allows this (big if??? - maybe data exceptions too, but would be interesting to try) you might be able to move the time stamp to the appropriate date field and then reference the data structure name as if it were an alpha field. You can also do a lot of character shuffling with the XLATE op code: D FmtdStruct DS 26 D 2 D DateAlpha 8 * D AlphaVar S 26 D FmtMask S 8 * D YMD_FMT C 'CD/EF/GH' D DMY_FMT C 'GH/EF/CD' D MDY_FMT C 'EF/GH/CD' D TS_FMT C 'ABCD/EF/GH.XX.XX.XX.XXXXXX' * C MOVE TimeStamp AlphaVar * C SELECT C WHEN DateFmt = 1 C EVAL FmtMask = YMD_FMT C WHEN DateFmt = 2 C EVAL FmtMask = DMY_FMT C WHEN DateFmt = 3 C EVAL FmtMask = MDY_FMT C ENDSL * C TS_FMT:AlphaVar XLATE FmtMask FmtdStruct * If I thought through this correctly (no guarantees), this will give you a value of the two digit century followed by the desired date value and '.XX.XX.XX.XXXXXX' in FmtdStruct, and the desired date value alone in DateAlpha. hth Pete Pete Hall peteh@inwave.com http://www.inwave.com/~peteh/ +--- | This is the Midrange System Mailing List! | To submit a new message, send your mail to MIDRANGE-L@midrange.com. | To subscribe to this list send email to MIDRANGE-L-SUB@midrange.com. | To unsubscribe from this list send email to MIDRANGE-L-UNSUB@midrange.com. | Questions should be directed to the list owner/operator: david@midrange.com +---
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.