View previous topic :: View next topic
|
Author |
Message |
pullaiah.cts
New User
Joined: 02 Sep 2010 Posts: 50 Location: Pune
|
|
|
|
Hi,
I need your help in converting signed EBCDIC values to signed ASCII values.We used to get the price values in EBDCIC format and we need to convert that price into signed ASCII to consume this price by down stream applications.
For example:
in the input file,
picture clause of price field -- S9(6)V9(6)
price value ----- 57833728971{
output file:
picture clause of price field -- need to find out
price value ----- 578337.289710
if input price value is 57833728971E then o/p should be 578337.289715
if input price value is 57833728971} then o/p should be -578337.289710
if input price value is 57833728971N then o/p should be -578337.289715
I have read the below topic understand to this converstion.But still i am confusing about writing the COBOL code.
www.3480-3590-data-conversion.com/article-signed-fields.html
Can anybody please look into this and let me know how to convert the price in the above format.Thanks in advance. |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8697 Location: Dubuque, Iowa, USA
|
|
|
|
How about using a MOVE statement?
Code: |
01 WS-VAR.
05 WS-ORIGINAL-AMT PIC S9(06)V9(06).
05 WS-OUTPUT-AMT PIC -9(07).9(06).
PROCEDURE DIVISION .
0000-START.
MOVE +578337.289710 TO WS-ORIGINAL-AMT.
MOVE WS-ORIGINAL-AMT TO WS-OUTPUT-AMT.
DISPLAY 'WS-ORIGINAL-AMT <' WS-ORIGINAL-AMT '>'.
DISPLAY 'WS-OUTPUT-AMT <' WS-OUTPUT-AMT '>'.
MOVE -578337.289710 TO WS-ORIGINAL-AMT.
MOVE WS-ORIGINAL-AMT TO WS-OUTPUT-AMT.
DISPLAY 'WS-ORIGINAL-AMT <' WS-ORIGINAL-AMT '>'.
DISPLAY 'WS-OUTPUT-AMT <' WS-OUTPUT-AMT '>'. |
produces output of
Code: |
WS-ORIGINAL-AMT <57833728971{>
WS-OUTPUT-AMT < 0578337.289710>
WS-ORIGINAL-AMT <57833728971}>
WS-OUTPUT-AMT <-0578337.289710> |
Although your terminology is extremely fuzzy. If the data is on a mainframe, both formats are EBCDIC -- the separate sign format is NOT ASCII since the mainframe uses EBCDIC. The COBOL term is "numeric edited". |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
You need to understand that your requirement has nothing to do with ASCII/EBCDIC.
What you are doing is changing the data from signed zoned-decimal to an edited field.
The download will convert the EBCDIC to ASCII with no additional work needed. |
|
Back to top |
|
|
pullaiah.cts
New User
Joined: 02 Sep 2010 Posts: 50 Location: Pune
|
|
|
|
Hi Dick and Robert,
Sorry for getting back to you lately.I tried your advices,I have made below chnages in my code.
Input price declaration:
15 WP-AUSDP PIC S9(10)V9(8).
Working storage price declaration:
10 WS-CUSIP-PRICE PIC -9(11).9(8) VALUE ZEROS.
Output price declaration:
10 OUT-CUSIP-PRICE PIC -9(11).9(8) VALUE ZEROS.
MOVE logic:
Code: |
MOVE WP-AUSDP TO WS-CUSIP-PRICE.
MOVE WS-CUSIP-FLD TO OUT-PRICE-FLE-REC.
WRITE OUT-PRICE-FLE-REC.
|
But,while compiling my program it is getting failed with below error message.
More than 18 digit positions were specified in a "PICTURE" string for a numeric or numeric edited item. A "PICTURE" string of "S9(18)" was assumed.
Can you please let us know is my declaration is correct?If so,what should I do to prevent the above error. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
pullaiah.cts wrote: |
[...]
Working storage price declaration:
10 WS-CUSIP-PRICE PIC -9(11).9(8) VALUE ZEROS.
Output price declaration:
10 OUT-CUSIP-PRICE PIC -9(11).9(8) VALUE ZEROS.
[...] |
Why 9(11)? You have 9(10) for your input, why not for when you display it? |
|
Back to top |
|
|
pullaiah.cts
New User
Joined: 02 Sep 2010 Posts: 50 Location: Pune
|
|
|
|
Hi Bill,
Sorry for that,I assumed that we need to mention one extra byte for storing sign.I have corrected it to PIC -9(10).9(8) and it's working fine.
Thanks for your quick response. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Sign is an extra byte, represented in your picture by the "-". It is not an extra numeric digit.
Glad you got it. Does it end your other topic on compiler options? |
|
Back to top |
|
|
pullaiah.cts
New User
Joined: 02 Sep 2010 Posts: 50 Location: Pune
|
|
|
|
Yes Bill.Yeah,I will close the discussion on compiler option as it is releated the same query.
Thanks again for your help. |
|
Back to top |
|
|
|