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
 

 

Issue with LE migration - with TRUNC option

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

Active User


Joined: 11 Apr 2008
Posts: 144
Location: Jamshedpur

PostPosted: Tue Nov 13, 2012 8:01 pm    Post subject: Issue with LE migration - with TRUNC option
Reply with quote

Hi All,

Recently we migrated our code from VS COBOL II to enterprise and we faced one problem.Below code abended in Enterprise COBOL -

MOVE SUB TO FETCH-CNT
01 SUB PIC 9(2) COMP
01 FETCH-CNT PIC 999

In NON LE the trunc coption was OPT.

In LE the trunc option is STD.

My hypothesis was the trunc option is playing the spoilsport, since in LE we are limiting the size of variable SUB to 2 bytes when 100 is moved only 00 is stored and hence the issue.

In NON LE the trunc option is OPT. Since 100 can still be stored in halfword, the truncation is not happening as a result the program is working.

To prove this, I put displays in both LE and NON LE modules. In LE the variable SUB shows 00 and then it is abending. In NON LE, the variable SUB shows 00, but FETCH-CNT shows 100 which means correct data is moved to FETCH-CNT. But my "Dsiplay" is limiting the display to 2 bytes ie 00 only. My question is -
1. Is my hypothesis correct? If so, how can I display that SUB is able to hold 100 in NON LE.

Please let me know in case of any concerns.
Back to top
View user's profile Send private message

enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Tue Nov 13, 2012 8:29 pm    Post subject: Reply to: Issue with LE migration - Issue with TRUNC
Reply with quote

speak to the person/group that customized the new cobol installation
THEY should have read and understood before deploying it the differences between the old and new

and should know how to customize the new defaults option by assembling with the proper parameters the IGYCOPT macro

such a simple issue should have been spotted pretty early in the installation procedure
Back to top
View user's profile Send private message
Ed Goodman

Active Member


Joined: 08 Jun 2011
Posts: 556
Location: USA

PostPosted: Tue Nov 13, 2012 8:59 pm    Post subject:
Reply with quote

Quote:
THEY should have read and understood before deploying it


[/quote]
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Tue Nov 13, 2012 9:02 pm    Post subject: Reply to: Issue with LE migration - Issue with TRUNC
Reply with quote

as usual
they do not have the time to do <things> in the right way
but they have the time to do them twice icon_wink.gif
Back to top
View user's profile Send private message
saurabh39
Warnings : 1

Active User


Joined: 11 Apr 2008
Posts: 144
Location: Jamshedpur

PostPosted: Tue Nov 13, 2012 9:13 pm    Post subject: Reply to: Issue with LE migration - Issue with TRUNC
Reply with quote

Hi All,

My next step is to go to them only, but before I say or ask them to do something, I wanted to be sure of what I am speaking thats why I came here.

Regards,
Tushar
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7241

PostPosted: Tue Nov 13, 2012 9:24 pm    Post subject: Reply to: Issue with LE migration - Issue with TRUNC
Reply with quote

The options you are talking about are Cobol options, nothing to do with LE.

You only want OPT if your data conforms to PICture. Which means, if you have COMP PIC 9(2), then with OPT your results will be unreliable and only predictable from the particular code-sequence the compiler chooses to generate.

You should review all compile options, if one is "wrong" there may be others (plus note it is not "wrong", it is different).

Someone has not done there homework. Time to start it now.

EDIT: Meaning when you are stuffing greater than 99 into it.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7914
Location: Bellevue, IA

PostPosted: Tue Nov 13, 2012 9:32 pm    Post subject:
Reply with quote

TRUNC(OPT) is a dangerous option, especially in production. From the Enterprise COBOL Programming Guide manual on the TRUNC option:
Quote:
Use the TRUNC(OPT) option only if you are sure that the data being moved into the binary areas will not have a value with larger precision than that defined by the PICTURE clause for the binary item. Otherwise, unpredictable results could occur. This truncation is performed in the most efficient manner possible; therefore, the results are dependent on the particular code sequence generated. It is not possible to predict the truncation without seeing the code sequence generated for a particular statement.
In other words, your site got lucky that OPT worked as BIN in your case -- it very easily could not have, and in my simple testing OPT worked like STD not BIN. Production sites should NEVER execute something where "unpredictable results could occur".

Testing your hypothesis is real simple -- compile a program that displays the values of SUB and FETCH-CNT after moving 100 to SUB, then moves SUB to FETCH-CNT. Use compiler option TRUNC(OPT) and execute, then recompile with TRUNC(BIN) and execute -- optionally, use TRUNC(STD) and recompile, then execute so you can see all the options.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7241

