Preparing for Abap in the Cloud, Installation Eclipse ADT and Setting for SAP BTP
@EndUserText.label : 'General Student Data'
@AbapCatalog.enhancement.category : #NOT_EXTENSIBLE
@AbapCatalog.tableCategory : #TRANSPARENT
@AbapCatalog.deliveryClass : #A
@AbapCatalog.dataMaintenance : #RESTRICTED
define table zui_students {
key client : abap.clnt not null;
key student_num : abap.int1 not null;
key lesson_num : abap.int1 not null;
lesson_point : abap.int1;
lesson_score : abap.char(1);
}
@EndUserText.label : 'General Lesson Data'
@AbapCatalog.enhancement.category : #NOT_EXTENSIBLE
@AbapCatalog.tableCategory : #TRANSPARENT
@AbapCatalog.deliveryClass : #A
@AbapCatalog.dataMaintenance : #RESTRICTED
define table zui_lessons {
key client : abap.clnt not null;
key lesson_num : abap.int1 not null;
lesson_name : abap.char(40);
effect : abap.char(1);
fields : abap.char(20);
}
@EndUserText.label : 'Student Names and Surnames'
@AbapCatalog.enhancement.category : #NOT_EXTENSIBLE
@AbapCatalog.tableCategory : #TRANSPARENT
@AbapCatalog.deliveryClass : #A
@AbapCatalog.dataMaintenance : #RESTRICTED
define table zui_student_name {
key client : abap.clnt not null;
key student_num : abap.int1 not null;
student_name : abap.char(40);
student_surname : abap.char(40);
}
CLASS zui_fill_tables DEFINITION
PUBLIC
FINAL
CREATE PUBLIC .
PUBLIC SECTION.
INTERFACES if_oo_adt_classrun.
PROTECTED SECTION.
PRIVATE SECTION.
ENDCLASS.
CLASS zui_fill_tables IMPLEMENTATION.
METHOD if_oo_adt_classrun~main.
* Clear Database Tables
DELETE FROM zui_students.
DELETE FROM zui_lessons.
DELETE FROM zui_student_name.
"Table and Structure Def.
DATA: ls_students TYPE zui_students,
lt_students TYPE TABLE OF zui_students,
ls_lessons TYPE zui_lessons,
lt_lessons TYPE TABLE OF zui_lessons,
ls_names TYPE zui_student_name,
lt_names TYPE TABLE OF zui_student_name.
"Append internal table for Lessons
ls_lessons-lesson_num = 100.
ls_lessons-lesson_name = 'Calculus'.
ls_lessons-effect = '4'.
ls_lessons-fields = 'MATHS'.
APPEND ls_lessons TO lt_lessons.
CLEAR ls_lessons.
ls_lessons-lesson_num = 101.
ls_lessons-lesson_name = 'Algorithm'.
ls_lessons-effect = '5'.
ls_lessons-fields = 'CS'.
APPEND ls_lessons TO lt_lessons.
CLEAR ls_lessons.
ls_lessons-lesson_num = 102.
ls_lessons-lesson_name = 'Electronics'.
ls_lessons-effect = '3'.
ls_lessons-fields = 'Physics'.
APPEND ls_lessons TO lt_lessons.
CLEAR ls_lessons.
"fill dbtable
INSERT zui_lessons FROM TABLE @lt_lessons .
COMMIT WORK AND WAIT.
"Append internal table for Students
ls_students-student_num = 200.
ls_students-lesson_num = 100.
ls_students-lesson_point = 80.
ls_students-lesson_score = 'A'.
APPEND ls_students TO lt_students.
CLEAR ls_students.
ls_students-student_num = 200.
ls_students-lesson_num = 101.
ls_students-lesson_point = 60.
ls_students-lesson_score = 'C'.
APPEND ls_students TO lt_students.
CLEAR ls_students.
ls_students-student_num = 200.
ls_students-lesson_num = 102.
ls_students-lesson_point = 40.
ls_students-lesson_score = 'D'.
APPEND ls_students TO lt_students.
CLEAR ls_students.
ls_students-student_num = 201.
ls_students-lesson_num = 100.
ls_students-lesson_point = 60.
ls_students-lesson_score = 'C'.
APPEND ls_students TO lt_students.
CLEAR ls_students.
ls_students-student_num = 201.
ls_students-lesson_num = 101.
ls_students-lesson_point = 70.
ls_students-lesson_score = 'B'.
APPEND ls_students TO lt_students.
CLEAR ls_students.
ls_students-student_num = 201.
ls_students-lesson_num = 102.
ls_students-lesson_point = 90.
ls_students-lesson_score = 'A'.
APPEND ls_students TO lt_students.
CLEAR ls_students.
ls_students-student_num = 202.
ls_students-lesson_num = 100.
ls_students-lesson_point = 30.
ls_students-lesson_score = 'F'.
APPEND ls_students TO lt_students.
CLEAR ls_students.
ls_students-student_num = 202.
ls_students-lesson_num = 101.
ls_students-lesson_point = 60.
ls_students-lesson_score = 'C'.
APPEND ls_students TO lt_students.
CLEAR ls_students.
ls_students-student_num = 202.
ls_students-lesson_num = 102.
ls_students-lesson_point = 80.
ls_students-lesson_score = 'A'.
APPEND ls_students TO lt_students.
CLEAR ls_students.
"fill dbtable
INSERT zui_students FROM TABLE @lt_students .
COMMIT WORK AND WAIT.
""Append internal table for Student Names
ls_names-student_num = 200.
ls_names-student_name = 'John'.
ls_names-student_surname = 'Lennon'.
APPEND ls_names TO lt_names.
CLEAR ls_names.
ls_names-student_num = 201.
ls_names-student_name = 'Freddie'.
ls_names-student_surname = 'Mercury'.
APPEND ls_names TO lt_names.
CLEAR ls_names.
ls_names-student_num = 202.
ls_names-student_name = 'David'.
ls_names-student_surname = 'Bowie'.
APPEND ls_names TO lt_names.
CLEAR ls_names.
"fill dbtable
INSERT zui_student_name FROM TABLE @lt_names.
COMMIT WORK AND WAIT.
out->write( 'All Datas are inserted' ).
ENDMETHOD.
ENDCLASS.
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'Student General Data Def.'
define root view entity zui_students_def
as select from zui_students as students
association [0..*] to zui_lessons as _lessons on $projection.lesson_num = _lessons.lesson_num
association [0..*] to zui_student_name as _sname on $projection.student_num = _sname.student_num
{
key student_num,
key lesson_num,
_lessons.lesson_name,
lesson_point,
lesson_score,
_lessons.effect,
@Semantics.name.givenName
_sname.student_name,
@Semantics.name.familyName
_sname.student_surname
}
@EndUserText.label: 'Students Projection View'
@AccessControl.authorizationCheck: #CHECK
@Search.searchable: true
@Metadata.allowExtensions: true
define root view entity ZC_UI_STUDENTS
as projection on zui_students_def as Student
{
key student_num,
key lesson_num,
lesson_name,
lesson_point,
@Search.defaultSearchElement: true
lesson_score,
effect,
student_name,
student_surname
}
@Metadata.layer: #CORE
@UI : { headerInfo : { typeName: 'Student',
typeNamePlural: 'Informations of Students',
title : { type: #STANDARD , label: 'Student Data', value: 'student_num' } } ,
presentationVariant: [{ sortOrder: [{ by: 'student_num', direction: #DESC }] }]}
annotate view ZC_UI_STUDENTS with
{
@UI.facet: [ { id: 'student_num',
purpose: #STANDARD,
type: #IDENTIFICATION_REFERENCE,
label: 'Student-Num',
position: 10 } ]
@UI:{ identification: [{ position: 1, label: 'Student Number' }] }
student_num;
@UI: { lineItem: [ { position: 10 } ],
identification: [ { position: 10 } ],
selectionField: [ { position: 10 } ] }
lesson_num;
@UI: { lineItem: [ { position: 20 } ],
identification: [ { position: 20 } ],
selectionField: [ { position: 20 } ] }
lesson_name;
@UI: { lineItem: [ { position: 30 } ],
identification: [ { position: 30 } ],
selectionField: [ { position: 30 } ] }
lesson_point;
@UI: { lineItem: [ { position: 40 } ],
identification: [ { position: 40 } ],
selectionField: [ { position: 40 } ] }
lesson_score;
@UI: { lineItem: [ { position: 50 } ],
identification: [ { position: 50 } ],
selectionField: [ { position: 50 } ] }
effect;
@UI: { lineItem: [ { position: 60 } ],
identification: [ { position: 60 } ],
selectionField: [ { position: 60 } ] }
student_name;
@UI: { lineItem: [ { position: 70 } ],
identification: [ { position: 70 } ],
selectionField: [ { position: 70 } ] }
student_surname;
}
You can follow me, if you liked the blog and stay tuned about the SAP ABAP
Best Regards,
Uğur İlhan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
11 | |
9 | |
8 | |
6 | |
5 | |
4 | |
4 | |
4 | |
4 | |
3 |