Translating from X'00' to X'40' directly in memory


    Sponsored Links


  • 1. purpose for the use of keyword ASSUME
    hi I want to know why in the display file we use the key word ASSUME with OVERLAY. if the record can be displayed over another using OVERLAY, then why assume is used? Sometimes it happens that without using ASSUME also our purpose is solved by using only OVERLAY.
  • 2. rpg, graphics and iseries access
    Question, Is there a way to allow an image file to be displayed while running an RPG program if a user would select that option and are using a client? If I want to allow a user, during the program, to press a command key and see a drawing or image, how could/would I do that? can someone point me in the right direction where I can do some reading on this? Obviously, I assume it would only work if using iseries access with access to PC types of applications?? That's fine as that is all the emulation we use, but as I said, would like to link as/400 rpg code to call some sort of pc application that would/could display image files... If anyone can point me to some articles, I would appreciate it. thanks, ga George Applegate XXXX@XXXXX.COM

Translating from X'00' to X'40' directly in memory

Postby Ewout » Sat, 12 Nov 2005 18:56:38 GMT

We have a service program that is used to put messages on a WebSphere
MQ message queue. The program receives a pointer as an input parameter
(i.e. not the text of the message itself). The messages are build (in
other programs) from data in the database. Some fields in the database
may have low values (hexadecimal 00's). These values can end up in the
message, and we think those values might cause problems when the
messages are processed on the target system. Therefore, we want to
replace the hexadecimal 00's by hexadecimal 40's (i.e. blanks). Now, in
the service program, I could define a field and base the field on the
pointer, but the maximum size of a field in RPG is about 65.000
characters. However, the messages can be much larger. The length might
even be in the megabytes. Of course, I could scan through the message
by first positioning the field on the address of the pointer, do the
scan, and then position the field on the address of the pointer plus
the length of the field, repeat the scan, and so on, until the length
of the message is completely covered, but this does not seem a very
elegant solution to me.

In fact, I am looking for a way to search an area in memory, without
having to use a field. Does anyone have a suggestion that could help me


Re: Translating from X'00' to X'40' directly in memory

Postby walker.l2 » Sat, 12 Nov 2005 19:35:07 GMT

Just thinking out loud:

Could User Spaces help somehow?
How about SQL's TRANSLATE function?

Still, if your RPG field is 65k long, you wouldn't need to do many
scans unless the message is tens of megabytes or more.


Re: Translating from X'00' to X'40' directly in memory

Postby walker.l2 » Sat, 12 Nov 2005 20:45:56 GMT

I'm also wondering if you could do something clever with a customised
CCSID / translation table...

I'm sorry I'm not giving you anything more concrete.


Re: Translating from X'00' to X'40' directly in memory

Postby Jonathan Bailey » Sat, 12 Nov 2005 20:51:05 GMT

The APIs I found which looked at all useful required an input & output
buffer & I assume you need to translate in place. I think that walking
your pointer is going to be as fast & efficient as you could get. I
suppost you are talking about xlate when you say scan ? I dont know if
xlateing 65k then moving is as good or better than pointing to a single
byte char , testing & converting then incrementing the pointer. I think
the xlate would be better but its just a guess.


Re: Translating from X'00' to X'40' directly in memory

Postby datacrush » Sat, 12 Nov 2005 23:37:52 GMT

I think it was as of V5R1 (or was it V4R4?) that you could solve your 
problem this way:

D Msg             S          65535A   Dim(100)
D MsgPtr          S               *   Inz(%Addr(Msg))

Where in debug the attribute is:

This way MsgPtr should be able to point to your MQGET parameter, and you 
could %SCAN the array for X'00'. The largest I've ever declared using 
this method was 12MB.

I don't think you can access the memory directly. You could try 
accessing some MI functions, but I really don't think IBM provides such 
a thing for security reasons.

Re: Translating from X'00' to X'40' directly in memory

Postby Barbara Morris » Sun, 13 Nov 2005 10:04:56 GMT

You could use the _XLATEB MI builtin function (see QSYSINC/MIH XLATEB). 
It takes a 256 byte translate table where you list all the characters
from x'00' to x'ff'; for the characters you want translated, you replace
them with the to-character.

D xlateTable       ds
D   xlatechars               3u 0   dim(256)

D xlateb           pr               extproc('_XLATEB')
D   data                      *     value
D   table                  256a     const
D   len                     10u 0   value

    // setup translate table
    for i = 1 to 256;
       xlatechars(i) = i - 1;  // setup with all the characters from
x'00' to x'ff'
    xlatechars(1) = x'40';     // replace x'00' by x'40' (blank)

    // translate x'00's to blanks
    xlateb (pointerToData : xlateTable : dataLength);

Re: Translating from X'00' to X'40' directly in memory

Postby Ewout » Sun, 13 Nov 2005 20:52:31 GMT

This seems really great! The for-loop is intended to initialize the
array? And I just need to change the entries that I want to be

I am not at the office right now, but I will try implement this
solution first thing in the (Monday) morning!


Re: Translating from X'00' to X'40' directly in memory

Postby Lou » Mon, 14 Nov 2005 03:02:11 GMT

The AS/400 has a feature, which will do this scrubbing for you much
faster than spinning through the message 1 byte at a time.

You define a tranlsation table with from and to byte values. In this
case you would start with the tranlsation table for your code set
(EBCDIC, ASCII, TCPEBD, TCPASC, etc.). Make of copy of that table.
Change the output mapping to be the same as the input mapping except
map x'00' to x'40'.

The call is to a program (not a bound procedure). The program is
QDCXLATE. This program takes several parameters, but only three are

1. Length of data being converted	Input	Packed(5,0)
2. Conversion data			I/O	Char(*)
4. Conversion table name		Input	Char(10)

If you are stuck using RPG, below is a function prototype of the call:

d translate       pr                  extpgm('QDCXLATE')
d  length                        5P 0 const
d  data                      32766A   options(*varsize)
d  table                        10A   const

Similar Threads:


fullkey klist
        kfld   keymaj
        kfld   keymin
        kfld   keyseq

partkey klist
        kfld   keymaj
        kfld   keymin

fullkey setgt file 
partkey readpe file
if %found(file)
eval keyseq+= keseq
write file

I know this is not exact, but what i want is the highest sequence key
in the file that has the equal property to keymaj/keymin so i can
insert a new record with a one up sequence in the file. if not found i
can write with a sequence of one. Problem is I am an rpg guy and i
need to do this in cobol efficiently, it's being handled by duplicate
execption processing now and that has to stop.  thankyou in advance
for the cobol help...........

3.Changing "Force Translate" in I-series navigator

I'm using the IBM I series navigator to run some sql. I use Navigator
to test my sql (using the "run SQL scripts" option), which I then
incorporate into a little VB application.

Depending on the datatype of any given field, the charcaters may show
up as some unreadable code. in the Iseries navigator window.

I'm 99.9% sure that this relates to the CCSID/ force translation
options. I'm quite sure because I changed these parameters when I had
similar issues with an ODBC connection and an OLEDB connection string.

Thus my question is, how and where I do I change the parameters for the
Force Translate in I series navgator so that I can read my fields as
they should be. Note that I'm not trying to change any server settings,
I just want to see the output correctly on my PC

I don't think it's relevant but it's worth mentioning... I'm connecting
to a server in the US, I'm using a French PC, and I've got the French
version of I sertries Navigator

Thanks for any assistance you can give.

4.HPT not translating accented characters properly

We print documents in both English and French using Xerox printers
that support PCL.  The AS400 uses host print transform to convert to
PCL, which works quite well.  Just have one problem.  In French,
lowercase accented characters print properly, but uppercase accented
characters print as lowercase.  For example, ?prints as ?and ?
prints as ?

These characters print fine from the AS400 to a printer that does not
use HPT and the Xerox printers print fine from a PC application, so
I'm quite sure that the problem is with the translation that HPT is

Anyone have any ideas?

Thanks in advance.
Ed to translate to free format?

C                   MOVEL     S@OUTDS       P@PARM          511

6. Ace Combat 6 interview (translated from japanese)

7. FA: TRANSLATE websites into your own LANGUAGE

8. FS: TranSLATE webpages into your own language

Return to as400


Who is online

Users browsing this forum: No registered users and 94 guest