banner



How To Create A Structure In Sap

1,910

Structure in SAP ABAP

When you read this word "STRUCTURE", what is the first thing that comes into your mind?  Is it a structure of a building, a structure of a bridge or a structure of a compound or Structure in SAP ABAP?

These are what I found in Microsoft Word Clip Arts. From these images it is clear that structure is something that is not the final product or final output but it is something that helps us to get the final output.

In SAP ABAP or in any other languages, structure is a group of fields grouped under one name. These fields can have different data types and different lengths. These structures can be reused.  These structures can even have a structure as a field called as Nested structure.

Definition

A Structure in SAP ABAP is a part of group TYPES in SE11, which consists components that also, refer to a type.

In simple terms, a structure is a reusable component that contains fields and holds single records at runtime.

Structure in SAP ABAP

Features:

  • A structure is an array of fields.
  • A work area is also a structure which holds single data at runtime and has pre allocated memory in database.
  • When we create a structure using TYPES statement in ABAP report, no memory is allocated in database. It is allocated when we define a work area of type Structure.
  • A Global structure is the one we create using SE11 ABAP Dictionary and a Local Structure is the one we declare in ABAP report using keyword
    TYPES: BEGIN OF XYZ,
    Field1 TYPE c,
    Field2 TYPE c,
    END OF XYZ.
  • The main purpose of Structure is to define the data at screen interface [e.g. ODATA Interface, ABAP GUI Interface & ABAP Module Pool Interface] and type for Interface Parameters of Classes and Function Modules.
  • A structure can also be included in a table.[only Flat Structures]

Types of Structure in SAP ABAP

On the basis of type of fields/components of structure, there are three types of Structure:

  1. Flat Structure in SAP ABAP:

As the name suggests, flat structure are the one that contains fields simply pointing to a Data Element or a predefined data type.

For example, we have four simple fields as shown below:

ABAP flat structure

  1.  Nested Structure in SAP ABAP:

As the name suggests, nested structure are the one that contains at least one field pointing to another structure.

*NOTE: A structure can be nested to any depths.

ABAP Nested Structure

Here we have structure with four fields and the third field is pointing to another structure consisting two fields.

  1. Deep Structure in SAP ABAP:

Deep structures are the one that contains at least one field pointing to table type. Table Type itself points to a structure or a table. That's why these are called deep structures.

ABAP Deep Structure

In above example we can see that Deep structure has a field pointing to a Table Type and the table type itself is pointing to a structure.

*NOTE: We can include only Flat structures in table.

Creation of Structure in SAP ABAP:

#Using ABAP Dictionary

Step 01: Open SE11.

Step 02: Click Data Type Radio Button and select Structure radio button from the given radio buttons.  Give your Structure name starting with Z or Y e.g. "ZBarry_struct".

Step 03: Click Create, Enter explanatory description for structure in Short Description e.g. "Structure for Test".

Step 04: In the components tab, maintain the following:

Fields Value Description
Component It can be 16 digit Alphanumeric word starting with a letter and can contain underscore It is the column name of your table
Key Tick all the fields whose value will be unique and can define the relationship with other tables A structure must contain at least one key field, else it can't be Activated
Initial Value Indicator Tick if the field must have an initial value All key fields must always be given initial values. By default all fields are assigned initial values irrespective of indicator.
Typing Method Choose from the available types: TYPE,LIKE,REF TO It gives you an option to specify whether you are creating a type field, like field or reference field.
Component Type Select your Data Element or create one If you are not using Predefined Type, you need to provide a Data Element
Predefined Type : If you are not using Data Element, click the Predefined Type tab & enter following:
Data Type Any Data type like CHAR,INT According to requirement specify the data type
Length Give max length of your field Length will be dependent upon Data Type
Decimal Places Number of places after decimal point Mainly for Float variables
Short Description Explanatory statement for your field What your field means/doing

Step 05: Under Entry help/check tab maintain the following: It will be maintained automatically after step 04. [You can skip this step]

FIELDS Value Description
Field Same as above Same as above
Data Element Same as above Same as above
Data Type Same as above Same as above
Foreign Keys Foreign Keys for that field It will be reflected after you maintain Foreign Key relationships
Check Table Check Table for Field It will be reflected once you have check table relationship for the field
Origin of input help Input help with fixed values, with check table, search helps, Static Input Help It reflects the way your input will be made to the given field
Srch Help Your Search Help name To attach Search Helps to field
Defaults Any Value depending upon the type of field To assign Default value for the field
Domain Domain of specified Data Element If your Data Element has a Domain, it will reflect here

Step 06: Under Currency/ Quantity Fields tab maintain the following: [You can skip this step]

FIELDS Value Description
Field Same as above Same as above
Data Element Same as above Same as above
Data Type Same as above Same as above
Reference Table Reference Table name If your data element refers to a table
Reference Field Field of Reference table being Referred It is actually the field being referred by the data element
Short Description Same as above Same as above

Step 07:  Append Structure from respective tab. [You can skip this step]

Step 08: Once all the above fields are maintained, save, check for errors and activate your Structure.

How To Create A Structure In Sap

Source: https://gocoding.org/structure-in-sap-abap/

Posted by: frittsfeellen.blogspot.com

0 Response to "How To Create A Structure In Sap"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel