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

Initialize vs Move spaces, Which is efficient


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
HARLEEN SINGH MANN
Warnings : 2

New User


Joined: 03 Aug 2007
Posts: 17
Location: Pune

PostPosted: Mon Oct 22, 2007 11:18 pm
Reply with quote

among the following which is most efficient:

1) initialize ww-data
2) move spaces to ww-data

consider ww-data to be alphanumeric in both cases.

Plz mention the reason why u think which one is efficient and efficient in wat sense?

Warning: Title Edited
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: Mon Oct 22, 2007 11:48 pm
Reply with quote

Hello,

If ww-data is a pic x elementary item, they both do the same thing. One will run the same as the other.
Back to top
View user's profile Send private message
Harm10

New User


Joined: 13 Oct 2007
Posts: 10
Location: Holland

PostPosted: Tue Oct 23, 2007 1:23 am
Reply with quote

I think you'll have to elaborate some more about the exact definition of ww-data. Like Dick Scherrer says if it is only an elementary item (i.e. there are no lower levels beneath it) then there will be no difference.
If there are lower levels then the move will be much faster because initialize initializes every element anew!
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Tue Oct 23, 2007 1:33 am
Reply with quote

If ww-data has lower levels and any of them are ever changed to numeric then initialize will handle it correctly but move spaces may just cause a 0C7 or some similar error that will cause 10 or 15 posting on this board before it is debugged.
Back to top
View user's profile Send private message
Harm10

New User


Joined: 13 Oct 2007
Posts: 10
Location: Holland

PostPosted: Tue Oct 23, 2007 1:43 am
Reply with quote

Craq Giegerich wrote:
If ww-data has lower levels and any of them are ever changed to numeric then initialize will handle it correctly but move spaces may just cause a 0C7 or some similar error that will cause 10 or 15 posting on this board before it is debugged.

Quit right! To me this is obvious.............. icon_wink.gif
Initialize looks nice but has some downfalls like not initializing fillers..... icon_confused.gif
Back to top
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 691
Location: Earth

PostPosted: Tue Oct 23, 2007 9:50 am
Reply with quote

Quote:
Initialize looks nice but has some downfalls like not initializing fillers.....

Harm10,
I think otherwise, Fact that initialize verb does not intialize fillers can be used for our advantage.
Back to top
View user's profile Send private message
UmeySan

Active Member


Joined: 22 Aug 2006
Posts: 771
Location: Germany

PostPosted: Tue Oct 23, 2007 3:28 pm
Reply with quote

Hi !

Fore the FILLER fields you could use:
INITIALIZE ... WITH FILLER.

Please also have a look at the TO VALUE option.

Regards, UmeySan
Back to top
View user's profile Send private message
Harm10

New User


Joined: 13 Oct 2007
Posts: 10
Location: Holland

PostPosted: Wed Oct 24, 2007 12:57 pm
Reply with quote

UmeySan wrote:
Fore the FILLER fields you could use:
INITIALIZE ... WITH FILLER.

I don't know that option. I tried it and our compiler doesn't accept it.
In what Cobol release this option gets introduced?
Would be very nice to have............. icon_wink.gif
Back to top
View user's profile Send private message
puzzled_elton

New User


Joined: 09 May 2005
Posts: 7

PostPosted: Wed Oct 24, 2007 1:41 pm
Reply with quote

Hi,
extra care needs to taken while using move statement to avoid any data exception problems.usually move is used for indivisual variable for resetting its values.
Initialise is used used at group level to initialise the indivisual datya types with spaces or zeros depending on data attributes.
Back to top
View user's profile Send private message
TG Murphy

Active User


Joined: 23 Mar 2007
Posts: 148
Location: Ottawa Canada

PostPosted: Wed Oct 24, 2007 7:16 pm
Reply with quote

Guys,

If you compile using the LIST option it will show the Assembler statements. INITIALIZE WS-VAR generates 3 statements. MOVE SPACES TO WS-VAR generates 2 statements.

So technically --- MOVE performs better than INITIALIZE. But big deal...

I would totally ignore this fact in my decision making as to whether I should use VALUE or MOVE or INITIALIZE in order to initialize a variable. The difference in performance is totally insignificant. What is important is this.

