How to Write Amount to CSV File



Unicenter CA-Easytrieve Plus Report Generator: CA's information retrieval and data management tool

How to Write Amount to CSV File

Postby MtClimber » Wed Jul 22, 2009 12:44 am

Hi;
I'm new to this forum. I accidentially attached my first post to another post (sorry) so I'm re-posting it here as it's own subject.
I need to modify an Easytrieve to extract a dollar amount from a database and write a comma delimited output file. I need the dollar amount to be zero filled with a decimal point. Example: $157.00 should be written in the output file as: 00157.00

I am a COBOL programmer struggling with an Easytrieve. This is what I've tried per Dick's suggestion.
(I'm only showing the lines relavant to my question)

Input field:
CT05-CHRG 92 4 P 2

Output field:
EXTRO-CHRG 84 8 A

Work Fields:
W-CHRG W 7 N 2 MASK ('99999.99')
W-CHRG-RD W-CHRG 7 A

Additional Code:
W-CHRG = CT05-CHRG
EXTRO-CHRG = W-CHRG-RD
PUT EXTRO

I'm getting 0015700 (no decimal point)
How do I get the output file to contain 00157.00?

What am I doing wrong.
Dan
MtClimber
 
Posts: 4
Joined: Tue Jul 21, 2009 9:51 pm
Has thanked: 0 time
Been thanked: 0 time

Re: How to Write Amount to CSV File

Postby dick scherrer » Wed Jul 22, 2009 8:20 am

Hi Dan,

Unfortunately, i'm not connected tonight and cannot provide anything tested.

You might change this
W-CHRG W 7 N 2 MASK ('99999.99')

to
W-CHRG S 8 N 2 MASK ('99999.99')
and give it a shot.

I'm out most of tomorrow (won't be connected to a mainframe), but will check the forum.

Which release of Easytrieve is used on your system?
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: How to Write Amount to CSV File

Postby MtClimber » Wed Jul 22, 2009 9:22 pm

Hi Dick;
I tried your suggestion, but, unfortunately it did not work. I still do not get the actual decimal point in the output record.

We are using Easytrieve Plus 11-C, SP3

Currently I am writing the output extract records as a file. After going over the Easytrieve manual again, the thought occurred to me that maybe I need to change the output to a printer report. Just direct the "report" to disk with the proper lrecl (147) and have no headings. Let Easytrieve think it is writing a printed report with all of the proper edit masks being applied, but, in reality it's writing detail report lines (my extract output records) to disk. What do you think of that idea?
Another option is to re-write it in COBOL :D
Dan
MtClimber
 
Posts: 4
Joined: Tue Jul 21, 2009 9:51 pm
Has thanked: 0 time
Been thanked: 0 time

Re: How to Write Amount to CSV File

Postby dick scherrer » Thu Jul 23, 2009 2:58 am

Hi Dan,

What do you think of that idea?
Writing a "report" should get the decimal. Give it a try and let us know what happens.

Somewhere long ago (before ezt was even a CA product), someone decided that edited fields go on reports and raw data fields go in files. . . . Of course, back then no one was downloading to a spreadsheet or an ssis package or. . . Edited fields were horrible to use as "input" :)

I don't have access to an r11 system, but will look around and see what i can find.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: How to Write Amount to CSV File

Postby MtClimber » Thu Jul 23, 2009 7:06 pm

Hello again;
I tried extracting my data as a "report", but got this B070 Error:

110 REPORT RPT-01                   +                       
        PRINTER RPT01               +                       
        LINESIZE 250                                         
110 *******B070 VALUE NOT WITHIN ACCEPTABLE RANGE - LINESIZE


It looks like can't have a printed line as long as I need.

I ended up doing this:

W-DP           W   1 A    VALUE '.'

W-CHRG                 W   7 N 2
W-CHRG-DOLS   W-CHRG       5 N 0
W-CHRG-CENTS  W-CHRG +05   2 N 0


