Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
If you want to automate analysis of Collection Services, you can use this approach to use SQL to discern the library in use by Collection Services (CS) and the member name in the CS files that corresponds to the current day.
begin
execute immediate 'create or replace variable qpfrdata.current_CS_library varchar(10) for sbcs data';
execute immediate 'create or replace variable qpfrdata.current_CS_member varchar(10) for sbcs data';
call qsys2.qcmdexc('QSYS/CHKPFRCOL');
set (qpfrdata.current_CS_library,qpfrdata.current_CS_member) =
(select rtrim(substr(message_tokens,1,10)) as cs_lib, rtrim(substr(message_tokens,11,10)) as cs_mbr
from table(qsys2.joblog_info('*')) where message_id = 'CPI0A16' order by ordinal_position desc limit 1);
execute immediate
'create or replace alias qtemp.goget_QAPMJOBWT for ' concat qpfrdata.current_CS_library concat '.QAPMJOBWT( ' concat qpfrdata.current_CS_member concat ')';
end;
select * from qtemp.goget_QAPMJOBWT;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment