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

Increment Character value say from A to B using Cobol pgm


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
udays51

New User


Joined: 21 Oct 2008
Posts: 2
Location: mumbai

PostPosted: Tue Oct 21, 2008 10:18 pm
Reply with quote

Hi all,

Can anyone let me know is there any way to increment Character value.
For example If i want a value say B0 which should come after A9. Is there any way other than using working storage variables or hard coding these values in the program
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8697
Location: Dubuque, Iowa, USA

PostPosted: Tue Oct 21, 2008 10:40 pm
Reply with quote

Define an array of the values you want and iterate over the array. And you're going to have to use WORKING-STORAGE items most likely, and may have to hard-code the values.

And what do B0 and A9 represent, anyway?
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2501
Location: Atlanta, Georgia, USA

PostPosted: Tue Oct 21, 2008 10:58 pm
Reply with quote

If these values are 01-Byte HEX, then the next value after X'A9' is X'AA'.

To increment these values, define a PIC 9(08) BINARY field and then redefine it as PIC X(04), clear the BINARY field to ZERO then move the 01-Byte HEX value to the 4th-Byte of the PIC X(04) redefined BINARY field. Then, ADD 1 to the BINARY field and you've just increment your HEX value by one.

Is this what you want to do?

Bill
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: Wed Oct 22, 2008 1:07 am
Reply with quote

Hello Uday and welcome to the forum,

What should come after Z9? Should the result value be something a user could enter/read or is it for internal use only?

If you explain your requirement in more detail, we can probably make better suggestions.
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2501
Location: Atlanta, Georgia, USA

PostPosted: Wed Oct 22, 2008 1:16 am
Reply with quote

Dick,

I believe IBM's got you on the Z9, it's a Z10 icon_wink.gif

Bill
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: Wed Oct 22, 2008 1:35 am
Reply with quote

Oh, pshaw. . .

I wasn't thinking of a hardware solution. . . icon_cool.gif

d
Back to top
View user's profile Send private message
udays51

New User


Joined: 21 Oct 2008
Posts: 2
Location: mumbai

PostPosted: Wed Oct 22, 2008 6:46 pm
Reply with quote

Thnaks,

the problem solved by using tables i rid it
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 Replace each space in cobol string wi... COBOL Programming 3
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
No new posts Generate random number from range of ... COBOL Programming 3
Search our Forums:

Back to Top