Hi All,
Please provide the COBOL code to replace spaces will NULL. i.e, if i have the string like 'COMMON BUSINESS' . space in the string to bre removed.
and string in the output shoul be 'COMMONBUSINESS'.
Replacing space with NULL value
Moderators: dbzTHEdinosauer, Moderator Group
- dbzTHEdinosauer
- Moderator
- Posts: 981
- Joined: Mon Oct 02, 2006 8:31 pm
Here is some code to start with.
Code: Select all
05 WS-INPUT-IMAGE PIC X(40).
05 WS-INPUT-TABLE
REDEFINES
WS-INPUT-IMAGE OCCURS 40 TIMES
INDEXED BY INPUT-IDX
PIC X(01).
88 WS-INPUT-SPACE VALUE SPACE.
05 WS-OUTPUT-IMAGE PIC X(40).
88 INIT-OUTPUT-IMAGE VALUE SPACES.
05 WS-OUTPUT-TABLE
REDEFINES
WS-OUTPUT-IMAGE OCCURS 40 TIMES
INDEXED BY OUTPUT-IDX
PIC X(01).
....
SET OUTPUT-IDX TO 1
SET INIT-OUTPUT-IMAGE TO TRUE
PERFORM VARYING INPUT-IDX
FROM 1
BY 1
UNTIL INPUT-IDX
> 40
IF WS-INPUT-SPACE(INPUT-IDX)
THEN
CONTINUE
ELSE
MOVE WS-INPUT-TABLE(INPUT-IDX)
TO WS-OUTPUT-TABLE(OUTPUT-IDX)
SET OUTPUT-IDX UP BY 1
END-IF
END-PERFORM
Dick Brenholtz
JCL, SQL and code in programs have an irritating habit of doing what you say,
not what you meant.
JCL, SQL and code in programs have an irritating habit of doing what you say,
not what you meant.
Jack,
You can use the one of the solution(running through the string and eliminating spaces) offered by dick
Or you can try out this
UNSTRING WS-STRING DELIMITED BY SPACES
INTO WS-STRING1 WS-STRING2
END-UNSTRING.
STRING WS-STRING1 DELIMITED BY SPACE
WS-STRING2 DELIMITED BY SPACE
INTO WS-STRING3
END-STRING.
Thanks,
Chanti.
You can use the one of the solution(running through the string and eliminating spaces) offered by dick
Or you can try out this
UNSTRING WS-STRING DELIMITED BY SPACES
INTO WS-STRING1 WS-STRING2
END-UNSTRING.
STRING WS-STRING1 DELIMITED BY SPACE
WS-STRING2 DELIMITED BY SPACE
INTO WS-STRING3
END-STRING.
Thanks,
Chanti.
- dbzTHEdinosauer
- Moderator
- Posts: 981
- Joined: Mon Oct 02, 2006 8:31 pm
FREE TUTORIALS
Tutorials
Free tutorials from mainframegurukul
- JCL Tutorial
Covers all important JCL concepts. - Cobol Tutorial
This tutorials covers all Cobol Topics from STRING to COMP-3. - DB2 Tutorial
DB2 Tutorial focuses on DB2 COBOL Programming. - SORT Tutorial
This Tutorial covers all important aspects of DFSORT with examples - CICS Tutorial
This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions
- Cobol Interview Questions
50+ Interview Questions - JCL Interview Questions
50+ Interview Questions - DB2 Interview Questions
100+ Interview Questions - CICS Interview Questions
70+ Interview Questions - VSAM Interview Questions
27 Interview Questions
Other References
Mainframe Tools and others
- XPEDITER Reference
Explains how we can debug a program - FILEAID Reference
Explains how to browse , edit and delete datasets - Change Man Reference
Quick Start tutorial on Changeman - Abend Reference
Important Abend codes explained - FaceBook Page
MainframeGurukul FaceBook Page - LinkedIn Page
MainframeGurkul Linkedin Page