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

Is it possible to create CDS views through Programming

former_member207873
Participant
7,062

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.

22 REPLIES 22
Read only

gurkanyilmaz
Explorer
6,521

Please check here

Dynamic CDS Creation

Read only

joltdx
Active Contributor
6,521

Hah, well, that is actually creating a CDS view in the system in a more complex way than necessary...

Read only

joltdx
Active Contributor
0 Likes
6,521

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.

Read only

0 Likes
6,521

Hello jorgen_lindqvist41

No I do not mean dynamic CDS views. I mean can I create CDS view through only ABAP coding .

Read only

joltdx
Active Contributor
0 Likes
6,521

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

Read only

0 Likes
6,521
Jörgen LindqvistI need to automate certain processes .
Read only

joltdx
Active Contributor
6,521

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... 🙂

Read only

0 Likes
6,521
Jörgen LindqvistThanks your reply. I would want to develop something for the process consultants who are not much knowledgeable in programming , sql queries to build CDS views with few selections , conditions and button clicks. Something like SQVI(SAP Query) does .
Read only

joltdx
Active Contributor
0 Likes
6,521

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?

Read only

Patrick_vN
Active Contributor
6,521

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

Read only

0 Likes
6,521
pvnierop

Can you please explain more about what you mean by RPA process ?

Read only

0 Likes
6,521

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

Read only

0 Likes
6,521

And have you checked the Query Designer application in SAP Fiori?

Read only

Patrick_vN
Active Contributor
0 Likes
6,521

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".

Read only

maheshpalavalli
Active Contributor
6,521

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 .

https://help.sap.com/viewer/65de2977205c403bbc107264b8eccf4b/Cloud/en-US/291f3c6f5b274cc98a0f55a87aa...

Read only

0 Likes
6,521

Considering XCO library, I think "the functionality ranges from reading the content of CDS entities to querying annotations".

Read only

0 Likes
6,521

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

Read only

6,521

sam.pot pvnierop

Tried this Sample code in SAP Cloud Platform(BTP), it works

https://help.sap.com/viewer/65de2977205c403bbc107264b8eccf4b/Cloud/en-US/65a7efb4e3114e2aaaf95dc8612...

 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( ).

Read only

former_member207873
Participant
0 Likes
6,521

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."


Read only

6,521

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

Read only

6,521

PS: a small tip: you can click on "Add a comment" to reply or interact with answers. "Submit your Answer" is only to provide an unique solution.

Read only

0 Likes
6,521

added the code in my original answer, you can check.