Page 1 of 2

Handling Packed Decimal

PostPosted: Wed Apr 03, 2013 12:48 am
by ragsara
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

Re: Handling Packed Decimal

PostPosted: Wed Apr 03, 2013 1:05 am
by Akatsukami
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.

Re: Handling Packed Decimal

PostPosted: Wed Apr 03, 2013 1:15 am
by Robert Sample
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)?

Re: Handling Packed Decimal

PostPosted: Wed Apr 03, 2013 1:41 am
by ragsara
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]

Re: Handling Packed Decimal

PostPosted: Wed Apr 03, 2013 1:48 am
by Akatsukami
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.

Re: Handling Packed Decimal

PostPosted: Wed Apr 03, 2013 1:55 am
by ragsara
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 ?

Re: Handling Packed Decimal

PostPosted: Wed Apr 03, 2013 2:06 am
by Akatsukami
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.

Re: Handling Packed Decimal

PostPosted: Wed Apr 03, 2013 2:18 am
by ragsara
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.

Re: Handling Packed Decimal

PostPosted: Wed Apr 03, 2013 2:32 am
by Akatsukami
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?

Re: Handling Packed Decimal

PostPosted: Wed Apr 03, 2013 2:38 am
by ragsara
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==.