on 04-27-2010 4:21 AM
Hello,
the code patterns that are generated by the very helpful Web Dynpro Code wizard seem to be a little inconsistent in their syntax structuring.
If I were to ask the wizard to read me a context node - I would get something like (some bits removed for brevity):
data lo_nd_result type ref to if_wd_context_node.
data lo_el_result type ref to if_wd_context_element.
data ls_result type wd_this->element_result.
* navigate from <CONTEXT> to <RESULT> via lead selection
lo_nd_result = wd_context->get_child_node( name = wd_this->wdctx_result ).
* get element via lead selection
lo_el_emp_search_result = lo_nd_emp_search_result->get_element( ).
* get all declared attributes
lo_el_emp_search_result->get_static_attributes(
importing
static_attributes = ls_emp_search_result ).
Yet if I were to ask the wizard to generate a message I would get:
* get message manager
data lo_api_controller type ref to if_wd_controller.
data lo_message_manager type ref to if_wd_message_manager.
lo_api_controller ?= wd_this->wd_get_api( ).
call method lo_api_controller->get_message_manager
receiving
message_manager = lo_message_manager
.
* report message
call method lo_message_manager->report_t100_message
exporting
msgid =
msgno =
msgty =
* p1 =
* p2 =
* p3 =
* p4 =
* msg_user_data =
* is_permanent = ABAP_FALSE
* scope_permanent_msg = CO_MSG_SCOPE_CONTROLLER
* view =
* show_as_popup =
* controller_permanent_msg =
* msg_index =
* cancel_navigation =
* enable_message_navigation =
receiving
message_id =
.
Edited by: Thomas Jung on Apr 27, 2010 8:56 AM
post split to avoid silly size/formatting limits
Ok - both work - but one is using the:
result = class_ref->methodname( parameters = paramvalue )
and one is using
call method class_ref->methodname
exporting parameters = paramvalue
receiving result = result.
As I often have to review code written by others, I encourage them to use these wizards - it helps speed code and prevents simple mistakes. But code that contains multiple different syntax structure approaches is harder to read (albeit only slightly), moreover - it looks sloppy.
But why are they not consistent in their syntax structure? (one could also argue why do we have multiple syntax structures for the same operation - but that's a different discussion).
Is there some way customers can update these structures to match with their own internal coding standards - or something we can change so that they go one way or another?
I look forward to other's thoughts on the same topic.
Cheers,
Chris
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The code wizards are far from perfect. They were probably created by different developers and took different approaches. It is unfortunete that they don't read the pattern settings in the workbench for method insertion. For the Code Completion Pattern Insertion we created multiple templates and use the user settings to control the output (when possible).
You will probably be even more disappointed with the code wizards once you are on 7.02. The code wizards continue to use the older syntax formatting instead of statement chaining. I find the code wizards at still a time saver, but each developer must pass over the generated code and be responsible for cleanup/optimization of the generated code.
Thanks for that answer (and for correcting my typo).
I'll add it to my wishlist for NW EhP4. I guess however, it will make it easy in code to see who understands code chaining, and who doesn't (leaves the wizards as they come).
I noticed that in the second example one part of the same wizard uses one structure and another part a different one. sigh
Guess this will be one of those questions that might not have an answer (yet). But I wonder if anyone has come up with a way to "enhance" SAP to change these wizards - rather than doing it in a more standard way.
- Chris
>
> Thanks for that answer (and for correcting my typo).
>
> I'll add it to my wishlist for NW EhP4. I guess however, it will make it easy in code to see who understands code chaining, and who doesn't (leaves the wizards as they come).
>
> I noticed that in the second example one part of the same wizard uses one structure and another part a different one. sigh
>
> Guess this will be one of those questions that might not have an answer (yet). But I wonder if anyone has come up with a way to "enhance" SAP to change these wizards - rather than doing it in a more standard way.
>
> - Chris
The WD Code Wizard generation isn't terribly sophisticated. It is simply concatenations of various strings. You can track down the class that does this (I did once) and use the enhancement framework to improve them.
The ABAP Editor Code Completion patterns are little more extensible. They use the ATL (ABAP Template Language) framework and there is a tool for customers to create their own customer specific versions of templates (Function module SRCC_CALL_TEMPLATE_MAINTENANCE).
>
> The WD Code Wizard generation isn't terribly sophisticated. It is simply concatenations of various strings. You can track down the class that does this (I did once) and use the enhancement framework to improve them.
Hello,
I've already done this (with your help)! Check your posting here: .
Regards,
Alej
And if any moderator would be so kind as to correct the spelling mistake in the title/subject of the first post - that'd be nice - seems I can't do it...
Thanks! - Chris
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
81 | |
9 | |
9 | |
7 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.