Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Task 1 - Create CDS View Entity ( August Developer Challenge )

sheenamk
Developer Advocate
Developer Advocate
29,667

First of all, thanks for the overwhelming response to the ABAP Developer Challenge. Kudos to everyone who took time out of their busy schedule and finished the pre-requisite – Task 0 last week.

Now let us dive right into the challenge.

Task 1 - In this challenge, we will create a custom table and explore the creation of CDS view entity from it. This also includes writing a simple logic to generate data into this table and to replace the existing values in a specific field.

Follow the instructions carefully and share with us the screenshots of the items mentioned in the ‘Validation’ section of this discussion.

Note: As suggested in Task 0 , please ensure that you give a unique ID ( something that can relate to your SAP Community ID ) to all your development objects.

Please use this separate thread to ask your questions and discuss issues.

So, let’s get started:

  1. Create a database table with the following fields:
    1. Client as Key
    2. Travel Id as Key
    3. Description
    4. Total Price
    5. Currency Code
    6. Status
  2. Create an ABAP class which will generate data from the table /dmo/travel  to the newly created database table.
  3. Write a logic in the ABAP class to map the below values to replace the existing value in the ‘Status’ column.
    1. N --> O
    2. P --> O
    3. B --> A
    4. For all other values update --> X
  4. Check the Data Preview of the table. The ‘Status’ column should have the distinct values specified in  Step 3
  5. Create a CDS view entity using ADT with reference to the above created table.
    1. Help Document for CDS View Entitiy
  6. Once the CDS View entity is created, check the fields created. Add the 'Currency Code’ annotation for ‘Total Price’ field. Save, Activate and check the Data Preview.

Validation : Share a screenshot of the following items as a reply to this thread to gain credits:

  1. Data preview of the CDS View Entity
  2. Logic in the ABAP class. In specific, the field ‘Status’ should only have values ( O, A or X ).

Enjoy!!!!

211 REPLIES 211

Ihor_Haranichev
Participant

Kaleshavalli
Discoverer
2,282

Successfully Completed the Task 1 🙂 So Nice Exercise . Thank you.

Kaleshavalli_0-1723387477549.png

Kaleshavalli_0-1723388205041.png

 

Thanks & Regards,

Kalesha.

Momaharshi
Discoverer

RakeshDevani
Explorer
3,064

CDS Preview:

rakeshdevani_0-1723391814453.png

ABAP Class:

rakeshdevani_1-1723391859000.png

And Status Having only values O, A, or X

rakeshdevani_2-1723391911331.png

 

3,062

1. Data Preview of the CDS:

Naveen_srinivasan_0-1723393930495.png

2. Logic in ABAP Class

Naveen_srinivasan_1-1723394055440.png

Best Regards,
Naveen

jonwalnikhilesh
Participant
3,033

Please find below solutionclass.pngCDS.png.

 

RLi2340
Discoverer
3,005

Hello,

Here are my screenshots - 

RLi2340_0-1723436788931.png

RLi2340_1-1723436885811.png

 

styles
Participant
2,974

Eager for more!!!


Class Logic:

styles_1-1723446334397.png

CDS View Entity Preview:

styles_0-1723446278647.png

"Programming is not about what we know, It is about what we can solve"

"Programming is not about what you know, it is about what you can solve"

2,974

Hi please find the attached screen shots below.

CDS view Preview

RahulChowdaryMaganti_0-1723447598356.png

Class logic

RahulChowdaryMaganti_1-1723447679344.png

Thanks & Regards,
Rahul.



p215636
Explorer
2,934

Screen shot 1

p215636_0-1723456835553.png

Screen Shot 2

p215636_1-1723456928512.png

I was going to highlight that given the distribution of values in the base table /DMO/TRAVEL within the ABAP Cloud Trial you wouldn't see any X's was that intentional..

p215636_2-1723457199372.png

 

ivansofronic
Associate
Associate
2,925

CDS view preview

ivansofronic_0-1723463700022.png

Class logic

CLASS zis_cl_travel_copy DEFINITION
  PUBLIC
  FINAL
  CREATE PUBLIC .

  PUBLIC SECTION.
    INTERFACES if_oo_adt_classrun.
  PROTECTED SECTION.
  PRIVATE SECTION.
ENDCLASS.



CLASS zis_cl_travel_copy IMPLEMENTATION.
  METHOD if_oo_adt_classrun~main.
    INSERT zis_travel
        FROM (
            SELECT travel_id,
                   description,
                   total_price,
                   currency_code,
                   CASE
                       WHEN status = 'N' THEN 'O'
                       WHEN status = 'P' THEN 'O'
                       WHEN status = 'B' THEN 'A'
                       ELSE 'X'
                   END
              FROM /dmo/travel ).
  ENDMETHOD.

ENDCLASS.

RazCherishya
Newcomer
2,924

Task1 Completed.

Class logic

RazCherishya_0-1723464043951.png

Data Preview/Output.

RazCherishya_1-1723464096837.png

