× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



While the file is still in the IFS, use PASE (call qp2term) to clean it.

You can use a sed "one-liner" to translate the bad characters.

Your original file:

[manny@x40 ~/qpgm/Viejo]$ cat data
90 Å A
91 Ç C
92 Ñ N
164 ¦
93 ø o
94 É E
95 Ê E
96 Ë E
97 È E
98 Í I
99 Î I
100 Ï I
101 Ì I
102 Ø O
103 « <

Translated using sed:

[manny@x40 ~/qpgm/Viejo]$ sed 'y/ÅÇѦøÉÊËÈÍÎÏÌØ«/ACN oEEEEIIIIO</' data
90 A A
91 C C
92 N N
164
93 o o
94 E E
95 E E
96 E E
97 E E
98 I I
99 I I
100 I I
101 I I
102 O O
103 < <

you can redirect the output to another file and use the result as your "good file".

sed is very old (1974), but very powerful, fast and compact.

On my computer (FreeBSD 10.2) it is only 31k!

[manny@x40 ~/qpgm/Viejo]$ ls -lh /usr/bin/sed
-r-xr-xr-x 1 root wheel 31K 25 dic 09:39 /usr/bin/sed

El Tue, 1 Mar 2016 17:42:09 +0000
Alan Shore <ashore@xxxxxxxx> escribió:
Hi everyone
Before I forget - we are on V5r4
Hopefully I can explain my predicament

We have a file on the AS/400, that has been created from a file on the ifs using the
following command CPYFRMSTMF FROMSTMF('/ifsdirectory/filename.xxx') +
TOMBR('/QSYS.LIB/LIBRARY.LIB/DATAFILE.FILE/+
filembr.MBR') MBROPT(*REPLACE) +
ENDLINFMT(*CRLF)

However - sometimes the data in the file contains line feed (X'25') in numerous places and
creates havoc further down the suite of programs

I have found the following sql script that works

update library/datafile
set field = translate(field, X'40', X'25')
WHERE field like '%' || X'25' || '%'

This is good - but I want to go further
We have a file called BADHEXCHR that contains 2 fields
BHCCHAR (Bad Hex Character)
BHCREPL (Replacement Character)

This contains numerous records like
Record# BHCCHAR BHCREPL
90 Å A
91 Ç C
92 Ñ N
164 ¦
93 ø o
94 É E
95 Ê E
96 Ë E
97 È E
98 Í I
99 Î I
100 Ï I
101 Ì I
102 Ø O
103 « <
Including X'25' to X'40'
Its used in a procedure that is called in numerous RPG programs
The question I have is
Is there anyway to change the SQL from
update library/datafile
set field = translate(field, X'40', X'25')
WHERE field like '%' || X'25' || '%'

To use this file so that any character in the string that is equal to BHCCHAR is replaced
with BHCREPL

I am getting nowhere fast (actually not so fast) and any help/pointers would be MUCH
appreciated


Alan Shore
E-mail : ASHORE@xxxxxxxx
Phone [O] : (631) 200-5019
Phone [C] : (631) 880-8640
'If you're going through hell, keep going.'
Winston Churchill





As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.