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

Removing Space from Alphanumeric edited item


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

New User


Joined: 29 Mar 2006
Posts: 59
Location: Montreal

PostPosted: Tue Jan 16, 2007 3:33 pm
Reply with quote

Hello All,
I have a record like this
01 delta-record
05 acct-num PIC x(10) VALUE SPACE.
05 comma PIC x(01) VALUE ','.
05 Address PIC x(20) VALUE SPACE.

But acutally acct-num data item will be populated with the data of legth 5, so the records are written with the spaces like shown below.

23456 ,house # 1 bsk ramanagaram
42358 , 786 bangalore

I want to supress the spaces which are inserted due to acc-num data item, keeping the legth of the dataitem as 10 itself, please suggest me the editing character for doing this.

Thanks in advance
Venkat
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Tue Jan 16, 2007 3:58 pm
Reply with quote

Assuming COBOL:
compute acct-num = function numval (acct-num)
Back to top
View user's profile Send private message
venktv

New User


Joined: 29 Mar 2006
Posts: 59
Location: Montreal

PostPosted: Tue Jan 16, 2007 4:21 pm
Reply with quote

Hi William,
acct-num is a alphanumeric item, so is it possible to use NUMVAL function on alphanumeric data item?

With regs
Venkat
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Tue Jan 16, 2007 4:25 pm
Reply with quote

My bad....
the source field "must be a nonnumeric literal or an alphanumeric data item" but the recieving field should have been numeric...
Back to top
View user's profile Send private message
venktv

New User


Joined: 29 Mar 2006
Posts: 59
Location: Montreal

PostPosted: Tue Jan 16, 2007 4:35 pm
Reply with quote

This data item may also contain non-numeric data in it, so I think this will not work, is there any editing chars we can use to supress the SPACES..like how we supress zeros using Z in numeric dataitems.

Thanks
Venkat
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Tue Jan 16, 2007 4:53 pm
Reply with quote

The only requirement is that at least one numeric character must exist in the source field.
Back to top
View user's profile Send private message
venktv

New User


Joined: 29 Mar 2006
Posts: 59
Location: Montreal

PostPosted: Tue Jan 16, 2007 6:42 pm
Reply with quote

Thanks William,

Now, I have another problem, since receiving filed should be capable of holding maximum 10 chars, I have declared it as X(10)...so still spaces are written into the file.

Is there any way to declare a variable of variable length?

thanks
Venkat
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Tue Jan 16, 2007 6:46 pm
Reply with quote

venktv wrote:
TNow, I have another problem, since receiving filed should be capable of holding maximum 10 chars, I have declared it as X(10)...so still spaces are written into the file.
Is there any way to declare a variable of variable length?
Declare it as 9(10), that'll stop those pesky spaces..... icon_lol.gif
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1353
Location: Israel

PostPosted: Tue Jan 16, 2007 7:55 pm
Reply with quote

Maybe the STRING command will come in handy:
Instead of:
Code:
01 delta-record
   05 acct-num PIC x(10) VALUE SPACE.
   05 comma PIC x(01) VALUE ','.
   05 Address PIC x(20) VALUE SPACE.
use only:
Code:
01  delta-record   PIC X(31).


and instead of moving the 2 fields (acct-num and Address) do a:
Code:
    STRING input-acct-num DELIMITED BY SPACE
          ','             DELIMITED BY SIZE
          input-address   DELIMITED BY SIZE
    INTO  delta-record

That may solve the problem.
Back to top
View user's profile Send private message
venktv

New User


Joined: 29 Mar 2006
Posts: 59
Location: Montreal

PostPosted: Wed Jan 17, 2007 12:21 pm
Reply with quote

Hi Marso,
Thanks very much, it is really cool option and working fine...

Hi William,
Thanks very much for your guidance...

With regards
Venkat
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 Replace each space in cobol string wi... COBOL Programming 3
No new posts Merge 2 lines based on Space from a S... DFSORT/ICETOOL 5
No new posts Allocated space calculation from DCOL... PL/I & Assembler 3
No new posts split a name based on space in ASM PL/I & Assembler 9
No new posts Adding space to a dataset - getting D37 ABENDS & Debugging 10
Search our Forums:

Back to Top