2005 May 05 5:54 AM
REPORT ystructureinclude .
DATA: BEGIN OF t_street,
name(30) TYPE c,
no(4) TYPE c,
END OF t_street.
DATA: BEGIN OF address,
name(30) TYPE c.
INCLUDE STRUCTURE t_street AS str
RENAMING WITH SUFFIX _str.
DATA END OF address.
address-name = 'Ali Khan'.
address-name_str = 'Abduallah Street'.
address-no_str = '131'.
WRITE:
address-name,
address-name_str,
address-no_str.
i am write this report. almost i understand everything in it confusion is that why we use t_street AS str in include statement. means why we use Alias str, and that is not using anywhere. plz help me to sort out this prob.
Thankx
Rai
2005 May 05 6:29 AM
Hi,
As per the documentation for the addition RENAMING WITH SUFFIX,
<b>
You can address the components included in INCLUDE STRUCTURE as a single entity using the group name name1. The behavior is the same as in not using SUFFIX. When the components of the structure t_street are included, the component names are renamed by appending the name name2. <i>This allows you to include structure t_street more than once.</i>
</b>
So if you intend to include the same structure more than once, giving it a suffix will allow you to do so and address it with that suffix. As an example:
DATA: BEGIN OF t_street,
name(30) TYPE c,
no(4) TYPE c,
END OF t_street.
DATA: BEGIN OF address,
name(30) TYPE c.
INCLUDE STRUCTURE t_street AS homestr
RENAMING WITH SUFFIX _homestr.
INCLUDE STRUCTURE t_street AS offstr
RENAMING WITH SUFFIX _offstr.
DATA END OF address.
Regards
Message was edited by: Shehryar Khan
2005 May 05 6:25 AM
Hi Rai,
You are only considering a part of the entire statement
INCLUDE STRUCTURE t_street AS str RENAMING WITH SUFFIX _str.
.
What it means is that you are including components of the structure <b>t_street</b> (name,no) into the structure <b>address</b>, but are also saying that the added comnponents should only be addressable by suffixing them with <b>_str</b>.
That is the reason you are able to specify <b>address-name_str</b> in your program. If you did not use the suffix in this case, then your structure address will ahve two fields with the component <b>name</b> and you will get a syntax error.
Also, specifying the AS addition will allow you to access all the components of the included structure directly using the alias.
Hope that is clear. Please get back if it isn't.
Regards,
Anand Mandalika.
2005 May 05 6:29 AM
Hi,
As per the documentation for the addition RENAMING WITH SUFFIX,
<b>
You can address the components included in INCLUDE STRUCTURE as a single entity using the group name name1. The behavior is the same as in not using SUFFIX. When the components of the structure t_street are included, the component names are renamed by appending the name name2. <i>This allows you to include structure t_street more than once.</i>
</b>
So if you intend to include the same structure more than once, giving it a suffix will allow you to do so and address it with that suffix. As an example:
DATA: BEGIN OF t_street,
name(30) TYPE c,
no(4) TYPE c,
END OF t_street.
DATA: BEGIN OF address,
name(30) TYPE c.
INCLUDE STRUCTURE t_street AS homestr
RENAMING WITH SUFFIX _homestr.
INCLUDE STRUCTURE t_street AS offstr
RENAMING WITH SUFFIX _offstr.
DATA END OF address.
Regards
Message was edited by: Shehryar Khan
2005 May 05 6:42 AM
REPORT ystructureinclude .
DATA: BEGIN OF t_street,
name(30) TYPE c,
no(4) TYPE c,
END OF t_street.
DATA: BEGIN OF address,
name(30) TYPE c.
INCLUDE STRUCTURE t_street AS street
RENAMING WITH SUFFIX _str.
DATA END OF address.
address-name = 'Ali Khan'.
address-name_str = 'Abduallah Street'.
address-no_str = '131'.
WRITE:
address-name,
address-name_str,
address-no_str.
i know that if you include a structure in another structure and there are some object with the same name then we use renaming with suffix, confusion is in
INCLUDE STRUCTURE t_street AS street
RENAMING WITH SUFFIX _str.
now in this situation suffix is _str
and alias is different but working what is the relationship between suffix and alias.
we are using suffix _str but not using alias street.
Thanks for replay
Rai Zeeshan
2005 May 05 6:44 AM
Dear
Thanks for replay plz try to understand my question. relation ship between alias and suffix
REPORT ystructureinclude .
DATA: BEGIN OF t_street,
name(30) TYPE c,
no(4) TYPE c,
END OF t_street.
DATA: BEGIN OF address,
name(30) TYPE c.
INCLUDE STRUCTURE t_street AS street
RENAMING WITH SUFFIX _str.
DATA END OF address.
address-name = 'Ali Khan'.
address-name_str = 'Abduallah Street'.
address-no_str = '131'.
WRITE:
address-name,
address-name_str,
address-no_str.
i know that if you include a structure in another structure and there are some object with the same name then we use renaming with suffix, confusion is in
INCLUDE STRUCTURE t_street AS street
RENAMING WITH SUFFIX _str.
now in this situation suffix is _str
and alias is different but working what is the relationship between suffix and alias.
we are using suffix _str but not using alias street.
Thanks for replay
Rai Zeeshan
2005 May 05 6:52 AM
Hi Rai,
You have not used the alias in your example program. But that does not mean that it cannot be used. consider the following code:
DATA: BEGIN OF t_street,
name1(30) TYPE c,
no(4) TYPE c,
END OF t_street.
DATA: BEGIN OF address,
name(30) TYPE c.
INCLUDE STRUCTURE t_street AS str.
DATA: END OF address.
address-name = 'Ali Khan'.
address-name1 = 'Abdullah'.
address-no = '123'.
WRITE: address-name,
/ address-str.
And the following code uses the suffix -
DATA: BEGIN OF t_street,
name(30) TYPE c,
no(4) TYPE c,
END OF t_street.
DATA: BEGIN OF address,
name(30) TYPE c.
INCLUDE STRUCTURE t_street AS str RENAMING WITH SUFFIX _str.
DATA: END OF address.
address-name = 'Ali Khan'.
address-name_str = 'Abdullah'.
address-no_str = '123'.
WRITE: address-name,
/ address-str.
Is that clear now ? It is just a matter of flexibility.
Regards,
Anand Mandalika.
2005 May 05 6:52 AM
Dear Zeeshan,
As Anand already mentioned, specifying a group name with addition AS <name>, STREET in your case, allows you to address the complete structure in one go rather than explicitly addressing each element as in the case of address-name_str, and address-no_str. You could simply have written WRITE:/ address-name, address-street and the output will be the same.
The SUFFIX addition allows you to include the same structure more than once.
Regards