Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

How to increment Hex values

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

New User


Joined: 22 Jun 2005
Posts: 65
Location: Mumbai

PostPosted: Mon Mar 05, 2012 10:38 pm    Post subject: How to increment Hex values
Reply with quote

Hi,

I have following requirement. I have file with one record.
Now I need to replecate 100 records as a test data for my testing but in only in particualr record position (i.e. 134th position I want to change the values from X'00', X'01', X'02', ….X'99')

Any idea if we can do it using sort card? If I want to increment and write the records using cobol program how to do it?

Regards,
Neil
Back to top
View user's profile Send private message

Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7226

PostPosted: Mon Mar 05, 2012 10:47 pm    Post subject: Reply to: How to increment Hex values
Reply with quote

Almost certainly can be done in Sort as well.

In Cobol

Code:
01  w-two-bytes-for-one-byte-binary comp pic s9(4) value zero.
01  filler redefines w-two-bytes-for-one-byte-binary.
    05  filler pic x.
    05  w-one-byte-binary pic x.


Every time you want to write a record:

Code:
add +1 to w-two-bytes-for-one-byte-binary
move w-one-byte-binary to record-field-position-whatever
Back to top
View user's profile Send private message
saiprasadh

Active User


Joined: 20 Sep 2006
Posts: 154
Location: US

PostPosted: Mon Mar 05, 2012 10:48 pm    Post subject:
Reply with quote

Hi Neil,

Please provide some input and output samples. based on what criteria you will select records.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7226

PostPosted: Mon Mar 05, 2012 10:59 pm    Post subject: Reply to: How to increment Hex values
Reply with quote

Rats. Just looked more closely at your sample. You don't want Hex, it looks like, you want decimal but with no sign, despite the subject.

A subtle change, then:

In Cobol

Code:
01  w-two-bytes-for-one-byte-binary comp-3 pic s99v9 value zero.
01  filler redefines w-two-bytes-for-one-byte-binary.
    05  w-one-byte-binary pic x.
    05  filler pic x.

Note the field being redefined is now comp-3 and has a decimal place (only for alignment) and the filler subordinate to the redefines is now the last field.

Every time you want to write a record:

Code:
add +1 to w-two-bytes-for-one-byte-binary
move w-one-byte-binary to record-field-position-whatever
Back to top
View user's profile Send private message
nileshyp

New User


Joined: 22 Jun 2005
Posts: 65
Location: Mumbai

PostPosted: Mon Mar 05, 2012 11:04 pm    Post subject: Reply to: How to increment Hex values
Reply with quote

Thanks Bill However do you have an example on how to do it using sort?

Sai:-

My input record looks as below
0110H (506869815..0.10551000.è...27
The Xex Value of the .(dot) after 0 is X'01'

Now I want to replcate same records but to increment the X'01' to X'02' till X'99' and then do the testing

How can I replicate using sort?

Reagrds,
Neil
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7226

PostPosted: Mon Mar 05, 2012 11:15 pm    Post subject: Reply to: How to increment Hex values
Reply with quote

What do you mean "however"? If you wanted to do it in Sort, why didn't you ask in the appropriate forum (JCL for Synsort, DFSORT for, er..., DFSORT)? You asked for a Cobol solution in the Cobol forum.

You mess up the subject, get two Cobol solutions, and all you can say is "However"? :-)

Fortunately Sai is handy.

You can do it the same way (either the first or the second) in Sort. You have some code to generate extra records, or you want that as well?

Get a sequence value, ten times bigger than it need be, in a PD field, beyond the end of your fixed-length record, say, 180,2,PD. Then, in your output, access 180,1,CH.
Back to top
View user's profile Send private message
saiprasadh

Active User


Joined: 20 Sep 2006
Posts: 154
Location: US

PostPosted: Mon Mar 05, 2012 11:15 pm    Post subject:
Reply with quote

Hi Neil,


Please use below mentioned SORT CARD.

Code:

