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

How to increment Hex values


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Mon Mar 05, 2012 10:47 pm
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
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Mon Mar 05, 2012 10:59 pm
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
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Mon Mar 05, 2012 11:15 pm
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
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Mon Mar 05, 2012 11:28 pm
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
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Tue Mar 06, 2012 12:01 am
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
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

Superior Member


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

PostPosted: Tue Mar 06, 2012 5:16 pm
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts INCLUDE OMIT COND for Multiple values... DFSORT/ICETOOL 5
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts Null values are considered in Total c... DFSORT/ICETOOL 6
No new posts Converting ASCII values to COMP-3 (ZD... JCL & VSAM 2
No new posts Generate output lines (SYSIN card for... DFSORT/ICETOOL 4
Search our Forums:

Back to Top