Application Development and Automation 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: 
Read only

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

sheenamk
Developer Advocate
Developer Advocate
61,150

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!!!!

212 REPLIES 212
Read only

stickman_0x00
Participant
Read only

Ihor_Haranichev
Participant
Read only

Kaleshavalli
Discoverer
6,067

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

Kaleshavalli_0-1723387477549.png

Kaleshavalli_0-1723388205041.png

 

Thanks & Regards,

Kalesha.

Read only

Momaharshi
Discoverer
Read only

RakeshDevani
Explorer
6,849

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

 

Read only

6,847

1. Data Preview of the CDS:

Naveen_srinivasan_0-1723393930495.png

2. Logic in ABAP Class

Naveen_srinivasan_1-1723394055440.png

Best Regards,
Naveen

Read only

jonwalnikhilesh
Participant
Read only

RLi2340
Discoverer
6,790

Hello,

Here are my screenshots - 

RLi2340_0-1723436788931.png

RLi2340_1-1723436885811.png

 

Read only

styles
Participant
6,759

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"
Read only

6,759

Hi please find the attached screen shots below.

CDS view Preview

RahulChowdaryMaganti_0-1723447598356.png

Class logic

RahulChowdaryMaganti_1-1723447679344.png

Thanks & Regards,
Rahul.



Read only

p215636
Explorer
6,719

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

 

Read only

ivansofronic
Associate
Associate
6,710

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.
Read only

RazCherishya
Newcomer
6,708

Task1 Completed.

Class logic

RazCherishya_0-1723464043951.png

Data Preview/Output.

RazCherishya_1-1723464096837.png

Distinct Value.

RazCherishya_2-1723464199364.png

 

 

 

Read only

Srinath_Mareedu
Discoverer
Read only

SUNDHARRAJAN
Discoverer
Read only

MatLakaemper
Participant
6,669

Here my Submission:

kind Regards,
Matthias Lakämper

MatLakaemper_0-1723468784406.png

MatLakaemper_1-1723468794016.png

 

 

Read only

Laco
Explorer
Read only

rohantiwari
Participant
Read only

SingireddySunil
Explorer
6,664

Submission of Task - 1:

CDS Preview: -

SingireddySunil_0-1723472107256.png

 

Class : -

SingireddySunil_1-1723471965904.png

 

Read only

JerryW
Explorer
6,653

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

 

 

Read only

viveksingh
Discoverer
6,636

Data Preview of CDS View Entity

viveksingh_0-1723474760056.png

 

ABAP Class

viveksingh_1-1723474803308.png

 

Read only

ThienPHAM
Participant
6,631

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.
Read only

maennflo
Discoverer
6,558

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

 

Read only

Harsh_Hunjan
Product and Topic Expert
Product and Topic Expert
6,476

1. CDS Data preview

Harsh_Hunjan_1-1723532442933.png

2. Logic in the ABAP class.

Harsh_Hunjan_0-1723532369034.png

 

Read only

J_Eck
Participant
Read only

Ravindhiran75
Discoverer
6,403

Hi,

My Solution:

Ravindhiran_0-1723545188942.pngRavindhiran_1-1723545199389.png

Regards,

Ravindhiran.

 

Read only

SROUT
Discoverer
6,382

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



Read only

rdulek
Explorer
6,350

Please find below screenshot.

rdulek_0-1723552319023.png

 

rdulek_1-1723552332184.png

 

Read only

siva1990
Explorer
6,289

Hello Team,

Plea

siva1990_3-1723557221376.png

 

se find the screenshots below,

siva1990_0-1723557132522.png

 

 

Read only

Bhumika_K
Associate
Associate
6,286

 Task - 1: Completed, please find my submission below

Class:

Aug_Task-1.1.png

CDS Preview:

Aug_Task-1.2.png

 

Thank You,

Bhumika

 

 

 

Read only

Jay_Dalsaniya
Participant
6,185

CDS Data Preview

dls_jay_0-1723568979585.png

ABAP Class to copy data to new table

dls_jay_1-1723569016847.png

 

Read only

fahadburney
Explorer
6,134

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

 

Read only

Kartheek
Explorer
6,111

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

Kartheek_0-1723604424347.png

Generator class:

Kartheek_1-1723604458618.png

 

Read only

TwanHunguyen01
Discoverer
6,113

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.

Read only

EnryIrala
Explorer
Read only

bruno_bonatti82
Newcomer
6,080

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

 

Read only

Akshay_Yelekar
Discoverer
Read only

Anne009
Discoverer
6,052

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

 

Read only

d_orozco
Discoverer