Thursday 25 April 2013

Include a structure more than once in a database table


Include a structure more than once in a database table

By Rajesh K Sahu
Prerequisite: User should know how to create a table and a structure.  
Scenario: We are trying to include the same structure more than once in a table.  
Use: This may be useful in certain scenario like if we need to maintain Temporary and Permanent address in table. For this, we will define all address related fields in a structure and will include this structure twice in table.  
Steps:  
1)     Go to tcode SE11, create a table as per requirement. In our case, table is  ZTESTTABLE where we will include the structure.  
2)     Again, using the same tcode, create a structure as per requirement. In our case, structure is ZADDRESS_TEST that contains the fields related to address.  
3) Now, include the structure created. Here we have included structure ZADDRESS_TEST into table ZTESTTABLE.  

4) After the structure is included, all fields of structure is listed into table. Here we can see all the address fields in table ZTESTTABLE.  
 
5) Now, we want to include the same structure again in the same table. So, to avoid the duplicity, assign a suitable group against that structure as described below.  
 
6) Double click on group GR1, it will ask for a suffix to add. Add a suffix in ‘Name suffix’. Once suffix added, Save and activate the table.
In our case, we have added suffix P as below:  
 
7) Now, our job is done. We can see that same structure ZADDRESS_TEST is added twice on table ZTESTTABLE with having suffix as ‘P’ against each fields.  
 
So, in this way we can include the same structure more than once in a table as per our requirement.

No comments:

Post a Comment