Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

UNSTRING of Variable length Data

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
kedianirmal

New User


Joined: 08 Feb 2008
Posts: 82
Location: Bangalore, India

PostPosted: Thu Jul 18, 2013 3:25 pm    Post subject: UNSTRING of Variable length Data
Reply with quote

Hi,

I have an input file having following data
Code:

01|1|0|4|24
01|1|0|8|8
01|1|0|14|14
01|1|0|17|17
01|1|0|20|20
01|1|0|22|22
01|1|0|23|23
01|1|0|24|24
01|1|0|25|25
01|1|0|26|26
01|1|0|28|28
01|1|0|32|32
01|1|0|33|33
01|1|0|41|41
01|1|569277|24|24


I am facing problem while UNSTRING as the last field is not comming properly. The data are numeric which I have to move to COMP-3.

Any suggestion.

Thanks,
Nirmal
Back to top
View user's profile Send private message

expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8593
Location: Back in jolly old England

PostPosted: Thu Jul 18, 2013 3:29 pm    Post subject: Re: UNSTRING of Variable length Data
Reply with quote

kedianirmal wrote:
as the last field is not comming properly. The data are numeric which I have to move to COMP-3.

Any suggestion.

Yes, I suggest that you explain what you mean by "not coming properly"

You really do need to learn to explain exactly what the problem is, and exactly what you have tried to resolve the issue, and of course the results from what you have tried.

Psychic day was Wednesday this week.
Back to top
View user's profile Send private message
kedianirmal

New User


Joined: 08 Feb 2008
Posts: 82
Location: Bangalore, India

PostPosted: Thu Jul 18, 2013 3:34 pm    Post subject:
Reply with quote

I have defined the file as
Code:

RECORDING MODE V
LABEL RECORDS STANDARD
RECORD CONTAINS 30 CHARACTERS
BLOCK CONTAINS 0 RECORDS.


Code:

UNSTRING  IN-REC-1  DELIMITED BY ALL '|'
        INTO       F1, F2, F3, F4, F5
END-UNSTRING


The variable are defined as:
Code:
F1   PIC X(02)
F2   PIC X(01)
F3   PIC 9(09)
F4   PIC 9(09)
F5   PIC 9(09)


In F5 i am getting value as 0 and not as defined in the input file.
Back to top
View user's profile Send private message
Pandora-Box

Moderator


Joined: 07 Sep 2006
Posts: 1529
Location: Andromeda Galaxy

PostPosted: Thu Jul 18, 2013 4:12 pm    Post subject:
Reply with quote

Wrote a sample code and find the output

Code:
 UNSTR-1 01|02|04|24
 DELIMITED BY ALL '|'
 UN-STR1 01
 UN-STR2 02
 UN-STR3 000000004
 UN-STR4 024     0
 UNSTR-1 01|02|04|24
 DELIMITED BY  '|'
 UN-STR1 01
 UN-STR2 02
 UN-STR3 000000004
 UN-STR4 024     0
 UNSTR-2 01|02|04|24|
 DELIMITED BY  '|'
 UN-STR1 01
 UN-STR2 02
 UN-STR3 000000004
 UN-STR4 000000024
Back to top
View user's profile Send private message
kedianirmal

New User


Joined: 08 Feb 2008
Posts: 82
Location: Bangalore, India

PostPosted: Thu Jul 18, 2013 4:30 pm    Post subject:
Reply with quote

Yes, if there is a delimiter at the end it will work fine but in the input file there is no delimeter at end of record. How to handle this.
Back to top
View user's profile Send private message
Pandora-Box

Moderator


Joined: 07 Sep 2006
Posts: 1529
Location: Andromeda Galaxy

PostPosted: Thu Jul 18, 2013 4:40 pm    Post subject:
Reply with quote

Why not move to X(9) field and then use NUMVAL?
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7905
Location: Bellevue, IA

PostPosted: Thu Jul 18, 2013 4:57 pm    Post subject:
Reply with quote

Have you tried
Code:
DELIMITED BY '|' OR SIZE
I have not tried this myself but the OR option is part of the syntax of the phrase.
Back to top
View user's profile Send private message
Pandora-Box

Moderator


Joined: 07 Sep 2006
Posts: 1529
Location: Andromeda Galaxy

PostPosted: Thu Jul 18, 2013 5:02 pm    Post subject:
Reply with quote

Hi Robert,

SIZE is not allowed in UNSTRING
Back to top
View user's profile Send private message
Aji

New User


Joined: 03 Feb 2006
Posts: 53
Location: Mumbai

PostPosted: Thu Jul 18, 2013 7:20 pm    Post subject:
Reply with quote

Hi,

DELIMITED BY '|' OR SPACE seems to be working, assuming there wont be any spaces in between the data.

Aji
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Thu Jul 18, 2013 7:25 pm    Post subject:
Reply with quote

Hello,

As suggested, UNSTRING into PIC X fields rather than numeric fields . . .
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts ODPP(Optim Data privacy Provider) Iss... Rama kishore IBM Tools 1 Mon Nov 07, 2016 5:46 pm
No new posts SQZ pipe delimited file with 1 column... Rick Silvers DFSORT/ICETOOL 2 Sun Nov 06, 2016 8:11 pm
No new posts Joinkeys operation when key1 and key2... Susanta DFSORT/ICETOOL 5 Wed Nov 02, 2016 5:35 pm
No new posts Can sending 5 MB data between cobol p... Kevin Vaz CICS 12 Tue Oct 18, 2016 4:50 pm
No new posts output data in CSV Format janmejay COBOL Programming 8 Sat Oct 15, 2016 2:20 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us