Handling IBM i system date formats with CL programs in WebSphere Adapters for IBM i

This article describes how the Command Language (CL) programs that are part of samples provided with IBM® WebSphere® Adapters for IBM i are manipulated now to support various date formats, such as YMD, MDY, DMY, and JUL. Also, this article describes how to change the date format in all CL programs dealing with system dates on an IBM i system.

Aparna Srinivasan (apasrini@in.ibm.com), Software Engineer, IBM

Photo of Aparna SrinivasanAparna Srinivasan is a test specialist working in the IBM WebSphere Cast Iron and Adapters QA team. She has around one and half years of experience working with various technologies such as Java and IBM Rational Functional Tester (RFT).



Deepika Udayagiri (deepika.udayagiri@in.ibm.com), Software Engineer, IBM

Photo of Deepika UdayagiriDeepika Udayagiri is working on the development and customer support for IBM WebSphere Cast Iron and Adapters. She has 4 years of experience working with various Java technologies, such as JCA.



Nagarjuna Surabathina (nasuraba@in.ibm.com), Software Engineer, IBM

Photo of   Nagarjuna SurabathinaNagarjuna Surabathina is a Software Developer with 3 years of experience working with the WebSphere Adapters team at the IBM Software Lab in Bangalore, India. His expertise includes Java, J2EE, and web technologies. He received his Master's degree in Computer Engineering from NIT, Warangal, India.



31 July 2013

Introduction

IBM WebSphere Adapters for IBM i are prebuilt software integration components compliant with Java™ Connector Architecture 1.5 (JCA). The IBM i adapter provides bi-directional connectivity between enterprise information system (EIS) and business applications through configuration only (without any coding approach) and can run on multiple application runtimes, such as IBM Process Center, IBM Process Server or IBM WebSphere Enterprise Service Bus (WebSphere ESB).

Using an inbound operation on the IBM i adapter, you can receive messages from a data queue present in the IBM i system. Two CL programs (I5INBOUND.clle and I5ARCHFAIL.clle) shipped as part of the samples with WebSphere Adapters for IBM i. These CL programs can now support the various date formats such as YMD, MDY, DMY, and JUL.

Objectives

This article explains:

  • Inbound configuration for IBM i adapters
  • Supported date formats of the previous version of CL programs
  • Changes in the CL program to support different date formats

Prerequisites

Prior knowledge on the IBM i adapter and basic knowledge of the IBM i enterprise information system is recommended for this article.

System requirements

  • IBM Integration Designer V7.5.0.0 (formerly called WebSphere Integration Developer)
  • WebSphere Adapter Version 7.5.0.0 with IBM i Adapter
  • IBM Business Process Manager V7.5.0.0
  • IBM i Enterprise Information System of V7R1 version

Inbound configuration for the IBM i adapter

Using inbound operation on an IBM i adapter, you can receive messages from a source data queue (can be simple or keyed data queue) present in the IBM i system. The IBM i adapter uses a staging data queue (a keyed data queue with a fixed key length of 18) and CL programs (provided as samples with adapter) for inbound processing. The CL programs transfer inbound events from the source queue to the staging queue to support persistence and assured event delivery. The events will be stored in the staging queue in the same order in which they are placed in the source queue.

The enterprise metadata discovery tooling is used to discover the business objects corresponding to the IBM i system (in this case, data queues). In this process, you need to provide information about the location of:

  • Staging data queue
  • Failed events data queue
  • Compiled CL programs

Note: You can find more information about the staging queue and failed events queue in the adapter documentation (available in the References section).

Figure 1 shows how to configure the above specified properties in the enterprise metadata discovery.

Figure 1: Inbound configuration
Figure 1: Inbound configuration

Supported date formats of the previous version of CL programs

Until IBM i adapter version 7.5.0.3, the CL programs were designed to work with the MDY date format of IBM i systems only. When the date format on the IBM i system were changed, the CL programs supplied with the samples had to be updated and compiled accordingly and had to be used, which was a tedious process.

The Julian date format is commonly used in astronomy, which is a serial date system starting from a reference.

The CL programs have been hard-coded in such a way that the date format has to be only in the MDY format. Users need to either change their IBM i system date format or change the hard-coded date format supported by CL programs to match with the IBM i system date format and compile it before running the CL programs.


Changes in the CL program to support different date formats

You can update these CL programs and can enable them to support any type of date format (irrespective of the date format of the IBM i system) as shown below.

YMD, MDY, DMY and JUL are the four date formats supported by the IBM i system. The first three date formats (YMD, MDY and DMY) represent the date with six digits and JUL represents the date with five digits. Two additional variables are added for this change. one with six characters and one with five characters.

                DCL VAR(&DATE) TYPE(*CHAR) LEN(6)
                DCL VAR(&JDATE) TYPE(*CHAR) LEN(5)

The date format of the IBM i system is retrieved by using the following command.

RTVSYSVAL SYSVAL(QDATFMT) RTNVAR(&DATFMT)

If the application requires the date in the YMD format, then the date format can be retrieved from the IBM i system and then converted to the YMD date format using the following commands:

                /* CONVERT DATE FORMAT FROM JUL TO YMD */
                if (&DATFMT='JUL') THEN(DO)
                RTVSYSVAL SYSVAL(QDATE) RTNVAR(&JDATE)
                CVTDAT DATE(&JDATE) TOVAR(&CVTDATE) FROMFMT(*JUL) TOFMT(*YMD) +
                TOSEP(*NONE)
                GOTO CMDLBL(CONTINUE)
                ENDDO
                /* CONVERT DATE FORMAT FROM non-JUL TO YMD */
                RTVSYSVAL SYSVAL(QDATE) RTNVAR(&DATE)
                CVTDAT DATE(&DATE) TOVAR(&CVTDATE) FROMFMT(*SYSVAL) TOFMT(*YMD) +
                TOSEP(*NONE)

Now, CVTDATE will have the date format as YMD.

The above code snippets can be used to convert any of the IBM i system date formats to the YMD date format in the CL program.

Note: In case your application requires the non-YMD date format, in the TOFMT(*FMT) field, replace FMT with the required date format.


Conclusion

In this article, you learned how to update the CL programs to support various date formats, irrespective of the date format of the IBM i system.


References


Acknowledgements

The authors would like to thank Raja Sreenivasan for reviewing and providing valuable suggestions for this article.

Comments

developerWorks: Sign in

Required fields are indicated with an asterisk (*).


Need an IBM ID?
Forgot your IBM ID?


Forgot your password?
Change your password

By clicking Submit, you agree to the developerWorks terms of use.

 


The first time you sign into developerWorks, a profile is created for you. Information in your profile (your name, country/region, and company name) is displayed to the public and will accompany any content you post, unless you opt to hide your company name. You may update your IBM account at any time.

All information submitted is secure.

Choose your display name



The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerWorks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

Required fields are indicated with an asterisk (*).

(Must be between 3 – 31 characters.)

By clicking Submit, you agree to the developerWorks terms of use.

 


All information submitted is secure.

Dig deeper into IBM i on developerWorks


static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=IBM i
ArticleID=939328
ArticleTitle=Handling IBM i system date formats with CL programs in WebSphere Adapters for IBM i
publish-date=07312013