
2 | Working with Objects 
CALL METHOD gr_date->set_date 
EXPORTING 
im_month - '9' 
im_day - '13' 
1m_year - '2009*. 
* Display the date in shorthand format (e.g. mm/dd/yyyy): 
gv_display - gr_date->display_short_format( ). 
WRITE: / 'Date in shorthand format:'. gv_display. 
* Display the date in longhand format: 
gv_display - gr_date->display_long_format( ). 
WRITE: / 'Date in longhand format:'. gv_display. 
Listing 2.22 Program YDATE_DEMO 
As you can see in Listing 2.22, program VDATE_OEMO creates an instance of class 
lcl_date, initializes the date value, and displays the date in a couple of different 
formats. The output of this program is shown in Figure 2.10. 
Test Driver Program to Demonstrate the Use of Local Classes] 
Tost Cri¥«r Progra* to Dwonttrat* tha U*a of local Clatsot 
5ate in shorthand foraat 99/13/2009 
>at« in longhand TorMt Sunday. S«9tMMr 13. 2009 
Figure 2.10 Output of Example Program YDATE_DEMO 
For demonstration purposes, the definition of class lcl_date is included inside 
the main executable program shown in Listing 2.22. In a real-world scenario, you 
would probably create an include program to define the local class just as you 
would normally do for other type declarations. You should do this partly because 
to avoid clutter in the main program, but the primary benefit comes from an 
increased opportunity for reuse. Local classes are only visible in the context in 
which they arc defined. Therefore, if you define a local class in an include pro-
gram, then that class can be included in other executable programs, module 
pools, and so on. So, if you want to work with local classes in your programs, it 
is highly recommended that you define them in a separate include program. Of 
course, normally you should to define such classes as global Repositoiy objects. 
You will see how to do that in the following section 2.4, Getting Started with the 
Class Builder. 
70