Hi I have requirement to read a input file, each record contains certain record
01 FILE-DATA.
05 FILE-FIELD-A PIC 9(18).
05 FILLER PIC X(01) VALUE '*'.
05 FILE-FILED-B PIC X(30).
05 FILLER PIC X(01) VALUE '*'.
input data: 12345*ACBDE12345
when I unstring the file record, each file is getting 000000012345 (leading zeroes) & 'ABCDE12345 ' (trailing spaces).
Strangely the file data is send with such variable length into to fixed data structure, to tackle this how can I go about removing the leading zeroes and Trailing spaces.
For leading zeroes: use COBOL editing
To remove trailing spaces (or possibly leading ones on the
FILE-FIELD-EDITEDvar): use the instrinsicTRIMfunction:which would then give the output you've shown above.
To learn more about editing and intrinsic functions see your COBOL implementation's language reference (that implementation may not have the
LEADINGandTRAILINGoption, for example) or for general COBOL the current COBOL draft standard.