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
 
Logic to remove hypen and string the data

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

Active User


Joined: 01 May 2006
Posts: 151
Location: Hyderabad

PostPosted: Tue May 01, 2007 8:27 pm    Post subject: Logic to remove hypen and string the data
Reply with quote

Hi all,

My requirement is like this,

01 A-VAR PIC X(10) VALUE KIRAN-CSC.

I need to transform this into KIRANCSC000.i.e,
1. Remove hyphen
2. Add '000' at end of the field.

I don't know where is the position of the string and how many Hyphen I have.
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: Tue May 01, 2007 9:46 pm    Post subject:
Reply with quote

Hello,

I'm going to guess that your "input" is 'KIRAN-CSC ' (note the ending space).

One way to do this is to redefine the original 10-byte field as an array of 10 single-bytes.

Then define a second array of 10 single-bytes.

For each new value:
Initialize the second array to 0000000000.
Set the index or a subscript to the beginning of each array.

If the character in the input is a '-' or a space,
. . skip that byte and increment the input array position.
Otherwise, move the input "keeper" character to the output array and
. . increment the position in both arrays.
Repeat until you've parsed the entire input field.

The "output" will now contain the non'-' values from the "input" and will have zeros filling the unused positions on the right side. The value in the output area will be 'KIRANCSC00'. Note this is not the same as the posted result - the posted result will not fit in a PIC X(10) field.

If you want exactly 3 zeros to follow the result value, you will have to code slightly differently.
Back to top
View user's profile Send private message
jasorn

Active User


Joined: 12 Jul 2006
Posts: 154
Location: USA

PostPosted: Wed May 09, 2007 7:12 am    Post subject: This is how I'd do it.
Reply with quote

Something like this.

Unstring A-VAR
delimited by all '-'
into ws-part1
ws-part2

string ws-part1 delimited by ' '
ws-part2 delimited by ' '
'000' delimited by size
into a-var-reformatted
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: Wed May 09, 2007 7:20 am    Post subject:
Reply with quote

Hello,

What if there are more than 2 places with a '-'?

What if the field won't hold 000 after the meaningful characters?

When (if) our TS responds we will be better able to offer suggestions.
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 line 52: Name or string > 250 char... Ashishpanpaliya CLIST & REXX 5 Sat Oct 14, 2017 2:29 am
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 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