View previous topic :: View next topic
|
Author |
Message |
alluri12
New User
Joined: 15 Aug 2006 Posts: 44 Location: Virginia, USA
|
|
|
|
Hi
I have following records in the input file
Code: |
aaa bbbbbbbb ccccc dd e f
aaaaa123 1111bbbb 2222222222 f g
mmm mmm mmm mmmmmm mmmmmmmm mmmm |
I need to have only one space between each word (i.e remove more than 2 spaces between each word and replace it with one space)
Output I am expecting is
Code: |
aaa bbbbbbbb ccccc dd e f
aaaaa123 1111bbbb 2222222222 f g
mmm mmm mmm mmmmmm mmmmmmmm mmmm |
Could anybody please help me how do achive this using Cobol |
|
Back to top |
|
|
murmohk1
Senior Member
Joined: 29 Jun 2006 Posts: 1436 Location: Bangalore,India
|
|
|
|
alluri,
Quote: |
Could anybody please help me how do achive this using Cobol |
I believe your req can achieved in DFSORT more easily.
If you need in COBOL only, provide the file layout with file lrecl. And also explain where do you want to squeeze the blanks (is it in the entire record or for few columns only)? |
|
Back to top |
|
|
CICS Guy
Senior Member
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
|
|
|
|
Code: |
move zero to J
perform varying I from 1 by 1 until I = length of INPUT
if INPUT(I:2) = space
continue
else
add 1 to J
move INPUT(I:1) to INPUT(J:1)
end-if
end-perform
|
|
|
Back to top |
|
|
alluri12
New User
Joined: 15 Aug 2006 Posts: 44 Location: Virginia, USA
|
|
|
|
Input file LRECL is 32600. It is a variable length.
Code: |
FD IN-FILE
RECORD IS VARYING DEPENDING ON REC-LENGTH.
01 WORK-DATA-EXTRACT-RECORD PIC X(32596). |
Input records are 500-600 record length. I need to squeeze entire record.
I tried the above code from CICS guy and i am getting abend
Code: |
"RECOCRD LENG: 00500
IGZ0074S A reference modification start position value of 32596 and length value of 2 on line 000506 caused reference
to be made beyond the rightmost character of data item WORK-DATA-EXTRACT-RECORD.
From compile unit WDBBD101 at entry point WDBBD101 at statement 506 at compile unit offset +00000C74 at
entry offset +00000C74 at address 3E00168C. " |
|
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
The example code from CG cannot be used "as it is". You had to change it to fit your specifics.
If you post what you compiled, we may be able to offer suggestions.
Without seeing your code, it sounds like you are trying to process data past the length of the current record read. You have a "depending on", so the length can change for each read - it will not be a constant. |
|
Back to top |
|
|
CICS Guy
Senior Member
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
|
|
|
|
Try length of input - 1...... |
|
Back to top |
|
|
alluri12
New User
Joined: 15 Aug 2006 Posts: 44 Location: Virginia, USA
|
|
|
|
It worked!!!!!!!!!. I got to initialize the I and J fields each and every record otherwise it will pickup from where it stopped. Here is the exact code i used and it worked. Thank you CICS guy and others for your help.
Code: |
INITIALIZE WS-ADDR-IN
INITIALIZE WS-ADDR-OUT
MOVE 0 TO WS-ADDR-OUT
PERFORM VARYING WS-ADDR-IN FROM 1 BY 1 UNTIL
WS-ADDR-IN >= REC-LENGTH
IF WS-DATA-EXTRACT-RECORD(WS-ADDR-IN:2) = SPACE
CONTINUE
ELSE
ADD 1 TO WS-ADDR-OUT
MOVE WS-DATA-EXTRACT-RECORD(WS-ADDR-IN:1)
TO WS-DATA-EXTRACT-RECORD(WS-ADDR-OUT:1)
END-IF
END-PERFORM
MOVE WS-ADDR-OUT TO REC-LENGTH |
|
|
Back to top |
|
|
CICS Guy
Senior Member
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
|
|
|
|
Glad to hear...... |
|
Back to top |
|
|
|