PostPosted: Tue Nov 13, 2012 10:17 pm    Post subject: Reply to: Issue with LE migration - Issue with TRUNC
Reply with quote

How did you manage to get an "abend" with the line of code you showed? I can think of no possible way to get that line of code, with those data definitions, to abend, so I'm interested.

If your data "conforms to PICture" and is COMP or COMP-4 - ie, PIC 9 has max value of 9, PIC 99 has max of 99, PIC 999 has max of 999, PIC 9999, then you may reliably your TRUNC(OPT), TRUNC(STD), TRUNC(BIN) in Enterprise Cobol.

If your data does not "conform to PICture" - ie, you'd like to store 10 or more, 100 or more, 1,000 or more, 10,000 or more, then only TRUNC(BIN) or defining as COMP-5 will do what you want.

As Robert has indicated, using OPT in your original programs was not a good choice, as you either "got lucky" or you don't yet know how unlucky you got.

This, for me, is one of those "I wish it wasn't like that, but at least we've discovered it now, so let's check on what's gone wrong because of it" moments. If your system has been USING OPT and deliberately not conforming to PICture, then it's been an accident-waiting-to-happen,-or,-that-has-happened-and-is-waiting-to-be-noticed.

On the question of the DISPLAY, the only way you'll get it to show the full value in itself is by redefining it as a PIC XX and displaying that, then look at it in HEX. OPT is assuming, not unreasonably, that if your have PIC 99 then you only want two digits when you DISPLAY it.
Back to top
View user's profile Send private message
saurabh39
Warnings : 1

Active User


Joined: 11 Apr 2008
Posts: 144
Location: Jamshedpur

PostPosted: Wed Nov 14, 2012 1:26 am    Post subject: Reply to: Issue with LE migration - Issue with TRUNC
Reply with quote

The line of code i showed was the culprit and not exactly the line of code at which program abended. Basically the receiving field FIXED-CNT is used as a subscript, so when 100 was moved, the FIXED-CNT had 00, so when the data was inserted into the table..it abended with Array out of bound.

Anyways, thanks everyone for response, I will talk to the admin team on this now.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7241

PostPosted: Wed Nov 14, 2012 2:23 am    Post subject: Reply to: Issue with LE migration - Issue with TRUNC
Reply with quote

OK, that makes more sense. However, to move a binary field to a USAGE DISPLAY field to use it as a subscript... where it will get turned back into a binary (each time going via converting it to packed) is a little wasteful :-)
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 Nov 14, 2012 3:56 am    Post subject: Reply to: Issue with LE migration - Issue with TRUNC
Reply with quote

Define the variable as an unsigned PIC 9(09) COMP or COMP-5 (if supported) and you won't go wrong.

Many years ago, out of the new fangled internal definition of the TRUNC compile option, I recommend programmers avoid halfwords and instead, use fullwords.

If you use TRUNC(OPT) and COMP-5 is not supported, your maximum is 999999999, which should cover you.

If your compiler supports COMP-5 (Native Binary), then use it instead.

The TRUNC option has no effect on COMP-5 variables and is ignored.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7241

PostPosted: Wed Nov 14, 2012 5:31 am    Post subject: Reply to: Issue with LE migration - Issue with TRUNC
Reply with quote

Yes, if you have a need to not conform to PICture, then use COMP-5 to define the item(s) in question.

You can then compile with either TRUNC(STD) or TRUNC(OPT) (OPT only if you are certain all other fields conform to PICture) without affecting the items defined as COMP-5.

If, however, it was just original coder-laziness to make something COMP PIC 99, then change it to 9(4)/9(9) (for TRUNC(STD)) or 9(4)/9(8) (for TRUNC(OPT)).

NOTE: TRUNC(OPT) behaves poorly with PIC 9(9). If you need that many digits and performance is a criteria use PIC 9(10)! This is according to R. J. Arellanes' Performance Tuning papers.
Back to top
View user's profile Send private message
Ed Goodman

Active Member


Joined: 08 Jun 2011
Posts: 556
Location: USA

PostPosted: Wed Nov 14, 2012 8:13 pm    Post subject:
Reply with quote

For anyone reading this thread later, a good example of NEEDING to not conform to picture:

IMS message length is 2 bytes binary, so PIC 9(04) COMP-5 works great.
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 Nov 14, 2012 8:36 pm    Post subject: Reply to: Issue with LE migration - Issue with TRUNC
Reply with quote

Bill,

