Handling Packed Decimal



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

Handling Packed Decimal

Postby ragsara » Wed Apr 03, 2013 12:48 am

Hi ,

Please find my below requirement and the issue faced during coding my requirement.

Requirement : Read KSDS file, move the first occurence of ROLL-NUMBER field (RTR:-ROLL-NUMBER PIC S9(02) PACKED-DECIMAL) to
SERIAL-NUMBER field (MCMM-SERIAL-NUMBER PIC S9(02) COMP-3) in Mini file, both files are already present in the system.

Issue :
1) When i directly code the below move statment, job abends with SOC7. And when i XPED the code, RTR-ROLL-NUMBER is filled with question marks ?? (Packed Decimal)
MOVE RTR-ROLL-NUMBER (1) TO MCMM-SERIAL-NUMBER
2) Later i tried to evaluate the RTR-ROLL-NUMBER filed, now for all records IF condition doesnt get satisfied and the control goes to the ELSE part (all MCMM-SERIAL-NUMBER were filled with ZEROES.)
IF RTR-MARKET-TYPE(1) IS NUMERIC
MOVE RTR-ROLL-NUMBER (1) TO MCMM-SERIAL-NUMBER
ELSE
MOVE ZEROES TO MCMM-SERIAL-NUMBER
END-IF
3) I tried moving the PAcked decimal to a working storage variable (PIC S9(02) VALE ZEROES), again job abended with SOC7
MOVE RTR-ROLL-NUMBER (1) TO WS-MCMM-SERIAL-NUMBER
4) I have checked the Packed decimal values present in the input file, and all values are NUmeric and valid. (Viewed it through File aid along with Input Files copy book)
Questions :
1) Cant we directly move a PACKED DECIMAL value to COMP-3 field (As both are same).
2) Please let me know the corrections which i need to incorporate in my process or If i have entirely change the approach.

Your help is higly appreciated
ragsara
 
Posts: 23
Joined: Thu Mar 22, 2012 5:17 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Handling Packed Decimal

Postby Akatsukami » Wed Apr 03, 2013 1:05 am

REPRO the KSDS to a PS data set. Browse the data set with HEX ON and COLS ON; post some representative data, indicating where the packed decimal fields are, in Code tags.
"You have sat too long for any good you have been doing lately ... Depart, I say; and let us have done with you. In the name of God, go!" -- what I say to a junior programmer at least once a day
User avatar
Akatsukami
Global moderator
 
Posts: 1058
Joined: Sat Oct 16, 2010 2:31 am
Location: Bloomington, IL
Has thanked: 6 times
Been thanked: 51 times

Re: Handling Packed Decimal

Postby Robert Sample » Wed Apr 03, 2013 1:15 am

4) I have checked the Packed decimal values present in the input file, and all values are NUmeric and valid.
YOU may think so; the system disagrees -- hence the S0C7. And I'm going to believe the system a whole lot more than you.

In COBOL, valid numeric data can be moved to a valid numeric or numeric edited or alphanumeric variable without problems. Note the word "valid" is in that sentence.
The correction will depend upon the problem. Unless you post actual, real data (using the CODE tag to preserve spacing), there is little to nothing we can do to help you.
Why are you using a subscript on your MOVE statements? If it occurs more than once, then the first line of your post should have so indicated, and if it is not then why the (1)?
Robert Sample
Global moderator
 
Posts: 3720
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times

Re: Handling Packed Decimal

Postby ragsara » Wed Apr 03, 2013 1:41 am

Hi ,


I have just changed the name MARKET-TYPE to ROLL NUMBER, just for the sake of not to use technical terms.

I have attached this word document containing the File layout, RTR Input file and my COBOl code.

According to the requirement only the first instance of the RTR-MARKET-TYPE should be moved to the MCMM-MARKET-TYPE-FIELD

Both the files COPY BOOKS have already been declred in the COBOL program.

Let me know if you need more details.
[Attachment deleted]
ragsara
 
Posts: 23
Joined: Thu Mar 22, 2012 5:17 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Handling Packed Decimal

Postby Akatsukami » Wed Apr 03, 2013 1:48 am

I asked you to post your data in Code tags. I have no intention of potentially contaminating either my personal or my client's machine by downloading files from unknown sources.
"You have sat too long for any good you have been doing lately ... Depart, I say; and let us have done with you. In the name of God, go!" -- what I say to a junior programmer at least once a day
User avatar
Akatsukami
Global moderator
 
Posts: 1058
Joined: Sat Oct 16, 2010 2:31 am
Location: Bloomington, IL
Has thanked: 6 times
Been thanked: 51 times

Re: Handling Packed Decimal

