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
 

 

alphanumeric sequence generation

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

New User


Joined: 21 Aug 2012
Posts: 17
Location: india

PostPosted: Wed Mar 30, 2016 3:03 am    Post subject: alphanumeric sequence generation
Reply with quote

I have the following requirement.Can you please help cobol pseudocode

NOW sequence number is 10-12 ( 3 bytes) - 10TH BITE IS alphabetic and 11-12 are numeric and control break is on field starting from character 5 and length of 5.whenever control break changes sequence number starts again from beginning. In new requirement they want to make this sequence number as alphanumeric and increment and new sequence start from BAA instead of AAA( A sequence is using for some other purpose). New sequence should be like BAA,BAB,BAC.....BAZ,BBA,BBB,..BZZ,...BA1,BA2,BA3...etc

Input file:

Code:
704812345B01 XXXXXXXXXXXXXXXXXX
704812345B02 XXXXXXXXXXXXXXXXXX
704812345B03 XXXXXXXXXXXXXXXXXX
.
,
.
.
704812345B98 XXXXXXXXXXXXXXXXXX
704812345B99 XXXXXXXXXXXXXXXXXX
704812345C01 XXXXXXXXXXXXXXXXXX
704812345C03 XXXXXXXXXXXXXXXXXX

704856789B01 XXXXXXXXXXXXXXXXXX
704856789B02 XXXXXXXXXXXXXXXXXX
.
.
.
704856789B98 XXXXXXXXXXXXXXXXXX
704856789B99 XXXXXXXXXXXXXXXXXX
704856789C01 XXXXXXXXXXXXXXXXXX
704856789C03 XXXXXXXXXXXXXXXXXX


