Skip to Content
0
Aug 17, 2023 at 09:56 AM

How to create test environment for multiple CDS in ABAP Test Driven Development

208 Views Last edit Aug 17, 2023 at 05:58 PM 7 rev

Hello Team

  • I am working on ABAP(Test Driven )Development.
  • Under this, I have created a method name ( M_METHOD_01)
  • this method uses : both select ( CDS and Database Table) combination to fetch data.

Example:

1. My Method has a select query which is inner join between exciting CDS View and a Database Table, (Something like below example)

SELECT cds~aktnr, cds~matnr, werks, max_troc, vkdab, vkdbi
FROM ZEXAMPLECDS1 AS cds
INNER JOIN ZTESTTABLE1 AS stores
ON cds~aktnr = stores~aktnr
AND cds~matnr = stores~matnr
AND cds~werks = stores~filnr
WHERE cds~aktnr IS NOT INITIAL
INTO TABLE @DATA(lt_temptable1).

2. Select statement is on Database tables (Something like below example) :

SELECT t001w~werks,
t001w~fabkl
FROM t001w
FOR ALL ENTRIES IN @lt_table2
WHERE werks = @lt_table2-werks
INTO TABLE @DATA(lt_calender_key).

3. Select on CDS View

SELECT cds~aktnr, cds~matnr, werks, max_troc, vkdab, vkdbi
FROM ZEXAMPLECDS2 AS cds WHERE cds~aktnr IS NOT INITIAL
INTO TABLE @DATA(lt_temptable2).

So, In this case, my method is combination of Selects on Database and different CDS Views.

Now, I have below questions on creating test environment for Test Driven Development for my Method:

  1. Is it recommended to create two different environment (One for SQL via cl_osql_test_environment=>create ) and (One for CDS View cl_cds_test_environment=>create ) together and using it together will work?
  2. Also in my Method i have two different CDS Views which i am using in individual selects, using CL_CDS_TEST_ENVIRONMENT=>CREATE_FOR_MULTIPLE_CDS will work here? (As in cl_cds_test_environment=>create i am able to pass only one CDS at a time)