Create an event using abap class (transaction swetypv)
Hi,
Im trying to create an event by using an abap class.
The purpose is to update po reqs using BAPI_REQUISITION_CHANGE upon saving a sales order. The exit is called on saving a sales order MV45AFZZ.
In MV45AFZZ the method cl_swf_evt_event is called and the object type, event, objkey and obj cat is exported.
Object Type = ZBUS203200
Event = Z_TRAD_ORDER_CHANGE_OO
I created my class ZCL_UPDATE_PUR_REQ (by copying CL_SWF_RUN_WIM_HANDLER
And using interface name BI_EVENT_HANDLER_STATIC )
In /nswetypv I assigned Class ZCL_UPDATE_PUR_REQ
to Object Type ZBUS203200
And Event Z_TRAD_ORDER_CHANGE_OO.
All that works fine except for passing in the objectkey.
In Class ZCL_UPDATE_PUR_REQ
Method BI_EVENT_HANDLER_STATIC~ON_EVENT
When I go to create a parameter for object key, I get the message
Parameters/exceptions of inherited methods or events cannot be changed.
Has anyone any suggestions for how I can get the object key into the method call BI_EVENT_HANDLER_STATIC~ON_EVENT?
Thanks
Ann
Hi Johann,
You don't need a class to do the job if you are on a 6.10 or higher system. Use command CALL TRANSFORMATION to create an XML from an internal table.
Regards,
John.
Similar Messages
-
Create an event using abap class
Hi,
Im trying to create an event by using an abap class.
The purpose is to update po reqs using BAPI_REQUISITION_CHANGE upon saving a sales order. The exit is called on saving a sales order MV45AFZZ.
In MV45AFZZ the method cl_swf_evt_event is called and the object type, event, objkey and obj cat is exported.
Object Type = ZBUS203200
Event = Z_TRAD_ORDER_CHANGE_OO
I created my class ZCL_UPDATE_PUR_REQ (by copying CL_SWF_RUN_WIM_HANDLER
And using interface name BI_EVENT_HANDLER_STATIC )
In /nswetypv I assigned Class ZCL_UPDATE_PUR_REQ
to Object Type ZBUS203200
And Event Z_TRAD_ORDER_CHANGE_OO.
All that works fine except for passing in the objectkey.
In Class ZCL_UPDATE_PUR_REQ
Method BI_EVENT_HANDLER_STATIC~ON_EVENT
When I go to create a parameter for object key, I get the message
Parameters/exceptions of inherited methods or events cannot be changed.
Has anyone any suggestions for how I can get the object key into the method call BI_EVENT_HANDLER_STATIC~ON_EVENT?
Thanks
AnnHi Johann,
You don't need a class to do the job if you are on a 6.10 or higher system. Use command CALL TRANSFORMATION to create an XML from an internal table.
Regards,
John. -
ALV using ABAP Classes and Objects
Hi All,
I am trying to print the values in my internal table using ALV, using ABAP classes and objects. Here the title for columns are picked based on the title specified in the data element. I want to set the title of my columns by my own. how to achieve this ?. Please provide me a sample code if possible.
thanks & regards,
Navneeth.KHello Navneeth
The following sample report shows how to build and modify a fieldcatalog (routine <b>BUILD_FIELDCATALOG_KNB1</b>).
*& Report ZUS_SDN_ALVGRID_EVENTS
REPORT zus_sdn_alvgrid_events.
DATA:
gd_okcode TYPE ui_func,
gt_fcat TYPE lvc_t_fcat,
go_docking TYPE REF TO cl_gui_docking_container,
go_grid1 TYPE REF TO cl_gui_alv_grid.
DATA:
gt_knb1 TYPE STANDARD TABLE OF knb1.
PARAMETERS:
p_bukrs TYPE bukrs DEFAULT '2000' OBLIGATORY.
* CLASS lcl_eventhandler DEFINITION
CLASS lcl_eventhandler DEFINITION.
PUBLIC SECTION.
CLASS-METHODS:
handle_hotspot_click FOR EVENT hotspot_click OF cl_gui_alv_grid
IMPORTING
e_row_id
e_column_id
es_row_no
sender.
ENDCLASS. "lcl_eventhandler DEFINITION
* CLASS lcl_eventhandler IMPLEMENTATION
CLASS lcl_eventhandler IMPLEMENTATION.
METHOD handle_hotspot_click.
* define local data
DATA:
ls_knb1 TYPE knb1,
ls_col_id TYPE lvc_s_col.
READ TABLE gt_knb1 INTO ls_knb1 INDEX e_row_id-index.
CHECK ( ls_knb1-kunnr IS NOT INITIAL ).
CASE e_column_id-fieldname.
WHEN 'KUNNR'.
SET PARAMETER ID 'KUN' FIELD ls_knb1-kunnr.
SET PARAMETER ID 'BUK' FIELD ls_knb1-bukrs.
CALL TRANSACTION 'XD03' AND SKIP FIRST SCREEN.
WHEN 'ERNAM'.
* SET PARAMETER ID 'USR' FIELD ls_knb1-ernam.
* NOTE: no parameter id available, yet simply show the priciple
CALL TRANSACTION 'SU01' AND SKIP FIRST SCREEN.
WHEN OTHERS.
* do nothing
ENDCASE.
* Set active cell to field BUKRS otherwise the focus is still on
* field KUNNR which will always raise event HOTSPOT_CLICK
ls_col_id-fieldname = 'BUKRS'.
CALL METHOD go_grid1->set_current_cell_via_id
EXPORTING
is_row_id = e_row_id
is_column_id = ls_col_id.
ENDMETHOD. "handle_hotspot_click
ENDCLASS. "lcl_eventhandler IMPLEMENTATION
START-OF-SELECTION.
SELECT * FROM knb1 INTO TABLE gt_knb1
WHERE bukrs = p_bukrs.
* Create docking container
CREATE OBJECT go_docking
EXPORTING
parent = cl_gui_container=>screen0
ratio = 90
EXCEPTIONS
OTHERS = 6.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* Create ALV grid
CREATE OBJECT go_grid1
EXPORTING
i_parent = go_docking
EXCEPTIONS
OTHERS = 5.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* Set event handler
SET HANDLER:
lcl_eventhandler=>handle_hotspot_click FOR go_grid1.
* Build fieldcatalog and set hotspot for field KUNNR
PERFORM build_fieldcatalog_knb1.
* Display data
CALL METHOD go_grid1->set_table_for_first_display
CHANGING
it_outtab = gt_knb1
it_fieldcatalog = gt_fcat
EXCEPTIONS
OTHERS = 4.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* Link the docking container to the target dynpro
CALL METHOD go_docking->link
EXPORTING
repid = syst-repid
dynnr = '0100'
* CONTAINER =
EXCEPTIONS
OTHERS = 4.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* ok-code field = GD_OKCODE
CALL SCREEN '0100'.
END-OF-SELECTION.
*& Module STATUS_0100 OUTPUT
* text
MODULE status_0100 OUTPUT.
SET PF-STATUS 'STATUS_0100'.
* SET TITLEBAR 'xxx'.
ENDMODULE. " STATUS_0100 OUTPUT
*& Module USER_COMMAND_0100 INPUT
* text
MODULE user_command_0100 INPUT.
CASE gd_okcode.
WHEN 'BACK' OR
'END' OR
'CANC'.
SET SCREEN 0. LEAVE SCREEN.
WHEN OTHERS.
ENDCASE.
CLEAR: gd_okcode.
ENDMODULE. " USER_COMMAND_0100 INPUT
*& Form BUILD_FIELDCATALOG_KNB1
* text
* --> p1 text
* <-- p2 text
FORM build_fieldcatalog_knb1 .
* define local data
DATA:
ls_fcat TYPE lvc_s_fcat.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
* I_BUFFER_ACTIVE =
i_structure_name = 'KNB1'
* I_CLIENT_NEVER_DISPLAY = 'X'
* I_BYPASSING_BUFFER =
* I_INTERNAL_TABNAME =
CHANGING
ct_fieldcat = gt_fcat
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
LOOP AT gt_fcat INTO ls_fcat
WHERE ( fieldname = 'KUNNR' OR
fieldname = 'ERNAM' ).
ls_fcat-hotspot = abap_true.
ls_fcat-scrtext_s = '<short text>'. " short text of column
ls_fcat-scrtext_m = '<medium text>'. " medium text of column
ls_fcat-scrtext_l = '<long text>'. " longtext text of column
ls_fcat-tooltip = '...'. " ALV control: Tool tip for column header
ls_fcat-coltext = '...'. " ALV control: Column heading
MODIFY gt_fcat FROM ls_fcat.
ENDLOOP.
ENDFORM. " BUILD_FIELDCATALOG_KNB1
Regards
Uwe -
Calling Portal event from ABAP class
Hi Experts,
I need a following clarificatrion, Please help,
1. Is it possible to call a webdynpro method from a normal ABAP class?
2. If no, we need a functionality of a class 'CL_WDR_HTTP_EXT_MIME_HANDLER' having method 'DO_DOMAIN_RELAX_HTML'.
Is there any alternative method which can be used in ABAP having the same functionality.
3. Is there any ways with which we can call portal event from ABAP class?
Thanks,
Shabir>1. Is it possible to call a webdynpro method from a normal ABAP class?
I wouldn't necessarily recommend this approach. You shouldn't try to trigger events or any of the standard WDDO* methods from outside the WD Component itself. That said, you can pass the object reference (like the WD_COMP_CONTROLLER object reference or the View Object Reference) into methods of normal classes. Be careful if you are finding yourself calling a lot of your added methods from outside WD. This is probably a sign that these methods should be in the Assistance Class or some other Class functioning as a Model Object.
>2. If no, we need a functionality of a class 'CL_WDR_HTTP_EXT_MIME_HANDLER' having method 'DO_DOMAIN_RELAX_HTML'.
Is there any alternative method which can be used in ABAP having the same functionality.
What exactly do you want to do here? Do you just want to get the relaxation script? For what purpose? You should never need to inject the relaxation script into WDA.
>3. Is there any ways with which we can call portal event from ABAP class?
To what purpose. Do you just want to delegate the triggering of the event that is inside WD Component to be called from a class? If so you can pass the portal API object reference into a class from the WD Component. However this only works while running within WD.
How is this class used? Are you running in WD? Are you trying to generate some HTML code that runs in the portal independent of WD? -
Function module equivalent to SWE_EVENT_CREATE while using ABAP classes
Hi there,
I used to use SWE_CREATE_EVENT to fire the events linked to my BOR objects, in order to start certain workflows.
Now I am using ABAP classes within the WorkFlows, and the name of the classes MUST (in my case) be longer than 10 characters, and SWE_EVENT_CREATE is cutting the name so it does not work
Do you know any FM equivalent to start an event from a ABAP class (SE24) object?
I have tried to use SAP_WAPI_START_WORKFLOW, but I cannot find the way to include my object in the container. Any ideas on this point would be welcome as well
Thanks so much,
MiguelThanks for such a quick reply,
You were right. I actually did follow Jocelyn's blogs, but somehow I skipped the raising event section.
Just for information, the URL with the solution to this problem is:
/people/jocelyn.dart/blog/2006/07/27/raising-abap-oo-events-for-workflow
Have a good one -
Creating a triangle using polygon class problem, URGENT??
Hi i am creating a triangle using polygon class which will eventually be used in a game where by a user clicks on the screen and triangles appear.
class MainWindow extends Frame
private Polygon[] m_polyTriangleArr;
MainWindow()
m_nTrianglesToDraw = 0;
m_nTrianglesDrawn = 0;
m_polyTriangleArr = new Polygon[15];
addMouseListener(new MouseCatcher() );
setVisible(true);
class MouseCatcher extends MouseAdapter
public void mousePressed(MouseEvent evt)
Point ptMouse = new Point();
ptMouse = evt.getPoint();
if(m_nTrianglesDrawn < m_nTrianglesToDraw)
int npoints = 3;
m_polyTriangleArr[m_nTrianglesDrawn]
= new Polygon( ptMouse[].x, ptMouse[].y, npoints);
}When i compile my code i get the following error message:
Class Expected
')' expectedThe two error messages are refering to the section new Polygon(....)
line. Please helpCannot find symbol constructor Polygon(int, int, int)
Can some one tell me where this needs to go and what i should generally
look like pleaseI don't think it is a good idea to try and add the constructor that the compiler
can't find. Instead you should use the constructor that already exists
in the Polygon class: ie the one that looks like Polygon(int[], int[], int).
But this requires you to pass two int arrays and not two ints as you
are doing at the moment. As you have seen, evt.getPoint() only supplies
you with a single pair of ints: the x- and y-coordinates of where the mouse
button was pressed.
And this is the root of the problem. To draw a triangle you need three
points. From these three points you can build up two arrays: one containing
the x-coordinates and one containing the y-coordinates. It is these two
arrays that will be used as the first two arguments to the Polygon constructor.
So your task is to figure out how you can respond to mouse presses
correctly, and only try and add a new triangle when you have all three of its
vertices.
[Edit] This assumes that you expect the user to specify all three vertices of the
triangle. If this isn't the case, say what you do expect. -
How to use ABAP Class to modify Web Query Result ??
Hi all !
We are using Web Templates to display our Query.
What I would like to do ( and seems a really important issue for our users! ) is to have a "PAGE BREAK" everytime the value of a charateristics change in the report
For Example :
-Page 1-
Division Project
A 1
2
3
-Page 2-
Division Project
B 1
2
3
and so on....
I read threads about using ABAP CLASS but no example what so ever...
We are presently under BW 3.1 but are considering upgrading to 7.0 by the end of the year so if there is a solution to my problem on either version i'd like to know.
If anyone has any information about how I can do this it would be most appreciated
Thx
JB.Hi Yong,
Ravi is right, first check the blogs by Jocelyn, and if you still have specific questions you can ask them. I have used ABAP classes in workflow and I know Mike Pokraka tries to use classes exclusively.
Regards,
Martin -
HOW TO creat BAR CHART using ABAP Programming
DEAR ALL,
I want some help as to how to creat GRAPHICAL display using ABAP programing (BAR CHART) any sample codes Example will be very helpful.
Regards,
VJOn earlier versions, you can do something like this.
[code]
REPORT ZRICH_0005 .
DATA: BEGIN OF ITAB_DATA OCCURS 0,
DATANAME(15),
QUANTITY1 TYPE I,
QUANTITY2 TYPE I,
QUANTITY3 TYPE I,
END OF ITAB_DATA.
Data: BEGIN OF ITAB_OPTIONS OCCURS 0,
OPTION(20),
END OF ITAB_OPTIONS.
ITAB_DATA-DATANAME = 'Maple'.
ITAB_DATA-QUANTITY1 = 5500.
ITAB_DATA-QUANTITY2 = 6200.
ITAB_DATA-QUANTITY3 = 5900.
APPEND ITAB_DATA.
ITAB_DATA-DATANAME = 'Oak'.
ITAB_DATA-QUANTITY1 = 3500.
ITAB_DATA-QUANTITY2 = 5200.
ITAB_DATA-QUANTITY3 = 4400.
APPEND ITAB_DATA.
ITAB_DATA-DATANAME = 'Cherry'.
ITAB_DATA-QUANTITY1 = 1800.
ITAB_DATA-QUANTITY2 = 2200.
ITAB_DATA-QUANTITY3 = 1900.
APPEND ITAB_DATA.
CALL FUNCTION 'GRAPH_MATRIX_3D'
EXPORTING
COL1 = 'Jan'
COL2 = 'Feb'
COL3 = 'Mar'
TITL = 'Lumber Usage in $'
TABLES
DATA = ITAB_DATA
OPTS = ITAB_OPTIONS
EXCEPTIONS
OTHERS = 1.
[/code]
Regards,
Rich Heilman -
Hide a specific cell using ABAP classes
Hi Experts,
Is there a way to hide a specific cell using ABAP classes for reports?
MarceloHello Thomas Daly
I never saw a way to grant permission to a List, the only way I ever saw a list get its permissions is thru
the group site it resides in, the Discussion Board is the problem in this case (it has preconfigure permissions but they seem more like properties that you select the value from RadioButtons). However, ms-addnew gets rid of the Add new link but it
gets rid of the one in the Discusson Board too because Discussion Board falls in the category of List.
In other words ms-addnew in the master got rid of all of the Add new items, link etc as hoped but now
I can't add to the Discussion Board.
I am alright with a hack (I am open to any suggestions) that would work if it works but, the List's I am referring to are all "Links" in the Quick Launch so I dont know how you would be able to apply the jquery, how would you apply the
jquery to a Links in a Quick Launch?
Thank you
Shabeaut -
How to Programmatically Create and Activate an ABAP Class
Hi,
I have a requirement to programmatically create and activate an ABAP class that implements a 'pre-defined' interface.
Do you have any ideas how this can be done?
Thanks,
Shreevathsa SHi,
Try if GENRATE SUBROUTINE POOL keyword can be of your help.
See the below example,
DATA itab TYPE TABLE OF string.
DATA prog TYPE string.
DATA class TYPE string.
APPEND `program.` TO itab.
APPEND `class main definition.` TO itab.
APPEND ` public section.` TO itab.
APPEND ` class-methods meth.` TO itab.
APPEND `endclass.` TO itab.
APPEND `class main implementation.` TO itab.
APPEND ` method meth.` TO itab.
APPEND ` message 'Test' type 'I'.` TO itab.
APPEND ` endmethod.` TO itab.
APPEND `endclass.` TO itab.
GENERATE SUBROUTINE POOL itab NAME prog.
CONCATENATE `\PROGRAM=` prog `\CLASS=MAIN` INTO class.
CALL METHOD (class)=>meth.
Regards,
Sesh -
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 -
Calling a custom tcode using abap class from workflow
Hi Experts,
I have a requirement of calling a custom tcode from my workflow.
For this i have created a class zcl_test ( has if_workflow ) .
I created a method ztest which will call the tcode.
CALL TRANSACTION 'ZTX'. ( My tcode just has 1 input field, for testing purpose )
Then i created a task in whichi hv used this abap class and method.
But the tcode does not run when i execute the workflow.
Please help.
Thank You,
Radhika Vadher.Radhika Vadher
use the sample code to get the data from the task container into the ABAP class
DATA :
w_ref TYPE REF TO if_swf_run_wim_internal,
w_ref_cnt TYPE REF TO if_wapi_workitem_context,
w_wi_ref TYPE REF TO if_swf_ifs_parameter_container.
TRY.
CALL METHOD cl_swf_run_wim_factory=>find_by_wiid
EXPORTING
im_wiid = w_wiid
RECEIVING
re_instance = w_ref.
CATCH cx_swf_run_wim_enq_failed .
CATCH cx_swf_run_wim_read_failed .
CATCH cx_swf_run_wim .
ENDTRY.
CALL METHOD w_ref->get_workitem_context
RECEIVING
re_ctx = w_ref_cnt.
CALL METHOD w_ref_cnt->get_wi_container
RECEIVING
re_container = w_wi_ref.
and the w_wi_ref is having a method GET use that method to get the values of the task container into the ABAP class. -
File to Proxy Scenario using ABAP Class and DB Multi Connect
Hello Friends,
I have a scenario below and a proposed solution. I would like some input as to whether i am headed the right way.
Scenario: Thousands of records come in from the legacy accounting system. The fields of these records need to be mapped to SAP fields using cross-reference tables stored in DB2. Finally, summarize the records by deleting a few fields and feed to R/3.
Solution i proposed:
(1) File Adapter is used to send the file
(2) Although JDBC adapter comes first to mind but since i need to access the DB2 tables multiple times for each record i propose to use an ABAP class for the mapping. Within the ABAP class the intent is to open an database connection to DB2, read the relevant cross tables using native SQL and finally generate the output XML.
(3) Reciever is Proxy which feeds this generated XML to SAP for creating posting via BAPI_ACC_DOCUMENT_POST
Question: Is the above solution correct or is there a better method to implement this scenario?
Please let me know.
Thanks,
Minhaj.Looks fine. Few observations -
1. Whether it is ABAP class or Mapping in RFC lookup, you are making multiple trips to the database.
2. It looks like PI is being used only for reading the file and converting it to XML.
3. If using PI is not mandatory, then a complete ABAP class on ECC it self would be faster than swtching between PI Java, PI ABAP then round trips to DB2 finally data push to ECC.
If you could look at something like fetching all the required RFC look up data in one go and then map the fields according, might save u on processor and network resources.
VJ -
How to Create an XML using Abap Objects
Hi there,
who has an example how to create an XML Document from an internal table using abap objects
e.g. Class CL_XML_DOCUMENT_BASE ?
any feedback is welcome.
thanks
JohannHi Johann,
You don't need a class to do the job if you are on a 6.10 or higher system. Use command CALL TRANSFORMATION to create an XML from an internal table.
Regards,
John. -
How to Handle Business Object event in ABAP class
Hello Everybody,
I wanted to know if it was possible to reference BOR objects in ABAP class and handle BOR events in ABAP Objects.
Thanks in advance.Hi,
Catch the et_VALIDATE event, when InnerEvent = False and ItemChanged = True.
If pVal.EventType = BoEventTypes.et_VALIDATE Then
If pVal.InnerEvent = False And pVal.ItemChanged Then
'TODO Your code here...
End If
End If
Regards,
Vítor Vieira
Maybe you are looking for
-
Should I use a screen protector for an iPhone 6 Plus?
I just bought an iPhone 6 Plus and can't decide if I want/need a screen protector on it. I take great care of my phones and do not set it carelessly down on any surface.
-
How can I import all of my bookmarks and not just some of the like the import tab does?
I tried to import my bookmarks but it took only a few bookmarks and left most of my list behind. I tried the import from IE many times and get the same result so how can I get all my bookmarks moved over?
-
My ipod video is not recognized by the computer what should i do/
my ipod video is not recognized by the computer what should i do?
-
Upagrading from CS2 to CS5.5 Design Standard
I'm here for some re-assurance and hand-holding really, as these new style installations seem to get more complicated despite all the unconvincing blurb about how easy it is. I've ordered CS5.5 upgrade - at last - because a) CS2 (especially Illustrat
-
Error on Analysis tab in GRC 10 on NWBC
Hi All, I am really new to the SAP environment and have been configuring it to run GRC, I have completed all the post installation tasks. So far I can log onto the system through NWBC and capture my Risks. However when I click on the analysis tab and