Example in ILE C: Retrieving the HOLD parameter (error code structure)
This ILE C program retrieves the value of the HOLD parameter of a job description (specified on the Create Job Description (CRTJOBD) or Change Job Description (CHGJOBD) command). Any errors are returned in an error code structure.
Note: By using the code examples, you agree to the terms of the Code license and disclaimer information.
/***********************************************************************/
/***********************************************************************/
/* */
/*Program Name: JOBDAPI */
/* */
/*Programming Language: ILE C */
/* */
/*Description: This example shows how to make use of an */
/* error returned in the error code structure. */
/* */
/*Header Files Included: STDIO - Standard Input/Output */
/* STRING - String Functions */
/* QUSEC - Error Code Parameter */
/* QWDRJOBD - Retrieve Job Description API */
/* QLIEPT - Entry Point Table */
/* */
/***********************************************************************/
/***********************************************************************/
#include <stdio.h>
#include <string.h>
#include <qusec.h> (1) /* Error Code Parameter Include for the API */
#include <qwdrjobd.h> /* Retrieve Job Description API Include */
#include <qliept.h>
/***********************************************************************/
/* Error Code Structure */
/* */
/* This shows how the user can define the variable length portion of */
/* error code for the exception data. */
/* */
/***********************************************************************/
typedef struct {
Qus_EC_t ec_fields;
char Exception_Data[100];
} error_code_t;
main(int argc, char *argv[])
{
error_code_t error_code;
char qual_job_desc[20];
char *qual_job_ptr = qual_job_desc;
char rec_var[390];
char hold_value[10];
char message_id[7];
char command_string[53];
char message_string[67];
memset(hold_value, ' ', 10);
/*********************************************************************/
/* Make sure we received the correct number of parameters. The argc */
/* parameter will contain the number of parameters that was passed */
/* to this program. This number also includes the program itself, */
/* so we need to evaluate argc-1. */
/*********************************************************************/
if (((argc - 1) < 2) || ((argc - 1 > 2)))
/*********************************************************************/
/* We did not receive all of the required parameters so exit the */
/* program. */
/*********************************************************************/
{
exit(1);
}
/*********************************************************************/
/* Move the two parameter passed in into qual_job_desc. */
/*********************************************************************/
memcpy(qual_job_ptr, argv[1], 10);
qual_job_ptr += 10;
memcpy(qual_job_ptr, argv[2], 10);
/*********************************************************************/
/* Set the error code parameter to 16. */
/*********************************************************************/
error_code.ec_fields.Bytes_Provided = 16; (3)
/*********************************************************************/
/* Call the QWDRJOBD API. */
/*********************************************************************/
QWDRJOBD(rec_var, /* Receiver Variable */
390, /* Receiver Length */
"JOBD0100", /* Format Name */
qual_job_desc, /* Qualified Job Description */
&error_code); /* Error Code */
/*********************************************************************/
/* If an error was returned, send an error message. */
/*********************************************************************/
if(error_code.ec_fields.Bytes_Available > 0) (2)
{
memcpy(message_id, error_code.ec_fields.Exception_Id, 7);
sprintf(message_string,
"SNDMSG MSG('Program failed with message ID %.7s') TOUSR(QPGMR)",
message_id);
system(message_string);
}
/*********************************************************************/
/* Let's tell everyone what the hold value was for this job. */
/*********************************************************************/
else
{
memcpy(hold_value, ((Qwd_JOBD0100_t *)rec_var)->Hold_Job_Queue, 10);
sprintf(command_string,
"SNDMSG MSG('HOLD value is %.10s') TOUSR(QPGMR)",
hold_value);
system(command_string);
}
} /* main */