220 pts.
 API to get the GMT date and time in AS400 system
Hi,

I need to get the GMT date and time from the AS400 system.Is their any API available to retrive the GMT date and Time. Please suggest the way to retrive the date and time. Its very urgent.



Software/Hardware used:
ASKED: May 3, 2010  1:05 PM
UPDATED: May 4, 2010  7:58 PM

Answer Wiki:
GMT (UTC) can be retrieved in a variety of ways. I don't have a RPG example handy that I can post, but I have one in ILE CL that uses two different methods. Either method will translate fairly directly to ILE RPG:<pre> pgm dcl &QTIME *char 6 dcl &QDATE *char 6 dcl &QDATETIME *char 20 dcl &QTIMZON *char 10 dcl &QUTCOFFSET *char 5 /* For Convert Date & Time... */ dcl &CDT_I_FORM *char 10 value( '*CURRENT' ) dcl &CDT_I_VAR *char 8 dcl &CDT_O_FORM *char 10 value( '*YYMD' ) dcl &CDT_O_VAR *char 20 dcl &CDT_I_TZ *char 10 value( '*JOB' ) dcl &CDT_O_TZ *char 10 value( '*UTC' ) dcl &CDT_O_TZi *char 111 value( ' ' ) dcl &CDT_O_TZl *int value( 111 ) dcl &CDT_O_Pi *char 1 value( '0' ) /* 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 all for CEE* transformations... */ dcl &RtnDt *int value( 0 ) dcl &RtnVal1 *char 8 dcl &RtnVal *char 15 dcl &PicStr *char 26 value( 'YYYYMMDDHHMISS999999' ) rtvsysval QTIME rtnvar( &QTIME ) rtvsysval QDATE rtnvar( &QDATE ) rtvsysval QDATETIME rtnvar( &QDATETIME ) rtvsysval QTIMZON rtnvar( &QTIMZON ) rtvsysval QUTCOFFSET rtnvar( &QUTCOFFSET ) chgvar &CDT_I_VAR &QTIME call QWCCVTDT ( + &CDT_I_FORM + &CDT_I_VAR + &CDT_O_FORM + &CDT_O_VAR + &ERRCODE + &CDT_I_TZ + &CDT_O_TZ + &CDT_O_TZi + &CDT_O_TZl + &CDT_O_Pi + ) chgvar &ERRLEN %bin( &ERRCODE 5 4 ) callprc CEEUTC ( + &RtnDT + &RtnVal1 + *omit + ) callprc CEEDATM ( + &RtnVal1 + 'Mmm ZD HH:MI:SS' + &RtnVal + *omit + ) dmpclpgm return endpgm</pre> The module does three things -- retrieves basic system values at run-time, CALLs QWCCVTDT to get the *UTC representation of *CURRENT date/time and CALLs CEEUTC to retrieve GMT (UTC) which is then converted to a 'Mmm ZD HH:MI:SS' picture string. The module dumps all variables before returning. From that, you can take your choice of the <a href="http://publib.boulder.ibm.com/infocenter/iseries/v5r4/index.jsp?topic=/apis/qwccvtdt.htm">Convert Date and Time Format (QWCCVTDT) API</a> or the <a href="http://publib.boulder.ibm.com/infocenter/iseries/v5r4/index.jsp?topic=/apis/CEEUTC.htm">Get Universal Time Coordinated (CEEUTC) API</a>, whichever suits you. The module should compile with CRTCLMOD without change on V5R3 or later. Then just use CRTPGM to create the program. Or if you prefer, just compile with CRTBNDCL. The API documentation should tell any details. If they work in CL, RPG should be simple; but questions might arise. Tom
Last Wiki Answer Submitted:  May 3, 2010  10:10 pm  by  TomLiotta   108,135 pts.
All Answer Wiki Contributors:  TomLiotta   108,135 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

Hi,

In V5R3 we dont have these two API’s , so we need to install these APIs.

Please give us the steps to install these two APIs( CEEUTC & CEEDATM).

Thanks,
Amutha

 220 pts.

 

In V5R3 we dont have these two API’s , so we need to install these APIs.

At V5R3, you already have those APIs. You don’t install them — they are part of the system. Documentation for all ILE CEE Date and Time APIs is in the V5R3 Information Center. Other CEE* APIs are given in surrounding topics.

The example program came from a V5R3 system.

You can’t search for them because they’re not program objects — they’re procedures. That’s why the CALLPRC command was used instead of CALL. The system will bind them into your programs automatically.

Tom

 108,135 pts.

 

Hi Tom,

Thanks.
The code was working fine.
CEEUTC & CEEDATM, I had seen that it is Procedure, but you have mentioned it as API.
So I was searching for it in QSYS and QPARMS. So i have raised a query.

Thanks and Regards,
P.Amutha

 220 pts.

 

As the link to the Information Center shows, IBM calls them “APIs”. I’m not aware that an API must be a “program”. An API is simply an interface that is made available to application programs — Application Program Interface.

For some APIs, you need to bind with a system service program. For others, the system binds automatically — these would usually be considered to be “built-ins”. For still others, you make an external program CALL.

Anyway, I hope the example and the documentation link provide what you need.

Tom

 108,135 pts.