IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Converting Price from one format to another


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
pullaiah.cts

New User


Joined: 02 Sep 2010
Posts: 50
Location: Pune

PostPosted: Thu Jan 05, 2012 11:36 pm
Reply with quote

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
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8697
Location: Dubuque, Iowa, USA

PostPosted: Thu Jan 05, 2012 11:52 pm
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Thu Jan 05, 2012 11:55 pm
Reply with quote

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
View user's profile Send private message
pullaiah.cts

New User


Joined: 02 Sep 2010
Posts: 50
Location: Pune

PostPosted: Mon Jan 09, 2012 3:00 pm
Reply with quote

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
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Mon Jan 09, 2012 3:23 pm
Reply with quote

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
View user's profile Send private message
pullaiah.cts

New User


Joined: 02 Sep 2010
Posts: 50
Location: Pune

PostPosted: Mon Jan 09, 2012 3:39 pm
Reply with quote

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
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Mon Jan 09, 2012 4:17 pm
Reply with quote

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
View user's profile Send private message
pullaiah.cts

New User


Joined: 02 Sep 2010
Posts: 50
Location: Pune

PostPosted: Mon Jan 09, 2012 5:01 pm
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Issues Converting From ZD to Signed N... DFSORT/ICETOOL 4
No new posts Populate last day of the Month in MMD... SYNCSORT 2
No new posts Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
No new posts Need to convert date format DFSORT/ICETOOL 20
No new posts InfoSphere OPTIM CSV ouput vs DSNTIUA... IBM Tools 3
Search our Forums:

Back to Top