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

Using HIGH-VALUES with different format fields


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

New User


Joined: 19 May 2009
Posts: 9
Location: Spain

PostPosted: Thu Jun 25, 2009 2:12 pm
Reply with quote

It's simple, I need to move high-values to a field, so I'm doing this:

MOVE HIGH-VALUES TO WK-SALES-1

But, I'm getting a compilation error, don't know why...

I changed three times the definition of the field, but the error continues. So, I can't use the HIGH-VALUES in my program??

1)
05 WK-SALES-1 PIC 9(9).

"HIGH-VALUES" AND "WK-SALES-1 (NUMERIC INTEGER)" DID NOT FOLLOW THE "MOVE" STATEMENT COMPATIBILITY RULES.

2)
05 WK-SALES-1 PIC S9(18) COMP.

"HIGH-VALUES" AND "WK-SALES-1 (BINARY INTEGER)" DID NOT FOLLOW THE "MOVE" STATEMENT COMPATIBILITY RULES.

3)
05 WK-SALES-1 PIC S9(9) COMP-3.

"HIGH-VALUES" AND "WK-SALES-1 (PACKED INTEGER)" DID NOT FOLLOW THE "MOVE" STATEMENT COMPATIBILITY RULES.

Don't understand which compatibility rules it means.

Regards and thanks.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Thu Jun 25, 2009 2:33 pm
Reply with quote

high-values is not a numeric literal.

normally, a 'high value' or 'highest value' for a numeric is all 9's.

if you explain your problem - what is it that you are trying to accomplish -
someone could propose a solution.
Back to top
View user's profile Send private message
Mathiv Anan

Active User


Joined: 23 Jul 2008
Posts: 106
Location: USA

PostPosted: Thu Jun 25, 2009 2:38 pm
Reply with quote

Ensign,

High-values - we can say non-numeric values. Isn't it?

Since you are moving high-values (X'FFFFFFFF' etc) to numeric values, it is saying not compatible for a move statement.

Could you please let us know your actual requirement.

If you are trying to initialize the variable, you can use INITIALIZE or Move ZEROS statement.

Thanks.
Back to top
View user's profile Send private message
Ensign

New User


Joined: 19 May 2009
Posts: 9
Location: Spain

PostPosted: Thu Jun 25, 2009 3:12 pm
Reply with quote

It's a matching between files:

IF WK-SALES-1 = WK-SALES-2
MOVE R-AUTCOM TO REG-SALIDA
MOVE FIC-CAE-COMERCIO TO SAL-CAE
DISPLAY 'SAL-CAE: ' SAL-CAE
PERFORM WRITE-SALIDA
PERFORM READ-FILE-1
ELSE
IF WK-SALES-1 < WK-SALES-2
MOVE R-AUTCOM TO REG-SALIDA
MOVE SPACES TO SAL-CAE
PERFORM WRITE-SALIDA
PERFORM READ-FILE-1
ELSE
PERFORM READ-FILE-2
END-IF.

I can't control the end-of-file of file number 2 with high-values in the read paragraph.

The fact is that I want to write all records of file number 1 in output file, and when file number 2 is ended, it should continue writing the remain records of file number 1.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


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

PostPosted: Thu Jun 25, 2009 4:57 pm
Reply with quote

You'll need a REDEFINES on WK-SALES-1 to PIC X(09) and move the HIGH-VALUES to the PIC X field. You'll also want to use the PIC X field in your comparison or you could get a S0C7 abend.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Thu Jun 25, 2009 5:08 pm
Reply with quote

or if no valid sales area (w-sales-) can be all 9's, use all 9's.
Back to top
View user's profile Send private message
Ensign

New User


Joined: 19 May 2009
Posts: 9
Location: Spain

PostPosted: Thu Jun 25, 2009 7:59 pm
Reply with quote

Got it. As you said I redefined the field into an alphanumeric and it worked perfectly.

Thanks for your support.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Thu Jun 25, 2009 8:29 pm
Reply with quote

nested EVALUATEs tend to make this an easy task and removes the need for specials flags in key fields. It does require the use of FILE-STATUS clause for both files and appropriate level 88's:
Code:


CONTROL-SECTION                                 SECTION.

PERFORM READ-FILE1
PERFORM READ-FILE2
PERFORM CONTROL-SECTION
               UNTIL (EOF-FILE1 AND EOF-FILE2)
               OR      FILE1-ERROR
               OR      FILE2-ERROR
               OR      PROGRAM-STOP-REQUESTED
PERFORM EOJ
GOBACK
           .
CONTROL-SECTION-EXIT.
        EXIT.

PROCESS-FILES-SECTION                        SECTION.

EVALUATE  TRUE
    WHEN  NOT-EOF-FILE1 AND NOT-EOF-FILE2
          EVALUATE  TRUE
              WHEN  KEY-FILE1 < KEY-FILE2
                    PERFORM KEY1-IS-LESS-THAN-KEY2
                    PERFORM READ-FILE2
              WHEN  KEY-FILE1 > KEY-FILE2
                    PERFORM  KEY1-IS-GREATER-THAN-KEY2
                    PERFORM READ-FILE1
              WHEN  OTHER
                    PERFORM KEYS-ARE-EQUAL
                    PERFORM READ-FILE1
                    PERFORM READ-FILE2
          END-EVALUATE
    WHEN  NOT-EOF-FILE1 AND EOF-FILE2
          PERFORM  ONLY-HAVE-KEY1
          PERFORM READ-FILE1
    WHEN  EOF-FILE1     AND NOT-EOF-FILE2
          PERFORM  ONLY-HAVE-KEY2
          PERFORM READ-FILE2
    WHEN  OTHER
          CONTINUE
END-EVALUATE
     .
PROCESS-FILES-SECTION-EXIT.
     EXIT.
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 Binary File format getting change whi... All Other Mainframe Topics 7
No new posts Populate last day of the Month in MMD... SYNCSORT 2
No new posts INCLUDE OMIT COND for Multiple values... DFSORT/ICETOOL 5
No new posts Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
Search our Forums:

Back to Top