2021 Feb 17 2:44 PM
Hello Experts,
Is it possible to create CDS views using programming ?
B.R.
Hello Experts,
Is it possible to create CDS views using programming ?
B.R.
2021 Feb 17 3:01 PM
2021 Feb 17 3:07 PM
Hah, well, that is actually creating a CDS view in the system in a more complex way than necessary...
2021 Feb 17 3:03 PM
If you're asking how to create a dynamic CDS view, then the answer is no. You need to specify names and fields in the CDS view definitions, so it's not possible to create dynamic CDS views.
2021 Feb 17 3:21 PM
Hello jorgen_lindqvist41
No I do not mean dynamic CDS views. I mean can I create CDS view through only ABAP coding .
2021 Feb 17 3:34 PM
Ok. But why? You would still have to do the same things, and write the same definitions. Only in a much more complex and difficult way, without any checks of the syntax or anything...
There must be something I'm missing here as to your requirement...
2021 Feb 17 4:40 PM
2021 Feb 17 5:01 PM
I understand, could you explain a bit more about the certain processes? Preferably in your main question, so we all can have more information to base our suggestions on. For instance:
On what do you want to create the CDS views? Input in Excel? From a SAPUI5 app? All the existing Z database views in the data dictionary? IDoc data? Are we talking about 10, 50, 100 or 300 CDS views?
Is this a one time thing? Is this something to run continually as part of something else? Are we talking about 1 each time or 100 for each run?
To which degree should this be automated? Fully, as in no human contact at all? Or is some human interaction ok?
We are full of ideas, but we need more to go on... 🙂
2021 Feb 17 5:23 PM
2021 Feb 18 4:29 AM
All right, that sounds like fun! 🙂 Difficult, tricky and hard, but fun!
And just out of curiosity then, as a next step, how are they going to use the CDS views? Some kind of dynamic ALV with IDA?
2021 Feb 17 3:06 PM
Theoretically I guess you could try to call the same APIs that eclipse/ADT does.. or the code behind the APIs.
I wouldn't consider it practical though. Then it might be easier to create some RPA process and let that do the actions in eclipse..
2021 Feb 17 3:28 PM
Can you please explain more about what you mean by RPA process ?
2021 Feb 17 4:02 PM
I have no idea why you would want to create your CDS views through programming, but you could use a Robotic Process Automation tool (based on a xls for example) to create those views in eclipse.
Not sure if that would be a time-gain though, that would depend on whether you have RPA knowledge available and/or the amount of views to be generated
2021 Feb 18 7:07 AM
And have you checked the Query Designer application in SAP Fiori?
2021 Feb 17 3:55 PM
Are you sure it covers the creating of CDS artifacts? As far I can see "the functionality ranges from reading the content of CDS entities to querying annotations".
2021 Feb 18 4:43 AM
You can check XCO library, but it depends on the abap version you have probably, I only know that it is available in abap on cloud .
2021 Feb 18 7:04 AM
Considering XCO library, I think "the functionality ranges from reading the content of CDS entities to querying annotations".
2021 Feb 18 7:46 AM
pvnierop Ohh, not sure about that statement in help, but I thought we can create cds views using XCO libraries, like how it was done in ABAP RAP Generator.
https://github.com/SAP-samples/cloud-abap-rap/blob/master/src/zcl_rap_bo_generator.clas.abap
2021 Feb 24 8:50 AM
sam.pot pvnierop
Tried this Sample code in SAP Cloud Platform(BTP), it works
DATA(environment) = xco_cp_generation=>environment->dev_system( CONV #( 'TRLK901342' ) ).
DATA(put_operation) = environment->create_put_operation( ).
DATA(interface) = put_operation->for-ddls->add_object( iv_name = 'ZTEST_DYNM_CDS_CREATION'
)->set_package( 'ZMPOLA' )->create_form_specification( ).
DATA(view_entity) = interface->set_short_description( 'Test dynamic creation' )->add_view_entity( ).
view_entity->set_root( abap_false )->data_source->set_view_entity( conv #( '/DMO/AGENCY' ) ).
view_entity->add_annotation( 'AccessControl.authorizationCheck' )->value->build( )->add_enum( 'CHECK' ).
view_entity->add_annotation( 'EndUserText.label' )->value->build( )->add_string( 'Testing 123' ).
view_entity->add_field( xco_cp_ddl=>field( 'AGENCY_ID' ) )->set_key( ).
view_entity->add_field( xco_cp_ddl=>field( 'NAME' ) ).
put_operation->execute( ).
2021 Feb 19 11:31 AM
Hello maheshkumar.palavalli,
Are you sure that we can create CDS views from XCO library ? Because in the documentation , I am finding only "The functionality ranges from reading the content of CDS entities to querying annotations."
2021 Feb 21 6:54 AM
Yes, it says that, but I am looking at the RAP generator from Andre . There the CDS views will also be created, I am not sure if it works only with RAP model. But give it a try, I hope it should not be any different from what is used in the below code. Make sure you abap version have those API's.
https://github.com/SAP-samples/cloud-abap-rap/blob/master/src/zcl_rap_bo_generator.clas.abap
2021 Feb 21 6:55 AM
2021 Feb 24 8:50 AM
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |