Following is an example of querying and setting the country code
and getting the date and time format in PL/I.
*PROCESS MACRO;
/*Module/File Name: IBMNLS
/**********************************************************/
/* */
/* Function CEE3CTY : query default country */
/* CEEFMDT : obtain the default date and */
/* time format */
/* CEEDATM : convert seconds to timestamp */
/* */
/* This example shows how to use several of the LE */
/* national language support callable services in a */
/* PL/I program. The current country is queried, saved, */
/* and then changed to Germany. The default date and */
/* time for Germany is obtained. CEEDATM is called to */
/* convert a large numeric value in seconds to the */
/* timestamp 16.05.1988 19:01:01 (May 16, 1988 7:01PM). */
/* */
/**********************************************************/
CESCNLS: PROC OPTIONS(MAIN);
%INCLUDE CEEIBMAW;
%INCLUDE CEEIBMCT;
DCL FUNCTN REAL FIXED BINARY(31,0);
DCL QUERY_COUNTRY REAL FIXED BINARY(31,0) INIT(2);
DCL SET_COUNTRY REAL FIXED BINARY(31,0) INIT(3);
DCL SECONDS REAL FLOAT DECIMAL(16);
DCL COUNTRY CHARACTER ( 2 );
DCL GERMANY CHARACTER ( 2 )INIT ('DE');
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);
DCL TIMESTP CHAR(80);
DCL PICSTR CHAR(80);
DCL PIC_VSTR CHAR(255) VARYING;
/********************************************************/
/* Query country setting */
/********************************************************/
FUNCTN = QUERY_COUNTRY;
CALL CEE3CTY ( FUNCTN, COUNTRY, FC );
IF FBCHECK( FC, CEE000) THEN DO;
/**************************************************/
/* Call CEE3CTY to set country to Germany */
/**************************************************/
FUNCTN = SET_COUNTRY;
COUNTRY = GERMANY;
CALL CEE3CTY ( FUNCTN, COUNTRY, FC );
IF ^ FBCHECK( FC, CEE000) THEN DO;
PUT SKIP LIST('Error ' || FC.MsgNo || ' in setting country');
END;
ELSE DO;
/******************************************************/
/* Call CEEFMDT to get default date/time format for */
/* Germany and verify format against published value. */
/******************************************************/
COUNTRY = ' ';
CALL CEEFMDT ( COUNTRY, PICSTR, FC );
IF ^ FBCHECK( FC, CEE000) THEN DO;
PUT SKIP LIST( 'Error ' || FC.MsgNo
|| ' getting default date/time format for Germany.');
END;
ELSE DO;
/***************************************************/
/* Call CEEDATM to convert the number representing */
/* the number of seconds from October 14, 1582 */
/* 12:00AM to 16 May 1988 7:01PM to character */
/* format. The default date and time format */
/* matches that of the default country, Germany. */
/***************************************************/
SECONDS = 12799191661.986;
PIC_VSTR = PICSTR;
CALL CEEDATM ( SECONDS, PIC_VSTR, TIMESTP, FC );
IF FBCHECK( FC, CEE000) THEN DO;
PUT SKIP EDIT ('Generated timestamp is ',
TIMESTP) (A, A);
END;
ELSE DO;
PUT SKIP LIST ('Error ' || FC.MsgNo
|| ' generating timestamp');
END;
END;
END;
END;
ELSE DO;
PUT SKIP LIST( 'Error ' || FC.MsgNo || ' querying country code');
END;
END CESCNLS;