View previous topic :: View next topic
|
Author |
Message |
karthikr44
Active User
Joined: 25 Aug 2007 Posts: 235 Location: Chennai
|
|
|
|
HI,
05 WK-DTL-RPMT-DATE PIC X(10).
05 WK-IN-RPMT-DATE.
10 WK-IN-RPMT-CCYY PIC 9(04) VALUE ZEROS.
10 WK-IN-RPMT-MM PIC 9(02) VALUE ZEROS.
10 WK-IN-RPMT-DD PIC 9(02) VALUE ZEROS.
INPUT:
12/02/2004
05/5/2003
I used the following statement
UNSTRING WK-DTL-RPMT-DATE DELIMITED BY ALL "/"
INTO WK-IN-RPMT-MM, WK-IN-RPMT-DD, WK-IN-RPMT-CCYY
END-UNSTRING
RESULT:
WK-IN-RPMT-DATE:20041202
WK-IN-RPMT-DATE:00300505
But i want to get value for 05/5/2003 as 20030505
Any one please help me...I need urgently
Regards
R KARTHIK |
|
Back to top |
|
|
the_gautam
Active User
Joined: 05 Jun 2005 Posts: 165 Location: Bangalore
|
|
|
|
I think you should first verify your data.
How is your DD carrying only one character? |
|
Back to top |
|
|
yogeshwar_ade
Active User
Joined: 31 Aug 2006 Posts: 103 Location: INDIA
|
|
|
|
karthikr44 wrote: |
HI,
05 WK-DTL-RPMT-DATE PIC X(10).
05 WK-IN-RPMT-DATE.
10 WK-IN-RPMT-CCYY PIC 9(04) VALUE ZEROS.
10 WK-IN-RPMT-MM PIC 9(02) VALUE ZEROS.
10 WK-IN-RPMT-DD PIC 9(02) VALUE ZEROS.
INPUT:
12/02/2004
05/5/2003
But i want to get value for 05/5/2003 as 20030505
|
As your input Value is 05/5/2003 not 05/05/2003 you are getting wrong output. |
|
Back to top |
|
|
karthikr44
Active User
Joined: 25 Aug 2007 Posts: 235 Location: Chennai
|
|
|
|
Input file may contain both format as belows
12/02/2004
05/5/2003
And i read into 05 WK-DTL-RPMT-DATE PIC X(10). |
|
Back to top |
|
|
Manuneedhi K
Active User
Joined: 07 May 2008 Posts: 115 Location: Chennai
|
|
|
|
Add this validation to the code after the unstring.
Code: |
IF WK-IN-RPMT-MM(2:1) = SPACES
MOVE WK-IN-RPMT-MM(1:1) TO WK-IN-RPMT-MM(2:1)
MOVE ZERO TO WK-IN-RPMT-MM(1:1)
END-IF
IF WK-IN-RPMT-DD(2:1) = SPACES
MOVE WK-IN-RPMT-DD(1:1) TO WK-IN-RPMT-DD(2:1)
MOVE ZERO TO WK-IN-RPMT-DD(1:1)
END-IF |
|
|
Back to top |
|
|
Manuneedhi K
Active User
Joined: 07 May 2008 Posts: 115 Location: Chennai
|
|
|
|
Forgot to mention. I declared the dates as alphanumeric.
Code: |
01 WK-DTL-RPMT-DATE PIC X(10).
01 WK-IN-RPMT-DATE.
05 WK-IN-RPMT-CCYY PIC X(04) .
05 WK-IN-RPMT-MM PIC X(02) .
05 WK-IN-RPMT-DD PIC X(02) . |
|
|
Back to top |
|
|
yogeshwar_ade
Active User
Joined: 31 Aug 2006 Posts: 103 Location: INDIA
|
|
|
|
You can use REFERNCE MODIFICATION to solve this problem. |
|
Back to top |
|
|
karthikr44
Active User
Joined: 25 Aug 2007 Posts: 235 Location: Chennai
|
|
|
|
HI Manuneedhi K,
Currently the Date and Month are correct.
Only WK-IN-RPMT-CCYY is wronng.
But in ur code WK-IN-RPMT-MM , WK-IN-RPMT-DD are used. |
|
Back to top |
|
|
the_gautam
Active User
Joined: 05 Jun 2005 Posts: 165 Location: Bangalore
|
|
|
|
i think the similar validation is more useful, if done before the UNSTRING |
|
Back to top |
|
|
Manuneedhi K
Active User
Joined: 07 May 2008 Posts: 115 Location: Chennai
|
|
|
|
Try with my code after declaring the dates as alphanumeric. It will work.
I have tested the code with your input data. |
|
Back to top |
|
|
the_gautam
Active User
Joined: 05 Jun 2005 Posts: 165 Location: Bangalore
|
|
|
|
Hi Manuneedhi K,
Definitely your code will work fine.
You are validating the data twice after the UNSTRING.
I think if you validate the data before the UNSTRING, it will save some coding as well as resource. |
|
Back to top |
|
|
Manuneedhi K
Active User
Joined: 07 May 2008 Posts: 115 Location: Chennai
|
|
|
|
Hi Gautam,
Can you clarify how coding this before the UNSTRING saves resource? If you are coding this before the UNSTRING you will again have to do the same ref mod to pad zeroes before the date and month, so i don't quite understand your point.
Thanks in advance.
Manu |
|
Back to top |
|
|
karthikr44
Active User
Joined: 25 Aug 2007 Posts: 235 Location: Chennai
|
|
|
|
HI all,
05 WK-LIT-RPMT-CCYYS PIC 9(05) VALUE ZEROS.
Now i got the solution.
UNSTRING WK-DTL-RPMT-DATE DELIMITED BY "/"
INTO WK-IN-RPMT-MM, WK-IN-RPMT-DD, WK-LIT-RPMT-CCYYS
END-UNSTRING
IF WK-LIT-RPMT-CCYYS(1:1) = ZERO
MOVE WK-LIT-RPMT-CCYYS(2:4) TO WK-IN-RPMT-CCYY
ELSE
MOVE WK-LIT-RPMT-CCYYS(1:4) TO WK-IN-RPMT-CCYY
END-IF
Since i want the RPMT date to numeric, I dont used Manunidhi code. But
i will arrrive at this code only by his sample code. Thanks |
|
Back to top |
|
|
|