splitting of records using cobol

This is a Mainframe COBOL forum - you can post your queries on Mainframe COBOL, VS COBOL II, COBOL/370 , Enterprise COBOL

Moderators: dbzTHEdinosauer, Moderator Group

Post Reply
gkrish
Member
Posts: 4
Joined: Fri Jun 13, 2014 5:30 pm

splitting of records using cobol

Post by gkrish » Tue Jun 24, 2014 1:22 pm

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

William Collins
Active Member
Posts: 732
Joined: Thu May 24, 2012 4:07 am

Post by William Collins » Tue Jun 24, 2014 2:09 pm

Have a look at UNSTRING and see if you'd find it useful.

gkrish
Member
Posts: 4
Joined: Fri Jun 13, 2014 5:30 pm

Post by gkrish » Tue Jun 24, 2014 8:12 pm

Thanks willam , had look into it, but if u see the 2 nd and 3 rd line of my input ddd is split into 2 lines if we use unstring it come as separate lines is there any way to concatenate these both

William Collins
Active Member
Posts: 732
Joined: Thu May 24, 2012 4:07 am

Post by William Collins » Tue Jun 24, 2014 8:50 pm

Can you show the code you used, the input you used, the output you received and the output you expected, please?

All inside the Code tags to preserve spacing.

dhiraj
Member
Posts: 48
Joined: Tue May 06, 2014 11:22 am

Post by dhiraj » Wed Jun 25, 2014 3:40 pm

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.
Thanks,
--Dhiraj Mishra

William Collins
Active Member
Posts: 732
Joined: Thu May 24, 2012 4:07 am

Post by William Collins » Wed Jun 25, 2014 6:45 pm

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.

dhiraj
Member
Posts: 48
Joined: Tue May 06, 2014 11:22 am

Post by dhiraj » Wed Jun 25, 2014 8:21 pm

Will, I got your point....so we need exact INPUT data because I thought after 3d there is one | .

|aaa|bbbb|
ccccc|ddd
dd|ee|


gkrish- You need to paste Exact INPUT and desired OUTPUT.
Thanks,
--Dhiraj Mishra

Post Reply

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



Other References
Mainframe Tools and others