Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Format the fields in a flatfile

Former Member
0 Likes
423

Hi all,

I have a flatfile which has 7 fields which I need to format.

The requirement is for every row in the flatfile, I have to check

FOR EVERY ROW in <flatfile>

IF NUMERIC Field

Right-justify field value & Pad with leading zeroes to the LEFT.

WRITE FIELD to <flatfile>

ELSE IF ALPHANUMERIC FIELD

Left-justify field value and Pad leading spaces to the RIGHT.

WRITE FIELD to <flatfile>

ENDIF

Please help me with the sample code.

Thanks and regards,

Anishur

Hi all,

I have a flatfile which has 7 fields which I need to format.

The requirement is for every row in the flatfile, I have to check

FOR EVERY ROW in <flatfile>

IF NUMERIC Field

Right-justify field value & Pad with leading zeroes to the LEFT.

WRITE FIELD to <flatfile>

ELSE IF ALPHANUMERIC FIELD

Left-justify field value and Pad leading spaces to the RIGHT.

WRITE FIELD to <flatfile>

ENDIF

Please help me with the sample code.

Thanks and regards,

Anishur

1 REPLY 1
Read only

Jelena_Perfiljeva
Active Contributor
0 Likes
394

I hope you don't need a code sample for how to read a file...

For "number / not number" validation and right-justify you can find a sample here:

http://friendlyabaper.blogspot.com/2006/10/fun-with-numbers.html

"Left-justify" - use SHIFT LEFT DELETING LEADING space.

Hope this helps.