//STEP01  EXEC PGM=SORT                                   
//SYSPRINT  DD SYSOUT=*                                   
//SYSOUT    DD SYSOUT=*                                   
//SORTIN    DD *                                         
----+----1----+----2----+----3----+----4----+----5----+---
506869815..0 10551000.è...27                             
/*                                                       
//SORTOUT   DD DSN=<output file>,                         
//             DISP=(NEW,CATLG,DELETE),                   
//             UNIT=SYSDA,                               
//             SPACE=(CYL,(100,200),RLSE),               
//             DCB=(RECFM=FB,LRECL=80)                   
//SYSIN    DD *                                           
  SORT FIELDS=COPY                                       
  OUTFIL FNAMES=SORTOUT,REPEAT=100,                       
  OUTREC=(1:1,12,13:SEQNUM,1,BI,START=1,INCR=1,14:14,67)   
/*       


Input:

Code:
----+----1----+----2----+----3----+----4-
506869815..0 10551000.è...27             
FFFFFFFFF44F0FFFFFFFF45444FF4444444444444
506869815BB0110551000B4BBB270000000000000


Output:

Code:
----+----1----+----2----+----3----+----4
----+----F----+----F----+----F----+----F
----+----1----+----2----+----3----+----4
 ---------------------------------------
506869815..0.10551000.è...27           
FFFFFFFFF44F0FFFFFFFF45444FF444444444444
506869815BB0110551000B4BBB27000000000000
 ---------------------------------------
506869815..0.10551000.è...27           
FFFFFFFFF44F0FFFFFFFF45444FF444444444444
506869815BB0210551000B4BBB27000000000000
 ---------------------------------------
506869815..0.10551000.è...27           
FFFFFFFFF44F0FFFFFFFF45444FF444444444444
506869815BB0310551000B4BBB27000000000000
 ---------------------------------------
506869815..0.10551000.è...27           
FFFFFFFFF44F0FFFFFFFF45444FF444444444444
506869815BB0410551000B4BBB27000000000000
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7226

PostPosted: Mon Mar 05, 2012 11:28 pm    Post subject: Reply to: How to increment Hex values
Reply with quote

Neil,

Do you want to start from x'00' or x'01'? You've said both.

Can you confirm that it is an "unsigned decimal" that you want, ie none of those nasty hexy letters? Or is that what you do want? Nasty hexy letters?
Back to top
View user's profile Send private message
nileshyp

New User


Joined: 22 Jun 2005
Posts: 65
Location: Mumbai

PostPosted: Mon Mar 05, 2012 11:47 pm    Post subject: Reply to: How to increment Hex values
Reply with quote

Thanks Sai & Bil for your quick help.

But it seems the SORT products in out shop does not support below mentioned syntax as I got below error after running the exact same job as given by sai.Please find below error

PRODUCT LICENSED FOR CPU SERIAL NUMBER 6682E, MODEL 2086 230
SYSIN :
WER164B 1,028K BYTES OF VIRTUAL STORAGE AVAILABLE, MAX REQUESTED,
WER164B 0 BYTES RESERVE REQUESTED, 1,000K BYTES USED
WER146B 24K BYTES OF EMERGENCY SPACE ALLOCATED
WER267A SORT STATEMENT : STATEMENT NOT FOUND
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7226

PostPosted: Tue Mar 06, 2012 12:01 am    Post subject: Reply to: How to increment Hex values
Reply with quote

Neil,

The most likely thing is you've accidently clobbered the cards provided somehow. Can you show what you are running, both in your JCL and on the output from the sort? Any outstanding answers you care to give would be good as well.
Back to top
View user's profile Send private message
saiprasadh

Active User


Joined: 20 Sep 2006
Posts: 154
Location: US

PostPosted: Tue Mar 06, 2012 1:07 am    Post subject:
Reply with quote

Neil,


The sort card i provided is for DFSORT. In your shop you are using SYNCSORT. Please check the command in SYNCSORT to repeat records.
Back to top
View user's profile Send private message
Anuj Dhawan

Senior Member


Joined: 22 Apr 2006
Posts: 6258
Location: Mumbai, India

PostPosted: Tue Mar 06, 2012 5:16 pm    Post subject: Re: Reply to: How to increment Hex values
Reply with quote

nileshyp wrote:
WER267A SORT STATEMENT : STATEMENT NOT FOUND
icon_neutral.gif
Back to top
View user's profile Send private message
nileshyp

New User


Joined: 22 Jun 2005
Posts: 65
Location: Mumbai

PostPosted: Tue Mar 06, 2012 5:44 pm    Post subject: Reply to: How to increment Hex values
Reply with quote

Hi,

I tried the way Bill suggested using a COBOL program and it worked fine.

Regards,
Neil
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 Overlaying one set of charater values... Kevin Lindsley SYNCSORT 7 Sat Nov 05, 2016 3:21 am
No new posts Low values Results from VARCHAR FORMAT balaji81_k DB2 10 Thu Oct 20, 2016 1:18 am
No new posts How can we create a flat file in JAVA... rakesh.v18 Java & MQSeries 7 Fri Sep 23, 2016 10:46 pm
No new posts Using 'parm' to vary SORTOUT record v... Sysaron DFSORT/ICETOOL 13 Wed Sep 07, 2016 9:24 pm
No new posts Unstring list of values into an array. Roshnii COBOL Programming 8 Mon Jun 27, 2016 6:25 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us