Open mastergago opened 2 years ago
As I try to stick with singular and plural should a range table be named in plural or singular? I ask this because a range table is a special type.
`data company_code_range type range of t001-bukrs.
data company_code_ranges type range of t001-bukrs.`
Nice question!
I usually use:
DATA company code_range TYPE RANGE OF t001-bukrs.
Don't know what the correct way to do it indeed.
IMO, there can be multiple company codes (plural) in the range (singular). Therefore, i prefer using this:
data RANGE_OF_COMPANY_CODES type range of T001-BUKRS.
I do DATA company_code_range TYPE RANGE OF bukrs
and DATA company_codes TYPE STANDARD TABLE OF bukrs
. I am not a native english speaker, to me I always understood range
as a collective noun/term (?), therefore what stands before it should be singular. Like to me it would be DATA company_code_list TYPE STANDARD TABLE OF REF TO company_code_model
and not company_codes_list
. vehicle_list
instead of vehicles_list
, therefore vehicle_range
-> company_code_range
. 🤷
If I see company_code_ranges
I'd assume it's TYPE STANDARD TABLE OF RANGE OF bukrs
(with an intermediate helper type...).
There is no perfect answer to this but in any case the sections Use descriptive names and Use plural should provide an outline to assist your in finding a good name for your context:
First of all note that company_code_range
tells you about the what but not the why. However the what is fully covered by the typing already. Sure, "company code" is clearer than the cryptic (yet in an SAP context well-understood) "BUKRS" yet providing some information about the why or what for is more helpful. Putting "range" or "list" in a name is redundant to some degree.
Consider this fictitious example with some context:
SELECT * FROM partners WHERE company_code IN collaboration_partner_codes INTO @DATA(partners_with_collab_agreement).
For the goal of understanding this code I believe it is sufficient to consider a range(s) table a set definition (in the mathematical sense) and thus simply use the plural.
I think I agree to a point, one thing that comes to mind though is that the variable does not actually contain a list of company codes like TYPE STANDARD TABLE OF bukrs
would. TYPE RANGE OF bukrs
may also use the whole feature set of ranges, that includes patterns and excluding values. One could argue it's a filter, so maybe company_code_filter
would also be an option if range is too technical.
Yes, I was aware that it is not actually a list of company codes - hence the pointer to the mathematical definition of a set that may describe it by the properties of its elements (i.e. a set-builder notation or set comprehension). To understand the goal of the algorithm, however, this "implementation detail" should not be required. Using the IN
operator is the next best thing to a fictitious SELECT * FROM partners WHERE has_collaboration_agreement( company_code ) INTO ...
in terms of pushing the filter logic down to the database.
Nevertheless, calling it a filter is closer to the intention so I would consider this an improvement over naming the variable *_range[s]
already.
Agree with @fabianlupa and @N2oB6n-SAP. In my non-prefixed code, I mostly use company_code_filter
or company_code_selector
to name ranges.
One confusing thing about naming ranges is that it's unclear what exactly "the range" is: Is it one row in the table, because it could be a BT
entry, so we effectly have a table of ranges? Or is it the table as such, because it describes "the range of things to select"?
As I try to stick with singular and plural should a range table be named in plural or singular? I ask this because a range table is a special type.
`data company_code_range type range of t001-bukrs.
data company_code_ranges type range of t001-bukrs.`