Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
How to replace the blanks spaces in the record

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: How to replace the blanks spaces in the record
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: 1439
Location: Bangalore,India

PostPosted: Sat Sep 29, 2007 11:24 am    Post subject:
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: 2150
Location: At my coffee table

PostPosted: Sat Sep 29, 2007 3:30 pm    Post subject:
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    Post subject:
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

Site Director


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

PostPosted: Sat Sep 29, 2007 9:23 pm    Post subject:
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: 2150
Location: At my coffee table

PostPosted: Sat Sep 29, 2007 9:34 pm    Post subject:
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    Post subject:
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: 2150
Location: At my coffee table

PostPosted: Sat Sep 29, 2007 11:10 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Copy 4 byte of data from the last rec... arunsoods DFSORT/ICETOOL 9 Fri Oct 06, 2017 12:15 pm
No new posts Remove leading spaces from numeric field rexx77 SYNCSORT 6 Wed Sep 06, 2017 2:15 am
No new posts Updating the Trailer count in variabl... satheshbabur DFSORT/ICETOOL 6 Wed Aug 30, 2017 9:49 pm
No new posts Repeat part of record multiple times Learncoholic DFSORT/ICETOOL 4 Tue Aug 29, 2017 11:33 am
No new posts Read two inputs and write into output... murali.andaluri DFSORT/ICETOOL 6 Wed Jul 26, 2017 7:35 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us