2007 Aug 22 8:51 PM
Hi,
Anybody suggest where to write a macro for global class.
I have a create a global class i need to add a macro into that . Please suggest me where to write the macro, Usually in function group we write in TOP include, But in Global Class ?
* Macro for controling the delete tables entries
define deletetable.
if not &2[] is initial.
delete &1 from table &2.
if sy-subrc ne 0 and sy-subrc ne 4.
move c_y to v_eflgd.
if not &2[] is initial.
i_idoc_status-docnum = v_docnum.
i_idoc_status-status = '51'.
i_idoc_status-msgty = 'E'.
i_idoc_status-msgid = 'YFE'.
i_idoc_status-msgno = '732'.
i_idoc_status-msgv1 = &3.
i_idoc_status-msgv2 = ' '.
i_idoc_status-msgv3 = ' '.
i_idoc_status-msgv4 = ' '.
append i_idoc_status.
endif.
else.
i_idoc_status-docnum = v_docnum.
i_idoc_status-status = '53'.
i_idoc_status-msgty = 'S'.
i_idoc_status-msgid = 'YFE'.
i_idoc_status-msgno = '737'.
i_idoc_status-msgv1 = &3.
i_idoc_status-msgv2 = ' '.
i_idoc_status-msgv3 = ' '.
i_idoc_status-msgv4 = ' '.
append i_idoc_status.
endif.
endif.
end-of-definition.
Sa_R
2007 Aug 22 8:57 PM
I would say that it is definitly not a good idea to use a macro, especially in a global class. Macro technology are somewhat obselete. You should wrap your logic in a private method within your class if you want to modularize the code.
Regards,
Rich Heilman
2007 Aug 22 8:57 PM
2007 Aug 22 9:08 PM
Thanks Rich,
I got your point.
I was trying to create private method, then i find macro option in the class.
Thanks for suggesting
Points awarded .
Issues closed.
Sa_R
2007 Aug 22 9:11 PM
2007 Aug 23 1:42 PM
Hi Rich
Without wanting to disagree with the Moderator too much I would say that using Macros to generate inline coding of repetitive statements STILL can be a good idea and is by no means obsolete technology.
For example It's much easier to code something like this ONCE
DEFINE toolbar_funcs.
CLEAR ls_toolbar.
MOVE 0 TO ls_toolbar-butn_TYPE.
MOVE &1 TO ls_toolbar-function.
MOVE SPACE TO ls_toolbar-disabled.
MOVE &2 TO ls_toolbar-icon.
MOVE &3 TO ls_toolbar-quickinfo.
APPEND ls_toolbar TO e_object->mt_toolbar.
END-OF-DEFINITION.
Now all you need to do in the on_toolbar method is to code something like this
METHOD on_toolbar.
customize this section with your own Buttons
When a button is pressed method ON_USER_COMMAND is entered
toolbar_funcs 'EXIT' icon_system_end 'Click2exit'.
toolbar_funcs 'SAVE' icon_system_save 'Savedata'.
toolbar_funcs 'EDIT' icon_toggle_display_change 'Edit data'.
toolbar_funcs 'PROC' icon_businav_process 'Process'.
toolbar_funcs 'EXCEL' icon_xxl 'Excel'.
toolbar_funcs 'REFR' icon_refresh 'Refresh'.
ENDMETHOD.
It saves quite a lot of tedious code typing -- OK the disadvantage is you can't debug it very easily but for "repetitive in line coding" the idea of using a macro is still perfectly valid.
Cheers
Jimbo
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |