T_PRSQRY - Parse a Transaction Query

**FREE
// Example Program: T_PRSQRY
// Description:
//  This is a test program to demonstrate parsing a transaction query
//  file using the CTI_ParseTransactionQuery() API.
//
//  This transaction query file must have been previously downloaded with
//  the CTI_QueryTransaction() API - see the T_QRYTRN example program
//  for a demonstration of this API.
//
//  To parse the transaction query data, generate a new unique ID with
//  the CTI_NextUniqueID() API. Then, call the API, passing in your
//  unique ID, the fully-qualified filepath for the report file, and the
//  error data structure parameters as shown.
//
//  CTI_ParseTransactionQuery() will return *On if no error was
//  encountered, or *Off if an error occurred. If an error occurred,
//  you should look at the fields in ErrorDS to retrieve information
//  about the error. Additional error information may be found in the
//  CTIERR file, or in the record for this query in the CTIQTD file.
//
//  Otherwise, you can perform a CHAIN against the CTIQTD physical
//  file, and the other CTIQTD* files, and retrieve the parsed fields.

Ctl-Opt ActGrp(*Caller) BndDir('CTIBND') Option(*NoDebugIO);

/COPY QRPGLECPY,CTICB

// This is included for demo output purposes.
Dcl-Pr WriteToJobLog Int(10) Extproc('Qp0zLprintf');
  pString Pointer Value Options(*String);
End-Pr;
Dcl-C NewLine x'15';

// This stores the unique ID for this API call
Dcl-S UniqueId Like(CTI_UniqueId_t) Inz;

Dcl-S Filepath Like(CTI_FilePath_t) Inz;
// This holds any error information returned by the API call
Dcl-Ds ErrorDS LikeDS(CTI_ErrorDS_t) Inz(*LikeDS);

// Modify this field to use your merchant ID
Dcl-S MerchantId Like(CTI_MerchantId_t) Inz('ikrengel');

reset ErrorDS;

UniqueId = CTI_NextUniqueId();
// This API will only parse a report in JSON format
Filepath = '/ktprod/cti/downloads/transactionquery_52.json';

if not CTI_ParseTransactionQuery( UniqueId : Filepath : ErrorDS );
  WriteToJobLog( 'Failure' + NewLine );
  WriteToJobLog( 'Source: ' + ErrorDS.Source + NewLine );
  WriteToJobLog( %Trim(ErrorDS.MessageId) + ': '
               + ErrorDS.Message + NewLine );
else;
  WriteToJobLog( 'Success' + NewLine );
endif;

// Write unique ID to job log for easy reference
WriteToJobLog( 'T_PRSQRY Unique ID: ' + %Char(UniqueId) + NewLine );

*INLR = *On;
return;