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

alphanumeric sequence generation


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

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Wed Mar 30, 2016 3:19 am
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
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: 8696
Location: Dubuque, Iowa, USA

PostPosted: Wed Mar 30, 2016 7:49 am
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
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: 8696
Location: Dubuque, Iowa, USA

PostPosted: Wed Mar 30, 2016 8:53 am
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

Global Moderator


Joined: 21 Sep 2010
Posts: 3051
Location: NYC,USA

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

Please,don't post multiple times the same question unless it is totally unrelated.
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts DFHPI1008 JSON generation failed COBOL Programming 0
No new posts Cobol program with sequence number ra... COBOL Programming 5
No new posts Started task using a generation dataset JCL & VSAM 7
No new posts Report generation JCL & VSAM 18
No new posts How can I get Generation Nbr of GDG f... IBM Tools 1
Search our Forums:

Back to Top