How to increase the no. of records accomodated in a sequence no. field of 6-digit (Numeric Field) length?

620 pts.
Tags:
AS/400
AS/400 Fields
AS/400 Records
Dear all! My situation is..... I have a field (Sequence Number) which is a numeric-field (Len 6,0). Now the records this field can accommodate is limited/restricted to a maximum of 999999. This application has been running for years together now. Therefore the demand to accommodate maximum no. of records has come into being. The client is very much concerned by this limit. Now will changing this Field to a 6-digit char field instead of 6-digit numeric, solve the issue?(incidentally I came up with this idea). But if we implement this idea; I don't know what will be the impact on the programs(as almost 90% of the programs use this Sequence Number). Also I'm unaware as to how many records this field will accommodate? for e.g. if we start with A00001 as the 1st record....continuing till A99999; then start with B00001......B99999; C00001.....C99999 & so on till it reaches Z99999; Then again Start with "AA0001......AA9999; then continue with AB0001......till..AB9999; & so on till it reaches AZ9999; Then Again start with AAA001.....AAA999; AAB001.....AAB999; AAC001.....AAC999; till it reaches AAZ999; Then Again start with AAAA01.....AAAA99; AAAB01.....AAAB99; AAAC01.....AAAC99; till it reaches AAAZ99; Then Again start with AAAAA1.....AAAAA9; AAAAB1.....AAAAB9; etc., till it reaches AAAAZ9; ---------------------------------------------------------------- I'm unable to visualize what other combinations can be possible like ABA001...ABA999; till it reaches ABZ999; then ACA001...ACA999; till it reaches ACZ999;...like that till AZZ999 etc., then again start with ABAA01...ABAA09 till ABAZ99; then again start with ABB001...ABB999 till ABZ999. I need a logic how to build this? Any thoughts/help would be greatly appreciated. Thanks -Svanky

Software/Hardware used:
AS/400

Answer Wiki

Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Discuss This Question: 13  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • TomLiotta
    I have a field(Sequence Number) which is a numeric-field(Len 6,0).   What kind of "numeric" field? Zoned or packed decimal?   If The data type can be changed to handle characters, why can't it simply changed to be a larger number? Surely that would be easier with much less work.   Tom
    125,585 pointsBadges:
    report
  • philpl1jb
    Yes, I did something like this 
    .. although we had the advantage 
    that the field was character.
    
    
    Before you start the computation, 
    you should consider characters that should not be used.  
    We eliminated I and O because they might be 
    confused with 1 and 0.  
    That left 24 characters + 10 digits.
    
    Positions 1 to 5 can each have 34 characters , 
    position 6 can have 10
    
    Compute number of values as 34 * 34 * 34 * 34 * 34 * 10 
    
    or 34 ^5 * 10 
    
    subtract the ones you've already used 100000 and you've got your answer.
    
    If I've used the calculator correctly it would be something like:
    
    525,218,750 - 100,000 = 525,118,750
    
    For our purpose, increasing the number of digits would
     have required layout changes to every file, report, 
    and screen.  
    But changing this to character may require similar efforts.
    
    50,205 pointsBadges:
    report
  • philpl1jb
    Every file with this field will need the type changed.Every program that puts this file into a hold field, screen field, report field will need to have the type changed on the field.Every program that computes a new serial number will need a code change to call a procedure to compute the new serial number.Any place where edit words or edit codes on the field will need to be changed.  But because the field is the same width, it will fit on the screens and reports.You may also be a sequencing issue if you sort or key on this field.  The letters A-Z come before 0-9.
    50,205 pointsBadges:
    report
  • TomLiotta
    You may also be a sequencing issue if you sort or key on this field.  The letters A-Z come before 0-9.   True, but alternate sequences can be defined and used. I'd expect that most users would quickly adapt to thinking of the letters as collating after digits. Where it would get tricky would be if positions after the left-most would need to be used in the future.   It's possible only the left-most position would be needed. That position has cycled from '0' to '9' in its lifetime, i.e., ten different values. With 24 new values to use, the projected future life ought to be at least double what it's been so far.   Tom
    125,585 pointsBadges:
    report
  • CharlieBrowne
    IF you change the DDS for this file to make the field larger 9P 0, Then you can just do a CHGPF command and it will not have to copy the data to the new format. Just recompile all the programs (Which you will need to do no matter what solution you choose).. If you are going to change the field type, I would suggest creating the file with SQL and using IDENTITY. That way you do not have to have logic to update the number and any Insert into the program from whatever source will automatically write the seq number.
    41,380 pointsBadges:
    report
  • svankipu
    Dear All!First let me thank each one of you for your prompt response/replies to my question.Tom!The numeric field is of length (Packed  6,0).I don't have the privilege to increase the length of this field, as we have no spaces left on the screen(that's what I meant by limit/restriction). this seq# field is also part of the account number automatically generated, which is to be displayed on the screen. This account no. is also used across other applications. hence I can't go for length-increase. Charlie!I have the same to tell you that I don't have space to make the field larger viz.,9P 0. This is a kind of R & D we have to come up with a new possibility.Thanks very much,- Svanky
    620 pointsBadges:
    report
  • philpl1jb
    What questions remain to be addressed?
    50,205 pointsBadges:
    report
  • svankipu
    Dear All!Iam not getting anything you guys are saying.The numeric field is of length (Packed  6,0). I don’t have the privilege to increase the length of this field, as we have no spaces left on the screen. This is also used across other applications. hence I can’t go for length-increase. I can only change it's data-type to char.What I know that I need a logic to build the above requirement(which is in my initial question)? Any thoughts/help(if somebody has already implemented this logic else-where; may be field-length would have been different; doesn't matter) would be greatly appreciated.Thanks -Svanky 
    620 pointsBadges:
    report
  • TomLiotta
    Yes, change the data type to character everywhere. It has to be changed in any other file that links to this file, too, not just display or print files.   There will be one or more programs that create new account numbers. In those programs, the account number should be created in a DS that is six bytes long. The first byte will be a 1-byte character subfield. The remaining five bytes will be a zoned decimal subfield. You will increment that field when you create a new account.   When the subfield goes past 99999, it will overflow. You will want to ensure that it's set back to zero when it overflows.   Also on overflow, you'll check the first byte to see if it's "9". If it is, you'll change it to be "A". If it's already "A", you'll set it to "B". If it's "B", set it to "C"... etc.   I'd probably create a 2-dimensional array that has 24 rows and is two elements wide. Each element will be 1 byte. The first element will have values "9", "A", "B", etc.; and the second will have "A", "B", "C", etc.
    9 A
    A B
    B C
    C D
    ...etc.
      Do a %lookup() on the first byte of the account number when overflow happens, and use the second element as the new account number first byte.  Tom
    125,585 pointsBadges:
    report
  • philpl1jb
    Sorry, I don't have the code available but it was something like this:
     H DEBUG(*YES)   DFTACTGRP(*NO)                                       
        D                                                                 
        D SerialNum       S              6a   inz('ABC999')               
         *Prototype                                                       
        D Increment       PR             6a                               
        D  SerialNum                     6a                               
         /FREE                                                            
          SerialNum = Increment(serialNum);                               
          *INLR = *ON;                                                    
          RETURN;                                                         
         /END-FREE                                                        
            // ------------------------------
            // -- Increment module -- adds 1 to serial number
            // ------------------------------
        P Increment       B                                               
        D Increment       PI             6a                               
        D  SerialIn                      6A                               
                                                                          
        D SerialNumDS     DS                                              
        D SerialNum                      6a                               
        D SNA                            1a   overlay(SerialNum) dim(6)   
                                                                          
        D D34DS           DS                                              
        D D20V                          20A   INZ('0123456789ABCDEFGHJK') 
        D D14V                          14A   INZ('LMNPQRSTUVWXYZ')       
        D D34                            1    DIM(34) OVERLAY(D34DS)      
        D                                                                 
        D D10DS           DS                                              
        D D10V                          10A   INZ('0123456789')           
        D D10                            1    DIM(10) OVERLAY(D10DS)      
        D                                                                 
        D dig             S              1S 0                             
        D pos             S              2S 0                             
         /Free                                                            
            SerialNum = SerialIn;                                         
                // assumes   last three can only be numeric               
            For dig = 6 downto 4 by 1;                                    
              pos = %lookup(sna(dig):D10   ) + 1;                         
              if pos <= %ELEM(D10);                                       
                 sna(dig) = d10(pos);                                     
                 return SerialNum;  // bug out with new number;           
              else;                                                       
                 sna(dig) = d10( 1 ); // loop and increment next digit                                    
              endif;                                                      
            Endfor;                                                       
                                                                          
            //assumes   first three can be alpha/numeric                  
            For dig = 3 downto 1 by 1;                                    
              pos = %lookup(sna(dig):D34   ) + 1;                         
              if pos <= %ELEM(D34);                                       
                 sna(dig) = d34(pos);                                     
                 return SerialNum;  // bug out with new number;           
              else;                                                       
    
                 sna(dig) = d34( 1 );                                     
              endif;                                                      
            EndFor;  
            if SerialNum = '000000';
                SerialNum = '000001';
            endif;                                                     
            Return SerialNum;                                             
         /END-FREE                                                        
        P Increment       E                                               
    
     
    50,205 pointsBadges:
    report
  • BigKat
    it looked normal when I submitted it
    D34DS           DS
    D D20V                          20A   INZ(’0123456789ABCDEFGHJK’)
    D D14V                          14A   INZ(‘LMNPQRSTUVWXYZ’)
    D D34                            1    DIM(34) OVERLAY(D34DS)
    D D10                            1    DIM(10) OVERLAY(D34DS)
    
    8,220 pointsBadges:
    report
  • BigKat
    drat  first line should be
    DD34DS           DS
    8,220 pointsBadges:
    report
  • philpl1jb
    Creating the next serial number is the easy part of this project. Changing all the files, program, screens, printer files .. that will be the big part of the project.
    50,205 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following