2024 Aug 07 12:53 PM - last edited on 2024 Aug 08 5:16 PM by thomas_jung
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:
Validation : Share a screenshot of the following items as a reply to this thread to gain credits:
Enjoy!!!!
2024 Aug 08 8:34 PM
Please find the below :
2024 Aug 08 8:48 PM
Task 1 Completed!
2024 Aug 08 9:08 PM
2024 Aug 08 10:25 PM
CDS Data Preview:
Code of the generator class:
2024 Aug 08 10:30 PM
CDS Data Preview
Data generation class;
2024 Aug 08 10:58 PM
Hi,
CDS View:
Generator Class:
2024 Aug 08 10:59 PM
2 Logic in the ABAP class. In specific, the field ‘Status’ should only have values ( O, A or X ).
2024 Aug 09 1:17 AM
😎
2024 Aug 09 2:39 AM
Interesting! Ready for next week!
2024 Aug 09 4:19 AM
Data preview of CDS view:
Logic in the ABAP class. In specific, the field ‘Status’ should only have values ( O, A or X )
2024 Aug 09 5:18 AM
Data preview of the CDS View Entity:
Logic in the ABAP class:
2024 Aug 09 7:35 AM
My solution:
CDS view entity data preview -
And the Data generation Class -
2024 Aug 09 9:47 AM
CDS Preview:
Class Logic:
2024 Aug 09 9:51 AM
2. Logic in the ABAP class. In specific, the field ‘Status’ should only have values ( O, A or X ).
2024 Aug 09 9:56 AM
Hello there,
my submission to the challenge:
CDS View output:
My ABAP class:
2024 Aug 09 10:34 AM
Data preview of the CDS View Entity
Logic in the ABAP class
Task 1 Completed...
2024 Aug 09 10:38 AM
Hi!
Data Preview of the CDS View
ABAP Class
CLASS zcl_spassaro_travel_generator DEFINITION
PUBLIC
FINAL
CREATE PUBLIC .
PUBLIC SECTION.
INTERFACES if_oo_adt_classrun.
PROTECTED SECTION.
PRIVATE SECTION.
ENDCLASS.
CLASS zcl_spassaro_travel_generator IMPLEMENTATION.
METHOD if_oo_adt_classrun~main.
DELETE FROM ZSPASSARO_TRAVEL.
INSERT ZSPASSARO_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.
2024 Aug 09 11:10 AM
Week 1 challenge completed....😀😀😀
Data Preview.
ABAP Class Logic for loading data.
2024 Aug 09 11:46 AM
Hi,
here's my solution:
and
2024 Aug 09 12:08 PM
Completed!
2024 Aug 09 12:32 PM
Hi,
My Solution
Output,
2024 Aug 09 12:44 PM
My solution for the Week 1 challenge 😊
The data preview of my own Travel database table:
The transformation class logic:
2024 Aug 09 4:23 PM
My Solution for Week 1 Challenge:
Data Preview of the CDS View:
My Method:
2024 Aug 09 4:34 PM
Interesting. Done with Task 1.
CDS entity and data preview.
Class and table
2024 Aug 09 8:23 PM
TASK 1 : Solution :
data Preview:
ABAP Class:
2024 Aug 09 10:21 PM
Hi, please find the below screenshots.
2024 Aug 09 11:23 PM
CDS View Preview:
The code:
CLASS zcl_travel_lha DEFINITION
PUBLIC
FINAL
CREATE PUBLIC .
PUBLIC SECTION.
TYPES: ty_tab_flight TYPE TABLE OF zttravels_lha.
INTERFACES : if_oo_adt_classrun.
METHODS: main,
collect_flights
EXPORTING e_flights TYPE ty_tab_flight,
map_flights
IMPORTING i_flights TYPE ty_tab_flight
EXPORTING e_flights_mapped TYPE abap_boolean,
display_flights
.
PROTECTED SECTION.
PRIVATE SECTION.
DATA : out TYPE REF TO if_oo_adt_classrun_out.
ENDCLASS.
CLASS zcl_travel_lha IMPLEMENTATION.
METHOD : if_oo_adt_classrun~main.
me->out = out.
main( ).
ENDMETHOD.
METHOD main.
me->collect_flights( IMPORTING e_flights = DATA(i_flights) ).
me->map_flights( EXPORTING i_flights = i_flights IMPORTING e_flights_mapped = DATA(flights_are_mapped) ).
IF flights_are_mapped EQ abap_true.
me->display_flights( ).
ELSE.
out->write( 'An error has occured' ).
ENDIF.
ENDMETHOD.
METHOD collect_flights.
SELECT FROM /dmo/travel
FIELDS client, travel_id, description, total_price, currency_code, status
INTO CORRESPONDING FIELDS OF TABLE @e_flights.
IF Sy-subrc NE 0.
ENDIF.
ENDMETHOD.
METHOD map_flights.
IF lines( i_flights ) GT 0.
DATA: lt_flights TYPE ty_tab_flight.
LOOP AT i_flights INTO DATA(ls_flight).
CASE ls_flight-status.
WHEN 'N' OR 'P'.
lt_flights = VALUE #( BASE lt_flights ( client = ls_flight-client
travel_id = ls_flight-travel_id
description = ls_flight-description
status = 'O'
total_price = ls_flight-total_price
currency_code = ls_flight-currency_code
) ).
WHEN 'B'.
lt_flights = VALUE #( BASE lt_flights ( client = ls_flight-client
travel_id = ls_flight-travel_id
description = ls_flight-description
status = 'A'
total_price = ls_flight-total_price
currency_code = ls_flight-currency_code
) ).
WHEN OTHERS.
lt_flights = VALUE #( BASE lt_flights ( client = ls_flight-client
travel_id = ls_flight-travel_id
description = ls_flight-description
status = 'X'
total_price = ls_flight-total_price
currency_code = ls_flight-currency_code
) ).
ENDCASE.
ENDLOOP.
MODIFY zttravels_lha FROM TABLE @LT_flights.
IF sy-subrc EQ 0.
e_flights_mapped = abap_true.
ENDIF.
ENDIF.
ENDMETHOD.
METHOD display_flights.
SELECT FROM zttravels_lha
FIELDS *
INTO TABLE @DATA(lt_flights).
IF sy-subrc EQ 0.
out->write( lt_flights ).
ENDIF.
ENDMETHOD.
ENDCLASS.
Any remarks on how I make the code better are welcomed 💙
2024 Aug 10 5:16 AM
Data Preview of CDS View
Class Logic
2024 Aug 10 6:54 AM
1. Data Preview of my CDS Entity
2. Logic of my ABAP Class
Task - 1 is Done
2024 Aug 10 8:25 AM
Hi,
Task 1 Completed waiting for next task.
CDS Preview:
Class Logic:
2024 Aug 10 8:26 AM
Hi,
Task 1 completed and waiting for the next task :).
CDS Preview:
ABAP Class:
Thanks,
Nandhini Thanikachalam.
2024 Aug 10 9:39 AM
Task 1 Completed.
1. DATA Preview:
2. Class logic:
2024 Aug 10 11:08 AM
1. Data Preview
2. Class
2024 Aug 10 11:14 AM
Task 1 Screen shot
Data preview of the CDS View Entity
Logic in the ABAP class. In specific, the field ‘Status’ should only have values ( O, A or X ).
2024 Aug 10 12:35 PM
Here is
2024 Aug 10 1:18 PM - edited 2024 Aug 10 1:31 PM
Hi,
2. Class Code :
2024 Aug 10 1:44 PM
Data preview of the CDS View Entity
Logic in the ABAP class. In specific, the field ‘Status’ should only have values ( O, A or X ).
2024 Aug 10 2:09 PM
Task 1 - Completed!!
Data View:
Method Implementation:
DISTINCT values of status:
2024 Aug 10 7:31 PM
2024 Aug 10 11:46 PM
Data Preview of CDS - ZAR_TRAVEL_CDS
Data Generating Class - ZCL_AR_GEN_DATA