Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Converting Price from one format to another

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Converting Price from one format to another
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.

http://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: 7931
Location: Bellevue, IA

PostPosted: Thu Jan 05, 2012 11:52 pm    Post subject:
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

Site Director


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

PostPosted: Thu Jan 05, 2012 11:55 pm    Post subject:
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    Post subject: Reply to: Converting Price from one format to another
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7251

PostPosted: Mon Jan 09, 2012 3:23 pm    Post subject: Re: Reply to: Converting Price from one format to another
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    Post subject: Reply to: Converting Price from one format to another
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7251

PostPosted: Mon Jan 09, 2012 4:17 pm    Post subject: Reply to: Converting Price from one format to another
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    Post subject: Reply to: Converting Price from one format to another
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts DB2 query Using Recursion, Converting... smilewithashu2 DB2 1 Tue Jan 03, 2017 12:50 pm
No new posts Match or compare two files in VB Format anatol DFSORT/ICETOOL 14 Thu Nov 03, 2016 7:41 pm
No new posts Low values Results from VARCHAR FORMAT balaji81_k DB2 10 Thu Oct 20, 2016 1:18 am
No new posts output data in CSV Format janmejay COBOL Programming 8 Sat Oct 15, 2016 2:20 pm
This topic is locked: you cannot edit posts or make replies. output data in CSV Format janmejay DFSORT/ICETOOL 3 Sat Oct 15, 2016 2:16 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us