IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Problem in UNSTRING....


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
karthikr44

Active User


Joined: 25 Aug 2007
Posts: 235
Location: Chennai

PostPosted: Wed Jun 04, 2008 3:13 pm
Reply with quote

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
View user's profile Send private message
the_gautam

Active User


Joined: 05 Jun 2005
Posts: 165
Location: Bangalore

PostPosted: Wed Jun 04, 2008 3:23 pm
Reply with quote

I think you should first verify your data.
How is your DD carrying only one character?
Back to top
View user's profile Send private message
yogeshwar_ade

Active User


Joined: 31 Aug 2006
Posts: 103
Location: INDIA

PostPosted: Wed Jun 04, 2008 3:25 pm
Reply with quote

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
View user's profile Send private message
karthikr44

Active User


Joined: 25 Aug 2007
Posts: 235
Location: Chennai

PostPosted: Wed Jun 04, 2008 3:28 pm
Reply with quote

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
View user's profile Send private message
Manuneedhi K

Active User


Joined: 07 May 2008
Posts: 115
Location: Chennai

PostPosted: Wed Jun 04, 2008 3:34 pm
Reply with quote

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
View user's profile Send private message
Manuneedhi K

Active User


Joined: 07 May 2008
Posts: 115
Location: Chennai

PostPosted: Wed Jun 04, 2008 3:35 pm
Reply with quote

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
View user's profile Send private message
yogeshwar_ade

Active User


Joined: 31 Aug 2006
Posts: 103
Location: INDIA

PostPosted: Wed Jun 04, 2008 3:38 pm
Reply with quote

You can use REFERNCE MODIFICATION to solve this problem.
Back to top
View user's profile Send private message
karthikr44

Active User


Joined: 25 Aug 2007
Posts: 235
Location: Chennai

PostPosted: Wed Jun 04, 2008 3:46 pm
Reply with quote

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
View user's profile Send private message
the_gautam

Active User


Joined: 05 Jun 2005
Posts: 165
Location: Bangalore

PostPosted: Wed Jun 04, 2008 3:47 pm
Reply with quote

i think the similar validation is more useful, if done before the UNSTRING
Back to top
View user's profile Send private message
Manuneedhi K

Active User


Joined: 07 May 2008
Posts: 115
Location: Chennai

PostPosted: Wed Jun 04, 2008 3:52 pm
Reply with quote

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
View user's profile Send private message
the_gautam

Active User


Joined: 05 Jun 2005
Posts: 165
Location: Bangalore

PostPosted: Wed Jun 04, 2008 3:57 pm
Reply with quote

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
View user's profile Send private message
Manuneedhi K

Active User


Joined: 07 May 2008
Posts: 115
Location: Chennai

PostPosted: Wed Jun 04, 2008 4:05 pm
Reply with quote

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
View user's profile Send private message
karthikr44

Active User


Joined: 25 Aug 2007
Posts: 235
Location: Chennai

PostPosted: Wed Jun 04, 2008 4:07 pm
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Map Vols and Problem Dataset All Other Mainframe Topics 2
No new posts z/vm installation problem All Other Mainframe Topics 0
No new posts Job scheduling problem. JCL & VSAM 9
No new posts Problem with IFTHEN=(WHEN=GROUP,BEGIN... DFSORT/ICETOOL 5
No new posts Need to add field to copybook, proble... COBOL Programming 14
Search our Forums:

Back to Top