Skip to content
This repository has been archived by the owner on Jun 3, 2024. It is now read-only.

WEEK4CHALLENGE bhrgavreddy #26

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 25 additions & 20 deletions src/zcl_security_cc_problem_1.clas.abap
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,30 @@ CLASS zcl_security_cc_problem_1 IMPLEMENTATION.

METHOD if_oo_adt_classrun~main.

"Check that you have data that matches your input
SELECT * FROM /dmo/flight
WHERE carrier_id = @carrierId
AND connection_id = @connectionId
INTO TABLE @DATA(flights).
out->write( flights ).

DATA(dynamicUpdate) = |SEATS_MAX = '{ seatsMax }'|.
UPDATE /dmo/flight
SET (dynamicUpdate)
WHERE carrier_id = @carrierId
AND connection_id = @connectionId.

"Check the data afterwards
SELECT * FROM /dmo/flight
WHERE carrier_id = @carrierId
AND connection_id = @connectionId
INTO TABLE @flights.
out->write( flights ).

TRY.
"Check that you have data that matches your input
SELECT * FROM /dmo/flight
WHERE carrier_id = @carrierId
AND connection_id = @connectionId
INTO TABLE @DATA(flights).
out->write( flights ).

DATA(dynamicUpdate) = |SEATS_MAX = '{ cl_abap_dyn_prg=>check_int_value( i_seatsMax ) }'|.
UPDATE /dmo/flight
SET (dynamicUpdate)
WHERE carrier_id = @carrierId
AND connection_id = @connectionId.

"Check the data afterwards
SELECT * FROM /dmo/flight
WHERE carrier_id = @carrierId
AND connection_id = @connectionId
INTO TABLE @flights.
out->write( flights ).
CATCH: cx_abap_not_an_integer
cx_sy_dynamic_osql_syntax INTO DATA(lcx).
out->write( 'Error Occurred' ).
out->write( lcx->get_text( ) ).
ENDTRY.
ENDMETHOD.
ENDCLASS.
13 changes: 10 additions & 3 deletions src/zcl_security_cc_problem_2.clas.abap
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,15 @@ ENDCLASS.

CLASS zcl_security_cc_problem_2 IMPLEMENTATION.
METHOD if_oo_adt_classrun~main.
DATA(sql) = `CARRIER_ID = '` && input && `'`.
SELECT * FROM /dmo/flight WHERE (sql) INTO table @DATA(results).
out->write( results ).
TRY.
DATA(sql) = `CARRIER_ID = '` && input && `'`.
SELECT * FROM /dmo/flight WHERE (sql) INTO table @DATA(results).
out->write( results ).
CATCH cx_sy_open_sql_data_error
cx_sy_dynamic_osql_syntax
cx_sy_dynamic_osql_semantics INTO DATA(ex).
out->write('Error Occurred')
out->write( ex->get_text( ) ).
ENDTRY.
ENDMETHOD.
ENDCLASS.
28 changes: 19 additions & 9 deletions src/zcl_security_cc_problem_3.clas.abap
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,25 @@ ENDCLASS.

CLASS zcl_security_cc_problem_3 IMPLEMENTATION.
METHOD if_oo_adt_classrun~main.
DATA dref TYPE REF TO data.
FIELD-SYMBOLS <results> TYPE STANDARD TABLE.
CREATE DATA dref TYPE STANDARD TABLE OF (dbTable)
WITH EMPTY KEY.
ASSIGN dref->* TO <results>.
TRY.
cl_abap_dyn_prg=>check_table_name_str(
val = to_upper( dbTable )
packages = '/DMO/FLIGHT_LEGACY' ).
CATCH cx_abap_not_a_table
cx_abap_not_in_package INTO DATA(ex).
out->write('Error Occurred').
out->write( ex->get_text( ) ).
RETURN.
ENDTRY.

"Do you really want every table to be accessible? Yet it needs to be dynamic and support all tables within your Package
SELECT * FROM (dbTable) INTO TABLE @<results> UP TO 100 ROWS.
out->write( |Data for table: { dbTable }| ).
out->write( <results> ).
DATA dref TYPE REF TO data.
FIELD-SYMBOLS <results> TYPE STANDARD TABLE.
CREATE DATA dref TYPE STANDARD TABLE OF (dbTable)
WITH EMPTY KEY.
ASSIGN dref->* TO <results>.
"Do you really want every table to be accessible? Yet it needs to be dynamic and support all tables within your Package
SELECT * FROM (dbTable) INTO TABLE @<results> UP TO 100 ROWS.
out->write( |Data for table: { dbTable }| ).
out->write( <results> ).
ENDMETHOD.
ENDCLASS.