PIC 9(10) through PIC 9(18) COMP is treated as a Binary-Doubleword to COBOL (not that friendly to the language) and the last time I looked, COBOL uses run-time routines to perform arithmetic, which isn't that efficient. But, this was a while ago and the newer compilers may have changed and now do arithmetic in-line, especially if it's defined as COMP-5 and/or use 64-Bit register-instructions.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7241

PostPosted: Wed Nov 14, 2012 10:32 pm    Post subject: Reply to: Issue with LE migration - Issue with TRUNC
Reply with quote

Bill,

The paper says it is only an issue for TRUNC(OPT). TRUNC(BIN) (and COMP-5) and don't make no nevermind about 9(9).

With TRUNC(OPT), 9(10) is faster to process than 9(9), apparently :-)

With OPT, the 9(10) through 9(17) are processed in doubleword format, but so is the 9(9), needing conversion from, and to, fullword, so slower. 9(18) goes to a higher precision than doubleword, apparently, so is slowest of all.

With TRUNC(STD) the 9(18) is also treated differently, as is the 9(9), slower than 1-8, but faster than 10-17.

With TRUNC(BIN) or COMP-5 the 9(18) remains as doubleword, it seems.

All big fun, and information tucked away.

Despite all the above, OPT is consistently faster overall, followed by STD, followed by BIN/COMP-5.

Of course, wait for all of the above to change with the new Compiler.

TRUNC(BIN) reflects the ANSI 85 standard. OPT and STD are IBM Extensions.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7241

PostPosted: Thu Nov 15, 2012 1:25 am    Post subject: Reply to: Issue with LE migration - Issue with TRUNC
Reply with quote

This is IF field equal to 1, add 1 to field, for COMP PIC 9(9) and 9(10), TRUNC(OPT).

Code:

IF
5830 8058               L     3,88(0,8)               W-C-PIC-9-09             
4930 A00E               CH    3,14(0,10)              PGMLIT AT +10             
4770 B564               BC    7,1380(0,11)            GN=12(000758)             
                                                                               
ADD
4840 A00E               LH    4,14(0,10)              PGMLIT AT +10             
8E40 0020               SRDA  4,32(0)                                           
5860 8058               L     6,88(0,8)               W-C-PIC-9-09             
8E60 0020               SRDA  6,32(0)                                           
1A64                    AR    6,4                                               
1E75                    ALR   7,5                                               
47C0 B560               BC    12,1376(0,11)           GN=48(000754)             
5A60 C004               A     6,4(0,12)               SYSLIT AT +4             
               GN=48    EQU   *                                                 
5070 8058               ST    7,88(0,8)               W-C-PIC-9-09             
               GN=12    EQU   *                                                 
                                                                               
IF
D201 D2E6 A00E          MVC   742(2,13),14(10)        TS2=6          PGMLIT AT +10
D205 D2E0 C026          MVC   736(6,13),38(12)        TS2=0          SYSLIT AT +38
D507 8060 D2E0          CLC   96(8,8),736(13)         W-C-PIC-9-10   TS2=0
4770 B596               BC    7,1430(0,11)            GN=13(00078A)             
                                                                               
ADD
4840 A00E               LH    4,14(0,10)              PGMLIT AT +10             
8E40 0020               SRDA  4,32(0)                                           
5A40 8060               A     4,96(0,8)               W-C-PIC-9-10             
5E50 8064               AL    5,100(0,8)              W-C-PIC-9-10+4           
47C0 B592               BC    12,1426(0,11)           GN=49(000786)             
5A40 C004               A     4,4(0,12)               SYSLIT AT +4             
               GN=49    EQU   *                                                 
9045 8060               STM   4,5,96(8)               W-C-PIC-9-10             
               GN=13    EQU   *                                                 


So it looks quite possible that 9(10) is faster than 9(9) with TRUNC(OPT).

Yoiks, this is the same source code with TRUNC(STD). 9(9) definitely faster :-)

Code:

IF
5830 8058               L     3,88(0,8)               W-C-PIC-9-09 
4930 A00E               CH    3,14(0,10)              PGMLIT AT +10
4770 B50E               BC    7,1294(0,11)            GN=12(00071A)
                                                                   
ADD
4840 A00E               LH    4,14(0,10)              PGMLIT AT +10
8E40 0020               SRDA  4,32(0)                               
5860 8058               L     6,88(0,8)               W-C-PIC-9-09 
8E60 0020               SRDA  6,32(0)                               
1A64                    AR    6,4                                   
1E75                    ALR   7,5                                   
47C0 B506               BC    12,1286(0,11)           GN=48(000712)
5A60 C020               A     6,32(0,12)              SYSLIT AT +32
               GN=48    EQU   *                                     
