Sunday, April 20, 2008

How to define Types.

1. Simple type definitions
- TYPES type.
- TYPES type(len).

2. Defining a structured type
- TYPES: BEGIN OF structype
...
END OF structype.

Copy the below coding to test on the program.

Example of executable program.

*&---------------------------------------------------------------------*
*& Report ZFZ0004 *
*& *
*&---------------------------------------------------------------------*
*& *
*& *
*&---------------------------------------------------------------------*
*& Demo structure *
*& by mfbz *
*&---------------------------------------------------------------------*

REPORT ZFZ0004 .

TYPES: BEGIN OF company,
comname(15) TYPE c,
comcode(5) TYPE c,
END OF company.

TYPES: BEGIN OF staff,
title(5) TYPE c,
id TYPE i,
first(10) TYPE c,
last(10) TYPE c,
company TYPE company,
END OF staff.

DATA list TYPE staff.

list-title = 'Mr'.
list-id = 00001.
list-first = 'Abc'.
list-last = 'Xyz'.
list-company-comname = 'Company 1'.
list-company-comcode = 'C0001'.

WRITE list-title.
WRITE list-id.
WRITE list-first.
WRITE list-last.
WRITE list-company-comname.
WRITE list-company-comcode.

No comments: