November 27, 2007, 11:02 AM
RonnDate reformatting
I have a bill date coming from a flat file dataset that I read in using...
-READ BILLDAT2 &BILLCONST.A8 &BILLDATE.A8 &FILL1.A26 &COMMWK.A2 &HAULERWK.A2 &PERIOD.A2 &PREVDATE.A8 &CURRDATE.A8;
&BILLDATE's value is 11272007
I don't understand why this is difficult, but I want to change the format to 20071127 and keep it numeric, while simply using -SET commands. I know this can be done inside a DEFINE, but I really wish I don't have to do that.
Please help!
Here is my sample code that doesn't work:
-READ BILLDAT2 &BILLCONST.A8 &BILLDATE.A8 &FILL1.A26 &COMMWK.A2 &HAULERWK.A2 &PERIOD.A2 &PREVDATE.A8 &CURRDATE.A8;
-*
-RUN
-SET &BILLYEAR = EDIT(&BILLDATE,'$$$$9999');
-SET &BILLMONTH = EDIT(&BILLDATE,'99$$$$$$');
-SET &BILLDAY = EDIT(&BILLDATE,'$$99$$$$');
-SET &BILLDATEA = &BILLYEAR|&BILLMONTH|&BILLDAY;
-SET &BILLDATEN = EDIT(&BILLDATEA);
-SET &CDATE = &BILLDATEN;
..and here is what I get when running it (notice the error GOTO doesn't make sense):
DYNAM ALLOC FILE BILLDAT2 DATASET NAVL.OPR.DATALIB(BILLDAT2) SHR REUSE
-RUN
-READ BILLDAT2 &BILLCONST.A8 &BILLDATE.A8 &FILL1.A26 &COMMWK.A2 &HAULERWK.A2 &PERIOD.A2 &PREVDATE.A8 &CURRDATE.A8;
-*
-RUN
SET PASS = EDWARD
SET ALL = PASS
SET ASNAMES = ON
-RUN
-*
-*-SET &CDATE = EDIT(&DATEYYMD,'9999$99$99');
-SET &BILLYEAR = EDIT(11272007,'$$$$9999');
-SET &BILLMONTH = EDIT(11272007,'99$$$$$$');
-SET &BILLDAY = EDIT(11272007,'$$99$$$$');
-SET &BILLDATEA = 20071127;
(FOC283) IMPROPER USE OF 'GOTO'
...as you can see the &BILLDATEA looks correct but I still comes back with this GOTO error.
Thanks in advance.
November 27, 2007, 11:14 AM
Francis MarianiUse the CHGDAT function:
-SET &BILLDATE = '11272007';
-SET &BILLDATE1 = CHGDAT ('MDYY', 'YYMD', &BILLDATE, 'A17');
-TYPE &BILLDATE / &BILLDATE1
Francis
Give me code, or give me retirement. In FOCUS since 1991
Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
November 27, 2007, 01:32 PM
GinnyJakesYou can use most of the code that you have, just changed the concatenation to strong. Also, by definition, an amper variable is numeric so you don't have to do the conversion.
I also eliminated one of the edits since month and day are already in the right order.
-SET &BILLDATE=11272007;
-SET &BILLYEAR = EDIT(&BILLDATE,'$$$$9999');
-SET &BILLMODY = EDIT(&BILLDATE,'9999$$$$');
-SET &CDATE=&BILLYEAR||&BILLMODY;
-TYPE &CDATE
November 27, 2007, 02:21 PM
Francis MarianiOne wonderful line of code with the CHGDAT function.
Francis
Give me code, or give me retirement. In FOCUS since 1991
Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
November 27, 2007, 02:29 PM
RonnWow! That was amazingly simple.
I've seen this function before, but never used it, so I have forgotten all about it.
I knew it can't be that hard, I just need to know how to do it.
Thanks Francis!
November 27, 2007, 02:31 PM
RonnThat also worked Ginny!
Thanks as well!!!