QUSRJOBI 获得作业内部id
请问,用QUSRJOBI获得job内部id,为何总是空的?
无论是程序执行还是debug,Int_Job_ID 都是空的,请高手指点。
下面是调用:
QUSRJOBI(&jobinfo,
sizeof(jobinfo),
"JOBI0100",
"* ",
" ",
&errorCode);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(9)
本帖最后由 xjromance 于 2011-03-26 12:40 编辑
帮顶
期待高手解答
是不是概念错了?
问你几个问题:
1)这里的&jobinfo表示什么?
2)size of jobinfo是多少?
&jobinfo 应该是基于JOBI0100格式的数据结构 名称
你是用CLP调还是RPGIV调用API呢?程序开头定义了对应变量了么。
JOBI0100 Format
Offset Type Field
Dec Hex
0 0 BINARY(4) Number of bytes returned
4 4 BINARY(4) Number of bytes available
8 8 CHAR(10) Job name
18 12 CHAR(10) User name
28 1C CHAR(6) Job number
34 22 CHAR(16) Internal job identifier
50 32 CHAR(10) Job status
60 3C CHAR(1) Job type
61 3D CHAR(1) Job subtype
62 3E CHAR(2) Reserved
64 40 BINARY(4) Run priority (job)
68 44 BINARY(4) Time slice
72 48 BINARY(4) Default wait
76 4C CHAR(10) Purge
&jobinfo 的确是基于JOBI0100格式的数据结构
是在C 里调用的QUSRJOBI
只要把头文件引用进来就可以了
如果是C调用,第一项应该是获取返回结果数据结构的地址,而不是一个变量。
IBM技术文档:
Required Parameter Group:
1 Receiver variable Output Char(*)
2 Length of receiver variable Input Binary(4)
3 Format name Input Char(
4 Qualified job name Input Char(26)
5 Internal job identifier Input Char(16)
int Get400JobInfo(char *JobName, char *MsgId)
{
error_code_t error_code;
char rcv_var[8];
int rcv_len = 8;
char rjobd_fmt[8+1] = "OBJD0100";
char qualified_user_space[20+1] = "USERSPACE QTEMP ";
char user_space_type[10+1] = "*USRSPC ";
char ext_attr[10+1] = " ";
int user_space_size = 1;
char user_space_init = 0x00;
char user_space_auth[10+1] = "*ALL ";
char user_space_text[50] = "My User Space";
char user_space_rep[10+1] = "*YES ";
char user_space_dmn[10+1] = "*USER ";
char job_list_fmt[8+1] = "JOBL0100";
char job_status[10+1] = "*ACTIVE ";
char qualified_job_name[26+1];
int number_of_entries = 0;
int list_entry_length = 0;
int list_entry_offset = 0;
char list_job_entry[52+1];
Qwc_JOBI0200_t JobI0200;
char struct_fmt[8+1] = "JOBI0200";
char inter_job_id[16+1];
char user_name[10+1] = "*ALL";
char job_number[6+1] = "*ALL";
int i;
memset(MsgId, ' ', 7);
MsgId[7] = '\0';
for(i = 0; i < 26; i++) qualified_job_name[i] = ' ';
for(i = 0; i < 16; i++) inter_job_id[i] = ' ';
memmove(qualified_job_name+20, job_number, strlen(job_number));
memmove(qualified_job_name+10, user_name, strlen(user_name));
memmove(qualified_job_name, JobName, strlen(JobName));
/*
JobName: CHAR(10), A specific job name, a generic name, or one of the
following special values:
* Only the job that this program is running in. The
rest of the qualified job name parameter must be blank.
*CURRENT All jobs with the current job's name.
*ALL All jobs. The rest of the job name parameter must
be specified.
*/
error_code.ec_fields.Bytes_Provided = sizeof(error_code_t);
/********************************************************************/
/* Call QUSROBJD to see if the user space was previously created in */
/* QTEMP. If it was, simply reuse it. */
/********************************************************************/
QUSROBJD(rcv_var, /* Receiver variable */
rcv_len, /* Receiver variable length */
rjobd_fmt, /* Format */
qualified_user_space, /* User space name and library */
user_space_type, /* User object type */
&error_code); /* Error code */
if(error_code.ec_fields.Bytes_Available > 0)
{
/******************************************************************/
/* If a CPF9801 error was received, then the user space was not */
/* found. */
/******************************************************************/
if(memcmp(error_code.ec_fields.Exception_Id, "CPF9801", 7) == 0)
{
/****************************************************************/
/* Create a user space for the list generated by QSYLOBJP. */
/****************************************************************/
QUSCRTUS(qualified_user_space, /* User space name and library */
ext_attr, /* Extended attribute */
user_space_size, /* Size of the user space */
&user_space_init, /* Space initialization */
user_space_auth, /* Public authority to user space */
user_space_text, /* User space text */
user_space_rep, /* Replace existing user space? */
&error_code, /* Error Code */
user_space_dmn); /* Domain of created user space */
if(error_code.ec_fields.Bytes_Available > 0)
{
memmove(MsgId, error_code.ec_fields.Exception_Id, 7);
return -1;
}
}
else
{
memmove(MsgId, error_code.ec_fields.Exception_Id, 7);
return -2;
}
}
QUSLJOB(qualified_user_space, /* User space name and library */
job_list_fmt, /* Format name */
qualified_job_name, /* Qualified job name */
job_status, /* Status */
error_code); /* Optional Parameter Group 1: */
/* void * Error code */
if(error_code.ec_fields.Bytes_Available > 0)
{
memmove(MsgId, error_code.ec_fields.Exception_Id, 7);
return -3;
}
QUSRTVUS(qualified_user_space, /* Qualified User Space Name */
0x85, /* Starting Position */
0x04, /* Length of Data */
&number_of_entries, /* Reciever Variable */
error_code); /* Optional Parameter: */
/* Error Code */
if(error_code.ec_fields.Bytes_Available > 0)
{
memmove(MsgId, error_code.ec_fields.Exception_Id, 7);
return -4;
}
QUSRTVUS(qualified_user_space, /* Qualified User Space Name */
0x89, /* Starting Position */
0x04, /* Length of Data */
&list_entry_length, /* Reciever Variable */
error_code); /* Optional Parameter: */
/* Error Code */
if(error_code.ec_fields.Bytes_Available > 0)
{
memmove(MsgId, error_code.ec_fields.Exception_Id, 7);
return -5;
}
QUSRTVUS(qualified_user_space, /* Qualified User Space Name */
0x7D, /* Starting Position */
0x04, /* Length of Data */
&list_entry_offset, /* Reciever Variable */
error_code); /* Optional Parameter: */
/* Error Code */
if(error_code.ec_fields.Bytes_Available > 0)
{
memmove(MsgId, error_code.ec_fields.Exception_Id, 7);
return -6;
}
list_entry_offset += 1;
for(i = 0; i < number_of_entries; i++)
{
QUSRTVUS(qualified_user_space, /* Qualified User Space Name */
list_entry_offset, /* Starting Position */
list_entry_length, /* Length of Data */
list_job_entry, /* Reciever Variable */
error_code); /* Optional Parameter: */
/* Error Code */
if(error_code.ec_fields.Bytes_Available > 0)
{
memmove(MsgId, error_code.ec_fields.Exception_Id, 7);
return -7;
}
strcpy(qualified_job_name, "*INT ");
memmove(inter_job_id, list_job_entry+26, 16);
/* or:
memmove(qualified_job_name, list_job_entry, 26);
*/
rcv_len = sizeof(Qwc_JOBI0200_t);
QUSRJOBI(&JobI0200, /* Receiver variable */
rcv_len, /* Length of receiver variable */
struct_fmt, /* Format name */
qualified_job_name, /* Qualified job name */
inter_job_id, /* Internal job identifier */
error_code); /* Optional Parameter: */
/* Error Code */
if(error_code.ec_fields.Bytes_Available > 0)
{
memmove(MsgId, error_code.ec_fields.Exception_Id, 7);
return -8;
}
if(i < MAX_AS400_JOB_NUM)
{
memmove(AS400Jobs[i].Job_Name, JobI0200.Job_Name, 10);
memmove(AS400Jobs[i].User_Name, JobI0200.User_Name, 10);
memmove(AS400Jobs[i].Job_Number, JobI0200.Job_Number, 6);
memmove(AS400Jobs[i].Int_Job_ID, JobI0200.Int_Job_ID, 16);
memmove(AS400Jobs[i].Job_Status, JobI0200.Job_Status, 10);
memmove(AS400Jobs[i].Job_Type, JobI0200.Job_Type, 1);
memmove(AS400Jobs[i].Job_Subtype, JobI0200.Job_Subtype, 1);
memmove(AS400Jobs[i].Subsys_Name, JobI0200.Subsys_Name, 10);
memmove(AS400Jobs[i].Active_Job_Stat, JobI0200.Active_Job_Stat, 4);
AS400Jobs[i].CPU_Used = JobI0200.CPU_Used;
}
list_entry_offset += list_entry_length;
}
return number_of_entries;
}