ABAP OO Events
Dear all:
In ABAP OO programming, Events can be raised to announce a change of state (or action etc) and the associated Event Handlers can react to that.
SAP says that after the Event is raised:
- caller program halts processing
- all subscribed Event Handlers get executed
- once the Event Handlers finish execution, the control is sent back to the calling program
- the program resumes processing
If that is the case then what is the advantage of using Events+EventHandlers verses calling those Event Handler methods explicitely through the program? One advantage is that if there are multiple actions that should be taken based on event, you could specify all handlers at one place and all gets initiated when the event is raised. Do you envision any other advantage?
My main question is that if the event raiser program after triggering the event has to wait for the event handlers to finish processing - what benefit do we get by using Events+Event Handler combination verses calling the Event Hanlder methods explicitely? Is it only the convenience in coding or any other advantage too?
Thanks!
Hi Chetan,
Calling event handlers directly might be a bad thing. Event handlers should not be treated as merely subroutines. In some cases however, there is no difference in using a subroutine (form, function module, bapi or method) and the event handler.
But consider this.
When a button is available on a screen and when pressed an event is triggered, this will then run the event handler. The question you should ask yourself is: Can you predict when a user presses the button?
Answer: No, you cannot. So tell me, where in your code do you place the call to the event handler?
Once an event handler has been defined and it listens to a specific triggered event, this object can be used anywhere in ABAP OO by simply inherit the object. The only thing you need to do is to trigger the event (and ABAP OO takes care of the rest). Perfect reuseabillity.
So now to your question.
Designing OO programs is based on several techniques, where events have a crucial role. They signal to the system that something has happened. The (event) handler behind it acts on the signal. You can modify your event. You can modify the inhereted handler. Because if this capabillity you should use events with event handlers and not directly calling the handler. Furthermore it is not required to redefine an eventhandler once you declare an inherted object, but you are capable of doing so, thus changing its behaviour.
So this gives you as a devloper very good control over your program. And what more do we want.
Regards,
Rob.
Similar Messages
-
Hi,
I read the blog posted by Jocelyn Dart-<b><i>Raising ABAP OO Events for Workflow</i></b>...
<b>/people/jocelyn.dart/blog/2006/07/27/raising-abap-oo-events-for-workflow
When I tried the same using my own Class, I am getting some problem.
Well, I created my Class with two Attributes
1) <i>M_POR</i>(Persistent Object Reference Attribute)
2) <i>PERNR</i>(Employee Number)
And I created a Constructor with one parameter.
And I also coded the remaining standard methods as per that blog - <b><i>USING ABAP OO Methods in Workflow Tasks</i></b>.
Finally I activated my CLASS and each individual method.
I created one small report that raises ABAP OO Event as mentioned in the blog with the below mentioned code.
<i>report yworkflowtrigger_ooabap.
data : ls_ywftest1_key type p_pernr,
lv_objtype type sibftypeid,
lv_event type sibfevent,
lv_objkey type sibfinstid,
lr_event_parameters type ref to if_swf_ifs_parameter_container,
lv_param_name type swfdname,
lv_visit_date type datum.
lv_objtype = 'YWFTEST1'.
lv_event = 'STARTEVENT'.
Set up the LPOR Instance id
ls_ywftest1_key = '00000024'.
move ls_ywftest1_key to lv_objkey.
try.
call method cl_swf_evt_event=>raise
exporting
im_objcateg = cl_swf_evt_event=>mc_objcateg_cl
im_objtype = lv_objtype
im_event = lv_event
im_objkey = lv_objkey
IM_EVENT_CONTAINER =
catch cx_swf_evt_invalid_objtype .
catch cx_swf_evt_invalid_event .
endtry.</i>
I switched on my event trace and tried raising the Event. But event is not raised even after execution of this code. I checked the SY-SUBRC value at the ENDTRY, But this seems perfect(SY-SUBRC = 0).
Why is my event not getting triggered even after the execution of above code?
Is there anything which I have missed.
We are on <b>ECC 5.0</b>
Regards,
<i><b>Raja Sekhar</b></i>I missed this tip in that blog.
"<i><b>Tip! Just as for Business Object events, the COMMIT WORK statement is crucial when raising a Workflow event - without this the event will not be raised.</b></i>"
Regards,
<i><b>Raja Sekhar</b></i> -
CLBUS1007.created event triggered by an ABAP OO event?
Hello gurus,
I have noticed, that when the customer master is created in ECC 5.0, the CLBUS1007.created event is triggered (SWEL). However; CLBUS1007 object does not exist in the BOR directory. It must be ABAP OO event than, right? If so, how can I find out the corresponding class? I wonder how I can make a binding, check object attributes etc.
By the way, BUS1007 is obsolete in BOR. Do you know if I should use some other BOR object for a Customer or create a sub-class of this ABAP class that I don't know yet?
Regards,
Michal
PS. I know there is very good blog by Jocelyn Dart about this topic (/people/jocelyn.dart/blog/2006/07/27/raising-abap-oo-events-for-workflow), but it does not solve my problem of relation between SWEL object type and ABAP class.Hi Michael,
If you look at the header of BOR object BUS1007 you'll notice the last time this was changed was back in 1999 - i.e. 4.6a. So that object has been dead for quite some time.
It's almost certainly just an obsolete piece of code that hasn't been cleaned up properly. I suspect what is happening is that it is mix and matching the object category CL with the business object BUS1007 (which of course is category BO).
Either that or its an obsolete configuration entry that's getting picked up.
If it's annoying you, you could try putting a session breakpoint on function module SWE_EVENT_CREATE to see if you can track the call that causing the problem, and then of course report it in (Low priority) to get it cleaned up.
If you are just looking for the correct object to use, suggest you report it in anyway as a query... I notice they haven't bothered to specify the new object type in the documentation but if you look at SAP note 719936 it mentions that the new object type is KNA1 - which definitely is in the BOR directory.
I haven't seen an ABAP OO version of KNA1 yet in any of the systems... HR seems to be doing a fair bit in ABAP OO though.
Hope that helps.
Regards,
Jocelyn -
Hi guys,
in my workflow i have an activity with an abap method. This method works like a dialog. This means, i get a workitem in the business-workplace which shows a webdynpro where a pdf is displayed and where i can choose whether i click on button1 or button2.
When i click on one button, an abap-class event will be created. This event has a container. My target is, to bring the user desicion back to the workflow via event.
When i start a new workflow with this event then it works fine. But i dont want 2 workflows. I need a solution with one workflow. So i use a fork in my workflow. In branch 1 i have the activity which displays the pdf and create the event. In the other branch i have a waiting step, which waits for the event and bring the user-desision from the event-container to my workflow-container.
That was my plan, but it dont works this way. I checked the event-trace and theres no receaiver entered for my event. So my workflow stoped at the wait-step (wait step is ready).
I read, the the workflow system is automatikly doing the type-linkage and the instance-linkage, but i found only the instance-linkage filled. Can it be, that the wait step is only working with BOR-Events?
Any ideas?Hi swangir,
i tryed this FW SAP_WAPI_WRITE_CONTAINER some days ago. I can use SAP_WAPI_READ_CONTAINER easylie but when i try to modify the container then i get an enqeue exception in the SAP_WAPI_WRITE_CONTAINER FM. I guess this came up, because i call the webdynpro from an activie-step in the workflow and not a dialog-step. So i guess the container is locked and i cant write. I also tried to unlock it with dequee_e_ .. FM i forgot the name. But it also didnt work.
Thats why i tryed to bring the user desision via event back to the workflow. And it works, as long i use 2 workflows, like i explained in my first post.
What do u mean with...
"Alternatively, you can bind back the class event container to workflow container by binding back from the dialogue step."
Andre -
Hi All,
Could anybody send me a document for ABAP Object events.
And simple programs for Events.
My id - [email protected]
Thanks,
Ponraj.s.Hi,
Go thru this basic simple program with documentation which demonstrates how to handle events, for nodes in a tree using abap objects
REPORT YLIST_TREE MESSAGE-ID ZER_INFO.
CLASS LCL_EVT_HDLR DEFINITION DEFERRED. " definition is given later
CLASS CL_GUI_CFW DEFINITION LOAD. " global class to be loaded
DATA:G_EVENT(50), " to hold the event
G_NODE_KEY TYPE TV_NODEKEY, "holds the node key
G_ITEM_NAME TYPE TV_ITMNAME,
G_KEY TYPE TV_ITMNAME.
DATA:G_EVT_HDLR TYPE REF TO LCL_EVT_HDLR,
G_CUSTOM_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
G_TREE TYPE REF TO CL_GUI_LIST_TREE,
G_OK_CODE TYPE SY-UCOMM.
TYPES:ITEM_TABLE_TYPE LIKE STANDARD TABLE OF MTREEITM
WITH DEFAULT KEY.
CLASS lcl_evt_hdlr DEFINITION
CLASS LCL_EVT_HDLR DEFINITION.
PUBLIC SECTION.
METHODS:
*---- methods for action handling for nodes
NODE_DBL_CLK
FOR EVENT NODE_DOUBLE_CLICK
OF CL_GUI_LIST_TREE
IMPORTING NODE_KEY,
HANDLE_NODE_KEY_PRESS
FOR EVENT NODE_KEYPRESS
OF CL_GUI_LIST_TREE
IMPORTING NODE_KEY KEY,
*---- methods for action handling for Items
ITEM_DBL_CLK
FOR EVENT ITEM_DOUBLE_CLICK
OF CL_GUI_LIST_TREE
IMPORTING NODE_KEY ITEM_NAME,
HANDLE_ITEM_KEY_PRESS
FOR EVENT ITEM_KEYPRESS
OF CL_GUI_LIST_TREE
IMPORTING NODE_KEY ITEM_NAME KEY,
*---- Common methods for action handling
HANDLE_RIGHT_CLICK
FOR EVENT RIGHT_CLICK
OF CL_GUI_LIST_TREE,
HANDLE_EXPAND_NO_CHILDREN
FOR EVENT EXPAND_NO_CHILDREN
OF CL_GUI_LIST_TREE
IMPORTING NODE_KEY.
ENDCLASS. "lcl_evt_hdlr DEFINITION
CLASS lcl_evt_hdlr IMPLEMENTATION
CLASS LCL_EVT_HDLR IMPLEMENTATION.
METHOD NODE_DBL_CLK.
this method handles the node double click event of the tree control
and shows the key of the double clicked node in a dynpro field
G_EVENT = 'NODE_DOUBLE_CLICK'.
G_NODE_KEY = NODE_KEY.
G_ITEM_NAME = ' '.
ENDMETHOD. "node_dbl_clk
METHOD ITEM_DBL_CLK.
G_EVENT = 'ITEM_DOUBLE_CLICK'.
G_NODE_KEY = NODE_KEY.
G_ITEM_NAME = ITEM_NAME.
ENDMETHOD. "ITEM_DBL_CLK
METHOD HANDLE_NODE_KEY_PRESS.
G_EVENT = 'NODE_KEYPRESS'.
G_NODE_KEY = NODE_KEY.
G_ITEM_NAME = ' '.
G_KEY = KEY.
ENDMETHOD. "HANDLE_NODE_KEY_PRESS
METHOD HANDLE_ITEM_KEY_PRESS.
G_EVENT = 'ITEM_KEYPRESS'.
G_NODE_KEY = NODE_KEY.
G_ITEM_NAME = ITEM_NAME.
G_KEY = KEY.
ENDMETHOD. "HANDLE_ITEM_KEY_PRESS
METHOD HANDLE_RIGHT_CLICK.
G_EVENT = 'RIGHT_CLICK'.
ENDMETHOD. "handle_right_click
METHOD HANDLE_EXPAND_NO_CHILDREN.
G_EVENT = 'EXPAND_NO_CHILDREN'.
G_NODE_KEY = NODE_KEY.
ENDMETHOD. "handle_EXPAND_NO_CHILDREN
ENDCLASS. "lcl_evt_hdlr IMPLEMENTATION
*------ start-of-selection.
START-OF-SELECTION.
*data: G_EVT_HDLR TYPE REF TO LCL_EVT_HDLR.
CREATE OBJECT G_EVT_HDLR. "create an object for the class lcl_evt_hdlr
SET SCREEN 100.
MODULE pbo_100 OUTPUT
MODULE PBO_100 OUTPUT.
SET PF-STATUS 'BUT'.
IF G_TREE IS INITIAL.
the tree control has not yet been created
create a tree control and insert nodes into it.
PERFORM CREATE_AND_INIT_TREE.
ENDIF.
ENDMODULE. "pbo_100 OUTPUT
MODULE pai_100 INPUT
MODULE PAI_100 INPUT.
DATA:RETURN_CODE TYPE I.
CL_GUI_CFW=>DISPATCH must be called if events are registered
that trigger PAI
this method calls the event handler method of an event
CALL METHOD CL_GUI_CFW=>DISPATCH
IMPORTING
RETURN_CODE = RETURN_CODE.
IF RETURN_CODE <> CL_GUI_CFW=>RC_NOEVENT.
" a control event occured => exit PAI
CLEAR G_OK_CODE.
EXIT.
ENDIF.
*at user-command.
g_ok_code = sy-ucomm.
CASE G_OK_CODE.
WHEN 'BACK'. " Finish program
IF NOT G_CUSTOM_CONTAINER IS INITIAL.
" destroy tree container (detroys contained tree control, too)
CALL METHOD G_CUSTOM_CONTAINER->FREE
EXCEPTIONS
CNTL_SYSTEM_ERROR = 1
CNTL_ERROR = 2.
IF SY-SUBRC <> 0.
MESSAGE A000.
ENDIF.
CLEAR G_CUSTOM_CONTAINER.
CLEAR G_TREE.
ENDIF.
LEAVE PROGRAM.
ENDCASE.
CAUTION: clear ok code!
CLEAR G_OK_CODE.
ENDMODULE. "pai_100 INPUT
*& Form create_and_init_tree
text
--> p1 text
<-- p2 text
FORM CREATE_AND_INIT_TREE .
DATA:NODE_TABLE TYPE TREEV_NTAB,
ITEM_TABLE TYPE ITEM_TABLE_TYPE,
EVENTS TYPE CNTL_SIMPLE_EVENTS,
EVENT TYPE CNTL_SIMPLE_EVENT.
create a container for the tree control.
CREATE OBJECT G_CUSTOM_CONTAINER
EXPORTING
the container is linked to the custom control with the
name 'TREE_CONTAINER' on the dynpro
CONTAINER_NAME = 'TREE_CONTAINER'
EXCEPTIONS
CNTL_ERROR = 1
CNTL_SYSTEM_ERROR = 2
CREATE_ERROR = 3
LIFETIME_ERROR = 4
LIFETIME_DYNPRO_DYNPRO_LINK = 5.
IF SY-SUBRC <> 0.
MESSAGE A000.
ENDIF.
create a list tree control
CREATE OBJECT G_TREE
EXPORTING
PARENT = G_CUSTOM_CONTAINER
NODE_SELECTION_MODE = CL_GUI_LIST_TREE=>NODE_SEL_MODE_SINGLE
ITEM_SELECTION = 'X'
WITH_HEADERS = ' '
EXCEPTIONS
CNTL_SYSTEM_ERROR = 1
CREATE_ERROR = 2
FAILED = 3
ILLEGAL_NODE_SELECTION_MODE = 4
LIFETIME_ERROR = 5.
IF SY-SUBRC <> 0.
MESSAGE A000.
ENDIF.
*------- KEY = enter
CALL METHOD G_TREE->ADD_KEY_STROKE
EXPORTING
KEY = CL_TREE_CONTROL_BASE=>KEY_ENTER
EXCEPTIONS
FAILED = 1
ILLEGAL_KEY = 2
CNTL_SYSTEM_ERROR = 3.
IF SY-SUBRC <> 0.
MESSAGE W006 WITH 'ADD_KEY_STROKE'.
ENDIF.
define the events which will be passed to the backend
node double click
EVENT-EVENTID = CL_GUI_LIST_TREE=>EVENTID_NODE_DOUBLE_CLICK.
EVENT-APPL_EVENT = 'X'.
APPEND EVENT TO EVENTS.
EVENT-EVENTID = CL_GUI_LIST_TREE=>EVENTID_ITEM_DOUBLE_CLICK.
EVENT-APPL_EVENT = 'X'.
APPEND EVENT TO EVENTS.
EVENT-EVENTID = CL_GUI_LIST_TREE=>EVENTID_NODE_KEYPRESS.
EVENT-APPL_EVENT = 'X'.
APPEND EVENT TO EVENTS.
EVENT-EVENTID = CL_GUI_LIST_TREE=>EVENTID_ITEM_KEYPRESS.
EVENT-APPL_EVENT = 'X'.
APPEND EVENT TO EVENTS.
EVENT-EVENTID = LCL_EVT_HDLR=>EVENT_RIGHT_CLICK.
EVENT-APPL_EVENT = 'X'.
APPEND EVENT TO EVENTS.
EVENT-EVENTID = CL_GUI_LIST_TREE=>EVENTID_EXPAND_NO_CHILDREN.
EVENT-APPL_EVENT = 'X'.
APPEND EVENT TO EVENTS.
*------ register the events
CALL METHOD G_TREE->SET_REGISTERED_EVENTS
EXPORTING
EVENTS = EVENTS
EXCEPTIONS
CNTL_ERROR = 1
CNTL_SYSTEM_ERROR = 2
ILLEGAL_EVENT_COMBINATION = 3.
IF SY-SUBRC <> 0.
MESSAGE A000.
ENDIF.
assign event handlers in the application class to each desired events
SET HANDLER G_EVT_HDLR->NODE_DBL_CLK FOR G_TREE.
SET HANDLER G_EVT_HDLR->ITEM_DBL_CLK FOR G_TREE.
SET HANDLER G_EVT_HDLR->HANDLE_NODE_KEY_PRESS FOR G_TREE.
SET HANDLER G_EVT_HDLR->HANDLE_ITEM_KEY_PRESS FOR G_TREE.
SET HANDLER G_EVT_HDLR->HANDLE_RIGHT_CLICK FOR G_TREE.
SET HANDLER G_EVT_HDLR->HANDLE_EXPAND_NO_CHILDREN FOR G_TREE.
add some nodes to the tree control
PERFORM BUILD_NODE_AND_ITEM_TABLE USING NODE_TABLE ITEM_TABLE.
CALL METHOD G_TREE->ADD_NODES_AND_ITEMS
EXPORTING
NODE_TABLE = NODE_TABLE
ITEM_TABLE = ITEM_TABLE
ITEM_TABLE_STRUCTURE_NAME = 'mtreeitm'
EXCEPTIONS
FAILED = 1
CNTL_SYSTEM_ERROR = 3
ERROR_IN_TABLES = 4
DP_ERROR = 5
TABLE_STRUCTURE_NAME_NOT_FOUND = 6.
IF SY-SUBRC <> 0.
MESSAGE A000.
ENDIF.
ENDFORM. " create_and_init_tree
*& Form build_node_and_item_table
text
-->P_NODE_TABLE text
-->P_ITEM_TABLE text
FORM BUILD_NODE_AND_ITEM_TABLE USING
NODE_TABLE TYPE TREEV_NTAB
ITEM_TABLE TYPE ITEM_TABLE_TYPE.
DATA:NODE TYPE TREEV_NODE,
ITEM TYPE MTREEITM.
build the node table
node with key 'root'.
CLEAR NODE.
NODE-NODE_KEY = 'Root'. " key of the node
CLEAR NODE-RELATKEY. " root node has no parent node
CLEAR NODE-RELATSHIP.
NODE-HIDDEN = ' '. " the node is visible
NODE-DISABLED = ' '. " selectable
NODE-ISFOLDER = 'X'. " a folder
CLEAR NODE-N_IMAGE. " folder-/ leaf symbol in state "closed"
"use default.
CLEAR NODE-EXP_IMAGE. " folder-/ leaf symbol in state "open"
"use default.
CLEAR NODE-EXPANDER. " the width of the item is adjusted to its "
" content (text)
APPEND NODE TO NODE_TABLE.
node with key 'child1'.
CLEAR NODE.
NODE-NODE_KEY = 'Child1'. "key of the node
NODE-RELATKEY = 'Root'.
NODE-RELATSHIP = CL_GUI_LIST_TREE=>RELAT_LAST_CHILD.
NODE-ISFOLDER = 'X'.
APPEND NODE TO NODE_TABLE.
node with key 'Subchild1' for child1.
CLEAR NODE.
NODE-NODE_KEY = 'SubChild1'.
NODE-RELATKEY = 'Child1'.
NODE-RELATSHIP = CL_GUI_LIST_TREE=>RELAT_LAST_CHILD.
NODE-ISFOLDER = 'X'.
APPEND NODE TO NODE_TABLE.
node with key 'subchild2' for child1.
CLEAR NODE.
NODE-NODE_KEY = 'SubChild2'.
NODE-RELATKEY = 'Child1'.
NODE-RELATSHIP = CL_GUI_LIST_TREE=>RELAT_LAST_CHILD.
APPEND NODE TO NODE_TABLE.
node with key 'subchild3' for child1.
CLEAR NODE.
NODE-NODE_KEY = 'SubChild3'.
NODE-RELATKEY = 'Child1'.
NODE-RELATSHIP = CL_GUI_LIST_TREE=>RELAT_LAST_CHILD.
APPEND NODE TO NODE_TABLE.
node with key 'child2'.
CLEAR NODE.
NODE-NODE_KEY = 'Child2'. "key of the node
NODE-RELATKEY = 'Root'.
NODE-RELATSHIP = CL_GUI_LIST_TREE=>RELAT_LAST_CHILD.
NODE-ISFOLDER = 'X'.
NODE-EXPANDER = 'X'. " The node is marked with a '+', although
" it has no children. When the user clicks on the
" + to open the node, the event expand_nc is
" fired. The programmerr can
" add the children of the
" node within the event handler of the expand_nc
" event (see callback handle_expand_nc).
APPEND NODE TO NODE_TABLE.
items of the nodes
item with key 'root'.
CLEAR ITEM.
ITEM-NODE_KEY = 'Root'.
ITEM-ITEM_NAME = '1'.
ITEM-CLASS = CL_GUI_LIST_TREE=>ITEM_CLASS_TEXT. " text item
ITEM-ALIGNMENT = CL_GUI_LIST_TREE=>ALIGN_AUTO. "the width of the item
"is adjusted to its content
ITEM-FONT = CL_GUI_LIST_TREE=>ITEM_FONT_PROP. "use proportional font
" for the item
ITEM-TEXT = 'object'.
APPEND ITEM TO ITEM_TABLE.
item with key 'child1'.
CLEAR ITEM.
ITEM-NODE_KEY = 'Child1'.
ITEM-ITEM_NAME = '11'.
ITEM-CLASS = CL_GUI_LIST_TREE=>ITEM_CLASS_TEXT.
ITEM-ALIGNMENT = CL_GUI_LIST_TREE=>ALIGN_AUTO.
ITEM-FONT = CL_GUI_LIST_TREE=>ITEM_FONT_PROP.
ITEM-TEXT = 'dynpros'.
APPEND ITEM TO ITEM_TABLE.
item with key 'child2'.
CLEAR ITEM.
ITEM-NODE_KEY = 'Child2'.
ITEM-ITEM_NAME = '12'.
ITEM-CLASS = CL_GUI_LIST_TREE=>ITEM_CLASS_TEXT.
ITEM-ALIGNMENT = CL_GUI_LIST_TREE=>ALIGN_AUTO.
ITEM-FONT = CL_GUI_LIST_TREE=>ITEM_FONT_PROP.
ITEM-TEXT = 'programme'.
APPEND ITEM TO ITEM_TABLE.
items of node with key 'Subchild1'.
CLEAR ITEM.
ITEM-NODE_KEY = 'SubChild1'.
ITEM-ITEM_NAME = '111'.
ITEM-CLASS = CL_GUI_LIST_TREE=>ITEM_CLASS_TEXT.
ITEM-LENGTH = 11.
ITEM-TEXT = 'include'.
APPEND ITEM TO ITEM_TABLE.
items of node with key 'SubChild2'.
CLEAR ITEM.
ITEM-NODE_KEY = 'SubChild2'.
ITEM-ITEM_NAME = '112'.
ITEM-CLASS = CL_GUI_LIST_TREE=>ITEM_CLASS_TEXT.
ITEM-LENGTH = 4. " the width of the item is 4 chars
ITEM-IGNOREIMAG = 'X'. " see documentation of structure treev_item
ITEM-USEBGCOLOR = 'X'.
ITEM-T_IMAGE = '@01@'.
APPEND ITEM TO ITEM_TABLE.
CLEAR ITEM.
ITEM-NODE_KEY = 'SubChild2'.
ITEM-ITEM_NAME = '113'.
ITEM-CLASS = CL_GUI_LIST_TREE=>ITEM_CLASS_TEXT.
ITEM-LENGTH = 4. " the width of the item is 4 chars
ITEM-USEBGCOLOR = 'X'.
ITEM-TEXT = '0100'.
APPEND ITEM TO ITEM_TABLE.
CLEAR ITEM.
ITEM-NODE_KEY = 'SubChild2'.
ITEM-ITEM_NAME = '114'.
ITEM-CLASS = CL_GUI_LIST_TREE=>ITEM_CLASS_TEXT.
ITEM-LENGTH = 11.
ITEM-USEBGCOLOR = 'X'.
ITEM-TEXT = ' mueller'.
APPEND ITEM TO ITEM_TABLE.
CLEAR ITEM.
ITEM-NODE_KEY = 'SubChild2'.
ITEM-ITEM_NAME = '115'.
ITEM-CLASS = CL_GUI_LIST_TREE=>ITEM_CLASS_TEXT.
ITEM-ALIGNMENT = CL_GUI_LIST_TREE=>ALIGN_AUTO.
ITEM-FONT = CL_GUI_LIST_TREE=>ITEM_FONT_PROP.
ITEM-TEXT = ' comment to dynpro 100'.
APPEND ITEM TO ITEM_TABLE.
items of node with key 'SubChild3'.
CLEAR ITEM.
ITEM-NODE_KEY = 'SubChild3'.
ITEM-ITEM_NAME = '121'.
ITEM-CLASS = CL_GUI_LIST_TREE=>ITEM_CLASS_TEXT.
ITEM-LENGTH = 20.
ITEM-IGNOREIMAG = 'X'.
ITEM-USEBGCOLOR = 'X'.
ITEM-T_IMAGE = '@02@'.
ITEM-TEXT = ' 0200 harryhirsch'.
APPEND ITEM TO ITEM_TABLE.
CLEAR ITEM.
ITEM-NODE_KEY = 'SubChild3'.
ITEM-ITEM_NAME = '122'.
ITEM-CLASS = CL_GUI_LIST_TREE=>ITEM_CLASS_TEXT.
ITEM-ALIGNMENT = CL_GUI_LIST_TREE=>ALIGN_AUTO.
ITEM-FONT = CL_GUI_LIST_TREE=>ITEM_FONT_PROP.
ITEM-TEXT = ' comment to dynpro 200'.
APPEND ITEM TO ITEM_TABLE.
ENDFORM. " build_node_and_item_table
also i have sent a material to ur id
I hope you will get a clear idea on events
Regards,
Sowjanya -
Example programs on abap object events?
Hi Experts,
I need some example programs on abap object events.
regards,
vijayHi,
go thru the below program. hope it could help you.
REPORT sapmz_hf_alv_grid .
Type pool for icons - used in the toolbar
TYPE-POOLS: icon.
TABLES: zsflight.
To allow the declaration of o_event_receiver before the
lcl_event_receiver class is defined, decale it as deferred in the
start of the program
CLASS lcl_event_receiver DEFINITION DEFERRED.
G L O B A L I N T E R N A L T A B L E S
*DATA: gi_sflight TYPE STANDARD TABLE OF sflight.
To include a traffic light and/or color a line the structure of the
table must include fields for the traffic light and/or the color
TYPES: BEGIN OF st_sflight.
INCLUDE STRUCTURE zsflight.
Field for traffic light
TYPES: traffic_light TYPE c.
Field for line color
types: line_color(4) type c.
TYPES: END OF st_sflight.
TYPES: tt_sflight TYPE STANDARD TABLE OF st_sflight.
DATA: gi_sflight TYPE tt_sflight.
G L O B A L D A T A
DATA: ok_code LIKE sy-ucomm,
Work area for internal table
g_wa_sflight TYPE st_sflight,
ALV control: Layout structure
gs_layout TYPE lvc_s_layo.
Declare reference variables to the ALV grid and the container
DATA:
go_grid TYPE REF TO cl_gui_alv_grid,
go_custom_container TYPE REF TO cl_gui_custom_container,
o_event_receiver TYPE REF TO lcl_event_receiver.
DATA:
Work area for screen 200
g_screen200 LIKE zsflight.
Data for storing information about selected rows in the grid
DATA:
Internal table
gi_index_rows TYPE lvc_t_row,
Information about 1 row
g_selected_row LIKE lvc_s_row.
C L A S S E S
CLASS lcl_event_receiver DEFINITION.
PUBLIC SECTION.
METHODS:
handle_toolbar FOR EVENT toolbar OF cl_gui_alv_grid
IMPORTING
e_object e_interactive,
handle_user_command FOR EVENT user_command OF cl_gui_alv_grid
IMPORTING e_ucomm.
ENDCLASS.
CLASS lcl_event_receiver IMPLEMENTATION
CLASS lcl_event_receiver IMPLEMENTATION.
METHOD handle_toolbar.
Event handler method for event toolbar.
CONSTANTS:
Constants for button type
c_button_normal TYPE i VALUE 0,
c_menu_and_default_button TYPE i VALUE 1,
c_menu TYPE i VALUE 2,
c_separator TYPE i VALUE 3,
c_radio_button TYPE i VALUE 4,
c_checkbox TYPE i VALUE 5,
c_menu_entry TYPE i VALUE 6.
DATA:
ls_toolbar TYPE stb_button.
Append seperator to the normal toolbar
CLEAR ls_toolbar.
MOVE c_separator TO ls_toolbar-butn_type..
APPEND ls_toolbar TO e_object->mt_toolbar.
Append a new button that to the toolbar. Use E_OBJECT of
event toolbar. E_OBJECT is of type CL_ALV_EVENT_TOOLBAR_SET.
This class has one attribute MT_TOOLBAR which is of table type
TTB_BUTTON. The structure is STB_BUTTON
CLEAR ls_toolbar.
MOVE 'CHANGE' TO ls_toolbar-function.
MOVE icon_change TO ls_toolbar-icon.
MOVE 'Change flight' TO ls_toolbar-quickinfo.
MOVE 'Change' TO ls_toolbar-text.
MOVE ' ' TO ls_toolbar-disabled.
APPEND ls_toolbar TO e_object->mt_toolbar.
ENDMETHOD.
METHOD handle_user_command.
Handle own functions defined in the toolbar
CASE e_ucomm.
WHEN 'CHANGE'.
PERFORM change_flight.
LEAVE TO SCREEN 0.
ENDCASE.
ENDMETHOD.
ENDCLASS.
S T A R T - O F - S E L E C T I O N.
START-OF-SELECTION.
SET SCREEN '100'.
*& Module USER_COMMAND_0100 INPUT
MODULE user_command_0100 INPUT.
CASE ok_code.
WHEN 'EXIT'.
LEAVE TO SCREEN 0.
ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT
*& Module STATUS_0100 OUTPUT
MODULE status_0100 OUTPUT.
DATA:
For parameter IS_VARIANT that is sued to set up options for storing
the grid layout as a variant in method set_table_for_first_display
l_layout TYPE disvariant,
Utillity field
l_lines TYPE i.
After returning from screen 200 the line that was selected before
going to screen 200, should be selected again. The table gi_index_rows
was the output table from the GET_SELECTED_ROWS method in form
CHANGE_FLIGHT
DESCRIBE TABLE gi_index_rows LINES l_lines.
IF l_lines > 0.
CALL METHOD go_grid->set_selected_rows
EXPORTING
it_index_rows = gi_index_rows.
CALL METHOD cl_gui_cfw=>flush.
REFRESH gi_index_rows.
ENDIF.
Read data and create objects
IF go_custom_container IS INITIAL.
Read data from datbase table
PERFORM get_data.
Create objects for container and ALV grid
CREATE OBJECT go_custom_container
EXPORTING container_name = 'ALV_CONTAINER'.
CREATE OBJECT go_grid
EXPORTING
i_parent = go_custom_container.
Create object for event_receiver class
and set handlers
CREATE OBJECT o_event_receiver.
SET HANDLER o_event_receiver->handle_user_command FOR go_grid.
SET HANDLER o_event_receiver->handle_toolbar FOR go_grid.
Layout (Variant) for ALV grid
l_layout-report = sy-repid. "Layout fo report
Setup the grid layout using a variable of structure lvc_s_layo
Set grid title
gs_layout-grid_title = 'Flights'.
Selection mode - Single row without buttons
(This is the default mode
gs_layout-sel_mode = 'B'.
Name of the exception field (Traffic light field) and the color
field + set the exception and color field of the table
gs_layout-excp_fname = 'TRAFFIC_LIGHT'.
gs_layout-info_fname = 'LINE_COLOR'.
LOOP AT gi_sflight INTO g_wa_sflight.
IF g_wa_sflight-paymentsum < 100000.
Value of traffic light field
g_wa_sflight-traffic_light = '1'.
Value of color field:
C = Color, 6=Color 1=Intesified on, 0: Inverse display off
g_wa_sflight-line_color = 'C610'.
ELSEIF g_wa_sflight-paymentsum => 100000 AND
g_wa_sflight-paymentsum < 1000000.
g_wa_sflight-traffic_light = '2'.
ELSE.
g_wa_sflight-traffic_light = '3'.
ENDIF.
MODIFY gi_sflight FROM g_wa_sflight.
ENDLOOP.
Grid setup for first display
CALL METHOD go_grid->set_table_for_first_display
EXPORTING i_structure_name = 'SFLIGHT'
is_variant = l_layout
i_save = 'A'
is_layout = gs_layout
CHANGING it_outtab = gi_sflight.
*-- End of grid setup -
Raise event toolbar to show the modified toolbar
CALL METHOD go_grid->set_toolbar_interactive.
Set focus to the grid. This is not necessary in this
example as there is only one control on the screen
CALL METHOD cl_gui_control=>set_focus EXPORTING control = go_grid.
ENDIF.
ENDMODULE. " STATUS_0100 OUTPUT
*& Module USER_COMMAND_0200 INPUT
MODULE user_command_0200 INPUT.
CASE ok_code.
WHEN 'EXIT200'.
LEAVE TO SCREEN 100.
WHEN'SAVE'.
PERFORM save_changes.
ENDCASE.
ENDMODULE. " USER_COMMAND_0200 INPUT
*& Form get_data
FORM get_data.
Read data from table SFLIGHT
SELECT *
FROM zsflight
INTO TABLE gi_sflight.
ENDFORM. " load_data_into_grid
*& Form change_flight
Reads the contents of the selected row in the grid, ans transfers
the data to screen 200, where it can be changed and saved.
FORM change_flight.
DATA:l_lines TYPE i.
REFRESH gi_index_rows.
CLEAR g_selected_row.
Read index of selected rows
CALL METHOD go_grid->get_selected_rows
IMPORTING
et_index_rows = gi_index_rows.
Check if any row are selected at all. If not
table gi_index_rows will be empty
DESCRIBE TABLE gi_index_rows LINES l_lines.
IF l_lines = 0.
CALL FUNCTION 'POPUP_TO_DISPLAY_TEXT'
EXPORTING
textline1 = 'You must choose a line'.
EXIT.
ENDIF.
Read indexes of selected rows. In this example only one
row can be selected as we are using gs_layout-sel_mode = 'B',
so it is only ncessary to read the first entry in
table gi_index_rows
LOOP AT gi_index_rows INTO g_selected_row.
IF sy-tabix = 1.
READ TABLE gi_sflight INDEX g_selected_row-index INTO g_wa_sflight.
ENDIF.
ENDLOOP.
Transfer data from the selected row to screenm 200 and show
screen 200
CLEAR g_screen200.
MOVE-CORRESPONDING g_wa_sflight TO g_screen200.
LEAVE TO SCREEN '200'.
ENDFORM. " change_flight
*& Form save_changes
Changes made in screen 200 are written to the datbase table
zsflight, and to the grid table gi_sflight, and the grid is
updated with method refresh_table_display to display the changes
FORM save_changes.
DATA: l_traffic_light TYPE c.
Update traffic light field
Update database table
MODIFY zsflight FROM g_screen200.
Update grid table , traffic light field and color field.
Note that it is necessary to use structure g_wa_sflight
for the update, as the screen structure does not have a
traffic light field
MOVE-CORRESPONDING g_screen200 TO g_wa_sflight.
IF g_wa_sflight-paymentsum < 100000.
g_wa_sflight-traffic_light = '1'.
C = Color, 6=Color 1=Intesified on, 0: Inverse display off
g_wa_sflight-line_color = 'C610'.
ELSEIF g_wa_sflight-paymentsum => 100000 AND
g_wa_sflight-paymentsum < 1000000.
g_wa_sflight-traffic_light = '2'.
clear g_wa_sflight-line_color.
ELSE.
g_wa_sflight-traffic_light = '3'.
clear g_wa_sflight-line_color.
ENDIF.
MODIFY gi_sflight INDEX g_selected_row-index FROM g_wa_sflight.
Refresh grid
CALL METHOD go_grid->refresh_table_display.
CALL METHOD cl_gui_cfw=>flush.
LEAVE TO SCREEN '100'.
ENDFORM. " save_changes
regards
-Rakesh -
Hi,
I would like create new PO workflow (BUS2012) using ABAP OO workflow. Is it possible to use the existing BOR event, such as RELEASESTEPCREATED instead of creating new one for the ABAP OO workflow class? And if we can re-use the event, how do we bind the BOR to the class object?
ThanksHello Jani,
I just spotted this almost by accident. It is custom on this forum to ask new questions in a new thread. Why? Because your question is unrelated to the title of this thread, so it already has less chance to come to the attention of someone who knows the answer. Of course you can always place a link to an older thread into a new question as well.
Anyhow, to your question, you should use a RETURNING parameter, which enables you to perform the instantiation in a container operation step - far better performance-wise. This is described in detail in the WF book (all authors' proceeds donated to charity). But you're of course always still welcome to ask further questions on here if you get stuck.
Regards,
Mike -
ABAP webdynpro events in Portal
Hi All,
I am a novice in Portal. I am not sure if this is the right forum also to ask this question.
I created an application in ABAP webdynpro , created an iview using the ABAP webdynpro option.
My scenario : I have to create a work request in a ztable that I have created.
For this 1) create a uniques number using number_get_next
2) insert the values into the z table and show message
what is happening -->
Application appears with no problems.
when I click on button message appears
What is not happening on the portal
number get next doesnot get created
data doesnot get inserted in ztable
portal and abap webdynpro are on different URL
I tried to subscribe events that also didnot work .:(
Appreciate all the help.
Regards,
NarayaniHi All,
solved as below.
Regards,
Narayani -
Process Chain Review Question: function module/ABAP program/Event
Hi,
1. Can you tell me a bit more about function modules such as RSPC_CHAIN_ACTIVATE_REMOTE
2. What are function modules in general terms. i.e. What is their role?
3. How do I see all function module available?
4. When is function module used instead of ABAP program?
5. How do they help in the support and monitoring of Process Chains?
6. I am getting confused over the following under process chains job, event, function module and ABAP Program
Thanks2. What are function modules in general terms. i.e. What is their role?
Function module return a value ( most of the time), they return some value either a single value of rane of value or even a table. Example: FM to return fiscal period gieven the fiscal vaeiant and system date.
3. How do I see all function module available?
Go to Se37 and this is function builder. You will find FM starting with RS* more useful. You cna also create your own in Se37.
4. When is function module used instead of ABAP program?
In addtion to answer I gave in 3 above, program is used to check some logic and update some tables or give screen output.
You may note FM is also a program.
5. How do they help in the support and monitoring of Process Chains?
As I said, for monitoring chains, use Sm37 and logs in RSPC.
6. I am getting confused over the following under process chains job, event, function module and ABAP Program
I am not clear what are you looking for.
You cna schedule a FM or a program to run in a chain. Is that what you mean?
Ravi Thothadri -
WD(ABAP) - Oncheck Event by Interactive Form
Accessing Adobe Lifecycle Designer through Web Dynpro workplace will provide you with a set of fields in a special library called "Web Dynpro", in which I find some interesting element. Most of them are mentioned in the following place:
<a href="http://help.sap.com/saphelp_nw04/helpdata/en/1e/05853ff8ec2c17e10000000a114084/frameset.htm">http://help.sap.com/saphelp_nw04/helpdata/en/1e/05853ff8ec2c17e10000000a114084/frameset.htm</a>
As I understood, the script within field triggers a Web Dynpro event allowing developer to realize the value check, search help functions in PDF. For example: the "Check Field" button delivers the code:
app.eval("event.target.SAPCheckFields();");
In Netweaver developer Studio, an Oncheck event is linked with Interactive Form, you find it under the event property. However I cannot find the same event in Web Dynpro ABAP. Does it mean Web Dynpro ABAP doesn't support the oncheck event of interactive form?
I have tried to drag and drop a Check Field button on the form. When I click it at runtime, IE returns error message. Looking into ST22, The exception is CX_WDR_ADAPTER_UNKNOWN_EVENT' was raised.
Does somebody have clue? I appreciated your help on this.It's ugly, but it's true:
At this point in time, Web Dynpro for ABAP has only one Interactive-Forms-specific standard event (compared to the 2 in Java), which is the Submit event. I am hoping that both Web Dynpro worlds will be on the same level in terms of features in the next release.
Best regards,
Markus Meisl
SAP NetWeaver Product Management -
HI,
In any of the typical ABAP programs, we have some events that are native to ABAP runtime (e.g., initialization, start-of-selection,etc),now, i need to know that on which order these events will get executed. also below I've given the events just order them on their execution basis.
initialization
start-of-selection
top-of-page
end-of-page
at selection-screen
end-of-selection
at user-command
at selection-screen output
Regards,
Srikanth.P.hi use this....
REPORT zwk22671 LINE-COUNT 40(3)
LINE-SIZE 200
NO STANDARD PAGE HEADING.
*TABLES
TABLES : mkpf , "MATERIAL DOCUMENT
mseg , "DOCUMENT SEGMENT : MATERIAL
t156t , "MOVEMENT TYPE TEXT
makt. "MATERIAL DESCRIPTIONS
**DECLARATION OF STRUCTURE , INTERNAL TABLES , VARIABLES
*STRUCTURE OF INTERNAL TABLES
DATA : BEGIN OF xtab,
mblnr TYPE mkpf-mblnr , "DOCUMENT NUMBER
mjahr TYPE mkpf-mjahr , "YEAR
budat TYPE mkpf-budat , "POST DATE
blart TYPE mkpf-blart , "DOCUMENT TYPE
END OF xtab.
DATA : BEGIN OF ytab,
mblnr TYPE mseg-mblnr , "DOCUMENT NUMBER
mjahr TYPE mseg-mjahr , "YEAR
zeile TYPE mseg-zeile , "ITEM NUMBER
bwart TYPE mseg-bwart , "MOVEMENT TYPE
btext TYPE t156t-btext , "MOVEMENT DESCRIPTION
matnr TYPE mseg-matnr , "MATERIAL NUMBER
maktx TYPE makt-maktx , "MATERIAL DESCRIPTION
meins TYPE mseg-meins , "UNIT OF MEASURE
menge TYPE mseg-menge , "QUANTITY
dmbtr TYPE mseg-dmbtr , "AMOUNT
END OF ytab.
*INTERNAL TABLE DECLARATION
DATA : i_tab1 LIKE STANDARD TABLE OF xtab WITH HEADER LINE. "INTERNAL TABLE 1 : CONTAINS MATERIAL DETAILS
DATA : i_tab2 LIKE STANDARD TABLE OF ytab WITH HEADER LINE. "INTERNAL TABLE 2 : CONTAINS ITEMWISE MATERIAL DETAILS
*VARIABLES
DATA : v_color TYPE sy-tabix , "FOR SETTING COLOR FORMATS DURING GENERATING REPORT
v_field(20) , "FOR STORING THE CLICKED FIELD NAME
v_value(20) , "FOR STORING THE CLICKED FIELD VALUE
v_mblnr TYPE mkpf-mblnr , "FOR VALIDATING DOCUMENT NUMBER
v_mjahr TYPE mkpf-mjahr , "FOR VALIDATING DOCUMENT YEAR
v_bwart TYPE mseg-bwart , "FOR VALIDATING MOVEMENT TYPE
v_matnr TYPE mseg-matnr . "FOR VALIDATING MATERIAL NUMBER
**SELECTION-SCREEN
SELECTION-SCREEN : BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001.
SELECT-OPTIONS : s_mblnr FOR mkpf-mblnr , "DOCUMENT NUMBER
s_mjahr FOR mkpf-mjahr OBLIGATORY, "DOCUMENT YEAR
s_bwart FOR mseg-bwart NO INTERVALS NO-EXTENSION, "MOVEMENT TYPE
s_matnr FOR mseg-matnr . "MATERIAL NUMBER
SELECTION-SCREEN : END OF BLOCK blk1.
AT SELECTION-SCREEN
AT SELECTION-SCREEN.
PERFORM validation. "PERFORMS VALIDATION OF SELECTION-SCREEN FIELDS
*TOP-OF-PAGE
TOP-OF-PAGE.
PERFORM header. "CREATES HEADER FOR THE BASIC LIST
*END-OF-PAGE
END-OF-PAGE. "CREATES FOOTER FOR THE BASIC AND SECONDARY LIST
PERFORM footer.
*START-OF-SELECTION
START-OF-SELECTION.
PERFORM generation_basic. "GENERATES REPORT FOR BASIC LIST WHICH CONTAINS DOCUMENT NO , DOCUMENT YEAR
"POST DATE , DOCUMENT TYPE.
*END-OF-SELECTION
END-OF-SELECTION.
PERFORM report_basic. "DISPLAY REPORT FOR BASIC LIST
*AT LINE-SELECTION
AT LINE-SELECTION.
PERFORM generation_secondary. "GENERATES REPORT FOR SECONDARY LIST BASED ON THE DOCUMENT NUMBER AND DOCUMENT YEAR
"WHICH CONTAINS DOCUMENT NO , YEAR , ITEM NO , MOVEMENT TYPE , MOVEMENT DESCRIPTION ,
"MATERIAL NUMBER , MATERIAL DESC , UNIT OF MEASURE , QUANTITY AND AMOUNT
*TOP-OF-PAGE DURING LINE-SELECTION
TOP-OF-PAGE DURING LINE-SELECTION.
PERFORM header_secondary. "CREATES HEADER FOR THE SECONDARY LIST
*AT USER-COMMAND
AT USER-COMMAND.
PERFORM user_secondary. "SUBROUTINE FOR HANDLING USER EVENTS
*& Form VALIDATION
text
--> p1 text
<-- p2 text
FORM validation .
*VALIDATING MATERIAL DOCUMENT NUMBER
SELECT SINGLE mblnr
INTO v_mblnr
FROM mkpf
WHERE mblnr IN s_mblnr.
IF sy-subrc NE 0.
MESSAGE 'ENTER CORRECT DOCUMENT NUMBER' TYPE 'E'.
ENDIF.
*VALIDATING MATERIAL DOCUMENT YEAR
SELECT SINGLE mjahr
INTO v_mjahr
FROM mkpf
WHERE mjahr IN s_mjahr.
IF sy-subrc NE 0.
MESSAGE 'ENTER CORRECT MATERIAL DOCUMENT YEAR' TYPE 'E'.
ENDIF.
*VALIDATING MOVEMENT TYPE
SELECT SINGLE bwart
INTO v_bwart
FROM mseg
WHERE bwart IN s_bwart.
IF sy-subrc NE 0.
MESSAGE 'ENTER CORRECT MOVEMENT TYPE' TYPE 'E'.
ENDIF.
*VALIDATING MATERIAL NUMBER
SELECT SINGLE matnr
INTO v_matnr
FROM mseg
WHERE matnr IN s_matnr.
IF sy-subrc NE 0.
MESSAGE 'ENTER CORRECT MATERIAL NUMBER' TYPE 'E'.
ENDIF.
ENDFORM. " VALIDATION
*& Form HEADER
text
--> p1 text
<-- p2 text
FORM header .
WRITE :/30 'MATERIAL DOCUMENTS' COLOR 1. "TITLE OF BASIC LIST
WRITE :/1(89) sy-uline.
FORMAT COLOR 1.
WRITE :/1 sy-vline ,
3 'DOCUMENT NUMBER' ,
23 sy-vline ,
25 'YEAR' ,
45 sy-vline ,
47 'POST DATE' ,
67 sy-vline ,
69 'DOCTYP' ,
89 sy-vline .
FORMAT RESET.
WRITE :/1(89) sy-uline.
ENDFORM. " HEADER
*& Form FOOTER
text
--> p1 text
<-- p2 text
FORM footer .
IF sy-lsind EQ 0. "CHECKS WHICH LIST IS IT BASIC LIST OR SECONDARY (AND NO. OF SECONDARY LIST)
WRITE :/1(89) sy-uline.
ELSEIF sy-lsind EQ 1.
WRITE :/1(192) sy-uline.
ENDIF.
ENDFORM. " FOOTER
*& Form GENERATION_BASIC
text
--> p1 text
<-- p2 text
FORM generation_basic .
SELECT mkpf~mblnr "DOCUMENT NUMBER
mkpf~mjahr "DOCUMENT YEAR
mkpf~budat "POST DATE
mkpf~blart "DOCUMENT TYPE
INTO TABLE i_tab1
FROM mkpf INNER JOIN mseg ON mkpfmjahr EQ msegmjahr AND
mkpfmblnr EQ msegmblnr
WHERE mkpf~mblnr IN s_mblnr
AND mkpf~mjahr IN s_mjahr
AND mseg~bwart IN s_bwart
AND mseg~matnr IN s_matnr.
IF sy-subrc NE 0.
WRITE :/ 'MATERIAL DATA NOT FOUND'.
ENDIF.
DELETE ADJACENT DUPLICATES FROM i_tab1 COMPARING mblnr mjahr.
ENDFORM. " GENERATION_BASIC
*& Form REPORT_BASIC
text
--> p1 text
<-- p2 text
FORM report_basic .
LOOP AT i_tab1.
v_color = sy-tabix MOD 2.
IF v_color EQ 0.
FORMAT COLOR 1 INTENSIFIED OFF.
ELSE.
FORMAT COLOR 2 INTENSIFIED OFF.
ENDIF.
WRITE :/1 sy-vline ,
3 i_tab1-mblnr ,
23 sy-vline ,
25 i_tab1-mjahr ,
45 sy-vline ,
47 i_tab1-budat ,
67 sy-vline ,
69 i_tab1-blart ,
89 sy-vline .
HIDE : i_tab1-mblnr , i_tab1-mjahr. "STORING THE VALUE OF FIELDS CLICKED IN SYSTEM AREA
ENDLOOP.
FORMAT RESET.
WRITE :/1(89) sy-uline.
ENDFORM. " REPORT_BASIC
*& Form GENERATION_SECONDARY
text
--> p1 text
<-- p2 text
FORM generation_secondary .
IF sy-lsind EQ 1.
SET PF-STATUS 'DISPLAY'.
GET CURSOR FIELD v_field VALUE v_value. "GET THE FIELD VALUE AND NAME WHERE THE CURSOR WAS CLICKED
CASE v_field.
WHEN 'I_TAB1-MBLNR'. "DISPLAYS SECONDARY LIST ONLY IF DOCUMENT NUMBER IS CLICKED
SELECT mseg~mblnr "DOCUMENT NUMBER
mseg~mjahr "DOCUMENT YEAR
mseg~zeile "ITEM NUMBER
mseg~bwart "MOVEMENT TYPE
t156t~btext "MOVEMENT DESCRIPTION
mseg~matnr "MATERIAL NUMBER
makt~maktx "MATERIAL DESCRIPTION
mseg~meins "UNIT OF MEASURE
mseg~menge "QUANTITY
mseg~dmbtr "AMOUNT
INTO TABLE i_tab2
FROM ( ( mseg INNER JOIN t156t
ON msegbwart EQ t156tbwart )
INNER JOIN makt
ON msegmatnr EQ maktmatnr )
WHERE mseg~mblnr EQ i_tab1-mblnr
AND mseg~mjahr EQ i_tab1-mjahr
AND t156t~spras EQ sy-langu
AND makt~spras EQ sy-langu.
DELETE ADJACENT DUPLICATES FROM i_tab2 COMPARING mblnr mjahr.
WHEN OTHERS.
MESSAGE 'SELECT DOCUMENT NUMBER' TYPE 'E'.
ENDCASE.
LOOP AT i_tab2.
v_color = sy-tabix MOD 2.
IF v_color EQ 0.
FORMAT COLOR 1 INTENSIFIED OFF.
ELSE.
FORMAT COLOR 2 INTENSIFIED OFF.
ENDIF.
WRITE :/1 sy-vline ,
3 i_tab2-mblnr ,
12 sy-vline ,
14 i_tab2-mjahr ,
19 sy-vline ,
21 i_tab2-zeile ,
30 sy-vline ,
32 i_tab2-bwart ,
40 sy-vline ,
42 i_tab2-btext ,
72 sy-vline ,
74 i_tab2-matnr ,
94 sy-vline ,
96 i_tab2-maktx ,
146 sy-vline ,
148 i_tab2-meins ,
153 sy-vline ,
155 i_tab2-menge ,
170 sy-vline ,
172 i_tab2-dmbtr ,
192 sy-vline .
ENDLOOP.
WRITE :/1(192) sy-uline.
FORMAT RESET.
ELSEIF sy-lsind EQ 2.
GET CURSOR FIELD v_field VALUE v_value. "GET THE FIELD VALUE AND NAME WHERE THE CURSOR WAS CLICKED
CASE v_field.
WHEN 'I_TAB2-MBLNR'. "DISPLAYS SECONDARY LIST ONLY IF DOCUMENT NUMBER IS CLICKED
SET PARAMETER ID : "SETTING PARAMETER ID FOR DOCUMENT NUMBER AND YEAR.
'MBN' FIELD i_tab2-mblnr ,
'MJA' FIELD i_tab2-mjahr.
CALL TRANSACTION 'MB03' AND SKIP FIRST SCREEN. "CALLING TRABSACTION CODE 'MBO3'.
WHEN OTHERS.
MESSAGE 'SELECT DOCUMENT NUMBER' TYPE 'E'.
ENDCASE.
ENDIF.
ENDFORM. " GENERATION_SECONDARY
*& Form HEADER_SECONDARY
text
--> p1 text
<-- p2 text
FORM header_secondary .
WRITE :/50 'ITEMWISE MATERIAL DOCUMENTS' COLOR 1.
WRITE :/1(192) sy-uline.
FORMAT COLOR 1.
WRITE :/1 sy-vline ,
3 'DOCUMENT NO' ,
12 sy-vline ,
14 'YEAR' ,
19 sy-vline ,
21 'ITEM NO.' ,
30 sy-vline ,
32 'MOV TYP' ,
40 sy-vline ,
42 'MOV DESCRIPTION' ,
72 sy-vline ,
74 'MATERIAL NO' ,
94 sy-vline ,
96 'MATERIAL DESCRIPTION' ,
146 sy-vline ,
148 'UOM' ,
153 sy-vline ,
155 'QUANTITY' ,
170 sy-vline ,
172 'AMOUNT' ,
192 sy-vline .
WRITE :/1(192) sy-uline.
FORMAT RESET.
ENDFORM. " HEADER_SECONDARY
*& Form USER_SECONDARY
text
--> p1 text
<-- p2 text
FORM user_secondary .
IF sy-ucomm EQ 'DISPLAY'. "EXECUTES ONLY IF 'DISPLAY DOCUMENTS' ITEM IS CLICKED ON APPLICATION TOOL BAR.
IF sy-lsind EQ 2.
GET CURSOR FIELD v_field VALUE v_value. "GET THE FIELD VALUE AND NAME WHERE THE CURSOR WAS CLICKED
CASE v_field.
WHEN 'I_TAB2-MBLNR'. "DISPLAYS SECONDARY LIST ONLY IF DOCUMENT NUMBER IS CLICKED
SET PARAMETER ID :
'MBN' FIELD i_tab2-mblnr ,
'MJA' FIELD i_tab2-mjahr.
CALL TRANSACTION 'MB03' AND SKIP FIRST SCREEN.
WHEN OTHERS.
MESSAGE 'SELECT DOCUMENT NUMBER' TYPE 'E'.
ENDCASE.
ENDIF.
LEAVE PROGRAM.
ENDIF.
ENDFORM. " USER_SECONDARY
**& Module USER_COMMAND_0100 INPUT
text
*module USER_COMMAND_0100 input.
*if sy-ucomm eq 'SUBMIT'.
*submit zwk22671. " and return using selection-set 'MATERIAL VAR'.
*ENDIF.
*endmodule. " USER_COMMAND_0100 INPUT
regards,
venkat. -
Webdynpro abap onChange event for input
Hello,
I wanted to know if "onChange" event for input field is somehow possible in wd abap or if it is planned for next ehp releases
of ECC6.
(Like in Developer studio 7.11)
thanks.Hi Thomas,
Opening in on a Very old post, but i kind of need an onChange event functionality in one of my Web App. Basically we are dealing with a input field which is populated using a barcode scanner and the user wishes to be able to pull all the information related to the material number read by the scanner in an Input Field Element and display the related info in other fields "Without having to hit ENTER". Sounds a bit lazy but thts wht they need.
I was wondering if its possible to modify the SuggestValue functionality to implement such an event. Any pointers to documents which explain how the SuggestValue works? I am just looking for code blocks (even if they are AJAX/Javascripts) tht i can somehow modify to make this thing work.
P.S. Also if there is any other functionality already introduced by SAP since the last comment on this thread to help solve this will be helpful too
Thanks,
Parth -
Control not going from Adobe Interactive form to ABAP WD Event handler
Hi
I am facing an issue with adobe interactive forms and WD ABAP integration.
The buttons in adobe interactive form when clicked is going round and round and the control is not going to the ABAP code(WD ABAP event handler code whatsoever). I have also set the debugger but the control is not moving to the ABAP code from the adobe interactive form.
Can anyone help me what can be the issue here and how can I resolve the same?
Thanks.
SidHi Babi,
In the adobe form layout library Use the Submit(which internally means submit to SAP) button from the Webdynpro Native category.
Only this button action can connect adobe to web dynpro.
Whenever we click on this particular button the event will be trigger in the ONsubmit event of interactive form UI element in the webdynpro.There we can write our abap code.Hope this will help you.
Regards,
Simi A M
Edited by: amsimi on Mar 22, 2011 11:37 AM -
Use abap class event as terminating event
Hi,
The class is say ZCL_WF_CLASS and the event END_WF.
What needs to be done to have this event used correctly as a terminating event of a workflow? Does this event require a parameter to hold the workitem id (or workflow id), as currently this event has no parameters?
Previous developer has developed the class and event and installed as a terminating event but the workflow is going into error not terminating correctly. I believe the incorrect development of the event and/or its use in the workflow is the issue. Note that nowhere is this event currently raised in any code of the workflow.
Cheers,
RossHello,
Unless I'm mistaken, a terminating event for a workflow is just like any wait-for event in a workflow.
It can be based on any object or class and it can be used in various ways - to terminate a branch or terminate the workflow, for example.
The workflow listens out for the event and checks if there is a matching key. You could base it on the key of a workflow object but it makes more sense to base it on an object or class that's used in the workflow - e.g. the POSTED event of an object would be used to terminate a workflow seeking approval for the posting of an object.
It definitely won't work if the event has no parameters. I guess if you do base it on the workflow object then you would use the top-level workitem id. Try it with a test workflow and SWUE to generate the event.
regards
Rick Bakker
hanabi technology -
What is abap program events & when it gets Trigered
Sinha
This is another list
Events in alv and their FM
Please tell me what are the main events in alv and their FM and
why we use these:
1. SLIS_PRINT_ALV.
2. SLIS_T_LISTHEADER.
3. SLIS_T_EVENT.
4. SLIS_T_SORTINFO_ALV.
5. SLIS_T_LAYOUT_ALV.
6. SLIS_T_FIELDCAT_ALV.
and in classic reports what is the sequence of events:
=== Events are
At selection-screen output.
Initialization.
At selection-screen on field
At selection-screen on end of field
At selection-screen on Radiobutton Group R1. (If you have any radio buttons)
At selection-screen on block b1. (If you have any blocks)
Start-of-selection.
Get node. (if the data is retreived from a logical database)
Get node late. (if the data is retreived from a logical database)
Top-of-page. (if the write statement is in the end-of-selection event or we can say that before the first write statement)
end-of-selection.
and fuction modules are
LISTHEADER - Is used to print the header information in the ALV List. Name, Date, Time, ALV Name and other details are called as Header information.
EVENT - Basically this is the FM to handle Event's. When the user needs to do some event operation like when double clicking the a particular field we need to perform some operation.
These events are captured by this FM.
LAYOUT - This FM is used to define the layout of the List. There are many options available in this FM to define the Layout style.
FIELDCAT - These are used to populate the List header. We can change them according to our req.
These are some of the FM. I hope it is useful.
Reward points if it is usefull. ...
Girish
Maybe you are looking for
-
Song dissapeared from my iPhone and iTunes account
I recently purchased an Album for my kids (Madagascar 2) and have been listening to it near daily on my iPhone. There is one song in particular that they love (The Traveling Song) that could only be purchased by buying the entire album. For some reas
-
Hi, I've recently updated Lumia Imaging SDK to v 2 in my app and sometimes I started to get the below exception: [TypeLoadException: Requested Windows Runtime type 'Lumia.Imaging.JpegTools' is not registered.] System.StubHelpers.StubHelpers.GetWi
-
How do i change the computer user name
I registered the computer as under my name originally. I want to change it to my daughters name. How can I do this?
-
Efficient way of saving documents uploaded by users
Hello Experts, We are looking out for an efficient way of storing of documents uploaded by the users. Below is the explanation of our scenario in detail. We are working on the SAP E-Recruiting module and have designed custom Interactive Adobe Forms &
-
Hi Gurrus, Could you please suggest should better option for outline creation in planning application (9.3.1) should i prefer through Planning or essbase and few steps if possible will be useful for me. Thanks N Kumar