04-29-2004 8:29 AM
I have a syntax question about the command TYPES
I want to define a Type that consists of the complete structure of a database table + two other fields.
What syntax do i have to use for this
04-29-2004 8:42 AM
Two ways. Assume table dbtab has a field called f1.
TYPES:
BEGIN OF MYTYPE,
dbtab TYPE dbtab,
myf1,
myf2,
END OF MYTYPE.
DATA:
myvar TYPE MYTYPE.
...
WRITE: myvar-dbtab-f1, myvar-myf1.
or
TYPES:
BEGIN OF MYTYPE.
INCLUDE STRUCTURE dbtab.
TYPES:
myf1,
myf2,
END OF MYTYPE.
DATA:
myvar TYPE MYTYPE.
...
WRITE: myvar-f1, myvar-f2.
Personally I dislike the syntax of the second since it requires a break in the chaining (that is a second TYPES statement). It is possible that nowadays INCLUDE STRUCTURE xxx should be INCLUDE TYPE xxx - haven't tried for a while but you should get the idea.
It is also clearer (IMO) with the first approach what the data represents, plus you don't have to worry about field-names conflicting - that is, it wouldn't matter if dbtab also had a field called myf1.
Scott
04-29-2004 8:42 AM
Use INCLUDE STRUCTURE and then individually place the other two fields between BEGIN and END in the TYPE definition.
TYPES: BEGIN OF....
INCLUDE STRUCTURE DBNAME.
TYPES: f1 type ..
f2 type ..
END OF ...