cancel
Showing results for 
Search instead for 
Did you mean: 

how to load initial data to nested entity - SAP CAP

babuilyas
Participant

Hello CAP enthusiastic,

I wonder how to load initial test data (CSV) to nested entities and compositions of many.

babuilyas
Participant
0 Kudos
entity transaction : managed {
    key id                        : Integer;
        descr                     : localized String;
        status                    : Integer enum {
            unknown     = 0;
            reconcilled = 1;
            void        = 2;
        };
        type                      : transaction_type not null;
        lines                  : Composition of many {
                                        account       : Association to one account not null;
                                        payee         : Association to one payee;
                                        amount        : Decimal;
                                        currency      : Currency;
                                        exchange_rate : Decimal;
                                        category      : Association to one category;
                                        fee           : Decimal;
                                        feecat        : Association to one category;
                                    }
        items                     : Composition of many {
                                        item     : Association to one item;
                                        quantity : Integer;
                                    }
        image                     : LargeBinary @Core.MediaType : 'image/png';
        voice                     : LargeBinary @Core.MediaType : 'audio/wav';
        // UI conidtional actions
        virtual enableVoid        : Boolean;
        virtual enableReconcilied : Boolean;
}


Accepted Solutions (1)

Accepted Solutions (1)

tobias_steckenborn
Active Participant

You can also use a CSV file.

Let’s say you have a namespace named test. Your initial data for your transaction would be in a file called test-transaction.csv.

Now, using the lines as an example, you would need to create a test.transaction-lines.csv file.

Note that you need to add an up__id reference in this file to create your lines as part of the correct transaction.

Best regards
Tobias

babuilyas
Participant
0 Kudos

Wow. I had prepared the rest but the mistake was in underscore (_). It should by hyphen (-). Thanks for swift response.

Answers (2)

Answers (2)

tobias_steckenborn
Active Participant
0 Kudos

For the visual learners out there I've recorded a short video on this: https://www.youtube.com/watch?v=a2bGQ6GZCwY

vLeonkev
Employee
Employee
0 Kudos

Find an example here: sap.capire.orders-Orders_Items.csv