I have following input file:
Code:
|aaa|bbbb|
ccccc|ddd
dd|ee|
record length is fixed to 80
I need the following output file:
aaa
bbbb
ccccc
ddddd
ee
here record length has to be 80
i.e. i need the data between any two | as one record of 80 length with padding
splitting of records using cobol
Moderators: dbzTHEdinosauer, Moderator Group
-
- Active Member
- Posts: 732
- Joined: Thu May 24, 2012 4:07 am
-
- Active Member
- Posts: 732
- Joined: Thu May 24, 2012 4:07 am
Inspect the UNSTRING data(only for first character). if matches then STRING those data.
Example:
UNSTRING Record delimited by '|'
into WS-var1 WS-var2 WS-var3 WS-var4......
End-Unstring
If WS-var2(1:1) = WS-var3(1:1)
String WS-var2 DELIMITED BY SIZE
WS-var2DELIMITED BY SIZE
INTO WS-var5.
Example:
UNSTRING Record delimited by '|'
into WS-var1 WS-var2 WS-var3 WS-var4......
End-Unstring
If WS-var2(1:1) = WS-var3(1:1)
String WS-var2 DELIMITED BY SIZE
WS-var2DELIMITED BY SIZE
INTO WS-var5.
Thanks,
--Dhiraj Mishra
--Dhiraj Mishra
-
- Active Member
- Posts: 732
- Joined: Thu May 24, 2012 4:07 am
Dhiraj,
You need to re-think that considerably. Why would ( 1 : 1 ) of anything be equal to ( 1 : 1 ) of anything else? If you delimit by SIZE, you'll get trailing blanks. You'd also need to set all those fields to space first, else you'll get values "left over" from the previous UNSTRING if there are more pipes on the previous than on the current.
You need to re-think that considerably. Why would ( 1 : 1 ) of anything be equal to ( 1 : 1 ) of anything else? If you delimit by SIZE, you'll get trailing blanks. You'd also need to set all those fields to space first, else you'll get values "left over" from the previous UNSTRING if there are more pipes on the previous than on the current.
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