65 pts.
 Problems eliminating HEX 41 character.
I have a number of files on my DB2/400 database that have spaces with a Hex code of 41 instead of 40. This causes a problem when FTP'ing to a PC for integration with a barcode labeling application. Does anyone know how I can change this character to ANYTHING other than Space HEX 41 !! Potentially any space in a character field could be HEX 41 and I need to ensure it is changed to HEX 40. Many thanks.

Software/Hardware used:
ASKED: March 28, 2007  9:03 AM
UPDATED: January 5, 2010  3:46 PM

Answer Wiki:
Hi You can do this by creating a character conversion table and then specifying it on the FTP command: a) Get a copy of the QASCII (EBCDIC to ASCII) conversion table by using the RTVTBLSRC command: RTVTBLSRC TBL(QASCII) SRCFILE(my_lib/QTXTSRC) SRCMBR(MYQASCII) b) Use SEU (or WDSC) to edit the MYQASCII source member you just created. Line 3.00 of the source member should be changed to begin "2020" instead of "20A0". c) Save the source member and then create your new table using the CRTTBL command: CRTTBL TBL(QGPL/MYQASCII) SRCFILE(*LIBL/QTXTSRC) 7) When using FTP, add the parameter TBLFTPOUT and specify your new conversion table: FTP RMTSYS('192.168.0.1') TBLFTPOUT(QGPL/MYQASCII) Hope it helps Jonathan ================================================================ Note that you only want to use a translation table against character fields. A hex-41 byte can appear in non-character areas of a record and those <i>should not</i> be translated. <pre>UPDATE myfile SET mycol = replace( mycol ,x'41',x'40')</pre>You should be able to run that against any table MYFILE for any column MYCOL. If you create it as a QM query, you can place substitution variables for the table and column names. Tom
Last Wiki Answer Submitted:  January 4, 2010  7:32 am  by  TomLiotta   107,695 pts.
All Answer Wiki Contributors:  TomLiotta   107,695 pts. , astradyne   370 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

Use the xlate opcode to change the as400 data:

CL0N01Factor1+++++++Opcode&ExtFactor2+++++++Result c X’41′:X’40′ xlate Fldnam Fldnam

You can also use the %xlate, just fill in the parms with data from above and is also a %xlate in /Free.

 0 pts.

 

I have solved the problem within RPG :
I load the field into an array and read a character at a time looking for X’41′ and replace with X’40′.
if array(X) = X’41′
eval array(X) = X’40′
endif
Perhaps this will help others who encounter this problem.

Thanks for everyone who took the time to think about this one.

Neil.

 65 pts.

 

Unless you’re using an earlier version of RPG that doesn’t support either the XLATE opcode or the %XLATE bif, you’re not improving your program performance by cycling through arrays.

 5,670 pts.