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

Issue with REDEFINE clause


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

New User


Joined: 21 Jan 2012
Posts: 58
Location: India

PostPosted: Sat Aug 25, 2012 8:47 am
Reply with quote

I have 2 programs. Program A is calling program B and both the programs are using same copybook. Program A will pass values in that include and program B will do some calculations and will update the fields in the same copybook.

Copybook is defined something like this:
Code:

10 WS-TBL-FIELDS.                                 
   15 WS-01V-AUTH-SALES-TODAY    PIC S9(7)V99 COMP-3.
   15 WS-50V-AUTH-TODAY-DTE      PIC S9(9)    COMP-3.
   15 WS-AUTH-SALES.
       20 WS-09V-AUTH-SALE-DTE    PIC S9(9)    COMP-3.
       20 WS-10V-AUTH-SALE-AMT    PIC S9(7)V99 COMP-3.
       20 WS-11V-AUTH-SALE-DTE    PIC S9(9)    COMP-3.
       20 WS-12V-AUTH-SALE-AMT    PIC S9(7)V99 COMP-3.
       20 WS-13V-AUTH-SALE-DTE    PIC S9(9)    COMP-3.
       20 WS-14V-AUTH-SALE-AMT    PIC S9(7)V99 COMP-3.
       20 WS-15V-AUTH-SALE-DTE    PIC S9(9)    COMP-3.
       20 WS-16V-AUTH-SALE-AMT    PIC S9(7)V99 COMP-3.
       20 WS-17V-AUTH-SALE-DTE    PIC S9(9)    COMP-3.
       20 WS-18V-AUTH-SALE-AMT    PIC S9(7)V99 COMP-3.
       20 WS-19V-AUTH-SALE-DTE    PIC S9(9)    COMP-3.
       20 WS-20V-AUTH-SALE-AMT    PIC S9(7)V99 COMP-3.
       20 WS-21V-AUTH-SALE-DTE    PIC S9(9)    COMP-3.
       20 WS-22V-AUTH-SALE-AMT    PIC S9(7)V99 COMP-3.
       20 WS-51V-AUTH-SALE-DTE    PIC S9(9)    COMP-3.
       20 WS-52V-AUTH-SALE-AMT    PIC S9(7)V99 COMP-3.
       20 WS-53V-AUTH-SALE-DTE    PIC S9(9)    COMP-3.
       20 WS-54V-AUTH-SALE-AMT    PIC S9(7)V99 COMP-3.
       20 WS-55V-AUTH-SALE-DTE    PIC S9(9)    COMP-3.
       20 WS-56V-AUTH-SALE-AMT    PIC S9(7)V99 COMP-3.
   15 FILLER  REDEFINES  WS-AUTH-SALES.               
       20 WS-AUTH-SALE-ENTRY      OCCURS 10 TIMES     
                                 INDEXED BY WS-ASX.
           25 WS-AUTH-SALE-DTE     PIC S9(9)    COMP-3.
           25 WS-AUTH-SALE-AMT     PIC S9(7)V99 COMP-3.                                 

Program B is having logic like this:
Code:

