Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Forum Index
 
Register
 
IBM Mainframe Forum 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: 8784
Location: Welsh Wales

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: 1568
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: 1568
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: 8491
Location: Dubuque, Iowa, 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: 1568
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: 19254
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 How to place name of the file where t... danielgp89 DFSORT/ICETOOL 14 Thu Oct 17, 2019 12:55 am
No new posts Can GLobal variable used under TSOE/REXX Kaliragavendran CLIST & REXX 5 Tue Sep 24, 2019 7:16 am
No new posts How to force ISPF to allocate ISPF te... Michele Giannuli TSO/ISPF 9 Thu Sep 12, 2019 2:03 pm
No new posts Need to fetch data from database base... Satandale COBOL Programming 8 Sun Sep 08, 2019 12:01 am
No new posts How to append data from PARM in OUTFIL Poha Eater DFSORT/ICETOOL 17 Thu Aug 22, 2019 4:03 pm

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