Application Development Blog Posts
Learn and share on deeper, cross technology development topics such as integration and connectivity, automation, cloud extensibility, developing at scale, and security.
cancel
Showing results for 
Search instead for 
Did you mean: 
chau1995
Active Participant
2,719
With the ECC system in the past, when handling logic to filter the table together, we usually used For all entries - FAE. But, when we use it, we could not be able to utilize power in open SQL (ex Built-in function, order by). Known this disadvantage in the system, SAP has developed alternative solutions (CTE, View, ...), one of the solutions which are a Global Temporary Tables, also known as GTT. So what it is, let's stay tuned!!!

Prerequisites



  • SAP NW AS ABAP 7.52 or higher


Agenda



  1. What is GTT

  2. Handling with GTT

  3. Summary


What is GTT


Global Temporary Tables, called GTT, is a temporary table to store data in the program. In essence, GTT is also a transparent table. But it is slightly different than a transparent table, which means it only stores temporary and will be deleted at the end of the program.

GTT is always empty at the beginning of LUW and will be cleared at the end of LUW, which means data has only existed in the process of running the program.

At the end of the program, you must use statement DELETE <YOUR_GTT_NAME> FROM @dbtab to prevent the run-time error COMMIT_GTT_ERROR.

By using GTT, you will able to be more flexible in the query in Open SQL (easy to use order by, aggregate function, built-in function...) without the same restriction as FAE

Please note that we don't need to create more key fields in GTT, because at this time, the number of key fields is only 15.

Handling with GTT


Create GTT in SE11


Firstly, go to tcode SE11 to create a database table


In Delivery Class, you must choose "L"


At menu ->Extras, select Change Display table Category to change transparent table to GTT


Check option Global temporary table and click OK


After choosing GTT option, you will see text Transparent Table will be changed to Global Temporary T


At tab Fields, create some fields (key or non-key fields) which you want to filter/store data in your program. In this sample, I will create 3 key fields which are Company Code (BUKRS), Fiscal Year(GJAHR), and document number (BELNR).
Please note that Max key fields = 15.



Implement GTT in program


In se38, create a program and write some code the same as the image below. I will use GTT same as table to inner join with another table in the system. In this way, I can use built-in function or some feature in open SQL without any restrictions.

At the end of program, you must delete this GTT, if you don't delete it, your system will be crashed with exception COMMIT_GTT_ERROR


Run program and you will see result



Summary


Through this blog, I hope you will have alternative ways to handle data instead of the traditional ways previously.

Hope this helps!!!
6 Comments
Labels in this area