ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Renaming Fields

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Renaming Fields

    Hi,
    I try to convert an old rpg III program to free format, but the compilation always give me errors.
    The questions is a bit complicated.
    I have two differente file with a field that differ for its dimension:


    Code:
    * ORDPD0F
    A          R RORDPD                    TEXT('Tracciato Ordini')   
     * various common field
    A            COMMON1   10
    A            COMMON2    5
    *two field differ
    A            OCOME          7S 3    
    A                                   
    A            OBOLE          7S 3    
    A                                   
    
    * ORDUS0F
     A          R RORDUS 
     * various common field
    A            COMMON1   10
    A            COMMON2    5
    * two field differ
    A            OCOME         11  4      
    A            OBOLE          7  2
    Now this old rpg program declare 4 logical file 2 for ORDPD0F and 2 for ORDUS0F and with and I-spec resolve the conflict:

    Code:
    fordpdq1l  if   e           k disk    rename(rordpd:rordql)   
    fordpd8l   if   e           k disk    rename(rordpd:rord8l)   
    fordusq1l  if   e           k disk    rename(rordus:roruql)   
    fordus8l   if   e           k disk    rename(rordus:roru8l)   
    
    Iroruql                                            
    I              ocome                       ocomeu  
    I              obole                       oboleu  
    Iroru8l                                            
    I              ocome                       ocomeuu 
    I              obole                       oboleuu 
    
    ...
    Compiling this I didn't have problem, when I read from ones of the four logical files the common fields are always evaluated.

    I try to covert it to free format:

    Code:
    dcl-f OrdPdQ1l keyed rename(rOrdPd:ROrdQl);       
    dcl-f OrdPd8l  keyed rename(rOrdPd:rord8l);       
    dcl-f OrdUsQ1l keyed rename(rOrdUs:roruql);       
    dcl-f OrdUs8l  keyed rename(rOrdUs:roru8l);       
    
    Dcl-Ds DsOrdUsQ1l Ext ExtName('ORDUSQ1L' :*Input) ;          
      OComeU        ExtFld('OCOME');                             
      OBoleU        ExtFld('OBOLE');                             
    End-Ds;                                                      
    Dcl-Ds DsOrdUs8l  Ext ExtName('ORDUS8L' :*Input);            
      OComeUU       ExtFld('OCOME');                             
      OBoleUU       ExtFld('OBOLE');                             
    End-Ds;
    But the compiler give me a lot of error:
    *RNF3804 30 86 Name in external description is not renamed; external name is
    ignored.
    *RNF7407 30 4 Decimal-Positions entry does not match the definition of the
    input field; specification is ignored.
    *RNF7408 30 2 The length of the input field does not match the definition
    of the field; specification is ignored.

    Someone could help me to convert the first rpg into a free format?
    Probably I can resolve by using Qualified, but if so I have to make a lot of job , because before all the common fields are always evaluated.

    Many thanks.

  • #2
    Hi all,

    my boss found a solutions, but there are still a problem....
    Here's the code:

    Code:
      dcl-f OrdPdQ1l keyed rename(rOrdPd:ROrdQl);                   
      dcl-f OrdPd8l  keyed rename(rOrdPd:rord8l);                   
      dcl-f Ordus8l  keyed rename(rOrdus:ROrU8l) Prefix(not_);      
      dcl-f Ordusq1l keyed rename(rOrdus:ROruql) Prefix(not2_);     
    
      Dcl-Ds DsOrdus  ExtName('ORDUS0F':*Input) ;                   
        OBolEren      ExtFld('OBOLE');                              
        Ocomeren      ExtFld('OCOME');                              
      End-Ds;                                          
    
      *InLr = *On;                                                  
    
      Read Ordpdq1l;                                                
      Read Ordpd8l;                                                 
      Read Ordus8l  DsOrdUs;                                        
      Read Ordusq1l  DsOrdUs;                                       
    
      Return;
    But the compiler goes in error:

    *RNF7595 20 002800 The result data structure DSORDUS does not include a
    subfield in position 1 for record format RORU8L.
    *RNF7595 20 002900 The result data structure DSORDUS does not include a
    subfield in position 1 for record format RORUQL.

    Any Idea?

    Comment


    • #3

      Hi, here's the final solutions...

      Code:
        dcl-f OrdPdQ1l keyed rename(rOrdPd:ROrdQl);                 
        dcl-f OrdPd8l  keyed rename(rOrdPd:rord8l);                 
        dcl-f Ordus8l  keyed rename(rOrdus:ROrU8l) Prefix(not_);    
        dcl-f Ordusq1l keyed rename(rOrdus:ROruql) Prefix(not2_);   
      
        Dcl-Ds DsOrdus  ExtName('ORDUS8L':*All) ;                   
          Ocomeren      ExtFld('OCOME') ;                           
          OBolEren      ExtFld('OBOLE') ;                           
        End-Ds;                                                     
        Dcl-Ds DontUse ExtName('ORDUSQ1L':*All) Qualified;          
          Ocomeren      ExtFld('OCOME') ;                           
          OBolEren      ExtFld('OBOLE') ;                           
        End-Ds;                                                     
        //                                                          
        // Main Line                                                
      
        *InLr = *On;                                                
      
        Read Ordpdq1l;                                              
        Read Ordpd8l;                                               
        Read Ordus8l  DsOrdUs;                                      
        Read Ordusq1l DontUse;                                      
      
        DsOrdUs = DontUse;

      Comment

      Working...
      X