1. VALUE behaves differently than MOVE or INITIALIZE. It only executes on the first call to a subprogram (there are exceptions). Whereas MOVE and INITIALIZE can execute every time in. (Exception is when you code the INITIAL keyword on PROGRAM-ID statement)

2. The INITIALIZE statement is great. Before it was introduced (yes - I'm getting old) you had to often code many MOVE statements to initialize a structure. It was error prone. All these tedious MOVE statements can be replaced with 1 simple INITIALIZE statement. Do I care that the INITIALIZE statement generates a few additional MVI assembler instructions? Nope.

3. If your concern is performance, your time is much better spent optimizing other things (ie. your design, your SQL). Much greater payback on your time investment there.

Cheers
Back to top
View user's profile Send private message
UmeySan

Active Member


Joined: 22 Aug 2006
Posts: 771
Location: Germany

PostPosted: Fri Oct 26, 2007 1:10 pm
Reply with quote

Hi !

@ HARM_10

It's COBOl Enterprise V3R4. But There's also al lot more:
• Raise 16Mb COBOL data item size limit
• Unicode support stage 2
• NUMVAL, NUMVAL-C, enhancements
• DB2 enhancements
• REDEFINES enhancement
• MDECK compiler option
• SEARCH ALL statement updates

There are also some stealth features for retrieving Z/OS informations.
• Send your own messages to operator
• Decide if you want to stop or continue after error
• Log error information
– Environment variables: Setting and Retrieving
– Dynamic file allocation without assembler (not CBLQDA)
– Retrieving information about an ABEND with COBOL
– XML GENERATE
– Retrieving SYSTEM info using COBOL
– Displaying HEX data as printable
– Testing bit settings in COBOL

Please check it out at IBM website. There's some PDF stored.

Prettig weekend & Veel succes, UmeySan


@TG Murphy

Respect, I agree. Nowadays some micro-milli-nano or whatever fucking seconds don't matter. Also some Bytes more don't have an effect.

It's better spending time in creating a clear, neatly arranged and structured program, whatever language you use, Cob or Ass, so that mostley everyone could simply do a needed change in the middle of the night after some bottels of red wine and a lazy time with two blonds.

That's what we had to do years ago, and also sometimes today.
Amendment statement: Today, ... there is still only the red wine

Regards & nice Weekend, UmeySan
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Sat Oct 27, 2007 1:42 am
Reply with quote

UmeySan wrote:
night after some bottels of red wine and a lazy time with two blonds.

Amendment statement: Today, ... there is still only the red wine

Regards & nice Weekend, UmeySan


Did the 2 blonds go because of the cheap red wine or did you go to cheap red wine because the 2 blonds left?
Back to top
View user's profile Send private message
Harm10

New User


Joined: 13 Oct 2007
Posts: 10
Location: Holland

PostPosted: Sat Oct 27, 2007 1:57 am
Reply with quote

UmeySan wrote:
Please check it out at IBM website. There's some PDF stored.

Prettig weekend & Veel succes, UmeySan

Will check it out!
Veel plezier met de blondjes............... icon_wink.gif
Back to top
View user's profile Send private message
UmeySan

Active Member


Joined: 22 Aug 2006
Posts: 771
Location: Germany

PostPosted: Tue Oct 30, 2007 1:51 pm
Reply with quote

Hi Craq !

Who the hell put rumours in circulation, that it had been cheap red wine ?
It's the the exact opposite. In fact of the expensive wine and the conspicuous consumption, I couldn't pay the blonds anymore.

Becoming older, you must change the order of priorities !!! ;-)

Have a nice time, UmeySan
Back to top
View user's profile Send private message
Harm10

New User


Joined: 13 Oct 2007
Posts: 10
Location: Holland

PostPosted: Thu Nov 01, 2007 6:53 pm
Reply with quote

@ Umeysan
I checked the reference guide of Cobol Enterprise Server V3R4 and the option WITH FILLER is not specified.
As we got this version running I tried the option and it is not recognized.
Could you please check again what version contains this option?
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: Thu Nov 01, 2007 7:57 pm
Reply with quote

Hello,

INITIALIZE "WITH FILLER" is valid with Fujitsu and Micro-Focus COBOL (and others i believe).

I've not seen it with IBM mainframe COBOL compilers.
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