IF  WS-01V-AUTH-SALES-TODAY  NOT =  ZEROS               
    MOVE  WS-AUTH-SALE-ENTRY (9)  TO                   
                                WS-AUTH-SALE-ENTRY (10)
    MOVE  WS-AUTH-SALE-ENTRY (8)  TO                   
                                WS-AUTH-SALE-ENTRY (9) 
    MOVE  WS-AUTH-SALE-ENTRY (7)  TO                   
                                WS-AUTH-SALE-ENTRY (8) 
    MOVE  WS-AUTH-SALE-ENTRY (6)  TO                   
                                WS-AUTH-SALE-ENTRY (7) 
    MOVE  WS-AUTH-SALE-ENTRY (5)  TO                   
                                WS-AUTH-SALE-ENTRY (6) 
    MOVE  WS-AUTH-SALE-ENTRY (4)  TO                   
                                WS-AUTH-SALE-ENTRY (5) 
    MOVE  WS-AUTH-SALE-ENTRY (3)  TO                   
                                WS-AUTH-SALE-ENTRY (4) 
    MOVE  WS-AUTH-SALE-ENTRY (2)  TO                   
                                WS-AUTH-SALE-ENTRY (3) 
    MOVE  WS-AUTH-SALE-ENTRY (1)  TO                   
                                WS-AUTH-SALE-ENTRY (2) 
    MOVE  WS-01V-AUTH-SALES-TODAY  TO                   
                                WS-AUTH-SALE-AMT (1)   
    MOVE  WS-50V-AUTH-TODAY-DTE  TO                     
                                WS-AUTH-SALE-DTE (1)   
    MOVE  ZEROS             TO  WS-01V-AUTH-SALES-TODAY.


Before call to program B initial values for some of the fields are:
WS-01V-AUTH-SALES-TODAY = 100
WS-50V-AUTH-TODAY-DTE is = 20120824.
and
WS-09V-AUTH-SALE-DTE = 20120823
WS-10V-AUTH-SALE-AMT = 50 so as per the copybook definition these 2 fields should be equal to WS-AUTH-SALE-ENTRY(1).

Now the issue is as per the logic in program B value in WS-AUTH-SALE-ENTRY(1) should be moved to WS-AUTH-SALE-ENTRY(2). But I am not at all getting any values from WS-AUTH-SALE-ENTRY(1) to (10) in the called program B.

I am suspecting that something wrong with my REDEFINE caluse but I could not figure out. Can anyone assist me?
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: Sat Aug 25, 2012 9:03 am
Reply with quote

Hello,

At a quick glance, the redefine looks ok. Suggest you put a few displays in program B after the moves and in program A after the call to program B.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Sat Aug 25, 2012 9:03 am
Reply with quote

WHY do you think something is wrong with your REDEFINES? From the symptoms you've described, the problem most likely is in the CALL statement in program A or the LINKAGE SECTION or PROCEDURE DIVISION USING in program B.

Have you displayed the values in program A just before the CALL? Have you displayed the values in program B first thing in the PROCEDURE DIVISION? If not, why not?

What do you think can go wrong with a REDEFINES anyway? All a REDEFINES does is take the exact same storage and give different names to the bytes of storage -- not a whole lot can go wrong with that. There could be something wrong if your various definitions don't match (for example, one has USAGE COMP and the other uses the same bytes as USAGE COMP-3), but that's your fault, not the REDEFINES.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Sat Aug 25, 2012 10:59 am
Reply with quote

Quote:
Copybook is defined something like this:

something?
and you want us to verify that?
show us the copybook and receive an analysis.

that you would have to even ask,
indicates a very low experience level.

as a result everything is subject to question,
and none of your assumptions can be trusted.

something like that!
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Sat Aug 25, 2012 11:25 am
Reply with quote

Code:
15  FILLER 
    REDEFINES 
    WS-AUTH-SALES.               
    20  WS-AUTH-SALE-ENTRY             OCCURS 10 TIMES     
                                       INDEXED BY WS-ASX-1,
                                                  WS-ASX-2.
        25  WS-AUTH-SALE-DTE           PIC S9(9)    COMP-3.
        25  WS-AUTH-SALE-AMT           PIC S9(7)V99 COMP-3.



Code:
PERFORM VARYING WS-ASX-2
           FROM 10
             BY -1
          UNTIL WS-ASX-2 = 1
    SET WS-ASX-1 TO WS-ASX-1
    SET WS-ASX-1 DOWN BY 1
    MOVE WS-AUTH-SALE-ENTRY (WS-ASX-1)
      TO WS-AUTH-SALE-ENTRY (WS-ASX-2)
END-PERFORM


The code that you showed us
(even though I obviously take issue)
did not cause your problem.

