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

UNSTRING of Variable length Data


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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: 8797
Location: Welsh Wales

PostPosted: Thu Jul 18, 2013 3:29 pm
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
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

Global Moderator


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

PostPosted: Thu Jul 18, 2013 4:12 pm
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
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

Global Moderator


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

PostPosted: Thu Jul 18, 2013 4:40 pm
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: 8696
Location: Dubuque, Iowa, USA

PostPosted: Thu Jul 18, 2013 4:57 pm
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

Global Moderator


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

PostPosted: Thu Jul 18, 2013 5:02 pm
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
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

Moderator Emeritus


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

PostPosted: Thu Jul 18, 2013 7:25 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Store the data for fixed length COBOL Programming 1
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts PARSE Syntax for not fix length word ... JCL & VSAM 7
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Data set Rec-Cnt and Byte-Cnt Testing & Performance 2
Search our Forums:

Back to Top