OUTPUT ( As part of bussiness requirement sequence number is making alphanumeric and should start from BAA:

Code:
704812345BAA XXXXXXXXXXXXXXXXXX
704812345BAB XXXXXXXXXXXXXXXXXX
704812345BAC XXXXXXXXXXXXXXXXXX
.
,
.
.
704812345BAZ XXXXXXXXXXXXXXXXXX
704812345BBA XXXXXXXXXXXXXXXXXX
704812345BBB XXXXXXXXXXXXXXXXXX
704812345BBC XXXXXXXXXXXXXXXXXX

704856789BAA XXXXXXXXXXXXXXXXXX
704856789BAB XXXXXXXXXXXXXXXXXX
.
.
.
704856789BAZ XXXXXXXXXXXXXXXXXX
704856789BBA XXXXXXXXXXXXXXXXXX
704856789BBB XXXXXXXXXXXXXXXXXX
704856789BBC XXXXXXXXXXXXXXXXXX
Back to top
View user's profile Send private message

enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10203
Location: italy

PostPosted: Wed Mar 30, 2016 3:19 am    Post subject: Reply to: alphanumeric sequence generation
Reply with quote

just basic IT arithmetics,
think about the representation of a number in base 36
Back to top
View user's profile Send private message
sivaprasad.gadhi

New User


Joined: 21 Aug 2012
Posts: 17
Location: india

PostPosted: Wed Mar 30, 2016 3:31 am    Post subject: Reply to: alphanumeric sequence generation
Reply with quote

I have tried but unable to code combining with control break logic and getting looping issues.Do you have any sample code?

Thanks for your help
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7914
Location: Bellevue, IA

PostPosted: Wed Mar 30, 2016 7:49 am    Post subject:
Reply with quote

You would VASTLY simplify your logic if you put the sequence in collating sequence (BAA, BAB, ..., BAZ, BA1, BA2, ... BA9, BBA, ...) instead of the way you posted. And I'm not sure why you're having problems with the code --a complete COBOL program to DISPLAY the various letter / number combinations of the sequence ran 46 lines of COBOL when I wrote it a few minutes ago. Doing it the way you posted wouldn't add more than 10 lines to that total, I would think.
Back to top
View user's profile Send private message
sivaprasad.gadhi

New User


Joined: 21 Aug 2012
Posts: 17
Location: india

PostPosted: Wed Mar 30, 2016 8:08 am    Post subject:
Reply with quote

I am able to produce sequence numbers but unable to reinitialize sequence after the control break.Can you please provide me your code.

Thanks for your help

regards
siva
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7914
Location: Bellevue, IA

PostPosted: Wed Mar 30, 2016 8:53 am    Post subject:
Reply with quote

This is supposed to be a forum for professionals, who should not need code given to them. But I'm feeling generous tonight -- you should be to adapt this code to whatever you need.
Code:
000100  ID DIVISION.                                                   
000200  PROGRAM-ID.                     MF0002.                       
000300  ENVIRONMENT DIVISION.                                         
000400  DATA DIVISION.                                                 
000500  WORKING-STORAGE SECTION.                                       
000600  01  WS-VARS.                                                   
000700      05  WS-CHAR1-SUB            PIC 9(02).                     
000800      05  WS-CHAR2-SUB            PIC 9(02).                     
000900      05  WS-CHAR3-SUB            PIC 9(02).                     
001000      05  WS-CHAR1-TABLE          PIC X(34) VALUE               
001100          'BCDEFGHIJKLMNOPQRSTUVWXYZ123456789'.                 
001200      05  WS-CHAR1-ARRAY          REDEFINES WS-CHAR1-TABLE       
001300                                  OCCURS 34                     
001400                                  PIC X(01).                     
001500      05  WS-CHAR2-TABLE          PIC X(35) VALUE               
001600          'ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789'.                 
001700      05  WS-CHAR2-ARRAY          REDEFINES WS-CHAR2-TABLE       
001800                                  OCCURS 34                     
001900                                  PIC X(01).                     
002000      05  WS-CHAR3-TABLE          PIC X(35) VALUE               
002100          'ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789'.                 
002200      05  WS-CHAR3-ARRAY          REDEFINES WS-CHAR3-TABLE       
002300                                  OCCURS 34                     
002400                                  PIC X(01).                     
002500      05  WS-OUTPUT-VAR.                                         
002600          10  WS-OV-1             PIC X(01).                     
002700          10  WS-OV-2             PIC X(01).                     
002800          10  WS-OV-3             PIC X(01).                     
002900  PROCEDURE DIVISION.                                           
003000      PERFORM                                                   
003100          VARYING WS-CHAR1-SUB FROM 1 BY 1                       
003200            UNTIL WS-CHAR1-SUB > 34                             
003300          PERFORM                                               
003400              VARYING WS-CHAR2-SUB FROM 1 BY 1                   
003500                UNTIL WS-CHAR2-SUB > 35                         
003600              PERFORM                                           
003700                  VARYING WS-CHAR3-SUB FROM 1 BY 1               
003800                    UNTIL WS-CHAR3-SUB > 35                     
003900                  MOVE WS-CHAR1-ARRAY (WS-CHAR1-SUB) TO WS-OV-1   
004000                  MOVE WS-CHAR2-ARRAY (WS-CHAR2-SUB) TO WS-OV-2   
004100                  MOVE WS-CHAR3-ARRAY (WS-CHAR3-SUB) TO WS-OV-3   
004200                  DISPLAY '>' WS-OUTPUT-VAR '<'                   
004300              END-PERFORM                                         
004400          END-PERFORM                                             
004500      END-PERFORM                                                 
004600      STOP RUN.                                                   
Back to top
View user's profile Send private message
Rohit Umarjikar

Senior Member


Joined: 21 Sep 2010
Posts: 1610
Location: NY,USA

PostPosted: Wed Mar 30, 2016 10:42 pm    Post subject:
Reply with quote

Please,don't post multiple times the same question unless it is totally unrelated.
http://ibmmainframes.com/viewtopic.php?t=64953&highlight=
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
This topic is locked: you cannot edit posts or make replies. How to move a long alphanumeric data ... lind sh COBOL Programming 8 Mon Dec 05, 2016 7:51 pm
No new posts Sequence number add in SORT pshongal SYNCSORT 3 Fri Sep 02, 2016 3:32 pm
No new posts Random Password (in string format) ge... ezhavendhan COBOL Programming 10 Mon Aug 29, 2016 3:18 pm
This topic is locked: you cannot edit posts or make replies. Alphanumeric to Numeric move on UNIX mistah kurtz COBOL Programming 16 Wed Jul 27, 2016 8:47 pm
No new posts alphanumeric sequence generation sivaprasad.gadhi DFSORT/ICETOOL 8 Mon Mar 21, 2016 1:09 am


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