EZT - Data conversion from Alphanumeric to Packed decimal

Unicenter CA-Easytrieve Plus Report Generator: CA's information retrieval and data management tool
Sandy
Posts: 1
Joined: Fri May 16, 2014 2:35 am
Skillset: Cobol, DB2, PL/1
Referer: Google

EZT - Data conversion from Alphanumeric to Packed decimal

Postby Sandy » Fri May 16, 2014 2:45 am

Hi,

New to EZT. Need help.

I have an input file that contains amount field from column 102 to 111 (i.e, alphanumeric 10). It can contain -ve values too.
It is variable length. For example it can contain '-500.00' or '1234567.00'.

The EZT pgm has to read this amount field from input file and move it to a packed decimal field AMT1 W 8 P 2.
I am using this packed decimal to update the amount field in a db2 table. The amount field in the table has its datatype defined as DECIMAL(15,2). Hence I need to define my AMT1 as W 8 P 2. Otherwise I am getting datatype error while updating it.

Please help!

Thanks,
Sandy

NicC
Global moderator
Posts: 3025
Joined: Sun Jul 04, 2010 12:13 am
Skillset: JCL, PL/1, Rexx, Utilities and to a lesser extent (i.e. I have programmed using them) COBOL,DB2,IMS
Referer: Google
Location: Pushing up the daisies (almost)

Re: EZT - Data conversion from Alphanumeric to Packed decima

Postby NicC » Fri May 16, 2014 12:35 pm

If all your easytrieve is doing is converting that one field then you would be better off using your sort product - but I will leave others to judge on that.
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic

BillyBoyo
Global moderator
Posts: 3805
Joined: Tue Jan 25, 2011 12:02 am
Skillset: Easytrieve Plus, Cobol, Utilities, that sort of stuff
Referer: Google

Re: EZT - Data conversion from Alphanumeric to Packed decima

Postby BillyBoyo » Fri May 16, 2014 1:37 pm

To convert that field in Easytrieve Plus, you'd need to write some code, a loop starting at the right, ignoring blanks. You'll have to transfer from first non-blank, byte at a time, ignoring ".", into a numeric (N) field that is redefined as A with the OCCURS. You need to make sure your receiving field starts are zero. When you arrive at a -, set a flag, if you find no sign, set the flag to something else.

Testing the flag, set you packed-decimal field to either the numeric field you've just populated or (0 - the numeric field you've just populated).

Or use SORT, which has SFF, a format for a Signed Free-Format field (which is what you have).


  • Similar Topics
    Replies
    Views
    Last post