Hello, all. I came across an example of someone using CL it seems to work with the Retrieve System Status (QWCRSSTS) API:
https://itknowledgeexchange.techtarg...n-into-a-file/
Here's the whole program procedure someone helpfully posted in the replies section:
I understand this part of pgm below, there's an IBM API doc that tells you what format to use:
IBM doc: https://www.ibm.com/support/knowledg...s/qwcrssts.htm
However, the once piece I don't yet understand is how these variables below were chosen, or where they came from:
If I go back to the IBM doc it shows the different Dec/Hex values and what the different fields are, but that's it. Did the original user who created the pgm above simply use custom variables? Just curious as to how they were chosen. I'd appreciate some insight. Thank you!
https://itknowledgeexchange.techtarg...n-into-a-file/
Here's the whole program procedure someone helpfully posted in the replies section:
Code:
pgm /* The API parms... */ /* For Retrieve System Status... */ dcl &Sts_Data *char 68 dcl &Sts_Len *int value( 68 ) dcl &Sts_Format *char 8 value( 'SSTS0200' ) dcl &Reset_Ind *char 10 value( '*NO' ) /* For Convert Date & Time... */ dcl &CDT_I_Form *char 10 value( '*DTS' ) dcl &CDT_I_Var *char 8 dcl &CDT_O_Form *char 10 value( '*YMD' ) dcl &CDT_O_Var *char 16 /* And we'll need to specify an errcode receiver at one point... */ dcl &errcode *char 116 value( x'00000074') dcl &errlen *int value( 0 ) /* + Will tell us how long any exception data + is... */ /* These are *char versions of the *dec vars... */ dcl &ElpHH_C *char 2 dcl &ElpMM_C *char 2 dcl &ElpSS_C *char 2 dcl &CPUPct_C *char 8 dcl &JobCnt_C *char 6 dcl &PADPct_C *char 7 dcl &TADPct_C *char 7 dcl &ASPSiz_C *char 9 dcl &ASPPct_C *char 8 dcl &TotAux_C *char 9 dcl &CurUnp_C *char 6 dcl &MaxUnp_C *char 6 /* The SQL statement gets built from *CATted values... */ dcl &SQL_Stmt *char 256 dclf SYSYSSTSPF call Qsys/QWCRSSTS ( + &Sts_Data + &Sts_Len + &Sts_Format + &Reset_Ind + &errcode + ) chgvar &CDT_I_Var %sst( &Sts_Data 9 8 ) call Qsys/QWCCVTDT ( + &CDT_I_Form + &CDT_I_Var + &CDT_O_Form + &CDT_O_Var + &errcode + ) /* Test for an exception... */ chgvar &errlen %bin( &errcode 5 4 ) /* Test for any error... */ if ( &errlen *gt 0 ) do sndpgmmsg msgid( CPF9898 ) msgf( QCPFMSG ) + msgdta( + %sst( &errcode 9 7 ) *bcat + 'error exception' + ) + msgtype( *ESCAPE ) enddo chgvar &DATTIM &CDT_O_Var chgvar &ElpHH_C %sst( &Sts_Data 25 2 ) chgvar &ElpMM_C %sst( &Sts_Data 27 2 ) chgvar &ElpSS_C %sst( &Sts_Data 29 2 ) chgvar &CPUPCT ( %bin( &Sts_Data 33 4 ) * 0.1 ) chgvar &CPUPct_C &CPUPCT chgvar &JOBCNT %bin( &Sts_Data 37 4 ) chgvar &JobCnt_C &JOBCNT chgvar &PADPCT ( %bin( &Sts_Data 41 4 ) * 0.001 ) chgvar &PADPct_C &PADPCT chgvar &TADPCT ( %bin( &Sts_Data 45 4 ) * 0.001 ) chgvar &TADPct_C &TADPCT chgvar &ASPSIZ %bin( &Sts_Data 49 4 ) chgvar &ASPSiz_C &ASPSIZ chgvar &ASPPCT ( %bin( &Sts_Data 53 4 ) * 0.0001 ) chgvar &ASPPct_C &ASPPCT chgvar &TOTAUX %bin( &Sts_Data 57 4 ) chgvar &TotAux_C &TOTAUX chgvar &CURUNP %bin( &Sts_Data 61 4 ) chgvar &CurUnp_C &CURUNP chgvar &MAXUNP %bin( &Sts_Data 65 4 ) chgvar &MaxUnp_C &MAXUNP /* All values have been extracted from the API and converted to + *char. (The conversion allows the *CATs in RUNSQL below...) */ chgvar &SQL_Stmt ( 'insert into SYSYSSTSPF + values (''' *cat &DATTIM *tcat ''',' + *bcat &ElpHH_C *tcat ',' *bcat &ElpMM_C + *tcat ',' *bcat &ElpSS_C *tcat ',' *bcat + &CPUPct_C *tcat ',' *bcat &JobCnt_C *tcat + ',' *bcat &PADPct_C *tcat ',' *bcat + &TADPct_C *tcat ',' *bcat &ASPSiz_C *tcat + ',' *bcat &ASPPct_C *tcat ',' *bcat + &TotAux_C *tcat ',' *bcat &CurUnp_C *tcat + ',' *bcat &MaxUnp_C *tcat ')') RRUNSQL SQL( &SQL_Stmt ) return endpgm
Code:
/* The API parms... */ /* For Retrieve System Status... */ dcl &Sts_Data *char 68 dcl &Sts_Len *int value( 68 ) dcl &Sts_Format *char 8 value( 'SSTS0200' ) dcl &Reset_Ind *char 10 value( '*NO' )
However, the once piece I don't yet understand is how these variables below were chosen, or where they came from:
Code:
/* These are *char versions of the *dec vars... */ dcl &ElpHH_C *char 2 dcl &ElpMM_C *char 2 dcl &ElpSS_C *char 2
Comment