AS400 CLP Using CAT/BCAT/TCAT

Combining the two character variables on the AS400 CLP can use CAT, TCAT or BCAT. Here are the details:

  • CAT – concatenates 2 strings according to variable length (as is).
  • TCAT – concatenates 2 strings by ignoring variable lengths and removing trailing blanks for the first variable.
  • BCAT – concatenates 2 strings by ignoring variable lengths, removing trailing blanks on the first variable and adding spaces between the two variables.
PGM                                                                   
             DCL        VAR(&CHAR1) TYPE(*CHAR) LEN(10) VALUE('SAUL ')
             DCL        VAR(&CHAR2) TYPE(*CHAR) LEN(10) +             
                          VALUE('LIMBONG ')                           
             DCL        VAR(&CAT) TYPE(*CHAR) LEN(20)                 
             DCL        VAR(&TCAT) TYPE(*CHAR) LEN(20)                
             DCL        VAR(&BCAT) TYPE(*CHAR) LEN(20)                
                                                                      
             CHGVAR     VAR(&CAT) VALUE(&CHAR1 *CAT &CHAR2)           
             CHGVAR     VAR(&TCAT) VALUE(&CHAR1 *TCAT &CHAR2)         
             CHGVAR     VAR(&BCAT) VALUE(&CHAR1 *BCAT &CHAR2)         
                                                                      
             SNDPGMMSG  MSG('Using CAT :')                            
             SNDPGMMSG  MSG(&CAT)                                     
             SNDPGMMSG  MSG('Using TCAT :')                           
             SNDPGMMSG  MSG(&TCAT)                                    
             SNDPGMMSG  MSG('Using BCAT :')                           
             SNDPGMMSG  MSG(&BCAT)                                    
ENDPGM                                                                

Compile and run the program.

One thought on “AS400 CLP Using CAT/BCAT/TCAT”

Leave a Reply