Distinct Value.

RazCherishya_2-1723464199364.png

 

 

 

Srinath_Mareedu
Discoverer

SUNDHARRAJAN
Discoverer

MatLakaemper
Participant
2,884

Here my Submission:

kind Regards,
Matthias Lakämper

MatLakaemper_0-1723468784406.png

MatLakaemper_1-1723468794016.png

 

 

rohantiwari
Participant

SingireddySunil
Explorer
2,879

Submission of Task - 1:

CDS Preview: -

SingireddySunil_0-1723472107256.png

 

Class : -

SingireddySunil_1-1723471965904.png

 

JerryW
Explorer
2,868

Here is my submission - thanks!

Data preview of the CDS View Entity

JerryW_0-1723472191139.png

Logic in the ABAP class. 

JerryW_1-1723472354134.png

 

 

viveksingh
Discoverer
2,851

Data Preview of CDS View Entity

viveksingh_0-1723474760056.png

 

ABAP Class

viveksingh_1-1723474803308.png

 

ThienPHAM
Participant
2,846

So excited.

ThienPHAM_0-1723475637818.png

CLASS zcl_travel IMPLEMENTATION.

  METHOD if_oo_adt_classrun~main.
    INSERT ztbtravel FROM
  ( SELECT travel_id, 
           description, 
           total_price, 
           currency_code,
  CASE
    WHEN status = 'N' THEN 'O'
    WHEN status = 'P' THEN 'O'
    WHEN status = 'B' THEN 'A'
    ELSE 'X'
    END
  FROM
   /dmo/travel ).
  ENDMETHOD.
ENDCLASS.

maennflo
Discoverer
2,773

Here we go.

A little bit more SE80 style from me.

Class implementation:

maennflo_0-1723498385575.png

Result in CDS view:

maennflo_1-1723498422735.png

 

Harsh_Hunjan
Associate
Associate
2,691

1. CDS Data preview

Harsh_Hunjan_1-1723532442933.png

2. Logic in the ABAP class.

Harsh_Hunjan_0-1723532369034.png

 

J_Eck
Participant
2,655

CDS View Data Preview

J_Eck_0-1723539874762.png

Class

J_Eck_1-1723539896809.png

 

 

Ravindhiran
Discoverer
2,618

Hi,

My Solution:

Ravindhiran_0-1723545188942.pngRavindhiran_1-1723545199389.png

Regards,

Ravindhiran.

 

SROUT
Discoverer
2,597

For task1 challenge
Here is the preview of the CDS view entity data preview

SROUT_0-1723549132496.png

Here is the ABAP class code

SROUT_1-1723549163015.png



rdulek
Explorer
2,565

Please find below screenshot.

rdulek_0-1723552319023.png

 

rdulek_1-1723552332184.png

 

siva1990
Explorer
2,504

Hello Team,

Plea

siva1990_3-1723557221376.png

 

se find the screenshots below,

siva1990_0-1723557132522.png

 

 

Bhumika_K
Associate
Associate
2,501

 Task - 1: Completed, please find my submission below

Class:

Aug_Task-1.1.png

CDS Preview:

Aug_Task-1.2.png

 

Thank You,

Bhumika

 

 

 

Jay_Dalsaniya
Participant
2,400

CDS Data Preview

dls_jay_0-1723568979585.png

ABAP Class to copy data to new table

dls_jay_1-1723569016847.png

 

fahadburney
Explorer
2,349

Completed the First Task 😀

1)Data Preview of Database Table : ZDMO_TRAVEL_DB

fahadburney_0-1723590564157.png

 

2)Class Logic : 2 screenshots : ZCL_GENERATE_DATA_DMOTRAVEL

fahadburney_1-1723590583779.pngfahadburney_2-1723590617863.png

3)Data Preview for CDS View : ZCDS_DMO_TRAVELMFB 

fahadburney_3-1723590655661.png

 

Kartheek
Explorer
2,326

Here it is!!
Data preview of the CDS Entity:

Kartheek_0-1723604424347.png

Generator class:

Kartheek_1-1723604458618.png

 

TwanHunguyen01
Discoverer
2,328

Hi, here is my screenshots:

TwanHunguyen01_0-1723605555665.png

TwanHunguyen01_1-1723605566796.png

If you think there could be improvement in my work, please let me know. Thank you.

EnryIrala
Explorer

bruno_bonatti
Newcomer
2,295

Hello!

Data preview of the CDS View Entity
bruno_bonatti_0-1723609970074.png

Logic in the ABAP class. In specific, the field ‘Status’ should only have values ( O, A or X ).

 

bruno_bonatti_5-1723610252308.png

CDS View Entity
bruno_bonatti_3-1723610181690.png

 

Akshay_Yelekar
Discoverer

Anne009
Discoverer
2,267

Hi, Task 1 Completed.

Preview: With old status vs new status.

Anne009_0-1723618825702.png

Class to update the database table.

Anne009_1-1723618856007.png

 

d_orozco
Discoverer