Quantcast
Channel: IBM Mainframe Computers Forums
Viewing all 8500 articles
Browse latest View live

COBOL Programming :: Moving a COMP-3 Variable to a Numeric data-item

$
0
0
Author: ajayachander
Subject: Moving a COMP-3 Variable to a Numeric data-item
Posted: Thu Dec 14, 2017 5:46 pm (GMT 5.5)

Requirement:
I have a variable with the below declaration with data coming from a file
Code:
05 MODEPREM1            PIC S9(7)V99 USAGE COMP-3.


This field needs to be moved to a report and displayed in readable numeric format (i.e. 1500.00)

Issue:
I have done a fair bit of reading, did try out a few ways but I have consistently managed to fail to accomplish what is required.
So here I am.

I understand that a S9(7)V99 COMP-3 is stored in 5 bytes = [(7+2) numeric + 1 sign(half byte)]/2
(Correct me if I got any of it wrong, I am here to learn!

I have tried displaying the data and it shows
Code:
MODEPREM1 :.0Ü0.0.0.


I opened the file in File-Aid to see how it is represented in HEX and it shows
Code:
MODEPREM1 5/PS   X'F0C0F0F0F0'

(I tried converting the HEX value to a numeric decimal through an online tool and it shows "1034029166832") - Is this the underlying data?
If Yes, then should it be 10340291668.32? It has a total of 13 numerical values, so I believe this won't be right. (If it indeed is right, how are 13 digits accommodated in 9(7)V99)
If NO, what is the underlying value?

When I try moving it to a Working storage variable declared with the same PIC clause in COMP-3 such as
Code:
05 WS-AMOUNT-COMP3          PIC S9(7)V99 USAGE COMP-3.


A simple MOVE statement failed with S0C7
Code:
MOVE MODEPREM1 TO WS-AMOUNT-COMP3


So I rather tried a compute and it failed as well with the same reason
Code:
COMPUTE WS-AMOUNT-COMP3 = MODEPREM1 * 1


I ran a condition to check if the field in question (MODEPREM1) was indeed numeric
Code:
IF MODEPREM1 IS NUMERIC
 DISPLAY "NUMERIC TRUE"
ELSE
 DISPLAY "NOT NUMERIC"
END-IF

and it failed. It went to the ELSE part of the loop to display "Not Numeric"
(I always had the understanding that a COMP-3 variable could only be Numeric, but then...)

And now I am stuck!
Can anybody throw a suggestion on where I have gone wrong.

icon_rolleyes.gif
Hope I have given enough information to make this post meaningful.
If not please let me know what else is required. And go easy, this is my first post.

Cobol Version:
PP 5655-S71 IBM Enterprise COBOL for z/OS 4.2.0


COBOL Programming :: RE: Moving a COMP-3 Variable to a Numeric data-item

$
0
0
Author: Robert Sample
Posted: Thu Dec 14, 2017 6:20 pm (GMT 5.5)

Your first problem is that X'F0C0F0F0F0' is NOT a packed decimal value! This is a zoned decimal value with 4 zeroes in the first and third through fifth characters and a { in the second character.

You need to find out how the non-numeric data is getting into that variable -- table overflow is the most likely culprit but there are other possibilities.

If you have a valid numeric value in the packed decimal variable, File Aid will show something like X'123456789' (since the decimal point is implied and not actually part of the value); File Aid most likely would display 123456789 as the value if it is a proper packed decimal value.
_________________
TANSTAAFL

The first rule of code reuse is that the code needs to be worth re-using.

"We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil." -- Donald Knuth

SYNCSORT :: RE: Inefficient BUILD - VB records padding with spaces to LRECL

$
0
0
Author: Marso
Posted: Thu Dec 14, 2017 7:46 pm (GMT 5.5)

SYNCSORT may be able to recalculate the RDW.
I would try without copying it:
Code:
       BUILD=(5,1500,SQZ=(SHIFT=LEFT,...
and see if it works
(Sorry, currently not able to check by myself)

SYNCSORT :: RE: Inefficient BUILD - VB records padding with spaces to LRECL

$
0
0
Author: Marso
Posted: Thu Dec 14, 2017 7:51 pm (GMT 5.5)

Finally found this:
Syncsort Programmer’s Guide wrote:
If INREC or OUTREC processing changes the output record length, the contents of the
Record Descriptor Word will be automatically revised by the sort.

It seems to confirm what I wrote before: let Syncsort do the calculation.

DFSORT/ICETOOL :: SORT BUT RETAIN HIGHEST VALUE ON NON-SORTED FIELDS

$
0
0
Author: leondan22
Subject: SORT BUT RETAIN HIGHEST VALUE ON NON-SORTED FIELDS
Posted: Thu Dec 14, 2017 8:13 pm (GMT 5.5)

We receive an employee file from an outside entity in fixed block format. Record length = 36. There can be multiple records for an employee if they work in more than one position. The key fields to group on are AGENCY_CD and EMPLOYEE_ID. Our objective is to combine multiple records for an employee into 1 record, given the following criteria:
    Select non-TEMP (permanent) position first.
    If multiple records for an employee are non-TEMP or all are TEMP, select most recent appointment date.).
    If all records have the same appointment date, select the highest position ID (which is unique).

It would be easy enough to group on AGENCY_CD and EMPLOYEE_ID, sort the records per the criteria above and then SUM to remove the duplicate records, but there's a catch. Each record has 4 privacy indicators with a value of 'Y' or 'N'. We want the strictest privacy indicator value ('Y') for each indicator for that employee in our output record. Example (focusing on the record with AGENCY_CD = 110000 AND EMPLOYEE_ID = 000000002):

INPUT:
Code:

AGENCY_CD   EMPLOYEE_ID   POSITION_ID   TEMP_IND   APPT_DT      PRIVACY_1   PRIVACY_2   PRIVACY_3   PRIVACY_4
110000      000000001     111111        N          2000-08-01   N           N           N           N
110000      000000002     222222        N          2014-01-22   Y           N           Y           N
110000      000000002     333333        Y          2017-11-03   N           Y           N           N
210000      000000001     121212        N          2015-07-15   N           N           N           N


DESIRED OUTPUT:
Code:

AGENCY_CD   EMPLOYEE_ID   POSITION_ID   TEMP_IND   APPT_DT      PRIVACY_1   PRIVACY_2   PRIVACY_3   PRIVACY_4
110000      000000001     111111        N          2000-08-01   N           N           N           N
110000      000000002     222222        N          2014-01-22   Y           Y           Y           N
210000      000000001     121212        N          2015-07-15   N           N           N           N


Any help would be greatly appreciated!

SYNCSORT :: RE: Inefficient BUILD - VB records padding with spaces to LRECL

$
0
0
Author: Daniel Prosser
Posted: Thu Dec 14, 2017 8:48 pm (GMT 5.5)

@Marso

Seemed like a good idea, unfortunately it gives the following error:

Code:
     OUTREC IFTHEN=(WHEN=INIT,                                       
      BUILD=(5,1500,SQZ=(SHIFT=LEFT,PAIR=QUOTE))),                   
      IFTHEN=(WHEN=INIT,FINDREP=(IN=C'"',OUT=C'')),                 
      IFTHEN=(WHEN=INIT,FINDREP=(IN=C'6/6/2066',OUT=C'1/1/0001')),   
      IFTHEN=(WHEN=INIT,FINDREP=(IN=C'06/06/2066',OUT=C'1/1/0001')) 

WER901I  **WARNING** SYNCSORT 1.4.0.1 WILL EXPIRE IN 26 DAYS         
WER276B  SYSDIAG= 362785, 4401136, 4401136, 5442460                 
WER164B  2,052K BYTES OF VIRTUAL STORAGE AVAILABLE, MAX REQUESTED,   
WER164B     16K BYTES RESERVE REQUESTED, 2,028K BYTES USED           
WER146B  20K BYTES OF EMERGENCY SPACE ALLOCATED                     
WER108I  SORTIN   : RECFM=VB   ; LRECL=  1500; BLKSIZE= 27998       
WER073I  SORTIN   : DSNAME=...             
WER257I  INREC RECORD LENGTH =  1211                                 
WER235A  OUTREC   RDW NOT INCLUDED                                   
WER211B  SYNCSMF  CALLED BY SYNCSORT; RC=0000                       
WER449I  SYNCSORT GLOBAL DSM SUBSYSTEM ACTIVE                       
******************************* Bottom of Data **********************

COBOL Programming :: RE: Moving a COMP-3 Variable to a Numeric data-item

$
0
0
Author: sergeyken
Posted: Fri Dec 15, 2017 3:24 am (GMT 5.5)

Correct data for COBOL format PIC S9(7)V99 USAGE COMP-3 would be:
Code:

0.00             --> X'000000000C'
+1.00            --> X'000000100C'
+0.01            --> X'000000001C'
+1.11            --> X'000000111C'
+1000000.00      --> X'100000000C'
-1.00            --> X'000000100D'
-0.01            --> X'000000001D'
-1.11            --> X'000000111D'
-1000000.00      --> X'100000000D'

Everything else should cause ABEND S0C7, as expected.

No mystery arithmetic operation would help, when the original data is wrong.

In File-Aid, if PS-type field is displayed in HEX that means the decimal format is wrong. You can try to enter real decimal thru File-Aid Edit function, and then view it in hex mode to find out what is correct decimal format.

P.S.
File-Aid doesn't recognize the COBOL decimal point (assumed) position marked with 'V' in its PICTURE definition.
_________________
Tyrannosaurus-REXX

SYNCSORT :: RE: Inefficient BUILD - VB records padding with spaces to LRECL

$
0
0
Author: sergeyken
Posted: Fri Dec 15, 2017 3:34 am (GMT 5.5)

Daniel Prosser wrote:
@Marso

Seemed like a good idea, unfortunately it gives the following error:

Code:
     OUTREC IFTHEN=(WHEN=INIT,                                       
      BUILD=(5,1500,SQZ=(SHIFT=LEFT,PAIR=QUOTE))),                   
      IFTHEN=(WHEN=INIT,FINDREP=(IN=C'"',OUT=C'')),                 
      IFTHEN=(WHEN=INIT,FINDREP=(IN=C'6/6/2066',OUT=C'1/1/0001')),   
      IFTHEN=(WHEN=INIT,FINDREP=(IN=C'06/06/2066',OUT=C'1/1/0001')) 
     
WER276B  SYSDIAG= 362785, 4401136, 4401136, 5442460                 
WER164B  2,052K BYTES OF VIRTUAL STORAGE AVAILABLE, MAX REQUESTED,   
WER164B     16K BYTES RESERVE REQUESTED, 2,028K BYTES USED           
WER146B  20K BYTES OF EMERGENCY SPACE ALLOCATED                     
WER108I  SORTIN   : RECFM=VB   ; LRECL=  1500; BLKSIZE= 27998       
WER073I  SORTIN   : DSNAME=...             
WER257I  INREC RECORD LENGTH =  1211                                 
WER235A  OUTREC   RDW NOT INCLUDED                                   
WER211B  SYNCSMF  CALLED BY SYNCSORT; RC=0000                       
WER449I  SYNCSORT GLOBAL DSM SUBSYSTEM ACTIVE                       
******************************* Bottom of Data **********************

You MUST specify RDW explicitly for every BUILD= parameter:
BUILD=(1,4, ...whatever else ...
_________________
Tyrannosaurus-REXX


DFSORT/ICETOOL :: RE: SORT BUT RETAIN HIGHEST VALUE ON NON-SORTED FIELDS

$
0
0
Author: sergeyken
Posted: Fri Dec 15, 2017 3:42 am (GMT 5.5)

I'm lazy to test it, but try to use MAX operation in SORT, for your privacy columns.
'Y' value is greater than 'N' when considered in format BI.
_________________
Tyrannosaurus-REXX

DFSORT/ICETOOL :: RE: SORT BUT RETAIN HIGHEST VALUE ON NON-SORTED FIELDS

$
0
0
Author: leondan22
Posted: Fri Dec 15, 2017 5:06 am (GMT 5.5)

sergeyken wrote:
I'm lazy to test it, but try to use MAX operation in SORT, for your privacy columns.
'Y' value is greater than 'N' when considered in format BI.


For the employee in my example with multiple position IDs, I would select POSITION_ID 222222 because it is the non-temporary position. PRIVACY_1 has a value of 'Y', so if I sort by max value for PRIVACY_1, all is good. However, the PRIVACY_2 indicator for that record has a value of 'N' whereas PRIVACY_2 indicator for that same employee in POSITION_ID 333333 has a value of 'Y'. Since I need the strictest value for each of the privacy indicators, I would need to replace the value of the PRIVACY_2 indicator for POSITION_ID 222222 with the PRIVACY_2 value found in POSITION_ID 333333. I hope that makes sense! icon_smile.gif

TSO/ISPF :: RE: TBSARG - Deleting the search criteria after a TBSCAN/TBDISPL

$
0
0
Author: ISPFHerc
Subject: Reply to: TBSARG - Deleting the search criteria after a TBSCAN/TBDISPL
Posted: Fri Dec 15, 2017 8:47 am (GMT 5.5)

The description of TBVCLEAR in the manual does not make any reference to clearing the data from a previously issued TBSARG. It simply states - " All dialog variables that correspond to columns in the table, specified when the table was created, are cleared." To me, this implies all the KEY and NAME table dialog variables, but not the EXTENSION variables.

If an application issues -
.
.
TBVCLEAR table1

TBSARG table1 ARGLIST(extvar1,extvar2)

TBSCAN table1

TBVCLEAR table1
.
.

I think the ARGLIST search criteria will still be in effect after the last TBVCLEAR is issued, unless TBVCLEAR also clears the TBSARG search criteria, but this was never documented.

Any comments would be most appreciated.

Thank you,

Wally
_________________
Wally

TSO/ISPF :: RE: TBSARG - Deleting the search criteria after a TBSCAN/TBDISPL

$
0
0
Author: Willy Jensen
Posted: Fri Dec 15, 2017 12:26 pm (GMT 5.5)

While not specifically stated, I would assume that TBSARG without ARGLIST will remove extenson variables from the search. TBVCLEAR does not reset the search criteria, you must do a TBSARG immediately after the TBVCLEAR, as a value of null for one of the dialog variables means that the corresponding table variable is not to be examined during the search.
_________________
WJ

TSO/ISPF :: RE: TBSARG - Deleting the search criteria after a TBSCAN/TBDISPL

$
0
0
Author: Willy Jensen
Posted: Fri Dec 15, 2017 12:26 pm (GMT 5.5)

While not specifically stated, I would assume that TBSARG without ARGLIST will remove extenson variables from the search. TBVCLEAR does not reset the search criteria, you must do a TBSARG immediately after the TBVCLEAR, as a value of null for one of the dialog variables means that the corresponding table variable is not to be examined during the search.
_________________
WJ

TSO/ISPF :: RE: TBSARG - Deleting the search criteria after a TBSCAN/TBDISPL

$
0
0
Author: expat
Posted: Fri Dec 15, 2017 12:57 pm (GMT 5.5)

Oh gosh, there seems to be an echo in here icon_razz.gif
_________________
Some people are like Slinkies. They have no real value,
but it sure is fun to see them pushed down the stairs.

DB2 :: Change NULL indicator in UNLOAD utility

$
0
0
Author: Khadhar Basha
Subject: Change NULL indicator in UNLOAD utility
Posted: Fri Dec 15, 2017 3:01 pm (GMT 5.5)

Hi Experts,

I am in process of doing a POC of z/Os DB2 to DB2 LUW 11.1 migration.

I ran UNLOAD and the SYSPUNCH looks like below

Code:
LOAD DATA INDDN SYSREC   LOG NO  RESUME YES
 EBCDIC  CCSID(00037,65534,65534)
 INTO TABLE
 "HEXM002".
 "DEPARTMENT"
 NUMRECS                    3
 ( "DEPTNO"
  POSITION(  00001:00003) CHAR(00003)
 , "DEPTNAME"
  POSITION(  00004:00034) VARCHAR
 , "MGRNO"
  POSITION(  00036:00041) CHAR(00006)
                          NULLIF(00035)=X'FF'
 , "ADMRDEPT"
  POSITION(  00042:00044) CHAR(00003)
 , "LOCATION"
  POSITION(  00046:00061) CHAR(00016)
                          NULLIF(00045)=X'FF'
 )



Now I have problem specifying NULL indicator while uploading data into LUW.

In LUW the load utility syntax as follows :
Code:

load from D:\db2V11Express\load\department.txt of asc method l modified by striptblank nullindchar=x'FF' (1 3,4 34,36 41,42 44,46 61) null indicators (0,0,35,0,45)
insert into DEPARTMENT;


But as per db2luw 11.1 manuals
Quote:
nullindchar must specify symbols included in the standard ASCII set between code points x20 and x7F


which means I cannot mention x'FF' while loading data into table.

Is there any way to specify values between code points x20 and x7F as null indicator in unloaded data in z/Os unload utility DSNUTILB.

I have an other method as optional of creating a dynamic sort card with the use syspunch output to overlay X'FF' with ASCII set between code points x20 and x7F, but reading and editing all the downloaded code with take much time and cpu.

Please help me out, if there is a way to specify null values indicator other than x'FF' in unloaded file thru utility itself.
_________________
Khadhar Basha


DB2 :: RE: Change NULL indicator in UNLOAD utility

$
0
0
Author: enrico-sorichetti
Subject: Reply to: Change NULL indicator in UNLOAD utility
Posted: Fri Dec 15, 2017 7:10 pm (GMT 5.5)

meditate a bit longer on the DB2 LUW manuals ...
EBCDIC vs ASCII , NULL INDICATOR LIST , ..., ..., ...
_________________
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort icon_cool.gif

SYNCSORT :: RE: Inefficient BUILD - VB records padding with spaces to LRECL

$
0
0
Author: Daniel Prosser
Posted: Fri Dec 15, 2017 9:55 pm (GMT 5.5)

So after 2 days of investigation I worked out how to do it icon_rolleyes.gif

I added a OUTFIL line to the SYSIN

Code:
 SORT FIELDS=COPY                           
 OUTFIL FNAMES=SORTOUT,FTOV,VLTRIM=X'40'     
 INREC PARSE=(%01=(ENDBEFR=C'|',FIXLEN=20)
 ...


icon_biggrin.gif

SYNCSORT :: RE: Inefficient BUILD - VB records padding with spaces to LRECL

$
0
0
Author: sergeyken
Posted: Sat Dec 16, 2017 12:25 am (GMT 5.5)

If the original requirement is true:
Quote:
I have a VB dataset which I want to sort/reformat a little into another VB dataset

Then
Code:
OUTFIL ...,FTOV,...   
will not work
_________________
Tyrannosaurus-REXX

DB2 :: RE: Change NULL indicator in UNLOAD utility

$
0
0
Author: Khadhar Basha
Posted: Sat Dec 16, 2017 10:34 am (GMT 5.5)

Hi Enrico,

Thanks for the replay, When I read LUW load manuals I found below.

Quote:
If there is a Y in the column's null indicator position for a given record, the column will be NULL. If there is an N, the data values in the column's data positions of the input record (as defined in L(........)) are used as the source of column data for the row.


or we can use nullindchar to specify the null indicator
Quote:
nullindchar must specify symbols included in the standard ASCII set between code points x20 and x7F


So, when I unload using DSNUTILB I get X'FF' in my file to specify the columns as NULL or not.

If I want to just upload without doing any changes to my data I need to use nullindchar=x'FF' in my LUW load statement - but nullindchar will not accept X'FF'

otherwise, I need to edit data X'FF' overlay with Y or N or other valid nullindchar between X20 and X7F.

Goal is I need a way to upload data into LUW without having to edit the data.
That is I need to change the null indicator during DSNUTILB itself.

Please correct me if I am missing any other options of nullindcahr from LUW manuals, kindly let me know if there are any other options.

Thanks
Khadhar Basha

TSO/ISPF :: RE: TBSARG - Deleting the search criteria after a TBSCAN/TBDISPL

$
0
0
Author: ISPFHerc
Posted: Mon Dec 18, 2017 4:58 am (GMT 5.5)

I agree with you that a "TBSARG table1" with no arguments may clear the search criteria, but its not like IBM to not provide and document a mechanism to do this.

All comments are welcome.

Thank you,

wally
_________________
Wally

Viewing all 8500 articles
Browse latest View live