Your style of code suggests that your error lies elsewhere
in the event,
that your CALL USING list
and your PROCEDURE DIVISION USING list
are correct.
Quote:
Program A will pass values in that include

INCLUDE is a DB2 pre-compiler term.
Back to top
View user's profile Send private message
chetanambi

New User


Joined: 21 Jan 2012
Posts: 58
Location: India

PostPosted: Sat Aug 25, 2012 12:00 pm
Reply with quote

Thanks a lot for your quick replies..

I found that program B itself is zeroing out the fields based on logic in the program. I overlooked the program. Sorry for that. I will be meticulous next time before posting.

Quote:

something?
and you want us to verify that?
show us the copybook and receive an analysis.

I didn't meat it dbZ. I just wanted to show piece of copybook. Maybe wrong with my english. Anways thanks dbZ.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Sat Aug 25, 2012 12:58 pm
Reply with quote

glad you found your problem.

i will give you more slack next time
and treat you as the professional that you appear to be.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Sat Aug 25, 2012 2:25 pm
Reply with quote

Is the purpose of the REDEFINES only that "shuffle"?

I don't see much problem with coding-out the MOVEs without the REDEFINES. If the REDEFINES has other use, then with the literal values for subscripts it seems OK.

The loop is less "lines of code", but more effort for the poor little machine :-)

Zippiest of all is an "overlapping" MOVE, but you get a diagnostic message these days...

[Edit: Ignore the above line. It will be fast, but will not do what you want]

If you ever think a REDEFINES is wrong, the easiest thing is to look at the compile listing and reassure (or otherwise) yourself that way.
Back to top
View user's profile Send private message
chetanambi

New User


Joined: 21 Jan 2012
Posts: 58
Location: India

PostPosted: Sat Aug 25, 2012 2:36 pm
Reply with quote

Quote:

Is the purpose of the REDEFINES only that "shuffle"?

This code is existing from long. BUt in this program its for only that shuffle.

By the way thanks for more information, Bill..
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Sat Aug 25, 2012 9:33 pm
Reply with quote

Quote:
The loop is less "lines of code", but more effort for the poor little machine :-)

the TS indicated that the copybook presented was a 'snapshot' of the real copybook.
in that some of the variable names have 56,
we are talking about more that 10 moves.
instead of using subscripts
which is more code that actual reference names,
the redefine should be done differently,
so as not to need indexing.
less lines of code means smaller module.
smaller module means, possibly,
another job could be executing,
instead of waiting for this job - with the large amount of code - to finish icon_lol.gif

Quote:
Zippiest of all is an "overlapping" MOVE, but you get a diagnostic message these days...


the MVC and MVCL instructions move left to right which is not what you want,
and why you get the warning during compile.
in the case of MVCL, if overlap occurs (as it will)
the condition code will be set to 3 and no move is done
if it is done, the first part of the sending
would be repeatedly propagated throughout the receiving.
what you want in the case of a shuffle down,
is a right to left move.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Sat Aug 25, 2012 11:03 pm
Reply with quote

[Edit:

I pickled this one. Something should have "clicked", in fact "thudded", when I mentioned INITIALIZE. But didn't.

None of the below is to do with the question asked. As dbz says later, the example will copy A across the entire field, which is where we get to the initialisation, but where, right up front, we divert from the question. Sorry about that]

MVC and MVCL go left to right. Good. Not the way I want it? Wrong. Exactly the way I want. Lucky, eh?

Code:

ABCDEFGH
________
 +++++++


If you move the field defined by _________ to that defined by ++++++++, from left to right, do you get the answer wanted?

Code:
AABCDEFG


Then you splat the first A.

The warning comes because the compiler, these days, has concerns over whether we've coded what we want. Well, we have, and unfortunately no way to get rid of the message (OK, there is, but no way by changing any code and still doing what we want).

