COBOL - UNSTRING com FUNCTION UPPER-CASE e LOWER-CASE



Desenvolvido por DORNELLES Carlos Alberto - Analista de Sistemas - Brasília DF. - cad_cobol@hotmail.com

COBOL - UNSTRING combinando com FUNCTION UPPER-CASE e FUNCTION LOWER-CASE
 IDENTIFICATION DIVISION.
 PROGRAM-ID.    UNSTRING.
 AUTHOR.        DORNELLES CARLOS ALBERTO.
*-----------------------------------------------------------------
*  PROGRAMA      : UNSTRING                                       
*  OBJETIVO      : COMANDO UNSTRING COMBINADO COM UMA FUNCTION           
*  ANALISTA      : CARLOS ALBERTO DORNELLES                       
*  LINGUAGEM     : COBOL                                          
*  MODO OPERACAO : BATCH                                          
*-----------------------------------------------------------------
*  VERSAO DD.MM.AAAA  HISTORICO/AUTOR                             
*  ------ ----------  ---------------                             
*    001  14.08.2021  PROGRAMA INICIAL                            
*-----------------------------------------------------------------
 DATA DIVISION.
 WORKING-STORAGE SECTION.

 01  WS-AUXILIARES.
     05  WS-NOME-COMPLETO    PIC X(30) VALUE "Carlos Alberto Dornelles".
     05  WS-PRIMEIRO         PIC X(06).
     05  WS-SEGUNDO          PIC X(07).
     05  WS-TERCEIRO         PIC X(09). 

 PROCEDURE DIVISION.



UNSTRING Normal

UNSTRING 
        WS-NOME-COMPLETO DELIMITED BY SPACE 
   INTO WS-PRIMEIRO WS-SEGUNDO WS-TERCEIRO
END-UNSTRING

DISPLAY "UNSTRING Normal"
DISPLAY "               "
DISPLAY "Primeiro = " WS-PRIMEIRO.
DISPLAY "Segundo  = " WS-SEGUNDO.
DISPLAY "Terceiro = " WS-TERCEIRO.
DISPLAY "               "    

UNSTRING combinando com a FUNCTION UPPER-CASE

UNSTRING 
         FUNCTION UPPER-CASE (WS-NOME-COMPLETO) DELIMITED BY SPACE 
    INTO WS-PRIMEIRO WS-SEGUNDO WS-TERCEIRO
END-UNSTRING

DISPLAY "UNSTRING combinando com a FUNCTION UPPER-CASE"
DISPLAY "               "
DISPLAY "Primeiro = " WS-PRIMEIRO.
DISPLAY "Segundo  = " WS-SEGUNDO.
DISPLAY "Terceiro = " WS-TERCEIRO.
DISPLAY "               "    

UNSTRING combinando com a FUNCTION LOWER-CASE

UNSTRING 
         FUNCTION LOWER-CASE (WS-NOME-COMPLETO) DELIMITED BY SPACE 
    INTO WS-PRIMEIRO WS-SEGUNDO WS-TERCEIRO
END-UNSTRING

DISPLAY "UNSTRING combinando com a FUNCTION LOWER-CASE"
DISPLAY "               "
DISPLAY "Primeiro = " WS-PRIMEIRO.
DISPLAY "Segundo  = " WS-SEGUNDO.
DISPLAY "Terceiro = " WS-TERCEIRO.
STOP RUN.





Resultado dos testes:

UNSTRING Normal

Primeiro = Carlos
Segundo  = Alberto
Terceiro = Dornelles

UNSTRING combinando com a FUNCTION UPPER-CASE
Primeiro = CARLOS
Segundo  = ALBERTO
Terceiro = DORNELLES

UNSTRING combinando com a FUNCTION LOWER-CASE

Primeiro = carlos
Segundo  = alberto
Terceiro = dornelles

Veja também: