Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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: 1542
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: 1542
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: 8165
Location: East Dubuque, Illinois, USA

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: 1542
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 Copy 4 byte of data from the last rec... arunsoods DFSORT/ICETOOL 9 Fri Oct 06, 2017 12:15 pm
No new posts sort records based on length exceeds ... maxsubrat DFSORT/ICETOOL 7 Wed Oct 04, 2017 4:48 pm
No new posts opening a dataset after reading it fr... arunsoods DFSORT/ICETOOL 5 Wed Oct 04, 2017 3:54 pm
This topic is locked: you cannot edit posts or make replies. PS file data should be passed as symb... d_sarlie JCL & VSAM 15 Tue Oct 03, 2017 5:18 am
No new posts File Aid tool to compare numeric data balaji81_k Compuware & Other Tools 2 Tue Sep 26, 2017 3:35 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us