Using basic callable services

If you plan to use a Language Environment callable service, you must code a call to the service in your source code, then recompile your source under the latest Language Environment-conforming version of the language you are writing in. The standard call to a Language Environment service is different in each language, but does not differ across operating systems.

The following examples illustrate how the CEEFMDT callable service is called in C, C++, PL/I, and COBOL. CEEFMDT sets the default date and time formats for a specified country. In the examples, country is a 2-character fixed-length string representing a Language Environment-defined country code. Picture string (pic_str or PICSTR) is a character string, containing the default date and time for the country, that is returned by CEEFMDT. A feedback code (fc) returned from the service is checked to determine if the service completed correctly.

Figure 1. z/OS XL C/C++ routine with a call to CEEFMDT
/*Module/File Name:  EDCSTRT  */
/****************************************************************/
/*                                                              */
/*  Function:  CEEFMDT - Obtain default date and time format    */
/*                                                              */
/****************************************************************/

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <leawi.h>
#include <ceeedcct.h>

int main(void) {

   _FEEDBACK fc;
   _CHAR2 country;
   _CHAR80 date_pic;

   /* get the default date and time format for Canada */
   memcpy(country,"CA",2);
   CEEFMDT(country,date_pic,&fc);
   if ( _FBCHECK ( fc , CEE000 ) != 0 ) {
      printf("CEEFMDT failed with message number %d\n",
             fc.tok_msgno);
      exit(2999);
   }
   /* print out the default date and time format */
   printf("%.80s\n",date_pic);
}
Figure 2. COBOL program with a call to CEEFMDT
CBL LIB,QUOTE
      *Module/File Name: IGZTSTRT
      *************************************************
      **                                             **
      ** CBLFMDT - Call CEEFMDT to obtain default    **
      **           date & time format                **
      **                                             **
      *************************************************
       IDENTIFICATION DIVISION.
       PROGRAM-ID. CBLFMDT.

       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  COUNTRY                 PIC X(2).
       01  PICSTR                  PIC X(80).
       01  FC.
           02  Condition-Token-Value.
           COPY  CEEIGZCT.
               03  Case-1-Condition-ID.
                   04  Severity    PIC S9(4) BINARY.
                   04  Msg-No      PIC S9(4) BINARY.
               03  Case-2-Condition-ID
                         REDEFINES Case-1-Condition-ID.
                   04  Class-Code  PIC S9(4) BINARY.
                   04  Cause-Code  PIC S9(4) BINARY.
               03  Case-Sev-Ctl    PIC X.
               03  Facility-ID     PIC XXX.
           02  I-S-Info            PIC S9(9) BINARY.

       PROCEDURE DIVISION.
       PARA-CBLFMDT.
      **************************************************
      ** Specify country code for the US              **
      **************************************************
           MOVE "US" TO COUNTRY.
      **************************************************
      ** Call CEEFMDT to return the default date and  **
      **     time format for the US                   **
      **************************************************
           CALL "CEEFMDT" USING COUNTRY, PICSTR, FC.

      **************************************************
      ** If CEEFMDT runs successfully, display result.**
      **************************************************
           IF CEE000 of FC THEN
               DISPLAY "The default date and time "
                   "format for the US is: " PICSTR
           ELSE
               DISPLAY "CEEFMDT failed with msg "
                   Msg-No of FC UPON CONSOLE
               STOP RUN
           END-IF.

           GOBACK.
Figure 3. PL/I routine with a call to CEEFMDT
*PROCESS MACRO;
 /*Module/File Name: IBMSTRT
 /********************************************/
 /**                                        **/
 /** Function: CEEFMDT - obtain default     **/
 /**                     date & time format **/
 /**                                        **/
 /********************************************/

 PLIFMDT: PROC OPTIONS(MAIN);

    %INCLUDE  CEEIBMAW;
    %INCLUDE  CEEIBMCT;

    DCL COUNTRY CHARACTER ( 2 );
    DCL PICSTR  CHAR(80);
    DCL 01 FC,                      /* Feedback token */
           03 MsgSev    REAL FIXED BINARY(15,0),
           03 MsgNo     REAL FIXED BINARY(15,0),
           03 Flags,
              05 Case      BIT(2),
              05 Severity  BIT(3),
              05 Control   BIT(3),
           03 FacID     CHAR(3),    /* Facility ID */
           03 ISI                   /* Instance-Specific Information */
                        REAL FIXED BINARY(31,0);

    COUNTRY = 'US'; /* Specify country code for     */
                    /* the United States            */

    /* Call CEEFMDT to get default date format      */
    /*    for the US                                */
    CALL CEEFMDT ( COUNTRY , PICSTR , FC );

    /* Print default date format for the US         */
    IF  FBCHECK( FC, CEE000)  THEN  DO;
       PUT SKIP LIST( 'The default date and time '
          || 'format for the US is ' || PICSTR );
       END;
    ELSE  DO;
       DISPLAY( 'CEEFMDT failed with msg '
          || FC.MsgNo );
       STOP;
       END;


 END PLIFMDT;

See z/OS Language Environment Programming Reference for detailed instructions on how to call Language Environment services and for more information about the CEEFMDT callable service.