ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Convert data ISO to data number into a logical file

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

  • Convert data ISO to data number into a logical file

    Hi,
    I have a physical file on the AS400 that contains several fields;

    FIELD01 15 A
    FIELD02 7 A
    DATA01 10 L
    .......

    I would like to create a logical file with the key

    FIELD01 K
    DATA01 K

    However, I need to be able to convert the DATA01 field from 10 L to 8.0 (numeric) directly within the logical file.

    Is there a way to use a keyword to convert the DATA01 field from 10 (Iso) to 8.0 (numeric)?


  • #2
    It is actually simple.

    Given you have a physical file MYFILEP1 with the format
    Code:
         A          R MYFILER1                              
         A*                                                
         A            FIELD01       15A                    
         A            FIELD02        7A                    
         A            DATA01          L                    
         A*                                                  ​

    Then all you have to do is to create a logical file over it ( here called MYFILEL1 ) with the format
    Code:
         A          R MYFILER1                                    
         A                                      PFILE(MYFILEP1)    
         R            FIELD01                                      
         R            FIELD02                                      
         R            DATA01         8S                      
         A*                                                        
         A          K FIELD01                                      
         A          K DATA01                                        ​
    The trick is to cast the type of DATA01 from "L" to "8S" in the logical file.

    Regards
    Peder
    Last edited by Peder Udesen; May 6, 2026, 03:42 AM.

    Comment

    Working...
    X