Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

move spaces and move all spaces

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
sanil m

New User


Joined: 24 Aug 2007
Posts: 38
Location: chennai

PostPosted: Wed Feb 06, 2008 2:45 pm    Post subject: move spaces and move all spaces
Reply with quote

Hi,

I would like to know is there any difference between

MOVE SPACES TO WS-VAR-A

MOVE ALL SPACES TO WS-VAR-A

When exactly is MOVE ALL SPACES used?
Back to top
View user's profile Send private message

Gnanas N

Active Member


Joined: 06 Sep 2007
Posts: 785
Location: Chennai, India

PostPosted: Wed Feb 06, 2008 3:09 pm    Post subject:
Reply with quote

No.
Back to top
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 685
Location: Earth

PostPosted: Wed Feb 06, 2008 3:17 pm    Post subject:
Reply with quote

Quote:
When exactly is MOVE ALL SPACES used?

We will never need to use it. Let me explain with small example.
Suppose
Code:
  01  WS-VAR-A PIC X(10).

 Move '*' to WS-VAR-A
 Now the contents of WS-VAR-A will be '*         '

That means for an alphanumeric move, if length of source operand lesser than the destination operand, spaces will be appended.
Hope it is clear now.
Back to top
View user's profile Send private message
sanil m

New User


Joined: 24 Aug 2007
Posts: 38
Location: chennai

PostPosted: Wed Feb 06, 2008 4:19 pm    Post subject:
Reply with quote

thanx for clearing my doubt....
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Wed Feb 06, 2008 4:38 pm    Post subject: move spaces and move all spaces
Reply with quote

The MOVE ALL statement comes in handy when you need to populate a variable (IE: WS-VAR-A) with something other than a figurative constant, for example all '9's.

Code:

MOVE ALL '9' TO WS-VAR-A.

The compiler will calculate the field-length, regardless of its size and pad the entire field with '9'.

Note that MOVE SPACES, MOVE ZEROS, MOVE LOW-VALUES and MOVE HIGH-VALUES don't require the ALL clause and will fully populate a target-field with the proper figurative constant value.

HTH....

Regards,

Bill
Back to top
View user's profile Send private message
ksk

Active User


Joined: 08 Jun 2006
Posts: 356
Location: New York

PostPosted: Wed Feb 06, 2008 5:07 pm    Post subject:
Reply with quote

MOVE ALL SPACES never be used. Even if you want to move ALL spaces, just use MOVE SPACES.

KSK
Back to top
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 685
Location: Earth

PostPosted: Wed Feb 06, 2008 5:40 pm    Post subject:
Reply with quote

Quote:
The compiler will calculate the field-length, regardless of its size and pad the entire field with '9'.

Nice imagination but NO. For "move all" compiler will generate an MVC instruction with overlapping operands wherever possible. It is unnecessary to calculate length.
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Wed Feb 06, 2008 6:34 pm    Post subject:
Reply with quote

agkshirsagar wrote:
Quote:
The compiler will calculate the field-length, regardless of its size and pad the entire field with '9'.

Nice imagination but NO. For "move all" compiler will generate an MVC instruction with overlapping operands wherever possible. It is unnecessary to calculate length.

Well actually, an MVI is issued against the first byte, followed by the normal MVC propagation technique of the remainder.

However, if the variable exceeds a certain length (could be the 256-max of the MVC but, I'm not too sure of the cutoff point), the compiler will generate an MVCL.

Nice try.... icon_rolleyes.gif

Bill
Back to top
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 685
Location: Earth

PostPosted: Wed Feb 06, 2008 8:31 pm    Post subject:
Reply with quote

Well.. agreed to all that you said I agree that I misjudged you. icon_smile.gif
My point was length will not be calculated in case of MOVE ALL.
Compiler will use implicit length of destination field as it knows the length of variable from our declaration.

Code:
  WS-VAR-A         DS               CL10
   
    MVI WS-VAR-A,C'9'
    MVC WS-VAR-A+1(9),WS-VAR-A

I am a newbie in ASSEMBLER but do let me know if I wrote it right. I don't have access to mainframe these days, otherwise I would have checked my code by writing a small COBOL prog and producing assembler listing.
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
This topic is locked: you cannot edit posts or make replies. How to move a long alphanumeric data ... lind sh COBOL Programming 8 Mon Dec 05, 2016 7:51 pm
No new posts Protection Exception while move 0 to ... Kevin Vaz CICS 10 Tue Oct 18, 2016 4:19 pm
No new posts To trim spaces in a pipe delimited da... Nish84 COBOL Programming 16 Mon Oct 10, 2016 1:54 pm
No new posts Removing Extra Spaces in a comma sepa... Puspojit DFSORT/ICETOOL 3 Tue Sep 13, 2016 7:46 am
This topic is locked: you cannot edit posts or make replies. Alphanumeric to Numeric move on UNIX mistah kurtz COBOL Programming 16 Wed Jul 27, 2016 8:47 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us