z/OS DFSMSrmm Application Programming Interface
Previous topic | Next topic | Contents | Contact z/OS | Library | PDF


Using the object-oriented DFSMSrmm application programming interface using C++

z/OS DFSMSrmm Application Programming Interface
SC23-6872-00

DFSMSrmm samples provided in SAMPLIB: EDGHCLT is shipped in SAMPLIB. The sample code shows how to issue RMM subcommands by using the DFSMSrmm high-level language application programming interface classes and methods.

Requirement: The dynamic link library (DLL) is compiled using the IBM® z/OS® V1R10 XL C/C++ compiler. To compile your own program, you can use compiler versions up to and including the IBM z/OS V1R10 XL (ISO C/C++) level of the compiler.

Related reading: For information about using the IBM z/OS V1R10 XL C/C++ compiler, see z/OS XL C/C++ User's Guide. For migration and compatibility considerations, see z/OS XL C/C++ Compiler and Run-Time Migration Guide for the Application Programmer.

You can use C++ and other high-level programming languages to write programs to obtain information about DFSMSrmm resources. You use the same DFSMSrmm subcommand strings that you can use with the EDGXCI application programming interface. You can get output as structured field introducers or in Extensible Markup Language (XML). The XML output contains data and tags to define the data. DFSMSrmm provides a schema called rmmxml.xsd that contains the definitions for the XML. For XML output, DFSMSrmm converts the data to character in Unicode format as defined in the XML Schema file for the DFSMSrmm resources. See Receiving extensible markup language (XML) output data in the XML output buffer.

To create your own program as shown in Figure 1, you need access to the EDGXHCLU (header file) and the EDGXHCLL (definition side deck). The header file is necessary for the compile step and located in SYS1.MACLIB. The definition side deck is necessary for the bind step and is located in SYS1.SIEASID.
Figure 2 shows sample JCL that you can use to request information for the RMM LISTVOLUME subcommand.
Figure 2. Sample JCL for requesting LISTVOLUME information
//*--------------------------------------------------------------------*             
//* JCL Example to use C/C++ HLLAPI submitting RMM LIST VOLUME command,*
//* using sample program EDGHCLT,                                      *
//* EDGHCLT needs access to DLL: SYS1.SIEALNKE(EDGXHCLL)               *
//* receiving SFI output (SFIFILE) and XML output (XMLFILE)            *
//*--------------------------------------------------------------------*
//SMPLAPI  EXEC PGM=EDGHCLT,PARM='"LISTVOLUME A00001"'
//STEPLIB  DD DISP=SHR,DSN=HLQ.CPP.LOAD
//XMLFILE  DD DISP=(NEW,CATLG),DSN=USERID.OUTPUT.XMLFILE,
//            UNIT=SYSALLDA,VOL=SER=RMMDSK,
//            SPACE=(CYL,(5,5)),DCB=(RECFM=VB,LRECL=1028,BLKSIZE=6144)
//SFIFILE  DD DISP=(NEW,CATLG),DSN=USERID.OUTPUT.SFIFILE,
//            UNIT=SYSALLDA,VOL=SER=RMMDSK,
//            SPACE=(CYL,(5,5)),DCB=(RECFM=VB,LRECL=1028,BLKSIZE=6144)
//SYSPRINT DD SYSOUT=*         
   

You need to write the program using C++ using the DFSMSrmm API classes and DFSMSrmm API methods to establish the connection to DFSMSrmm, issue the DFSMSrmm subcommands, and receive the output. If you select SFI format for the output, DFSMSrmm returns the information in structured field formats with all the fields provided.

Here is sample code that you can modify to use the high-level application programming interface.

/**********************************************************************
*                                                                     *
*  Module Name:  EDGHCLT                                              *
*                                                                     *
*  Description:  SAMPLE CODE for USING C/C++ HIGH LEVEL API INTERFACE *
*                                                                     *
***********************************************************************
*                                                                     *
* z/OS DFSMSrmm V1R11                                                 *
*                                                                     *
* PROPRIETARY V3 STATEMENT                                            *
* Licensed Materials - Property of IBM                                *
* 5694-A01                                                            *
* Copyright IBM Corp. 1993,2009                                       *
* END PROPRIETARY V3 STATEMENT                                        *
***********************************************************************
*                                                                     *
*  Function:                                                          *
*                                                                     *
*    This C++ Module is a sample program for the customer to use      *
*    the High Level Language C/C++ API                                *
*                                                                     *
***********************************************************************
*                                                                     *
* Change History                                                      *
*                                                                     *
* $LV=RMMV1R6,1R6,030707 BRB: Created High Level API Interface    @LVA*
*                                                                     *
**********************************************************************/
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <iostream.h>
#include "EDGXHCLU"