5D60 C01C               D     6,28(0,12)              SYSLIT AT +28
5060 8058               ST    6,88(0,8)               W-C-PIC-9-09 
               GN=12    EQU   *                                     
                                                                   
IF
D201 D2E6 A00E          MVC   742(2,13),14(10)        TS2=6         PGMLIT AT +10
D205 D2E0 C042          MVC   736(6,13),66(12)        TS2=0         SYSLIT AT +66
D507 8060 D2E0          CLC   96(8,8),736(13)         W-C-PIC-9-10  TS2=0
4770 B59A               BC    7,1434(0,11)            GN=13(0007A6)
                                                                   
ADD
4840 A00E               LH    4,14(0,10)              PGMLIT AT +10
8E40 0020               SRDA  4,32(0)                               
5A40 8060               A     4,96(0,8)               W-C-PIC-9-10 
5E50 8064               AL    5,100(0,8)              W-C-PIC-9-10+4
47C0 B53C               BC    12,1340(0,11)           GN=49(000748)
5A40 C020               A     4,32(0,12)              SYSLIT AT +32
               GN=49    EQU   *                                     
5D40 C01C               D     4,28(0,12)              SYSLIT AT +28
4E50 D2F0               CVD   5,752(0,13)             TS2=16       
F154 D2E0 D2F3          MVO   736(6,13),755(5,13)     TS2=0         TS2=19
4E40 D2F0               CVD   4,752(0,13)             TS2=16       
9110 D2E5               TM    741(13),X'10'           TS2=5         
D204 D2E5 D2F3          MVC   741(5,13),755(13)       TS2=5         TS2=19
4780 B560               BC    8,1376(0,11)            GN=50(00076C)
9601 D2E9               OI    745(13),X'01'           TS2=9       
               GN=50    EQU   *                                   
940F D2E4               NI    740(13),X'0F'           TS2=4       
D202 D2F0 C042          MVC   752(3,13),66(12)        TS2=16        SYSLIT AT +66
D204 D2F3 D2E5          MVC   755(5,13),741(13)       TS2=19        TS2=5
4F30 D2F0               CVB   3,752(0,13)             TS2=16       
F144 D2F3 D2E0          MVO   755(5,13),736(5,13)     TS2=19        TS2=0
4F50 D2F0               CVB   5,752(0,13)             TS2=16       
5C40 C01C               M     4,28(0,12)              SYSLIT AT +28
1E53                    ALR   5,3                                 
47C0 B58C               BC    12,1420(0,11)           GN=51(000798)
5A40 C020               A     4,32(0,12)              SYSLIT AT +32
               GN=51    EQU   *                                   
1233                    LTR   3,3                                 
47B0 B596               BC    11,1430(0,11)           GN=52(0007A2)
5B40 C020               S     4,32(0,12)              SYSLIT AT +32
               GN=52    EQU   *                                   
9045 8060               STM   4,5,96(8)               W-C-PIC-9-10
               GN=13    EQU   *                                   


Even yoiksier. TRUNC(BIN). Again the 9(9) must be faster than the 9(10) :-)

Code:

IF
5850 8058               L     5,88(0,8)               W-C-PIC-9-09
1F44                    SLR   4,4                                 
9045 D370               STM   4,5,880(13)             TS2=0       
D201 D37E A00E          MVC   894(2,13),14(10)        TS2=14       PGMLIT AT +10
D205 D378 C026          MVC   888(6,13),38(12)        TS2=8        SYSLIT AT +38
D507 D370 D378          CLC   880(8,13),888(13)       TS2=0        TS2=8
4770 B77A               BC    7,1914(0,11)            GN=12(000992)
                                                                   
ADD
5850 8058               L     5,88(0,8)               W-C-PIC-9-09
1F44                    SLR   4,4                                 
4860 A00E               LH    6,14(0,10)              PGMLIT AT +10
8E60 0020               SRDA  6,32(0)                             
1A46                    AR    4,6                                 
1E57                    ALR   5,7                                 
47C0 B776               BC    12,1910(0,11)           GN=70(00098E)
5A40 C004               A     4,4(0,12)               SYSLIT AT +4
               GN=70    EQU   *                                   
5050 8058               ST    5,88(0,8)               W-C-PIC-9-09
               GN=12    EQU   *                                   
                                                                   
