IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

How to replace the blanks spaces in the record


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
alluri12

New User


Joined: 15 Aug 2006
Posts: 44
Location: Virginia, USA

PostPosted: Sat Sep 29, 2007 10:50 am
Reply with quote

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
View user's profile Send private message
murmohk1

Senior Member


Joined: 29 Jun 2006
Posts: 1436
Location: Bangalore,India

PostPosted: Sat Sep 29, 2007 11:24 am
Reply with quote

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
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2146
Location: At my coffee table

PostPosted: Sat Sep 29, 2007 3:30 pm
Reply with quote

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
View user's profile Send private message
alluri12

New User


Joined: 15 Aug 2006
Posts: 44
Location: Virginia, USA

PostPosted: Sat Sep 29, 2007 9:08 pm
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Sat Sep 29, 2007 9:23 pm
Reply with quote

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
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2146
Location: At my coffee table

PostPosted: Sat Sep 29, 2007 9:34 pm
Reply with quote

Try length of input - 1......
Back to top
View user's profile Send private message
alluri12

New User


Joined: 15 Aug 2006
Posts: 44
Location: Virginia, USA

PostPosted: Sat Sep 29, 2007 10:16 pm
Reply with quote

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
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2146
Location: At my coffee table

PostPosted: Sat Sep 29, 2007 11:10 pm
Reply with quote

Glad to hear...... icon_lol.gif
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts FINDREP - Only first record from give... DFSORT/ICETOOL 3
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
Search our Forums:

Back to Top