Technical Design Time
So you are doing the technical design of a project. OK – so the design and the coding have been done and you are supporting it. (Me) But pretend I helped design the “mess” I call dynamic programming. Don’t get me wrong, I love dynamic programming when used with some common sense. But anyway… Back to the story, YOU are doing a technical design for a project.
A screen is needed to display a table. In the table there can be many records that relate back to one line. You want to display the table in one line for editing, creating, and displaying.
|Line||Name of Field||Description of Field||Value|
|1||Crazy1||Crazy field 1||Yes|
|1||Time_Dangerous||Time when dangerous||While Programming|
|2||Crazy1||Crazy field 1||No|
|3||Happy||When are happy||No computers|
Display / Change / Create – After clicked on line 1
Display/Change / Create – After clicked on line 2
|Line||Crazy Field 1|
OK Now lets make it a little harder – the fields for the lines are determined by different criteria.
|Line||Job||Number of years||People interaction||hours logged with people interaction||Color||Animal||Name of Field|
So it’s an interesting requirement. Let’s pretend nothing in standard SAP will work for the requirement. So what do you do? What do you put in your technical spec? How are you really going to program this beast?
Maybe the above isn’t enough information. So you get more and continue.
Dynamic programming is an option. Probably a good one. Use it with an ALV. Ahhhhh… Now you see where I’m going with the dynamic programming. But.. What about a Step-loop? It’s old, true. And the display will look different – going down the page instead of across. So which is the better choice?
Aha! It’s SAP ABAP we are talking about. So the answer “It depends”. Yes! Fist pump. That is the answer. I know it.
Questions to ask yourself
So step back – look at the mess and try to think about it. Now step back again look at it again, and decide which will be the easiest to code. Step back – yes look again, which is going to have the best performance. Alright one more time – the last and most import to all of us that support your code – step back look again. Which is going to be the easiest to support? What skill levels are on staff? What do they normally use? What about the development team who will be developing the code? What if it isn’t you – can they do what you want?
So many questions and no good answer.
So one more time – I’ll move forward.
I decide to use dynamic programming and an ALV output. I’m going to build a custom container to hold the code as I’m adding it via a screen exit.
Here’s some code:
I know not enough – but search on Dynamic programming. You’ll find a lot of examples. This blog isn’t meant to explain how to do it. Also I know the requirements are not all detailed. But hey we are developers, we know they aren’t always well defined! I like trying to read the back of the napkin for my functional requirements, it’s always fun.
So now – answers to my questions. Of course, my own answers.
Readability – Maintenance
Here’s where it gets fun. I’m a new program and have to maintain this. Oh boy. I wouldn’t know where to start. I’m an “older” programmer (Yes, I sure am) and I’ve never seen anything like this. Either way the maintenance cost will go up.
Here it gets a little harder…. If I had used a step loop, I would have been querying and adding data screen by screen. However, a step loop really didn’t meet the requirement. As a side note, if they used page up and down a lot – it really wouldn’t have been a good performance save. Do think about things like that if you are doing web programming, RF programming, etc. Screen by screen or all at once? And it would have depended on if I pulled all thedata up front before moving from screen to screen.
Not always the best way to go. It depends on your background. For me, no this wasn’t the easiest.
Should Dynamic programming been a technical requirement?
Do it sounds like step loop should have won, and dynamic programming should not have been used. Well I would say the answers are interesting. The one that would concern me would be the performance.
So did dynamic programming make sense? YES! Look at some different blogs. I get to ride my soapbox a bit. It’s always fun. It should have been used for many different reasons. It is more flexible. Once you learn it, it will be easy to maintain. For what I’m using it for, it meets the requirement much better. Performance is better. But one of the best reasons – it’s fun! No not really, the best reason. The best reason is it’s going to expand the technical skills of anyone who has to maintain it. Will it take longer for them to do? Of course. Will they complain? Maybe. But they will move forward a bit.
And yes, this is still a bit behind the times. No web, no HANA… What can I say? We aren’t there yet.
So what do YOU think Dynamic or some other form of programming? Would you have done something different? Maybe even a newer technique I didn’t think of. Feel free to get on your soapbox. I’d love to hear what you think.