Help calling QDCXLATE from itoolkit

Any IBM i topic that does not fit in another forum
Post Reply
hanspoo
Posts: 6
Joined: Tue Oct 08, 2024 3:25 pm

Help calling QDCXLATE from itoolkit

Post by hanspoo »

Hi,

We need to call QDCXLATE from itoolkit, to convert from hex ascii to ebcdic, but don't know how to. Until we can see the as400 doesn't have iconv; may be is too old.

Any help will be appreciated !!

Thanks
Hans
jonboy49
Posts: 244
Joined: Wed Jul 28, 2021 8:18 pm

Re: Help calling QDCXLATE from itoolkit

Post by jonboy49 »

I'm confused - is the data in hex format (2 bytes per character) or simply in ASCII and you need it in EBCDIC?

iconv has been available for a long time and google will find you many examples. Even if you have an AS400 - which I doubt as they are _really_ old - it should be available.
hanspoo
Posts: 6
Joined: Tue Oct 08, 2024 3:25 pm

Re: Help calling QDCXLATE from itoolkit

Post by hanspoo »

It's a long story, we have a propietary program that calls QDCXLATE with an hexadecimal data (4 bits) ascii, the call to QDCXLATE has the bitmaps to decode some iso8583 frames with transparent mode. I'm not an as400 expert, and need to call this program from nodejs with itoolkit.
jonboy49
Posts: 244
Joined: Wed Jul 28, 2021 8:18 pm

Re: Help calling QDCXLATE from itoolkit

Post by jonboy49 »

Why not use the node toolkit? https://www.npmjs.com/package/itoolkit

That should let you call it as you do now.

If you can't get that to work, I suggest asking the authors of the package.
hanspoo
Posts: 6
Joined: Tue Oct 08, 2024 3:25 pm

Re: Help calling QDCXLATE from itoolkit

Post by hanspoo »

Hi,

Thanks to all collaboration, in the end the next code calls the library using itoolkit:

Code: Select all

import { Connection, ProgramCall } from 'itoolkit';
import { XMLParser } from 'fast-xml-parser';

const conn = new Connection({
  transport: 'odbc',
  transportOptions: { dsn: '*LOCAL' },
});

const program = new ProgramCall('QDCXLATE');

const input = process.argv[2];

program.addParam({ name: 'par1', type: '5P0', value: 8 });
program.addParam({ name: 'par2', type: '512A', value: input });
program.addParam({ name: 'par3', type: '10A', value: 'QASCII' });
program.addParam({ name: 'par4', type: '10A', value: 'QSYS' });

conn.add(program);
conn.debug(1);

conn.run((error: any, xmlOutput: any) => {
  if (error) {
    console.log('error');
    return;
  }
  try {
    const Parser = new XMLParser();
    const result = Parser.parse(xmlOutput);
    if (result.myscript.pgm.error) {
      console.log(JSON.stringify(result.myscript.pgm.error));
      return;
    }
    const res = result.myscript.pgm.parm[1].data;
    console.log(res);
    //                resolve(segundoParm.data || segundoParm);
  } catch (error) {
    console.log(error);
  }
});



Thanks again,
Hans
Post Reply