Exactly why the compiler does that, I don't know. Maybe so many problems with reference-modification accidently overlapping?

Now, imagine that the move of the field is from the REDEFINES to a different place. Generates an MVCL. Super.

Now. imagine the we do the actual MOVE we want, with the overlap. What does the compiler do (along with issuing the warning)? It no longer uses MVCL because the compiler is also cognisant of that fact. So, instead, it generates a bunch of MVCs to do the job.

Now, at what point the code for a number of 256-byte MVCs become longer than the code for your loop and move, I can leave you to work out, if you want :-)

Where would the size of the program (which would only be a few bytes either way) affect any "waiting"? I always thought (and can easily be wrong) that the REGION determined how much memory was allocated, not the actual size of any programs.

Perhaps I have misunderstood your point?

Back to the first. Interesting question over whether, with OPT, the MOVEs would count as being for consecutive storage. I don't know. Have to check when I get the chance. Would OPT generate the "offset move"? Doesn't do it for INITIALIZE (which "offset move" beats), it would be funny if it did for this.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Sun Aug 26, 2012 12:20 am
Reply with quote

FM,

left to right would propagate the A throughout the +++++ receiving field. That is why I put the hyperlink in my post.

apparently the TS is aware of this,
since his shuffle was right to left.
9 to 10, 8 to 9, etc
instead of 1 to 2, 2 to 3, 3 to 4 (which is left to right).

Quote:
(and can easily be wrong) that the REGION determined how much memory was allocated


very easily, it is how much memory CAN be allocated, not is.

i don't think understanding my point was yours.

but, as far as individual instructions as apposed to loop,
admittedly, that was tongue-in-check.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Sun Aug 26, 2012 12:35 am
Reply with quote

Jeez, I must be thinking of too many things at once today (one) :-)
Back to top
View user's profile Send private message
chetanambi

New User


Joined: 21 Jan 2012
Posts: 58
Location: India

PostPosted: Sun Aug 26, 2012 8:11 am
Reply with quote

dbz and Bill,

Sometimes its very difficult to understand what you people discussing icon_neutral.gif. Its too technical. After reading few times I understood a little icon_razz.gif ..

By the way what TS refers to?
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: Sun Aug 26, 2012 8:31 am
Reply with quote

Hello,

TS = Topic Starter.

Several of us enjoy taking a topic "to another level".

There is a lot to be learned in these discussions, but unless you are a student of the particular discipline (which goes considerably deeper than using the discipline), it can be quite intimidating icon_cool.gif

This is true of programming languatges, jcl, database design/implementation, and just about everything else. . .

Hopefiully, in spite of us elaborating, you will, get what you need and what you want to get working - wll work.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Sun Aug 26, 2012 2:10 pm
Reply with quote

chetanambi wrote:
dbz and Bill,

Sometimes its very difficult to understand what you people discussing icon_neutral.gif. Its too technical. After reading few times I understood a little icon_razz.gif ..

By the way what TS refers to?


Sorry chetanambi, I made a complete pickle of the thing anyway.

My original point was supposed to be that the MOVEs with the literal subscripts are equivalent to the the MOVEs of the named fields. With literal subscripts, the compiler just uses the actual address and length, as it does with a named field. So I was wondering why not just do the named MOVEs and forget the REDFINES if not used for something else.

dbz pointed out that you may well have a considerable number of these.

I brilliantly suggested a method which would set all your fields to the value of the first field. "brilliant" I'm using ironically.

The real advantage of the loop over the individual moves is that it avoids the possibility of typos/editos where the wrong field eends up somewhere. With the loop correctly coded, this cannot happen.
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 SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts Issue after ISPF copy to Linklist Lib... TSO/ISPF 1
No new posts To search DB2 table based on Conditio... DB2 1
No new posts Facing ABM3 issue! CICS 3
No new posts Panvalet - 9 Character name - Issue c... CA Products 6
Search our Forums:

Back to Top