Citación del post de
Gatomalo
|
❞
Bueno siguiendo la politica del foro
Código COBOL:
01 DATOS-DET. 02 MED-ITEM PIC X(3). 02 FILLER PIC X VALUE ",". 02 CANT PIC ZZZ,ZZ9.99. 02 FILLER PIC X VALUE ",". 02 COD-PROD PIC ZZZ,ZZ9.99. 02 FILLER PIC X VALUE ",".
este codigo se registra como "NUI, 10.15, 105.30".
para que se ponga de esta manera "NUI,10.15,105.30".
compilador rmcobolv7
|
Tirar os espaços de uma string:
Código COBOL:
working-storage section.
01 source-field pic x(100).
01 source-index pic 9(004).
01 source-size pic 9(004) value 999.
01 target-field pic x(100).
01 target-index pic 9(004).
procedure division.
move 100 to source-index *> (depende do tamanos máximo da string)
move "NUI, 10.15, 105.30" to source-field
perform remove-spaces
target-field fica = a "NUI,10.15,105.30"
Código COBOL:
remove-space.
move spaces to target-field.
move zeroes to target-index
perform varying source-index from 1 by 1
until source-index > source-size
if source-field(source-index:1) > space
add 1 to target-index
move source-field(source-index:1) to
target-field(target-index:1)
end-if
end-perform.