Application Development 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: 

Create new rows quickly based on values of existing rows.

tleonenko
Discoverer
0 Kudos
427

Basically, what I've been asked to do is that based on a sales document, add as many rows as there are months in the contract and calculate the revenue per month (although there is some additional logic for which rows need to have this done to). I have been able to do this by using an AMDP class, creating a table in the function with the rows I need, and then using a cursor to iterate through each row, and then use a loop to add a month to the contact start date, calculate revenue, etc. and then add that to an empty table, and then return that built table to a table function which my CDS view uses. The only problem is that it takes a very long time to load as I'm basically using a double loop and I believe a lot of things I'm using to accomplish calculations aren't optimized by HDB (division, multiplication, concat function, extract function, add_months function, days_between function, insert into. Although I'm just an intern learning SAP HANA stuff for 2-3 weeks, so I'm not really sure on anything). So I'm just wondering if there is an alternative way to add these rows that doesn't take so long for the database to load, and if there isn't, is there a way to optimize the AMDP class? (I'm not sharing the code as I'm unsure whether I'm allowed to share code I develop for the company I'm working for)

2 REPLIES 2

xiswanto
Active Participant
0 Kudos
370

The part part that you mentioned takes a very long time to load -> have you debug which part is actually taking time, is it during select data query, or when you are calling the class?

In my case for custom program, I would check which line actually took time to process, then, if possible, finetune the code so it could run better. ( such as read table, select data, or other syntax )

Sandra_Rossi
Active Contributor
0 Kudos
370

Saying "it takes a very long time to load" is meaningless as you don't say how many lines you are loading and you didn't post your code, so it's difficult to investigate the issue. Maybe you are doing an endless loop...

The format of your question is awful, it's just one block of text, no spacing.