FILE* sfiFp;

/****************************************************************
 *  function to print SFI buffer into file                      *
 ****************************************************************/
 void printSFItoFile(RmmInterface::t_outp* outputPtr)
 {
   int outputlen=outputPtr->header.out_used;
   char* p = outputPtr->outputBuffer;
   char  ch;
   int i,len = 0;
   int offset = 0;
   int l = 0;                                                     

   for (l=0; l < outputlen; l++)                                 
   {
     len = (*p * 16) + *(p+1);

     if ( len == 0 ) break;

     fwrite(p,1,len,sfiFp);

     p = p + len;
   }

 }
/**************************************************************
* start main                                                  *
***************************************************************/
int main(int argc, char* argv [])                                
{
  long  rc = 0;
  FILE* xmlFp;
  RmmApi* pApi;
  RmmCommand* pCom;
  char* tsoCommand;
  tsoCommand = argv[1];

/**************************************************************
* get Output File names and open files                        *
***************************************************************/

  if ( (xmlFp = fopen("DD:XMLFILE","w")) == NULL )
  {
     printf("could not open %s\n","DD:XMLFILE");
     exit(0);
  }
  if ( (sfiFp = fopen("DD:SFIFILE","wb,type=record")) == NULL )
  {
     printf("could not open %s\n","DD:SFIFILE");
     exit(0);
  }

/***************************************************************
* create RmmApi object                                         *
****************************************************************/
  pApi = new RmmApi();
  printf(" \nAPI object created \n");

/***************************************************************
* open Api                                                     *
****************************************************************/
  if ( pApi->openApi() == 0 )
    {
     printf("API Return Code : %d\n",pApi->getApiRC());
     printf("API Reason Code : %d\n",pApi->getApiRS());
     printf("API Message     : %s\n",pApi->getMessageText());
    }
  else
    {
     printf("Could not open API \n");
     exit(0);
    }
/***************************************************************
* create RmmCommand object                                     *
****************************************************************/

     pCom = new RmmCommand(pApi);
/*****************************************************************
* processes a TSO command                                        *
*****************************************************************/

   rc = pCom->issueCmd(tsoCommand);

   switch ( rc )
   {
     case 0 :
        printf("Return Code : %d\n",pCom->getApiRC());
        printf("Reason Code : %d\n",pCom->getApiRS());
        printf("Message     : %s\n",pCom->getMessageText());
        printSFItoFile((RmmInterface::t_outp*) pCom->getBufferSfi());
        fprintf(xmlFp,"%s\n",pCom->getBufferXml());
        break;

      case 1 :
        printf("Return Code : %d\n",pCom->getApiRC());
        printf("Reason Code : %d\n",pCom->getApiRS());
        printf("Message     : %s\n",pCom->getMessageText());
        printSFItoFile((RmmInterface::t_outp*) pCom->getBufferSfi());
        fprintf(xmlFp,"%s\n",pCom->getBufferXml());

        while( (pCom->getApiRC()==0) && (pCom->getApiRS()==4) )   
        {
          rc = pCom->getNextEntry();
          printf("Return Code : %d\n",pCom->getApiRC());     
          printf("Reason Code : %d\n",pCom->getApiRS());  
          printf("Message     : %s\n",pCom->getMessageText());   
          printSFItoFile((RmmInterface::t_outp*) pCom->getBufferSfi());
          fprintf(xmlFp,"%s\n",pCom->getBufferXml());
        }
        break;

      case -1:
        printf("Return Code : %d\n",pCom->getApiRC());
        printf("Reason Code : %d\n",pCom->getApiRS());
        printf("Message     : %s\n",pCom->getMessageText());
        break;

      default:
        printf("Return Code : %d\n",pCom->getApiRC());
        printf("Reason Code : %d\n",pCom->getApiRS());
        printf("Message     : %s\n",pCom->getMessageText());
   }

/***************************************************************
* destruction
***************************************************************/
  delete pCom;
  delete pApi;

  fclose(sfiFp);
  fclose(xmlFp);
  exit(0);                                                       
}                            /* end main */

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014