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

move spaces and move all spaces


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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: 792
Location: Chennai, India

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

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

Active Member


Joined: 27 Feb 2007
Posts: 691
Location: Earth

PostPosted: Wed Feb 06, 2008 3:17 pm
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
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: 2501
Location: Atlanta, Georgia, USA

PostPosted: Wed Feb 06, 2008 4:38 pm
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: 355
Location: New York

PostPosted: Wed Feb 06, 2008 5:07 pm
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: 691
Location: Earth

PostPosted: Wed Feb 06, 2008 5:40 pm
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: 2501
Location: Atlanta, Georgia, USA

PostPosted: Wed Feb 06, 2008 6:34 pm
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: 691
Location: Earth

PostPosted: Wed Feb 06, 2008 8:31 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts leading spaces can be removed in trai... DFSORT/ICETOOL 1
No new posts COBOL - Move S9(11)v9(7) COMP-3 to -(... COBOL Programming 5
No new posts Cobol program with sequence number ra... COBOL Programming 5
No new posts How to move the first field of each r... DFSORT/ICETOOL 5
No new posts To Remove spaces (which is in hex for... JCL & VSAM 10
Search our Forums:

Back to Top