‎2013 Sep 30 6:00 AM
Hi expert,
I can't understand following syntax for structure t_str_reservationx. why using period for each line of this structure definition? and why use the second 'TYPES' before 'END OF'
TYPES:
BEGIN OF t_mark,
mark TYPE c,
END OF t_mark,
BEGIN OF t_str_reservationx.
INCLUDE STRUCTURE zptb00_hreservat.
INCLUDE TYPE t_mark.
TYPES:
END OF t_str_reservationx.
Many Thanks,
Andy
‎2013 Sep 30 9:02 AM
Hi,
Here there are two structures declared t_mark and t_str_reservationx.
The strucuture t_str_reservationx contain structure CAUFV, is be a standard one.ie declared globally.
The statement INCLUDE STRUCTURE CAUFV will include all the fields of the structure CAUFV in to the structure t_str_reservationx.
INCLUDE STRUCTURE to include standard structure
INCLUDE TYPES to include the local structure.
Using this declaration the structure t_str_reservationx will contain all the fields of the structure CAUFV and the field mark.
Double click on CAUFV to view all the fields in that structure.
TYPES: BEGIN OF ty.
INCLUDE STRUCTURE CAUFV.
TYPES: date TYPE d,
END OF ty.
In the above example I have included a structure. We have to use period in the line above the INCLUDE statement and TYPES below the INCLUDE this is how it is declared.
‎2013 Sep 30 8:28 AM
Hello Bo Zhang.
The code snippet which you had put is shortened form of
TYPES: BEGIN OF T_MARK,
MARK TYPE C.
TYPES: END OF T_MARK.
TYPES: BEGIN OF T_STR_RESERVATIONX.
INCLUDE STRUCTURE CAUFV.
INCLUDE TYPE T_MARK.
TYPES: END OF T_STR_RESERVATIONX.
Regarding the PERIOD part, it is standard ABAP syntax.
Regards.
‎2013 Sep 30 3:01 PM
Hi K.Arun,
for structure t_mark, all statements are all ended with comma, but for structure t_str_reservationx, all statements are all ended with period. why there have such difference?
Many Thanks,
‎2013 Sep 30 8:39 AM
Hi,
normally you can define a type structure by
TYPES: BEGIN OF t1,
field1,
field2,
...
fieldn,
END OF t1.
But if you want to include a type or structure with INCLUDE TYPE or INCLUDE STRUCTURE the line before must be closed by a dot, and that is where 1st TYPES: is ending. The following fields or the end of type structure must complete the TYPES declaration:
TYPES: BEGIN OF t1,
field1,
field2,
...
fieldn."<= closing dot here
INCLUDE STRUCTURE s1. "<= INCLUDE must also be closed by a dot.
TYPES:"<= needed for completion of TYPES structure
field m
...
fieldz,
END OF t1.
Now the TYPES declaration is completed.
Regards,
Klaus
‎2013 Sep 30 8:42 AM
HI,
When you define a structure rec (with DATA
or TYPES
), this statement copies the components of the structured data type
s to the structure rec.
Since, as of Release 3.0, you
can define nested data structures (i.e. structures with sub-structures), INCLUDE
STRUCTURE should no longer be used.
A data definition
DATA: BEGIN OF rec. INCLUDE STRUCTURE s. DATA: END OF rec.is equivalent to
DATA rec LIKE s.You are recommended to use the second formulation.
Even if the
structure rec to be defined contains additional components, instead
of
DATA: BEGIN OF rec, ... INCLUDE STRUCTURE s. DATA: ... END OF rec.you should use
DATA: BEGIN OF rec, ... rec LIKE s, ... END OF rec.so that s can be referenced as a sub-structure of
rec.
Note
Although "INCLUDE STRUCTURE subRec." breaks up the
sub-structure s into its components, the alignment of s
is retained. This means that padding fields may be inserted before the first
and/or before the last component of s in rec.
‎2013 Sep 30 8:46 AM
Hi,
DATA: BEGIN OF rec. INCLUDE STRUCTURE s. DATA rec LIKE s. DATA: BEGIN OF rec, ... DATA: BEGIN OF rec, ...with regards ,
Juneed K Manha
‎2013 Sep 30 8:55 AM
Hi,
In the above syntax you are actually including a structure inside a structure.
Its interesting why you need to know the definition.Its only a syntax to attach a structure to another structure.
Regards,
Alenlee MJ
‎2013 Sep 30 8:56 AM
use of '':' after a statement makes it a chain statement and is used to avoid writing the keyword repeatedly.
e.g :
Normal :
TYPES BEGIN OF ABC.
TYPES X TYPE Y.
TYPES END OF ABC.
Chain :
TYPES : BEGIN OF ABC,
X TYPE Y,
END OF ABC.
Chain is just for programmers ease to avoid writing same keyword again and again. It is interpreted same as normal example given above by the compiler.
Notice the ',' and '.' used. A period '.' marks the end of a chain i.e you need to provide keywords (TYPES in this case ) after it for next statements.
A ',' comma indicates continuation of the chain and that the same keyword has to be used and thus its not needed to be written again.
The second TYPES used with END OF is not needed if the statement is a part of the TYPES chain. But if the previous statement is ended by a period "." then you need to specify the keyword (TYPES) to be used again.
e.g :
TYPES : BEGIN OF ABC ,
INCLUDE STRUCTURE XYZ .
see the above statement is ended by a period so it ends the chain and you will have to use the keyword in next statement, which will make it as
TYPES END OF ABC.
regards,
Ashish Rawat
‎2013 Sep 30 9:02 AM
Hi,
Here there are two structures declared t_mark and t_str_reservationx.
The strucuture t_str_reservationx contain structure CAUFV, is be a standard one.ie declared globally.
The statement INCLUDE STRUCTURE CAUFV will include all the fields of the structure CAUFV in to the structure t_str_reservationx.
INCLUDE STRUCTURE to include standard structure
INCLUDE TYPES to include the local structure.
Using this declaration the structure t_str_reservationx will contain all the fields of the structure CAUFV and the field mark.
Double click on CAUFV to view all the fields in that structure.
TYPES: BEGIN OF ty.
INCLUDE STRUCTURE CAUFV.
TYPES: date TYPE d,
END OF ty.
In the above example I have included a structure. We have to use period in the line above the INCLUDE statement and TYPES below the INCLUDE this is how it is declared.
‎2013 Sep 30 9:02 AM
Hi
In your structure definition you are declaring two structure.
The first one is a normal one.
In the next structure definition "t_str_reservationx" you are including another structure( zptb00_hreservat) which is already defined using data(So using include structure).
And you are including t_mark as include type as the structure is defined as (Types and not data, else you would have used Include structure here too.)
The periods here represents that these structures have been included.It is merely a syntax only.
Regards
‎2013 Sep 30 9:51 AM
HI Bo Zhang,
It has used "Types - Begin Of" statement and shows the definition of struct_type. It is used to create structure type.
Syntax:
TYPES Begin of struct_type.
Types component_1...
Types component_2 type struct_type Boxed.
INCLUDE TYPE ...
INCLUDE STRUCTURE...
TYPES End of struct_type.
It is showing a TYPES statement with the addition of BEGIN OF and must finish with a TYPES statement with the addition END OF.
It can incorporate the following statements within this TYPES statements.
No structured types can be created that do not have at least one component.
Example:
TYPES:
BEGIN OF ty_standard,
class type char20,
rollno type char20,
end of ty_standard.
TYPES BEGIN OF ty_std.
INCLUDE STRUCTURE Zname_118235.
INCLUDE TYPE ty_standard.
TYPES END OF ty_std.
** Zname_118235 is the ABAP data dictionary structure.
For more details please see the link http://help.sap.com/abapdocu_731/en/abaptypes_struc.htm
Hope this will give you some idea.
Regards,
KK