and this:

W-CHRG              =  CT05-CHRG   
EXTRO-CHRG-DOLS     =  W-CHRG-DOLS
EXTRO-DP-1          =  W-DP       
EXTRO-CHRG-CENTS    =  W-CHRG-CENTS


It get's the job done, but with lots more code than I would like.

Dan
MtClimber
 
Posts: 4
Joined: Tue Jul 21, 2009 9:51 pm
Has thanked: 0 time
Been thanked: 0 time

Re: How to Write Amount to CSV File

Postby BillyBoyo » Sun Jan 30, 2011 4:45 am

Thought I was time-warping here...
MtClimber wrote:W-DP W 1 A VALUE '.'

W-CHRG W 7 N 2
W-CHRG-DOLS W-CHRG 5 N 0
W-CHRG-CENTS W-CHRG +05 2 N 0

and this:


W-CHRG = CT05-CHRG
EXTRO-CHRG-DOLS = W-CHRG-DOLS
EXTRO-DP-1 = W-DP
EXTRO-CHRG-CENTS = W-CHRG-CENTS



I wrote a reply to the question you accidently attached to another. I can't see the definition of your EXTRO- fields, but I assume EXTRO-CHRG-CENTS is 2 A, to get around the signed number problem?
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: How to Write Amount to CSV File

Postby dick scherrer » Sun Jan 30, 2011 4:48 am

Hello,

To repeat. . .

It is best to NOT reply to old, inactive topics. . .

d
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: How to Write Amount to CSV File

Postby BillyBoyo » Sun Jan 30, 2011 5:06 am

Sorry again, I was obviously writing that one while you were complaining about the first. Not much I can do about that.

Do you have it in your power to just purge this stuff then. Looking through the FAQs I don't think I can do it. Also, can't find unsubscribe.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: How to Write Amount to CSV File

Postby dick scherrer » Sun Jan 30, 2011 8:11 am

Hello,

Sorry again, I was obviously writing that one while you were complaining about the first. Not much I can do about that.
Not to worry. . . :)
If you believe those were "complaints" suggest a look around - those were simply gentle reminders.

Do you have it in your power to just purge this stuff then.
Yes, moderators can delete posts or entire topics. No, general members can't.

I'm not aware of an "unsubscribe". . .

Suggest also you look at a lot of other forums and see if you find some that encourage re-awakening multi-year inactive topics. I'm not aware of any that encourage this, but i've only been a participant of 15 or so over the years. . .
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: How to Write Amount to CSV File

Postby BillyBoyo » Sun Jan 30, 2011 6:09 pm

"If someone suggested you refrain, they should be able to explain why. . ."

As I tried to explain before, people are reading these forums to get, successfuly, information that may help them, according to posts I have read.

I realise that the answers are no good to the original questioner, which is why I didn't answer any of those until it was pointed out to me that this is "A Help & Support Forum for Mainframe Beginners and Students". If this is so, and other beginners and students are going to have the same types of problems as others have had previously, what is the problem with me (or anyone else) going through the old problems hoping that the answers might help beginners and students, and maybe even getting those new beginners and students to think that if they have a problem not covered already on these boards, that they may get answers to their new questions?

I posted a couple of things in the "suggestions" board, because looking through previous posts a lot of things tend to go "dead". OK, seems people on here don't think that that is a problem. Are you going to get rid of my posts on "old" topics, or are you just happy if I don't do any more. Many of the old ones there is not enough information, but some there is information to be able to provide some possible answers, which may help beginners and students, and some even which may stop those same being somewhat confused by some answers given.

For me, Easytrieve Plus is a very useful tool. It can be used for very complex tasks, whilst at the same time keeping things simple. But it can be used badly, very badly. Something that looks like it works, but doesn't completely or all the time. Anyone care? If so, is this board part of that discussion or not?
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Next

Return to CA-Easytrieve

 


  • Related topics
    Replies
    Views
    Last post