Application Development Blog Posts
Learn and share on deeper, cross technology development topics such as integration and connectivity, automation, cloud extensibility, developing at scale, and security.
cancel
Showing results for 
Search instead for 
Did you mean: 
matt
Active Contributor
31,034

Just a little note about a couple of common errors:


This is not rocket science ABAP programming.

But it does show how even the very basics can be mishandled. As ever, when developing, think about what is happening with the data in your variables. And always be prepared to challenge any spec of requirement, by leading the requester through the consequences.

What the user asks for and what the functional consultant requests are not always what they need!


ERROR 1: Using a select-option when you need a date range


If you want a start date and end date, it is a mistake to use a select option. It's a mistake often made by functional consultants as well. I've even challenged functional guys and they've insisted "no, I want a select option". When I've taken them through the requirement, they realise that they don't actually want a select option, they want a date range.


The reason it's a mistake is that the structure of a select option (an internal table with header line) is:



SIGN OPTION LOW HIGH


That means the user can enter all sorts of weird and wonderful combinations of selections, ranges and exclusions - and your code won't be able to handle it properly. What will you do if the user enters?



I BT 01.01.2014 31.01.2014


I BT 01.01.2013 31.01.2013


E EQ 02.01.2014


The user wants January 2013 and 2014, but not the second of January. But many date handling and validation routines, will fail with this selection. The user doesn't get what they expect.



ERROR 2: Mishandling an empty selection


Not infrequently, the specification will ask for special handling of an empty selection - something like "if the select is blank, then select nothing". This is also a mistake. An empty select option in standard SAP throughout the SAP system means "select everything". If you follow the functional consultants request, you've broken the expected functionality for the user.


So what's the solution?

Far better (and what most SAP programs do, where they really just want a start and end date) is to simply use:


PARAMETERS: start TYPE d, end TYPE d.


This solution satisfies the actual requirement 99% of the time, and makes your program behave in an expected way.


For the second error, use a checkbox next to the select option to specify whether to use the select option in the data seletion.


 
33 Comments
Labels in this area