Postby ragsara » Wed Apr 03, 2013 1:55 am

Hi,

Am really sorry,

I uploaded the doc as i didnt know to use the code tag, Can you please let me know how to use it ?
ragsara
 
Posts: 23
Joined: Thu Mar 22, 2012 5:17 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Handling Packed Decimal

Postby Akatsukami » Wed Apr 03, 2013 2:06 am

ragsara wrote:Hi,

Am really sorry,

I uploaded the doc as i didnt know to use the code tag, Can you please let me know how to use it ?

If you click on the "Quote" button on a post, or on the "Post Reply" button at the end of a thread, you are presented with an edit box with a row of buttons above it. One of these is labeled "Code"; clicking on it inserts a open-close set of Code tags at the cursor position.

Uncoded text looks like this:
----X----1----X----2
0000135700001357BDFF
000C246F00002468ACEF
Coded text looks like this:
----X----1----X----2
0000135700001357BDFF
000C246F00002468ACEF

You will perceive that the preservsation of alignment produced by a fixed-pitch font and not compressing multiple spaces is helpful, if not absolutely necessary, for comprehension.
"You have sat too long for any good you have been doing lately ... Depart, I say; and let us have done with you. In the name of God, go!" -- what I say to a junior programmer at least once a day
User avatar
Akatsukami
Global moderator
 
Posts: 1058
Joined: Sat Oct 16, 2010 2:31 am
Location: Bloomington, IL
Has thanked: 6 times
Been thanked: 51 times

Re: Handling Packed Decimal

Postby ragsara » Wed Apr 03, 2013 2:18 am

RTR Input file (Hex on) :
:RTR:-MARKET-TYPE(1)
2/PS               
(38-39)             
11------------------
********************
 <                 
04                 
0C                 
--------------------
                   
00                 
0C                 
--------------------
                   
00                 
0C                 
--------------------
                   
00                 
0C                 
--------------------


RTR Market type declaration in copy book :
05  :RTR:-MARKET-TYPE      PIC S9(02)  PACKED-DECIMAL.


Mini Market type declaration in copybook :
05  MCMM-MARKET-TYPE-1          PIC S9(02) COMP-3.


COBOL Code : (1 st scenario - Direct move ) : In this scenarion am encounetring SOC7 abend.
MOVE RTR-MARKET-TYPE(1) TO MCMM-MARKET-TYPE-1


COBOL Code : (Second Scenario - Evaluation ) : In this scenario "If condition" is not satisfied as RTR-MARKET-TYPE(1) is not numeric and is of PAcked decimal format
IF RTR-MARKET-TYPE(1) IS NUMERIC           
  MOVE RTR-MARKET-TYPE(1) TO MCMM-MARKET-TYPE-1
ELSE                                           
  MOVE ZEROES TO MCMM-MARKET-TYPE-1           
END-IF                                         


Please let me know if i need to use any Working Storage variables to overcome this issue, if so their declartion types too.
ragsara
 
Posts: 23
Joined: Thu Mar 22, 2012 5:17 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Handling Packed Decimal

Postby Akatsukami » Wed Apr 03, 2013 2:32 am

A packed decimal field ought always to have an odd number of digits; it is impossible to determine in this case whether you have erroneous code that accidentally works.

More to the point, however, RTR-MARKET-TYPE does not have an OCCURS clause. Unless it is subordinate to a higher-level item that does, your code is exceedingly misleading. Is the copybook included by means of a COPY REPLACING statement that changes the :RTR: tag to a RTR literal?
"You have sat too long for any good you have been doing lately ... Depart, I say; and let us have done with you. In the name of God, go!" -- what I say to a junior programmer at least once a day
User avatar
Akatsukami
Global moderator
 
Posts: 1058
Joined: Sat Oct 16, 2010 2:31 am
Location: Bloomington, IL
Has thanked: 6 times
Been thanked: 51 times

Re: Handling Packed Decimal

Postby ragsara » Wed Apr 03, 2013 2:38 am

Hi ,

It does contain occurs clause
03  :RTR:-SEGMENT-AREA     OCCURS 400 TIMES               
                           INDEXED BY RTR-I1.             
    05  :RTR:-PRODUCT          PIC X(03).                 
    05  :RTR:-MARKET-TYPE      PIC S9(02)  PACKED-DECIMAL.

and here is the declaration of the copybook, yes am replacing the RTR tag :
COPY VYRECPT0 REPLACING ==:RTR:== BY ==RTR==.
ragsara
 
Posts: 23
Joined: Thu Mar 22, 2012 5:17 pm
Has thanked: 0 time
Been thanked: 0 time

Next

Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post