IF
9845 8060               LM    4,5,96(8)               W-C-PIC-9-10
F8F0 D370 A088          ZAP   880(16,13),136(1,10)    TS2=0        PGMLIT AT +132
1244                    LTR   4,4                                 
4720 B798               BC    2,1944(0,11)            GN=72(0009B0)
4780 B7A8               BC    8,1960(0,11)            GN=73(0009C0)
FAF5 D370 A082          AP    880(16,13),130(6,10)    TS2=0        PGMLIT AT +126
5740 A06C               X     4,108(0,10)             PGMLIT AT +10
               GN=72    EQU   *                                   
4E40 D380               CVD   4,896(0,13)             TS2=16       TS2=16
FAF7 D370 D380          AP    880(16,13),896(8,13)    TS2=0        PGMLIT AT +120
FCF5 D370 A07C          MP    880(16,13),124(6,10)    TS2=0       
               GN=73    EQU   *                                   
1255                    LTR   5,5                                 
4720 B7BC               BC    2,1980(0,11)            GN=74(0009D4)
4780 B7C6               BC    8,1990(0,11)            GN=75(0009DE)
FAF5 D370 A082          AP    880(16,13),130(6,10)    TS2=0        PGMLIT AT +126
5750 A06C               X     5,108(0,10)             PGMLIT AT +104
               GN=74    EQU   *                                     
4E50 D380               CVD   5,896(0,13)             TS2=16       TS2=16 
FAF7 D370 D380          AP    880(16,13),896(8,13)    TS2=0         
               GN=75    EQU   *                                     
960F D37F               OI    895(13),X'0F'           TS2=15         
D50A D375 A029          CLC   885(11,13),41(10)       TS2=5        PGMLIT AT +37 
4770 B844               BC    7,2116(0,11)            GN=13(000A5C) 
                                                                     
ADD
9845 8060               LM    4,5,96(8)               W-C-PIC-9-10   
F8F0 D370 A088          ZAP   880(16,13),136(1,10)    TS2=0        PGMLIT AT +132 
1244                    LTR   4,4                                   
4720 B7F2               BC    2,2034(0,11)            GN=78(000A0A) 
4780 B802               BC    8,2050(0,11)            GN=79(000A1A) 
FAF5 D370 A082          AP    880(16,13),130(6,10)    TS2=0        PGMLIT AT +126 
5740 A06C               X     4,108(0,10)             PGMLIT AT +104
               GN=78    EQU   *                                     
4E40 D380               CVD   4,896(0,13)             TS2=16         
FAF7 D370 D380          AP    880(16,13),896(8,13)    TS2=0        TS2=16 
FCF5 D370 A07C          MP    880(16,13),124(6,10)    TS2=0        PGMLIT AT +120 
               GN=79    EQU   *                                     
1255                    LTR   5,5                                   
4720 B816               BC    2,2070(0,11)            GN=80(000A2E) 
4780 B820               BC    8,2080(0,11)            GN=81(000A38) 
FAF5 D370 A082          AP    880(16,13),130(6,10)    TS2=0        PGMLIT AT +126 
5750 A06C               X     5,108(0,10)             PGMLIT AT +104
               GN=80    EQU   *                                     
4E50 D380               CVD   5,896(0,13)             TS2=16         
FAF7 D370 D380          AP    880(16,13),896(8,13)    TS2=0        TS2=16 
               GN=81    EQU   *                                     
960F D37F               OI    895(13),X'0F'           TS2=15         
FAA0 D375 A033          AP    885(11,13),51(1,10)     TS2=5        PGMLIT AT +47 
D20F D380 D370          MVC   896(16,13),880(13)      TS2=16       TS2=0 
960F D38F               OI    911(13),X'0F'           TS2=31         
58F0 203C               L     15,60(0,2)              V(IGZCIDB )   
4110 A0AB               LA    1,171(0,10)             PGMLIT AT +167
0DEF                    BASR  14,15                                 
D207 8060 D390          MVC   96(8,8),912(13)         W-C-PIC-9-10 TS2=0
               GN=13    EQU   *                                     
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
No new posts BWO option in VSAM blayek CICS 3 Sat Nov 05, 2016 10:47 am
No new posts Regarding COBOL Stored Procedure opti... selvamsrinivasan85 DB2 4 Fri Nov 04, 2016 8:57 pm
No new posts DFHRESPONSE returns issue divated CICS 3 Wed Nov 02, 2016 6:32 pm
No new posts Can sending 5 MB data between cobol p... Kevin Vaz CICS 12 Tue Oct 18, 2016 4:50 pm
No new posts Db2 migration from V4/6 to V8/10 Venkatesh G DB2 1 Thu Jul 14, 2016 8:54 am


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