Midrange News for the IBM i Community


Posted by: Deepak Deshpande
AS/400 Freelance Programmer/Analyst
India
CPYF from a PF to flat file (With -ve values)
has no ratings.
Published: 19 Jul 2013
Revised: 19 Jul 2013 - 1526 days ago
Last viewed on: 22 Sep 2017 (2800 views) 

Using IBM i? Need to create Excel, CSV, HTML, JSON, PDF, SPOOL reports? Learn more about the fastest and least expensive tool for the job: SQL iQuery.

CPYF from a PF to flat file (With -ve values) Published by: Deepak Deshpande on 19 Jul 2013 view comments(4)

Hi

We have one CL where a PF is copied to a flat file to be FTPed later.

The PF has some amounts which can be negative. After CPYF to flat file, last digit from these negative values gets replaced by a char as follows:

o --> }

1 to 9 --> J through R

Example: 51.88- becomes 518Q and 130.30- becoems 1303}

Is there any way to avoid this? I know, I can write one small RPG program & do this. Just wondering if I can avoid that.

TIA

Deepak

Return to midrangenews.com home page.
Sort Ascend | Descend

COMMENTS

(Sign in to Post a Comment)
Posted by: bobcozzi
Site Admin ****
Chicagoland
Comment on: CPYF from a PF to flat file (With -ve values)
Posted: 4 years 2 months 5 days 22 hours 38 minutes ago

What do you want to do instead? Swallow the negative value? Insert a - before/after the number?

There's no built-in method to do that in CPYF, but there are tools and programming techniques. So you're going to have to write something.

Posted by: clbirk
Premium member *
Comment on: CPYF from a PF to flat file (With -ve values)
Posted: 4 years 2 months 5 days 22 hours 21 minutes ago

The only way I would know short of writing something would be that you copy to an import file (like a csv or tab) in the ifs and with the field definitions it would put out  -14.55 for you but obviously the file format would be different than it is now.

 

Posted by: DeepakD
Premium member *
India
Comment on: CPYF from a PF to flat file (With -ve values)
Posted: 4 years 2 months 5 days 22 hours 11 minutes ago

Bob,

Yes, I want to retain the -ve sign in the flat file. And I guessed there is no direct way using CPYF.

clbirk,

Yes, with the limitation of Input & Output file format, best way to achieve this is to write a small RPG and that's what I did.

Thanks to both of you for your reponses.

Deepak

Posted by: DaleB
Premium member *
Reading, PA
Comment on: CPYF from a PF to flat file (With -ve values)
Posted: 4 years 2 months 5 days 18 hours 3 minutes ago

How does CPYTOIMPF handle negative numbers? CPYTOIMPF does allow a flat file for TOFILE().