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: 
kevin_neale
Explorer
As promised in my previous blog Reusing Class Methods Should Be Easier, I am going to show how this object lookup program can be added to the ABAP editor pattern options. I have organised this blog so that, if you are an expert, you only need to read the overview and drill down to the details for specifics, but, if you prefer to read the detail immediately, you can click on this link and read the whole process step by step. You can copy and paste most stuff from this blog.

This exercise will teach the following skills if you are new to ABAP.

  1. SE11 How to create Structures and Table Types for method communication.

  2. SE24 How to create Classes and Methods including Event Handler Methods.

  3. SE37 How to create a Function Module with a Modal Dialog popup screen.

  4. How to add a dynamic pattern into your ABAP editor.



OVERVIEW


First create the communication structures with SE11.

Name: ZCAS_FIND_OBJECT_INPUT
Description: Input format for function Z_FIND_OBJECT_EDITOR_EXIT
Input structure field list.

Name: ZCAS_FIND_METHOD_OUTPUT
Description: Output structure for function
Output structure field list.

Then create a table type for each, named: ZCAT_FIND_METHOD_INPUT and ZCAT_FIND_METHOD_OUTPUT respectively.
Table types.

Next create a class called ZCL_COLOUR. (I prefer the English spelling but that's up to you. 🙂 )
Add the following attributes:
Add the ZCL_COLOUR class attributes.

Create another class called ZCL_FIND_OBJECT
Add the following methods:
Add the ZCL_FIND_OBJECT class methods.

The parameters and code for each method is as follows:
GET_DATA parameters.
GET_DATA Code.
PROCESS parameters.
PROCESS Code.
OUTPUT Code.
FORMAT_CALL parameters.
FORMAT_CALL Code.
SET_COLUMN_PROPERTIES parameters.
SET_COLUMN_PROPERTIES Code.
SET_HEADER parameters.
SET_HEADER Code.
HANDLE_DOUBLE_CLICK parameters.
HANDLE_DOUBLE_CLICK Code.

Add the attributes.
Add the ZCL_FIND_OBJECT class attributes.

Create a function module called Z_FIND_EDITOR_OBJECT_EXIT.
Add the table parameter
BUFFER	TYPE	RSWSOURCET

and the exception
CANCELLED	Cancelled by user

Enter the code.
Enter the globals.
Create the modal dialog screen something like this.
The data elements must be named like this and the flow logic must be like this.
Create a Dialog Box status like this linking the two buttons to [Enter] and [F12] respectively.

Finally, add the dynamic pattern to your ABAP Editor and call it Z_FIND_OBJECT and paste in *$&$MUSTER like this.


THE DETAILS STEP BY STEP


In SE11 - Create the communication structures


Set the option to Structure


Make the description something like, Input structure for Find Object.


Copy and paste the fields below into the components
CLSNAME	Types	SEOCLSNAME
CMPNAME Types SEOCMPNAME
CMPTYPE Types SEOCMPTYPE
MTDTYPE Types SEOMTDTYPE
MTDDECLTYP Types SEOMTDDECL
ATTDECLTYP Types SEOATTDECL
EXPOSE Types SEOEXPOSE
STATE Types SEOSTATE
ATTVALUE Types SEOVALUE


Select Extras -> Enhancement Category from the menu


Enter past the annoying nonsense.


Choose Cannot Be Enhanced (There is no reason to allow enhancement. Any future changes can be a modification in your own environment.)


Click the Activate button


 

Create the object entry as local. There is no reason to transport this to the Quality Assurance or Production system.


 

Then repeat this process for the Output structure with the following description and fields.


Output structure for Find Object.
CLSNAME	Types	SEOCLSNAME
CMPNAME Types SEOCMPNAME
CMPTYPE Types VAL_TEXT
MTDTYPE Types VAL_TEXT
ATTDECLTYP Types VAL_TEXT
EXPOSE Types VAL_TEXT
STATE Types VAL_TEXT
ATTVALUE Types SEOVALUE
COLOUR Types LVC_T_SCOL


After that, Create the Table types for the two structures as follows:

Note: This is the same name as the structures but with the fourth character changed from an S to a T.


Choose table type:


Enter the Structure name and Description and Click the Activate button.


 

Again, make it local then do the same for the output structure.



Next, go to SE24 and create the class ZCL_COLOUR.


Enter the description, "Colour Assist" accept the defaults and click Save.


Make it local.



Click the Attributes tab and paste in the following values.
NONE	Static Attribute	Public	Type	I		0
BLUE Static Attribute Public Type I 1
GREY Static Attribute Public Type I 2
YELLOW Static Attribute Public Type I 3
DARKBLUE Static Attribute Public Type I 4
GREEN Static Attribute Public Type I 5
RED Static Attribute Public Type I 6
ORANGE Static Attribute Public Type I 7

Click the Activate button.


 

Then click [Continue].


 

Create the ZCL_FIND_OBJECT class.


 

Enter the description "Find an object by description pattern", accept the defaults and click Save.


Keep it local.


Paste the following methods:
GET_DATA	Static	Public
PROCESS Static Public
OUTPUT Static Public
FORMAT_CALL Static Public
SET_COLUMN_PROPERTIES Static Private
SET_HEADER Static Private
HANDLE_DOUBLE_CLICK Static Private

Note: The last method “HANDLE_DOUBLE_CLICK” must be set as an Event Handler Method.

To do this, select the method HANDLE_DOUBLE_CLICK and click the Goto Properties icon.


 

Enter a description "Handle the user's double click event", check the Event Handler for and enter the Class and Event as follows then click Change.


 

Paste the following descriptions for the methods or enter your own.
Get the possible objects
Prepare the selection for display
Display the list
Format the method to return to the ABAP editor
Set up column properties
Set column headers

Note: As you paste in the following parameters and code activate the class by using [Ctrl]+[F3] frequently to confirm that nothing was stuffed up during the paste.


Click on the GET_DATA method and then click the [Parameters] button and paste the following parameters in.
IV_CLS	Importing	Type	VSEOCOMPDF-CLSNAME		Object Type Name
IV_CMP Importing Type VSEOCOMPDF-CMPNAME Component name
IV_MTH Importing Type FLAG Component type Method
IV_DAT Importing Type FLAG Component type Data
IV_EVT Importing Type FLAG Component type Event
ET_INPUT Exporting Type ZCAT_FIND_OBJECT_INPUT Input format for function Z_FIND_OBJECT_EDITOR_EXIT

Click [F11] to save the click on the methods button and double-click GET_DATA to enter the following code.

  method get_data.
data:
lv_typ type vseocompdf-cmptype,
lv_cls type vseocompdf-clsname,
lv_cmp type vseocompdf-cmpname.

clear at_output.
if iv_cls is initial.
move '%' to lv_cls.
else.
move iv_cls to lv_cls.
translate lv_cls using '*%'.
endif.
if iv_cmp is initial.
move '%' to lv_cmp.
else.
move iv_cmp to lv_cmp.
translate lv_cmp using '*%'.
endif.
case abap_true.
when iv_mth.
move 1 to lv_typ.
when iv_dat.
move 0 to lv_typ.
when iv_evt.
move 2 to lv_typ.
endcase.
select clsname, cmpname, cmptype, mtdtype, mtddecltyp,
attdecltyp, exposure, state, attvalue
from vseocompdf
where clsname like @lv_cls
and cmpname like @lv_cmp
and cmptype eq @lv_typ
and exposure eq 2
and state ne 2
into table @et_input.
endmethod.

Click [F11] to save the [F3] to exit the method.

 


Click on the PROCESS method and then click the [Parameters] button and paste the following parameters in.
IT_INPUT	Importing	Type	ZCAT_FIND_OBJECT_INPUT		Input format for function Z_FIND_OBJECT_EDITOR_EXIT


Click [F11] to save the click on the methods button and double-click PROCESS to enter the following code.
  method process.
field-symbols:
<ls_input> type zcas_find_object_input,
<ls_output> type zcas_find_object_output,
<ls_colour> type lvc_s_scol.

loop at it_input assigning <ls_input>.
append initial line to at_output assigning <ls_output>.
move: <ls_input>-clsname to <ls_output>-clsname,
<ls_input>-cmpname to <ls_output>-cmpname,
<ls_input>-attvalue to <ls_output>-attvalue,
<ls_input>-state to <ls_output>-state.
if <ls_input>-cmptype eq 1.
move <ls_input>-mtddecltyp to <ls_output>-attdecltyp.
endif.
if <ls_input>-state eq '2'.
move 'Obsolete'(d13) to <ls_output>-state.
else.
clear <ls_output>-state.
endif.
case <ls_input>-cmptype.
when 0.
move 'Data'(d01) to <ls_output>-cmptype.
append initial line to <ls_output>-colour assigning <ls_colour>.
move: 'CMPTYPE' to <ls_colour>-fname,
zcl_colour=>yellow to <ls_colour>-color-col.
when 1.
move 'Method'(d02) to <ls_output>-cmptype.
append initial line to <ls_output>-colour assigning <ls_colour>.
move: 'CMPTYPE' to <ls_colour>-fname,
zcl_colour=>green to <ls_colour>-color-col.
when 2.
move 'Event'(d03) to <ls_output>-cmptype.
append initial line to <ls_output>-colour assigning <ls_colour>.
move: 'CMPTYPE' to <ls_colour>-fname,
zcl_colour=>orange to <ls_colour>-color-col.
when 3.
move 'Type'(d04) to <ls_output>-cmptype.
append initial line to <ls_output>-colour assigning <ls_colour>.
move: 'CMPTYPE' to <ls_colour>-fname,
zcl_colour=>blue to <ls_colour>-color-col.
endcase.
if <ls_input>-cmptype eq 1.
case <ls_input>-mtdtype.
when 0.
move 'Method'(d02) to <ls_output>-mtdtype.
append initial line to <ls_output>-colour assigning <ls_colour>.
move: 'MTDTYPE' to <ls_colour>-fname,
zcl_colour=>green to <ls_colour>-color-col.
when 1.
move 'Handler'(d07) to <ls_output>-mtdtype.
append initial line to <ls_output>-colour assigning <ls_colour>.
move: 'MTDTYPE' to <ls_colour>-fname,
zcl_colour=>blue to <ls_colour>-color-col.
when 2.
move 'Constructor'(d08) to <ls_output>-mtdtype.
append initial line to <ls_output>-colour assigning <ls_colour>.
move: 'MTDTYPE' to <ls_colour>-fname,
zcl_colour=>orange to <ls_colour>-color-col.
when 3.
move 'Destructor'(d09) to <ls_output>-mtdtype.
append initial line to <ls_output>-colour assigning <ls_colour>.
move: 'MTDTYPE' to <ls_colour>-fname,
zcl_colour=>red to <ls_colour>-color-col.
endcase.
endif.
case <ls_input>-attdecltyp.
when 0.
move 'Instance'(d14) to <ls_output>-attdecltyp.
append initial line to <ls_output>-colour assigning <ls_colour>.
move: 'ATTDECLTYP' to <ls_colour>-fname,
zcl_colour=>green to <ls_colour>-color-col.
when 1.
move 'Static'(d15) to <ls_output>-attdecltyp.
append initial line to <ls_output>-colour assigning <ls_colour>.
move: 'ATTDECLTYP' to <ls_colour>-fname,
zcl_colour=>yellow to <ls_colour>-color-col.
when 2.
move 'Constant'(d16) to <ls_output>-attdecltyp.
append initial line to <ls_output>-colour assigning <ls_colour>.
move: 'ATTDECLTYP' to <ls_colour>-fname,
zcl_colour=>blue to <ls_colour>-color-col.
endcase.
case <ls_input>-expose.
when 0.
move 'Private'(d10) to <ls_output>-expose.
append initial line to <ls_output>-colour assigning <ls_colour>.
move: 'EXPOSURE' to <ls_colour>-fname,
zcl_colour=>red to <ls_colour>-color-col.
when 1.
move 'Protected'(d11) to <ls_output>-expose.
append initial line to <ls_output>-colour assigning <ls_colour>.
move: 'EXPOSURE' to <ls_colour>-fname,
zcl_colour=>yellow to <ls_colour>-color-col.
when 2.
move 'Public'(d12) to <ls_output>-expose.
append initial line to <ls_output>-colour assigning <ls_colour>.
move: 'EXPOSURE' to <ls_colour>-fname,
zcl_colour=>green to <ls_colour>-color-col.
endcase.
endloop.
endmethod.

Click [F11] to save the [F3] to exit the method.


Click on the methods button and double-click OUTPUT to enter the following code.
  method output.
data:
lo_functions type ref to cl_salv_functions_list,
lo_events type ref to cl_salv_events_table,
lo_columns type ref to cl_salv_columns_table,
lo_display type ref to cl_salv_display_settings,
lo_ref type ref to cx_root,
lo_layout type ref to cl_salv_layout,
ls_layout_key type salv_s_layout_key,
lv_text type text132.

try.
cl_salv_table=>factory(
importing
r_salv_table = ao_alv
changing
t_table = at_output ).
catch cx_salv_msg into lo_ref.
lv_text = lo_ref->get_longtext( ).
message e020(0D) with lv_text.
endtry.
lo_functions = ao_alv->get_functions( ).
lo_functions->set_all( abap_true ).
lo_events = ao_alv->get_event( ).
lo_layout = ao_alv->get_layout( ).
move sy-cprog to ls_layout_key-report.
lo_layout->set_key( ls_layout_key ).
lo_layout->set_default( abap_true ).
lo_layout->set_save_restriction( co_allow_none ).
lo_columns = ao_alv->get_columns( ).
lo_columns->set_key_fixation( abap_true ).
lo_columns->set_optimize( ).
set_column_properties( changing co_columns = lo_columns ).
lo_display = ao_alv->get_display_settings( ).
lo_display->set_striped_pattern( abap_true ).
try.
lo_columns->set_color_column( 'COLOUR' ).
catch cx_salv_data_error into lo_ref.
lv_text = lo_ref->get_longtext( ).
message e020(0D) with lv_text.
endtry.
set handler handle_double_click for lo_events.
ao_alv->set_screen_popup(
start_column = 5
end_column = 110
start_line = 5
end_line = 26 ).
ao_alv->display( ).
endmethod.

Click [F11] to save the [F3] to exit the method.


Click on the FORMAT_CALL method and then click the [Parameters] button and paste the following parameters in.
IV_CLSNAME	Importing	Type	SEOCLSNAME		Object Type Name
IV_CMPNAME Importing Type SEOCMPNAME Component name
IV_CMPTYPE Importing Type VAL_TEXT Short Text for Fixed Values
RT_BUFFER Returning Type RSWSOURCET ABAP Source


Click [F11] to save the click on the methods button and double-click FORMAT_CALL to enter the following code.
  method format_call.
data:
lt_parameters_int type cl_sedi_shared=>tt_parameters,
lt_parameters type seos_parameters_r,
lt_buffer type swbse_max_line_tab,
ls_mtdkey type seocpdkey,
lt_pattern type swbse_max_line_tab,
ls_cmpkey type seocmpkey,
lv_instance type seoclsname.

field-symbols:
<ls_parameter> type seos_parameter_r,
<ls_parameter_i> type cl_sedi_shared=>ts_parameter.

move: iv_clsname to ls_mtdkey-clsname,
iv_cmpname to ls_mtdkey-cpdname.
call function 'SEOM_CALL_METHOD_PATTERN_NEW'
exporting
mtdkey = ls_mtdkey
instance = lv_instance
tables
patternsource = lt_buffer
exceptions
others = 0.
move: iv_clsname to ls_cmpkey-clsname,
iv_cmpname to ls_cmpkey-cmpname.
call function 'SEO_METHOD_SIGNATURE_GET'
exporting
mtdkey = ls_cmpkey
importing
parameters = lt_parameters
exceptions
others = 1.
if sy-subrc = 0.
loop at lt_parameters assigning <ls_parameter>.
append initial line to lt_parameters_int
assigning <ls_parameter_i>.
move: <ls_parameter>-sconame to <ls_parameter_i>-name,
<ls_parameter>-typtype to <ls_parameter_i>-type,
<ls_parameter>-type to <ls_parameter_i>-obj.
endloop.
cl_sedi_shared=>parameters_to_pattern(
exporting
i_parameters = lt_parameters_int
importing
e_pattern = lt_pattern ).
append lines of: lt_pattern to rt_buffer,
lt_buffer to rt_buffer.
endif.
endmethod.

Click [F11] to save the [F3] to exit the method.


Click on the SET_COLUMN_PROPERTIES method and then click the [Parameters] button and paste the following parameters in.
CO_COLUMNS	Changing	Type Ref To	CL_SALV_COLUMNS_TABLE		Columns in Simple, Two-Dimensional Tables


Click [F11] to save the click on the methods button and double-click SET_COLUMN_PROPERTIES to enter the following code.
  method set_column_properties.
data:
lo_column type ref to cl_salv_column,
lo_ref type ref to cx_root,
lt_fieldcat type salv_t_column_ref,
lv_text type text132.

field-symbols:
<ls_fieldcat> type salv_s_column_ref.

lt_fieldcat = co_columns->get( ).
loop at lt_fieldcat assigning <ls_fieldcat>.
try.
lo_column = co_columns->get_column( <ls_fieldcat>-columnname ).
catch cx_salv_not_found into lo_ref.
lv_text = lo_ref->get_longtext( ).
message e020(0D) with lv_text.
endtry.
case <ls_fieldcat>-columnname.
when 'CLSNAME'.
set_header(
exporting
iv_header = 'Class'(h00)
changing
co_column = lo_column ).
when 'CMPNAME'.
set_header(
exporting
iv_header = 'Attribute'(h05)
changing
co_column = lo_column ).
when 'CMPTYPE'.
set_header(
exporting
iv_header = 'Attrib typ'(h01)
changing
co_column = lo_column ).
when 'MTDTYPE'.
set_header(
exporting
iv_header = 'Method Type'(h02)
changing
co_column = lo_column ).
when 'EXPOSE'.
set_header(
exporting
iv_header = 'Scope'(h03)
changing
co_column = lo_column ).
when 'ATTVALUE'.
set_header(
exporting
iv_header = 'Value'(h04)
changing
co_column = lo_column ).
when 'ATTDECLTYP'.
set_header(
exporting
iv_header = 'Declaration'(h07)
changing
co_column = lo_column ).
when 'STATE'.
set_header(
exporting
iv_header = 'State'(h06)
changing
co_column = lo_column ).
when others.
endcase.
endloop.
endmethod.

Click [F11] to save the [F3] to exit the method.


Click on the SET_HEADER method and then click the [Parameters] button and paste the following parameters in.
IV_HEADER	Importing	Type	TEXT40		Text, 40 Characters Long
CO_COLUMN Changing Type Ref To CL_SALV_COLUMN Individual Column Object


Click [F11] to save the click on the methods button and double-click SET_COLUMN_PROPERTIES to enter the following code.
  method set_header.
data:
lv_s_header type text10,
lv_m_header type text20,
lv_l_header type text40.

move iv_header to: lv_s_header,
lv_m_header,
lv_l_header.
co_column->set_short_text( lv_s_header ).
co_column->set_medium_text( lv_m_header ).
co_column->set_long_text( lv_l_header ).
endmethod.

Click [F11] to save the [F3] to exit the method.


Click on the HANDLE_DOUBLE_CLICK method and then click the [Parameters] button and paste the following parameters in.
ROW
COLUMN


Click [F11] to save the click on the methods button and double-click SET_COLUMN_PROPERTIES to enter the following code.
  method handle_double_click.
data:
lt_sconame type standard table of seosconame,
lv_refclsname type seoclsname,
lv_buffer type string.

field-symbols:
<ls_output> type zcas_find_object_output,
<lv_sconame> type seosconame.

read table at_output assigning <ls_output> index row.
if sy-subrc ne 0.
return.
endif.
case <ls_output>-cmptype.
when 'Method'.
at_buffer = zcl_find_object=>format_call(
iv_clsname = <ls_output>-clsname
iv_cmpname = <ls_output>-cmpname
iv_cmptype = <ls_output>-cmptype ).
when 'Data'.
if <ls_output>-attdecltyp = 'Instance'.
concatenate 'ME->' <ls_output>-cmpname
into lv_buffer.
else.
concatenate <ls_output>-clsname
<ls_output>-cmpname
into lv_buffer separated by '=>'.
endif.
append lv_buffer to at_buffer.
when 'Event'.
concatenate 'on_' <ls_output>-cmpname
into lv_buffer.
append lv_buffer to at_buffer.
concatenate '~~for event~'
<ls_output>-cmpname
'~of~'
<ls_output>-clsname
into lv_buffer.
translate lv_buffer using '~ '.
append lv_buffer to at_buffer.
select single refclsname
into lv_refclsname
from vseoevent
where clsname eq <ls_output>-clsname
and cmpname eq <ls_output>-cmpname.
if lv_refclsname is initial.
move <ls_output>-clsname to lv_refclsname.
endif.
select sconame
into table lt_sconame
from vseoeparam
where clsname eq lv_refclsname
and cmpname eq <ls_output>-cmpname
and langu eq sy-langu
order by editorder.
if lt_sconame is not initial.
append ' importing' to at_buffer.
endif.
loop at lt_sconame assigning <lv_sconame>.
shift <lv_sconame> right by 4 places.
append <lv_sconame> to at_buffer.
endloop.
endcase.
leave to screen 0.
endmethod.

Click [F11] to save the [F3] to exit the method.


Click on the Attributes tab and paste in the following:
AT_BUFFER	Static Attribute	Public	Type	RSWSOURCET	ABAP Source
CO_ALLOW_NONE Static Attribute Private Type I ALV Layout authority
AO_ALV Static Attribute Private Type Ref To CL_SALV_TABLE Basis Class for Simple Tables
AT_OUTPUT Static Attribute Private Type ZCAT_FIND_OBJECT_OUTPUT Table of output structure for Find Objects

Activate the class.


Click Continue.


The class should be activated.


Go to SE37 and create a function Group as follows:


Enter the group name and description and click [Save].


Make it local.

Enter the Function Module name "Z_FIND_OBJECT_EDITOR_EXIT" and click [Create].


Choose the Function Group that you just created, enter a description and click [Save].


Go to the Tables Tab and paste in:
BUFFER	TYPE	RSWSOURCET

Ignore the warning about tables being obsolete.


Click on Exceptions and paste is the following:
CANCELLED	Cancelled by user



Click on the Source Code tab and paste in the following overwriting anything defaulted in:
function z_find_object_editor_exit .
*"----------------------------------------------------------------------
*"*"Local Interface:
*" TABLES
*" BUFFER TYPE RSWSOURCET
*" EXCEPTIONS
*" CANCELLED
*"----------------------------------------------------------------------
clear: gf_cancelled, zcl_find_object=>at_buffer.
call screen 9000 starting at 10 5
ending at 60 8.
if gf_cancelled eq abap_true
or zcl_find_object=>at_buffer is initial.
raise cancelled.
else.
move zcl_find_object=>at_buffer to buffer[].
endif.
endfunction.

*&---------------------------------------------------------------------*
*& Module STATUS_9000 OUTPUT
*&---------------------------------------------------------------------*
* Set up the option screen
*----------------------------------------------------------------------*
module status_9000 output.
set pf-status 'STAT_9000'.
endmodule.

*&---------------------------------------------------------------------*
*& Module USER_COMMAND_9000 INPUT
*&---------------------------------------------------------------------*
* Process the user command
*----------------------------------------------------------------------*
module user_command_9000 input.
case sy-ucomm.
when 'OK'.
zcl_find_object=>get_data(
exporting
iv_cls = gs_input-clsname
iv_cmp = gs_input-cmpname
iv_mth = gv_cmptypem
iv_dat = gv_cmptyped
iv_evt = gv_cmptypee
importing
et_input = gt_input ).
zcl_find_object=>process(
exporting
it_input = gt_input ).
zcl_find_object=>output( ).
leave to screen 0.
when 'BACK'
or 'CANC'
or 'EXIT'.
move abap_true to gf_cancelled.
leave to screen 0.
endcase.
endmodule.


Select the menu option Goto->Global data and paste in the following code, overwriting anything defaulted in.
function-pool zabapeditor.                  "MESSAGE-ID ..
data:
gt_input type zcat_find_object_input,
gs_input type zcas_find_object_input,
gf_cancelled type flag.

Click [F3] to go back to the function module code then create the screen by double-clicking the 9000 in the call screen statement and click the [Yes] button.


Enter a description and select Modal dialog box as follows.



Create the screen layout something like the following:


Group the radio buttons by selecting them and then, right clicking and choosing Radio Button Group -> Define.


The data element in the screen must have the following names so after creating your layout just paste this into the screens

Element List.
GS_INPUT-CLSNAME
GS_INPUT-CLSNAME
GS_INPUT-CMPNAME
GS_INPUT-CMPNAME
GV_CMPTYPEM
GV_CMPTYPEM
GV_CMPTYPED
GV_CMPTYPED
GV_CMPTYPEE
GV_CMPTYPEE


Click on the Flow logic tab and paste the following:
process before output.
module status_9000.

process after input.
module user_command_9000.


Double click on status_9000 and navigate to the module which was already created. Then double click on STAT_9000, Click [Yes] to create the object.

Enter the description and select Dialog Box then click the [Continue] button.


Open the Application Toolbar and Function Keys and enter OK and CANC as shown.


Press [Enter] and click the [Continue] button.


Enter Continue in the Function test and click [Continue].

Double click Enter for the function key.


Follow the same for the CANC option. Click [Continue] on the following dialog.


Enter Cancel in the Function text and click the [Continue] button.


Double click F12 for the function key.

Activate the Dynpro and Status.


Select both and click the continue button.


Back out by clicking the [F3] button then activate the function module.


Select all and click [Continue].


Finally, it only remains to add this as a pattern in your ABAP Editor.

Go to SE37 and open Z_FIND_OBJECT_EDITOR_TEXT for display. Then select the create pattern option from the menu as follows:


Enter the name and click [Continue].


Then paste in *$&$MUSTER and press [F11] to save.

Ignore the message about 100 lines.


Test it in your ABAP Editor as follows.

Click the [Pattern] button.


Select Other Pattern, enter Z_FIND_OBJECT and click the [Continue] button.


Your dialog should pop up where you can select a class and/or attribute by pattern.


The result should come as follows from the first ZCL_COLOUR class you created.


Double click the line and the attribute is pasted into your ABAP Editor.

Try again for a method.


The results in my case...


Clicking on ERROR_TO_BAPIRET2 I get the following pasted into my editor.


Congratulations! If you have persevered this far you will now have an easy way to reuse methods.

If you didn't already know, this exercise will have taught you skills in:

  1. SE11 Structures and Table Types for method communication.

  2. SE24 Class and methods including Event Handler Methods.

  3. How to use a static class to hold global constants, in this case colours, which I can never remember the correct number for. This strategy should only be used for constants that cannot change and should not be used for data such as plant, storage location etc. even if there is only one plant in your organisation.

  4. SE37 How to create a function with a modal dialog screen.

  5. How to add a dynamic pattern into your ABAP editor.


If you find this blog useful please let me know by clicking "like" below or if you feel there is room for improvement please leave a comment.

You can review other posts on ABAP programming to improve your ABAP skills at:

– ABAP Development (https://community.sap.com/topics/abap) Topic Page,

– Ask questions about ABAP Development – (https://answers.sap.com/tags/833755570260738661924709785639136),

– Read other posts on ABAP Development (https://blogs.sap.com/tags/833755570260738661924709785639136/)

Have fun in your programming and remember: Keep it simple. Keep it neat.
7 Comments
matt
Active Contributor
Now that we're all (most of us) are using Eclipse, can this be extended to there?
kevin_neale
Explorer
Hi Matthew,

Actually, I have only just started to look at Eclipse as an ABAP editor and in my little circle of ABAPers, no one uses Eclipse.

I took a quick look at how to add a dynamic template to Eclipse but was not able to find out how. I have asked the question of the SAP Community. If I get a positive answer, I will add it to this blog.

Cheers,

Kevin.
abo
Active Contributor
0 Kudos
I think we need to be careful with "us" 😉

When it refers to the usual suspects in the Community, this is likely correct... outside that group, I'm afraid not so much. For example, in my previous job I was the only one in my group who always tried Eclipse first even when not strictly required, just because.
matt
Active Contributor
To be honest, I think only half of my team use Eclipse regularly. One of my colleagues still uses concatenate instead of && or string templates.
Jelena
Active Contributor
0 Kudos
Thanks for sharing! Honestly, sheer amount of dedication to the Pattern button is commendable. SE80 rules. Haters gonna hate.
ennowulff
Active Contributor

auto completion in eclipse works using wildcards! not at once like in this example but one after the other:

(Unfortunately I am not able to insert images right now...)

type:

zcl*log* ALT-SPACE and you will get a selection of all classes that fit to the pattern.

type:

zcl_logger->*n* ALT-SPACE and you will get all methods that fit to the pattern.

see thomasfiedler s blog post which is also suggested in the similar blog posts widget.

 

 

matt
Active Contributor
Oh wow. I've learned something today. That makes me happy!
Labels in this area