How to define event hander interface in Class Builder (se24)?
Hello,
I've got the following local interface defined.
INTERFACE lif_alv_grid_event_handler.
METHODS:
handle_button_click FOR EVENT button_click OF cl_gui_alv_grid
IMPORTING es_col_id es_row_no,
handle_double_click FOR EVENT double_click OF cl_gui_alv_grid
IMPORTING e_row e_column es_row_no,
handle_hotspot_click FOR EVENT hotspot_click OF cl_gui_alv_grid
IMPORTING e_row_id e_column_id es_row_no,
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.
ENDINTERFACE.
Now I want to define it as a dictionary object using se24.
My problem is I could not find the quivalent of "FOR EVENT"
word in it.
Is there any chance to do that in Class Builder?
Best regards
Pawel
Hello Pawel
Display your class with the event handler methods in SE24 / SE80 and choose the DETAIL button (above the table control with the methods).
Here you can define a method as "event handler for" an event of another class.
On SAP release >= 6.20 you can right-click on a method in the tree view and choose context menu function Display -> Definition (tabstrip Attributes ).
Regards
Uwe
Similar Messages
-
Use of events and interface in class
Dear All,
Could you please explain why we use events and interface in class.
Also please tell me the use of TRY and ENDTRY.
Regards,
AmarEvents may be a way of communication b/w classes. Imagine you want to call certain code from one class, you would need for that public method, but you don't want to expose it to external user. So you may use events for that. Also events are used to notify that certain state of class has changed (tiggering event). Then all handlers of this event executes and react accordingly.
Interfaces are a way of provide a service to class which implements it. Imagine that you have class office and hotel and gas station . They don't seems to have something in common. However, there can be some external energy provider which will be an interface. Each class which want to have a lease with this energy provided can implement it (the implementation can differ in some way), so he can provided energy to different classes. This way you will achieve polimorphism (meaning you call one interface method, but code behind it differs from class to class).
Interfaces are also means of multiple inheritance. One class can implement several service (interfaces). In contrary it can oly inherit from one class.
Try endtry are just new way of handling exceptions .
Try to search a litte bit you will find lots of info on the above.
Regards
Marcin -
How to assign the events in a specific method in class builder(se24)
i have declared one event in event part.i want to asign the event to one method .can any one help me .i have to do it in se24.pls
hi,
create a class in se24.
<b>click the <b>EVENTS</b> tab, define an event.</b>
<b>click the <b>METHODS</b> tab, define a method to trigger/ raise the event</b>
<b>define one more method as an event handler method for the event.</b>
for a method to be an event handler, click on the detail view,
select the check box <b>Event Handler for</b> give the classname where the event is defined and the event name, click on Change button.
<b>event can be in the same class or different from that of the event handler method.</b>
don't forget to <b>register the event handler method in the program.</b>
click the code button of ur trigger method(meth2 in my example) and write there,
raise event evt1.
now your class is ready.
now in se38 program,
declare a reference variable to ur class,
create an object,set the handler for ur event,
call the trigger method
<b>data:oref type ref to zsowcl1.
create object oref.
set handler oref->meth1 for oref. handler method
call method oref->meth2. raise evnt method</b>
hope it gives you clear idea,
Regards,
Message was edited by:
sowjanya s -
How to define generics in interfaces
I want to define an interface for Person, which has 2 attributes, 'Owner' and 'Access', but these attributes may be different types for different implementations of the interface. I have another interface that takes Person, so I have something like this:
public interface Person<O, A>
public abstract O getOwner();
public A getAccess();
public interface Entry
public void addPerson(Person<?, ?> person);
}I then have a base Entry implementation that does
import java.util.ArrayList;
import java.util.List;
public abstract class BaseEntry implements Entry
protected List<Person<?,?>> persons;
public void addPerson(Person<?, ?> person)
if (persons == null)
persons = new ArrayList<Person<?,?>>();
persons.add(person);
}and finally I have a concrete class that wants to use Entry and Person interfaces to do somthing like
public class RealEntry extends BaseEntry
private int personCount;
public void addPerson(Person<String, String> person)
super.addPerson(person);
personCount++;
}and I might have another implementation that does
public class ListEntry extends BaseEntry
public void addPerson(Person<String, List<String>> person)
super.addPerson(person);
}but the concrete implementations do not compile in Eclipse with the message
Name clash: The method addPerson(Person<String,String>) of type RealEntry has the same erasure as addPerson(Person<?,?>) of type BaseEntry but does not override it
I've read the generics tutorial, but it's not helped me. I'm not absolutely certain I should be using wildcards as opposed to generic method.
Anyone know what I'm doing wrong?
Thanks
AntonyHi Stefan, I see how your example breaks things, thanks.
My 'Entry' is a simple queue class. I compiles OK if I add the O, A to Entry and implementations, i.e.
public interface Entry<O, A>
public void addPerson(Person<O, A> person);
}but it seems strange (to me) that I have to define the O, A types for the Entry interface - it makes it cluttered. I thought it should be possible to have a generic Entry interface that takes a Person objects without having to tell Entry the subtypes of classes that make up the O and A inside Person.
I could be trying to do something impossible, but I something think it has to be possible as it seems such a common type of usage, i.e. I can have many classes that all define different types of Person implementations and can store them in Entry implementations. -
Main method not found and how to implement events in an inner class
How would I put all the event handling methods in an inner class and I have another class that just that is just a main function, but when i try to run the project, it says main is not found. Here are the two classes, first one sets up everything and the second one is just main.
mport java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.io.*;
public class JournalFrame extends JFrame {
private JLabel dateLabel = new JLabel("Date: ");
private JTextField dateField = new JTextField(20);
private JPanel datePanel = new JPanel(new FlowLayout());
BorderLayout borderLayout1 = new BorderLayout();
JPanel radioPanel = new JPanel();
JPanel statusPanel = new JPanel();
JPanel textAreaPanel = new JPanel();
JPanel buttonPanel = new JPanel();
GridLayout gridLayout1 = new GridLayout();
FlowLayout flowLayout1 = new FlowLayout();
GridLayout gridLayout2 = new GridLayout();
GridLayout gridLayout3 = new GridLayout();
JRadioButton personalButton = new JRadioButton();
JRadioButton businessButton = new JRadioButton();
JLabel status = new JLabel();
JTextArea entryArea = new JTextArea();
JButton clearButton = new JButton();
JButton saveButton = new JButton();
ButtonGroup entryType = new ButtonGroup();
public JournalFrame(){
try {
jbInit();
catch(Exception e) {
e.printStackTrace();
private void initWidgets(){
private void jbInit() throws Exception {
this.getContentPane().setLayout(borderLayout1);
radioPanel.setLayout(gridLayout1);
statusPanel.setLayout(flowLayout1);
textAreaPanel.setLayout(gridLayout2);
buttonPanel.setLayout(gridLayout3);
personalButton.setSelected(true);
personalButton.setText("Personal");
personalButton.addActionListener(new JournalFrame_personalButton_actionAdapter(this));
businessButton.setText("Business");
status.setText("");
entryArea.setText("");
entryArea.setColumns(10);
entryArea.setLineWrap(true);
entryArea.setRows(30);
entryArea.setWrapStyleWord(true);
clearButton.setPreferredSize(new Dimension(125, 25));
clearButton.setText("Clear Journal Entry");
clearButton.addActionListener(new JournalFrame_clearButton_actionAdapter(this));
saveButton.setText("Save Journal Entry");
saveButton.addActionListener(new JournalFrame_saveButton_actionAdapter(this));
this.setTitle("Journal");
gridLayout3.setColumns(1);
gridLayout3.setRows(0);
this.getContentPane().add(datePanel, BorderLayout.NORTH);
this.getContentPane().add(radioPanel, BorderLayout.WEST);
this.getContentPane().add(textAreaPanel, BorderLayout.CENTER);
this.getContentPane().add(buttonPanel, BorderLayout.EAST);
entryType.add(personalButton);
entryType.add(businessButton);
datePanel.add(dateLabel);
datePanel.add(dateField);
radioPanel.add(personalButton, null);
radioPanel.add(businessButton, null);
textAreaPanel.add(entryArea, null);
buttonPanel.add(clearButton, null);
buttonPanel.add(saveButton, null);
this.getContentPane().add(statusPanel, BorderLayout.SOUTH);
statusPanel.add(status, null);
this.pack();
setDefaultCloseOperation(EXIT_ON_CLOSE);
private void saveEntry() throws IOException{
if( personalButton.isSelected())
String file = "Personal.txt";
BufferedWriter bw = new BufferedWriter(new FileWriter(file,true));
entryArea.getText();
bw.write("Date: " + dateField.getText());
bw.newLine();
bw.write(entryArea.getText());
bw.newLine();
bw.flush();
bw.close();
status.setText("Journal Entry Saved");
else if (businessButton.isSelected())
String file = "Business.txt";
BufferedWriter bw = new BufferedWriter(new FileWriter(file,true));
bw.write("Date: " + dateField.getText());
bw.newLine();
bw.write(entryArea.getText());
bw.newLine();
bw.flush();
bw.close();
status.setText("Journal Entry Saved");
void clearButton_actionPerformed(ActionEvent e) {
dateField.setText("");
entryArea.setText("");
status.setText("");
void saveButton_actionPerformed(ActionEvent e){
try{
saveEntry();
}catch(IOException error){
status.setText("Error: Could not save journal entry");
void personalButton_actionPerformed(ActionEvent e) {
class JournalFrame_clearButton_actionAdapter implements java.awt.event.ActionListener {
JournalFrame adaptee;
JournalFrame_clearButton_actionAdapter(JournalFrame adaptee) {
this.adaptee = adaptee;
public void actionPerformed(ActionEvent e) {
adaptee.clearButton_actionPerformed(e);
class JournalFrame_saveButton_actionAdapter implements java.awt.event.ActionListener {
JournalFrame adaptee;
JournalFrame_saveButton_actionAdapter(JournalFrame adaptee) {
this.adaptee = adaptee;
public void actionPerformed(ActionEvent e) {
adaptee.saveButton_actionPerformed(e);
class JournalFrame_personalButton_actionAdapter implements java.awt.event.ActionListener {
JournalFrame adaptee;
JournalFrame_personalButton_actionAdapter(JournalFrame adaptee) {
this.adaptee = adaptee;
public void actionPerformed(ActionEvent e) {
adaptee.personalButton_actionPerformed(e);
public class JournalApp {
public static void main(String args[])
JournalFrame journal = new JournalFrame();
journal.setVisible(true);
}Here is the complete code (with crappy indentation) :
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.io.*;
public class JournalFrame extends JFrame {
private JLabel dateLabel = new JLabel("Date: ");
private JTextField dateField = new JTextField(20);
private JPanel datePanel = new JPanel(new FlowLayout());
BorderLayout borderLayout1 = new BorderLayout();
JPanel radioPanel = new JPanel();
JPanel statusPanel = new JPanel();
JPanel textAreaPanel = new JPanel();
JPanel buttonPanel = new JPanel();
GridLayout gridLayout1 = new GridLayout();
FlowLayout flowLayout1 = new FlowLayout();
GridLayout gridLayout2 = new GridLayout();
GridLayout gridLayout3 = new GridLayout();
JRadioButton personalButton = new JRadioButton();
JRadioButton businessButton = new JRadioButton();
JLabel status = new JLabel();
JTextArea entryArea = new JTextArea();
JButton clearButton = new JButton();
JButton saveButton = new JButton();
ButtonGroup entryType = new ButtonGroup();
public JournalFrame(){
try {
jbInit();
catch(Exception e){
e.printStackTrace();
private void initWidgets(){
private void jbInit() throws Exception {
this.getContentPane().setLayout(borderLayout1);
radioPanel.setLayout(gridLayout1);
statusPanel.setLayout(flowLayout1);
textAreaPanel.setLayout(gridLayout2);
buttonPanel.setLayout(gridLayout3);
personalButton.setSelected(true);
personalButton.setText("Personal");
personalButton.addActionListener(new JournalFrame_personalButton_actionAdapter(this));
businessButton.setText("Business");
status.setText("");
entryArea.setText("");
entryArea.setColumns(10);
entryArea.setLineWrap(true);
entryArea.setRows(30);
entryArea.setWrapStyleWord(true);
clearButton.setPreferredSize(new Dimension(125, 25));
clearButton.setText("Clear Journal Entry");
clearButton.addActionListener(new JournalFrame_clearButton_actionAdapter(this));
saveButton.setText("Save Journal Entry");
saveButton.addActionListener(new JournalFrame_saveButton_actionAdapter(this));
this.setTitle("Journal");
gridLayout3.setColumns(1);
gridLayout3.setRows(0);
this.getContentPane().add(datePanel, BorderLayout.NORTH);
this.getContentPane().add(radioPanel, BorderLayout.WEST);
this.getContentPane().add(textAreaPanel, BorderLayout.CENTER);
this.getContentPane().add(buttonPanel, BorderLayout.EAST);
entryType.add(personalButton);
entryType.add(businessButton);
datePanel.add(dateLabel);
datePanel.add(dateField);
radioPanel.add(personalButton, null);
radioPanel.add(businessButton, null);
textAreaPanel.add(entryArea, null);
buttonPanel.add(clearButton, null);
buttonPanel.add(saveButton, null);
this.getContentPane().add(statusPanel, BorderLayout.SOUTH);
statusPanel.add(status, null);
this.pack();
setDefaultCloseOperation(EXIT_ON_CLOSE);
private void saveEntry() throws IOException{
if( personalButton.isSelected()){
String file = "Personal.txt";
BufferedWriter bw = new BufferedWriter(new FileWriter(file,true));
entryArea.getText();
bw.write("Date: " + dateField.getText());
bw.newLine();
bw.write(entryArea.getText());
bw.newLine();
bw.flush();
bw.close();
status.setText("Journal Entry Saved");
else if (businessButton.isSelected()){
String file = "Business.txt";
BufferedWriter bw = new BufferedWriter(new FileWriter(file,true));
bw.write("Date: " + dateField.getText());
bw.newLine();
bw.write(entryArea.getText());
bw.newLine();
bw.flush();
bw.close();
status.setText("Journal Entry Saved");
void clearButton_actionPerformed(ActionEvent e) {
dateField.setText("");
entryArea.setText("");
status.setText("");
void saveButton_actionPerformed(ActionEvent e){
try{saveEntry();}catch(IOException error){
status.setText("Error: Could not save journal entry");
void personalButton_actionPerformed(ActionEvent e) {
class JournalFrame_clearButton_actionAdapter implements java.awt.event.ActionListener {
JournalFrame adaptee;
JournalFrame_clearButton_actionAdapter(JournalFrame adaptee) {
this.adaptee = adaptee;
public void actionPerformed(ActionEvent e) {
adaptee.clearButton_actionPerformed(e);
class JournalFrame_saveButton_actionAdapter implements java.awt.event.ActionListener {
JournalFrame adaptee;
JournalFrame_saveButton_actionAdapter(JournalFrame adaptee) {
this.adaptee = adaptee;
public void actionPerformed(ActionEvent e) {
adaptee.saveButton_actionPerformed(e);
class JournalFrame_personalButton_actionAdapter implements java.awt.event.ActionListener {
JournalFrame adaptee;
JournalFrame_personalButton_actionAdapter(JournalFrame adaptee) {
this.adaptee = adaptee;
public void actionPerformed(ActionEvent e) {
adaptee.personalButton_actionPerformed(e);
}BadLands -
How to get event 'out of the class'
I have been reading myself silly about this, I either don't get it or it is very difficult.
What I want to do:
1) setup
2) show panel
3) handle input in panel
4) once valid
5) "get out"
6) display other panel.
I can go all the way to 4.
But I can't get "out" of the panel.
All I can guess/understand is that I have to trigger an event that will be handled below/outside this panel.
Has anybody some idea how to do this? Maybe a link to some example code?
There is tons to read about event handling but the (only) part I understand is about events within classes just as all the examples are (One panel two buttons, two pictures etc)
I guess the only option I might envision is dividing by zero and catching the error outside the panel.
That would be bazooking a mosquito, but it also shows what I try to implement.
I'd be so happy to understand this part of the 'java system' ...
(please understand that I don't want 'cardlayout', I want to understand what I need to do)
Much thanks for any help!Thank you for your suggestion.
My problem is that I am (feel?) stuck within the panel.
So to put it differently, I cannot build a child panel with a button (in the child) that will have the parent pane change color. This as my 'code focus' is within the child panel and I cannot 'activate' code outside it.
I am totally confused now as to how java works.
So I cannot write a parent pane with a child pane where the child tests for a name and if the name is correct the child will be removed and some code will put in another child pane with fi a picture.
This seems so utterly basic to any programmers needs, but I cannot find one example - or I have gone blind looking for it. In my code if I want to read the input field I have to handle it within the child pane, if I want to change child panels I need to do that in the parents panel code. But I can't change the code focus. So the child needs to generate an event that the parents can act upon, but there are no examples while I actually expect tons of examples. So maybe I don't speak 'Java'.
This meaning that I cannot write a stack of panes and remove them one by one using fi the escape key.
I am just left clueless by Java. -
How to dispatch events from custom AS3 classes to MXML
Hello,
I introduce some custom classes inside my SCRIPT tag in MXML.
These classes should dispatch custom Events (or any events for that
matter) and the listeners should be defined inside the SCRIPT tag.
In the custom class I have:
quote:
dispatchEvent(new Event("customEvent"));
And inside the script tag:
quote:
addEventListener("customEvent", testListener);
quote:
public function testListener(evt:Event):void{
Alert("Event fired successfully.");
However, this event is not handled in the listener (the alert
is not shown). What could be wrong?<mx:Application xmlns:mx="
http://www.adobe.com/2006/mxml"
layout="absolute" creationComplete="init();">
<mx:Script>
<![CDATA[
import mx.controls.Alert;
private function init():void
addEventListener("customEvent", testListener);
dispatchEvent(new Event("customEvent"));
private function testListener(evt:Event):void{
Alert.show("Event fired successfully.");
Do like this
Alert is the Class Object. This is not the Function. -
Regarding class builder(SE24)
Hi to all,
I want to know how to create classes and its interfaces and methods using <b>SE24</b> transactions. Is there any documentation for this?Hi,
Just check the following links.
1) http://help.sap.com/saphelp_46c/helpdata/en/d3/2e974d35c511d1829f0000e829fbfe/frameset.htm
2) http://help.sap.com/saphelp_46c/helpdata/en/d6/0db357494511d182b70000e829fbfe/frameset.htm
3) http://www.henrikfrank.dk/abapexamples/SapScript/sapscript.htm
4) http://www.sapgenie.com/abap/example_code.htm ABAP example code
5) http://www.geocities.com/SiliconValley/Campus/6345/abapindx.htm
6) http://help.sap.com/printdocu/core/Print46c/en/Data/Index_en.htm
7) http://help.sap.com/saphelp_40b/helpdata/en/4f/991f82446d11d189700000e8322d00/applet.htm SAP Online Help.
9) http://www.sap-img.com/abap-function.htm ABAP Function Modules
10) http://www.sapgenie.com/abap/code/abap19.htm
11) http://www.sap-img.com/abap/more-than-100-abap-interview-faqs.htm ABAP Quest
12) http://www.planetsap.com/Tips_and_Tricks.htm Tricks & TIps for ABAP
13) http://help.sap.com/saphelp_40b/helpdata/ru/d6/0dc169494511d182b70000e829fbfe/applet.htm SAP Online Help.
14) http://www.henrikfrank.dk/abapexamples/SapScript/symbols.htm symbols & Controls commands
15) http://www.henrikfrank.dk/abapexamples/index.html ABAP Examples
16) http://sap.ittoolbox.com/documents/document.asp?i=752 SAP Introduction to ABAP Helps
17) http://members.aol.com/_ht_a/skarkada/sap/ SAP and ABAP Goodies
18) http://sappoint.com/abap/ SAP/ABAP Technical site.
19) http://members.tripod.com/abap4/SAP_Functions.html SAP Functions-ABAP Hints and Tips
20) http://members.ozemail.com.au/~anmari/sap/index.html SAP R/3 Configurations
21) http://www.planetsap.com/Userexit_List.htm All User-Wxirs
22) http://www.planetsap.com/Tips_and_Tricks.htm
23) http://www.kabai.com/abaps/q.htm
24) http://www.planetsap.com/Userexit_List.htm User-Exits
25) http://help.sap.com/saphelp_bw21c/helpdata/en/c4/3a8090505211d189550000e829fbbd/frameset.htm bakground jobs
26) http://www.sapgenie.com/abap/bapi/example.htm BAPI step by step
27) http://help.sap.com/saphelp_45b/helpdata/en/65/897415dc4ad111950d0060b03c6b76/content.htm SAPscript: Definition of borders, lines, and shading
28) http://www.sap-basis-abap.com/index.htm SAP ABAP/4 Programming, Basis Administration, Configuration Hints and Tips
29) http://help.sap.com/saphelp_40b/helpdata/en/fc/eb2c46358411d1829f0000e829fbfe/frameset.htm SAP Online help Dialog
30) http://help.sap.com/saphelp_46c/helpdata/en/aa/aeb23789e95378e10000009b38f8cf/frameset.htm Dilaog Prog.
31) http://www.geocities.com/ResearchTriangle/1635/system.html System fields
32) http://www.sapdesignguild.org/resources/MiniSG/3_Managing/3_Functions_Table_Control.htm Function of table control
33) http://help.sap.com/saphelp_45b/helpdata/en/d1/801bdf454211d189710000e8322d00/content.htm Defining table control
34) http://www.sapfans.com/sapfans/repos/saprep.htm SAP Repository
35) http://www.planetsap.com/howdo_a.htm ABAP
36) http://help.sap.com/saphelp_util464/helpdata/en/69/c2516e4ba111d189750000e8322d00/content.htm Table Maintenance Dialog
37) http://www.sapgenie.com/abap/smartforms_detail.htm smart forms
38) http://www.sap-img.com/abap.htm Sample ABAP Codes
3 9) http://help.sap.com/saphelp_46c/helpdata/en/fc/eb2d67358411d1829f0000e829fbfe/content.htm Processing Blocks in ABAP Programs
40) http://www.geocities.com/victorav15/sapr3/abap.html ABAP/4 compendium.
41) http://www.henrikfrank.dk/abapexamples/SapScript/sapscript.htm SAP SCRIPT IMP
42) http://abap4.tripod.com/Other_Useful_Tips.html Additional useful Tips
43) http://help.sap.com/saphelp_45b/helpdata/en/cf/21ee2b446011d189700000e8322d00/content.htm Searach Helps
44) http://www.sap-basis-abap.com/sapmm.htm SAP MM (Materials Management) Configuration Hints and Tips
45) http://sap.ittoolbox.com/nav/t.asp?t=303&p=448&h1=303&h2=322&h3=448
46) http://sapfans.com -
Define event types in Customizing and restart the transaction.
how to define event to restart the transaction in BADI
I have given error message in badi. it is giving
No SAP Event Management communication for events; no event types def
Message no. /SAPTRX/ASC084
Diagnosis
You have not defined event types for the business process types.
therefore not possible to communicate event data to SAP Event
Management.
System response
The communication of event data is aborted.
Procedure
Define event types in Customizing and restart the transaction.Hi Kevin,
What DataSource does your testalias refer to?
- If it is a custom DataSource, you must have created this custom DataSource also.
- If it is the default DataSource, you shouldn't have this problem in general...
In either case, you can try deploying your DataSource and/or DataSource alias together with your application:
http://help.sap.com/saphelp_nwce10/helpdata/en/45/07d2eeea3e0485e10000000a155369/frameset.htm
http://help.sap.com/saphelp_nwce10/helpdata/en/45/c82cd460a42e96e10000000a155369/frameset.htm
I hope that helps!
Regards,
Yordan -
To use logical database PNP in class builder
Hi
Inside the class builder (SE24), i have a created a method.
Now while implementing that method, that is between method and endmethod
statement can i implement logical database PNP or PNPCE.
If 'yes' how to use it.
if 'no' what is the other way to implement authorization.
Pls help meHello,
assume that the routines GET_ITnnnn are written by yourself. For reading infotypes ABAP Objects provides us with same very helpful classes as shown below:
* define data
DATA:
gif_employee type ref to if_pt_employee,
go_employee type ref to cl_pt_employee,
gt_infotypes TYPE tim_tmw_itlist_tab,
go_control TYPE REF TO if_pt_td_control,
go_data TYPE REF TO if_pt_td_base,
go_pnnnn TYPE REF TO if_pt_td_itnnnn,
gt_p0001 TYPE TIM_P0001_TAB,
gt_p0002 TYPE TIM_P0002_TAB,
gt_p0003 TYPE TIM_P0003_TAB.
start-of-selection.
GET pernr.
<b>* Create employee instance</b>
gif_employee = cl_pt_employee=>get_employee( pernr ).
go_employee ?= gif_employee.
<b>* Get master infotypes (0001, 0002)</b>
CALL METHOD go_employee->get_master_data
EXPORTING
im_begda = id_fromdate
im_endda = id_todate
IMPORTING
* EX_I0000 =
EX_I0001 = gt_p0001
EX_I0002 = gt_p0002
* EX_I0007 =
* EX_I0008 =
<b>* Append all other required infotypes to itab</b>
APPEND '0003' TO gt_infotypes.
CALL METHOD go_employee->get_infotypes
EXPORTING
i_itlist = gt_infotypes
i_fromdate = id_fromdate " start date
i_todate = id_todate " end date
* I_FILTER =
i_noauthcheck = 'X'
IMPORTING
e_result = gt_infty_request
e_retcd = gd_retcd.
* Please see documentation of parameter e_retcd...
LOOP AT gt_infty_request INTO go_control.
go_data = go_control->data. <b>" get data object</b>
* Casting
TRY.
go_pnnnn ?= go_data.
CATCH cx_sy_move_cast_error.
CONTINUE.
ENDTRY.
<b>* Convert infotype (semi-transparent -> transparent)</b>
CALL METHOD cl_hr_pnnnn_type_cast=>prelp_to_pnnnn
EXPORTING
prelp = lo_pnnnn->prelp
IMPORTING
pnnnn = gs_p0003.
APPEND gs_p0027 TO gt_p0003.
ENDLOOP.
The class CL_PT_EMPLOYEE provides us already with very easy access to so-called master infotypes (000, 0001, 0002, 0007 and 0008). All other infotypes can be read using method GET_INFOTYPES.
Using these classes we have a very convenient and standardized way of accessing all kinds of infotypes.
Vasanth -
OO ABAP - Retrieve source from Class Builder?
Hi. Is there a way to display the source code for a class or interface definition that was created with the class builder (se24).
I looked through the drop downs, but I didn't see anything to display the source.
Thanks in advance.
BrendanA class is distributed upon several includes. The Se24 in my 45b system offers to view the source via button on the bottom of the method list.
If you like you can try the following sample program also. Just paste the source and create the Pf-Status 'STA_MAIN' (line 135) and add the commands PICK(f2),Back, Exit, My_Edit(any key).
PS: double clicking on a include navigates forward ( if PICK is set to F2 ).
PPS: If you experience trouble with pasting the code and lost line termination, please paste into wordpad an save as text file.
[code]
report: Ze80Lite
created: 17.aug.2000
purpose
this report displays various informations of report-source files
Change History
#nn - dd.mmm.yyyy - Author
short description
#00 - 17.aug.2000 - KZI
initial
report Ze80Lite
no standard page heading
line-size 120
message-id sx.
*$ external types & constants =====================
*======================================================================
*$ local types ========================================================
*======================================================================
types:
typ_source type string,
typ_source_tab type standard table of typ_source,
begin of typ_file_info,
lsind type syst-lsind,
isvalid type flag,
r3state type d010sinf-r3state,
prgnam type programm,
srcnam type programm,
prgtyp type d010sinf-subc,
end of typ_file_info,
begin of typ_line_info,
flag_newline type flag,
flag_comment type flag,
text type string,
end of typ_line_info,
begin of typ_method_info,
methodname type tmdir-methodname,
methodindx type tmdir-methodindx,
end of typ_method_info,
typ_method_info_tab type standard table of typ_method_info,
typ_line_tab type standard table of typ_line_info.
selection-screen begin of block sel1 with frame title text-s01.
parameter:
p_prgnam type programm obligatory,
p_state type d010sinf-r3state default 'I',
p_typprg radiobutton group 0001 default 'X',
p_typcla radiobutton group 0001,
p_typifc radiobutton group 0001,
p_typfct radiobutton group 0001,
p_typmod radiobutton group 0001,
p_typool radiobutton group 0001.
selection-screen end of block sel1.
constants:
begin of gcr_rep,
typ_prg type i value 1,
typ_cla type i value 2,
typ_ifc type i value 3,
typ_fct type i value 4,
typ_mod type i value 5,
typ_pool type i value 6,
max_modi type syst-lsind value 5,
max_width type i value 80,
mem_prg type memoryid value 'ST22_PRGNAME',
mem_typ type memoryid value '91A', " missuse
mem_dir type memoryid value '91B', " missuse
mem_sta type memoryid value '91C', " missuse
end of gcr_rep.
data:
goa_file type standard table of typ_file_info.
=====================================================================
*$ report eventing ====================================================
=====================================================================
initialization.
perform sub_init.
at selection-screen.
perform sub_check.
start-of-selection.
perform sub_main.
at line-selection.
perform sub_click.
at user-command.
perform sub_command
using sy-ucomm.
sy-ucomm = ''.
=====================================================================
*$ subroutines ========================================================
=====================================================================
form : sub_main
purp. : main entry point for procecssing
param : <global> from selectio screen
rcode : ---
hist. : #00 - KZI - created
form sub_main.
data declaration
data:
lon_error type i,
lon_srctyp type i,
loc_srcnam type programm,
lor_file type typ_file_info.
init
set pf-status 'STA_MAIN'.
clear:
lor_file,
goa_file.
do 10 times.
append lor_file to goa_file[].
enddo.
get the type
" keep in sync with parameter, sub_check, sub_init
case 'X'.
when p_typprg.
lon_srctyp = gcr_rep-typ_prg.
when p_typcla.
lon_srctyp = gcr_rep-typ_cla.
when p_typifc.
lon_srctyp = gcr_rep-typ_ifc.
when p_typfct.
lon_srctyp = gcr_rep-typ_fct.
when p_typmod.
lon_srctyp = gcr_rep-typ_mod.
when p_typool.
lon_srctyp = gcr_rep-typ_pool.
when others.
lon_srctyp = gcr_rep-typ_prg.
endcase.
get true name
perform sub_get_srcnam
using
lon_srctyp
p_prgnam
changing
lon_error
loc_srcnam.
perform sub_dsp_source
using
p_prgnam
loc_srcnam.
the end
exit. " form
endform. "sub_main
form : sub_click
purp. : entry point for line selection
param : <global> sy-lisel
rcode : ---
hist. : #00 - KZI - created
form sub_click.
data declaration
data:
lon_error type i,
loc_prgnam type programm,
loc_srcnam type programm.
get possibly program name
if ( 0 eq lon_error ).
perform sub_get_word_from_list
changing
loc_prgnam.
if ( '' eq loc_prgnam ).
lon_error = 1.
else.
translate loc_prgnam to upper case.
endif.
endif.
get source name
if ( 0 eq lon_error ).
case loc_prgnam.
when 'METHODS'.
perform sub_dsp_methods.
when others.
perform sub_get_srcnam
using
gcr_rep-typ_prg
loc_prgnam
changing
lon_error
loc_srcnam.
if ( 0 eq lon_error ).
perform sub_dsp_source
using
loc_srcnam
loc_srcnam.
endif.
endcase.
endif.
the end
exit. " form
endform. "sub_click
form : sub_command
purp. : entry point for user command
param : ---
rcode : ---
hist. : #00 - KZI - created
form sub_command
using
value(poc_cmd) type syst-ucomm.
data declaration
data:
lon_error type i,
lon_lsind type syst-lsind,
lor_file type typ_file_info.
try to catch a valid file info
if ( 0 eq lon_error ).
read table goa_file[]
into lor_file
with key lsind = sy-lsind.
if ( 0 ne sy-subrc ).
lon_error = 1.
elseif ( 'X' ne lor_file-isvalid ).
lon_error = 1.
endif.
endif.
dispatch work
if ( 0 eq lon_error ).
case poc_cmd.
when 'MY_EDIT'.
editor-call for report lor_file-srcnam display-mode.
when 'MY_HELP'.
perform sub_dsp_help.
when others.
" nop
endcase.
endif.
endform. "sub_command
form : sub_get_word_from_list
purp. : get the word clicked on
param : <global> sy-lisel
rcode : ---
hist. : #00 - created
#01 - fixed a problem with words starting in first column
form sub_get_word_from_list
changing
prc_srcnam type programm.
data:
loc_cmp(1) type c,
lon_bgn type i,
lon_end type i,
lon_len type i.
get fundamental data
lon_len = strlen( sy-lisel ).
lon_bgn = sy-cucol.
lon_end = sy-cucol.
find begin/end of word
do.
loc_cmp = sy-lisel+lon_bgn(1).
if
'' eq loc_cmp or
'"'',.' ca loc_cmp
exit." do
endif.
lon_bgn = lon_bgn - 1.
if ( 0 GT lon_bgn ).
exit. " do
endif.
enddo.
lon_bgn = lon_bgn + 1.
do.
loc_cmp = sy-lisel+lon_end(1).
if
lon_len le lon_end or
'' eq loc_cmp or
'"'',.' ca loc_cmp
exit.
endif.
lon_end = lon_end + 1.
enddo.
lon_end = lon_end - 1.
if end >= begin give it back
if ( lon_end ge lon_bgn ).
lon_len = lon_end - lon_bgn + 1.
prc_srcnam = sy-lisel+lon_bgn(lon_len).
endif.
endform. "sub_get_word_from_list
form : sub_get_srcnam
purp. : builds sourcename according to selection screen settings
param : pon_prgtyp distinquish the various program types
pon_prgnam the program name used to build the source file
rcode : prn_error 0 success, else failure
prc_srcnam name of sourcefile
hist. : #00 - KZI - created
form sub_get_srcnam
using
value(pon_prgtyp) type i
value(poc_prgnam) type program
changing
prn_error type i
prc_srcnam type programm.
data declaration
data:
lon_error type i, " local errorflag
x type i, " simple counter
y type i, " simple counter
lor_tfdir type tfdir. " prog info tab.
build the true filename dependend on prg type
" keep this source in sync with parameter, sub_check, sub_init
case pon_prgtyp.
when gcr_rep-typ_prg.
" simple program
prc_srcnam = poc_prgnam.
when gcr_rep-typ_cla.
" class
prc_srcnam = poc_prgnam.
x = strlen( poc_prgnam ).
if ( 30 > x ).
y = 30 - x.
prc_srcnam+x(y) = '=============================='.
endif.
prc_srcnam+30(2) = 'CP'.
when gcr_rep-typ_ifc.
" interface
prc_srcnam = poc_prgnam.
x = strlen( poc_prgnam ).
if ( 30 > x ).
y = 30 - x.
prc_srcnam+x(y) = '=============================='.
endif.
prc_srcnam+30(2) = 'IP'.
when gcr_rep-typ_fct.
" function pool
concatenate
'SAPL'
poc_prgnam
into prc_srcnam.
when gcr_rep-typ_mod.
" function module
select
single *
into lor_tfdir
from tfdir
where funcname = poc_prgnam.
if ( 0 eq sy-subrc ).
concatenate
'L'
lor_tfdir-pname+4
'U'
lor_tfdir-include
into prc_srcnam.
else.
lon_error = 1.
endif.
when gcr_rep-typ_pool.
" type pool
concatenate '%_C' poc_prgnam into prc_srcnam.
when others.
" unknown type
lon_error = 1.
endcase.
the end
if ( 0 eq lon_error ).
prn_error = 0.
else.
prn_error = 1.
prc_srcnam = p_prgnam.
endif.
endform. "sub_get_srcnam
form : Sub_Dsp_Methods
purp. : displays methods of a Class
param : prc_ClassName the name of the class to display methods from
rcode :
hist. : #00 - KZI - created
form sub_dsp_methods.
data declaration
constants:
c_Num_Index type i value 35,
c_Num_Modulo type i value 36,
c_Index(37) type c
value '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ?'.
data:
lon_Fraction type i,
lon_Modulo type i,
lon_Index type i,
lon_Offset type i,
loa_methods type typ_method_info_tab,
loc_Class_Name type tmdir-classname,
loc_include_Name type programm,
lor_file type typ_file_info,
loc_Index(3) type c.
field-symbols:
<lor_method> type typ_method_info.
init &_ precheck
lor_file-isvalid = ''.
lor_file-prgtyp = ''.
lor_file-lsind = sy-lsind + 1.
modify goa_file[] from lor_file index lor_file-lsind.
read table goa_file[] index sy-lsind into lor_file.
if ( 0 ne sy-subrc or 'X' ne lor_File-isValid ).
exit.
endif.
loc_Class_Name = lor_File-PrgNam.
if ( loc_class_name cs '=' ).
loc_Class_Name = loc_class_name(sy-fdpos).
endif.
get all methods
select methodname methodindx from tmdir
into corresponding fields of table loa_methods[]
where
classname = loc_class_name AND
methodname <> ''
order by
methodindx.
if ( 0 ne sy-subrc ).
write:
'could not be loaded!'(e04),
/ 'No entry in TMDIR,' , loc_class_name.
exit.
endif.
put em on the list.
Format: Reset.
loc_Include_Name = loc_Class_Name.
concatenate
loc_Include_Name
'=================================================='
into loc_Include_Name.
loc_Include_Name+30 = 'CM'.
loop at loa_methods[] assigning <lor_method>.
loc_Index = '000'.
lon_Offset = 3.
lon_Modulo = <lor_Method>-MethodIndx mod c_Num_Modulo.
lon_Fraction = <lor_Method>-MethodIndx div c_Num_Modulo.
while ( ( lon_Fraction > 0 or lon_Modulo > 0 ) and lon_Offset > 0 ).
lon_Offset = lon_Offset - 1.
loc_Indexlon_Offset(1) = c_Indexlon_Modulo(1).
loc_Include_Name+32 = loc_Index.
lon_Modulo = lon_Fraction mod c_Num_Modulo.
lon_Fraction = lon_Fraction div c_Num_Modulo.
endwhile.
write: /
loc_include_name intensified,
at 40 <lor_method>-methodname(40).
endloop.
endform. "sub_Dsp_Methods
form : sub_Dsp_Source
purp. : loads source file from database and displays its contents
with write
param : prc_srcnam name of source piece to display
rcode : <hide> name of occasional included files
hist. : #00 - KZI - created
form sub_dsp_source
using
value(poc_prgnam) type programm
value(poc_srcnam) type programm.
data declaration
data:
lon_error type i,
lon_warn type i,
loa_source type standard table of typ_source,
loa_lines type typ_line_tab,
loc_line type string,
loc_print type string,
lon_tmp type i,
lon_tabix type syst-tabix,
lor_d010sinf type d010sinf,
lor_file type typ_file_info.
field-symbols:
<lof_source> type typ_source,
<lof_line> type typ_line_info.
init &_ precheck
format:
reset.
if ( gcr_rep-max_modi lt sy-lsind ). " limit modes
sy-lsind = gcr_rep-max_modi.
endif.
lor_file-srcnam = poc_srcnam.
lor_file-prgnam = poc_prgnam.
lor_file-lsind = sy-lsind + 1.
lor_file-r3state = p_state.
poc_srcnam = ucase( poc_srcnam ).
check existance
if ( 0 eq lon_error ).
select *
from d010sinf up to 1 rows
into lor_d010sinf
where
prog = poc_srcnam
order by
r3state
cdat.
if ( lor_d010sinf-r3state eq p_state ).
exit. " loop
endif.
endselect.
if ( 0 ne sy-subrc ).
lon_error = 1.
write:
'could not be loaded!'(e04),
/ 'No entry in D010SINF,' , poc_srcnam.
endif.
endif.
get report text
if ( 0 eq lon_error ).
read report poc_srcnam into loa_source[] state p_state.
if ( 0 ne sy-subrc and 'I' eq p_state ).
read report poc_srcnam into loa_source[] state 'A'.
lon_warn = 1.
endif.
if ( 0 ne sy-subrc ).
lon_tmp = strlen( poc_srcnam ).
write: / 'Program'(e01).
format inverse on. format color col_negative on.
write at (lon_tmp) poc_srcnam.
format inverse off. format color col_negative off.
write: /
'Cannot load source info, sy-subrc= '(e02),sy-subrc.
endif.
endif.
create display
if ( 0 eq lon_error ).
perform sub_dsp_source_lines
using
poc_prgnam
0
0
loa_source[]
changing
lon_error.
endif.
update internal memory
if ( 0 eq lon_error ).
lor_file-isvalid = 'X'.
if ( 0 eq lon_warn ).
lor_file-r3state = p_state.
else.
lor_file-r3state = 'A'.
endif.
lor_file-prgtyp = lor_d010sinf-subc.
else.
lor_file-isvalid = ''.
lor_file-prgtyp = ''.
endif.
modify goa_file[] from lor_file index lor_file-lsind.
the end
if ( 0 ne lon_warn ).
message s777 with
'There is no inactive version => no upload possible!'(i01).
endif.
exit. " form
endform. "sub_dsp_source
form : sub_dsp_source_lines
purp. : loads source file from database and displays its contents
with write
param : poc_prgnam name of source piece to display
pra_source source to display
rcode : prn_error 0 success
hist. : #00 - KZI - created
form sub_dsp_source_lines
using
value(poc_prgnam) type programm
value(pon_lwr_ndx) type i
value(pon_upr_ndx) type i
pra_source type typ_source_tab
changing
prn_error type i.
data declaration
data:
lon_Strlen type i,
lon_Tabix(5) type n,
loa_lines type typ_line_tab,
loc_line type string,
lon_error type i,
lon_tmp type i,
lon_lwr_ndx type syst-tabix,
lon_upr_ndx type syst-tabix.
field-symbols:
<lof_source> type typ_source,
<lof_line> type typ_line_info.
init &_ precheck
format:
reset.
lon_error = 0.
describe table pra_source[] lines lon_tmp.
if ( 1 gt pon_lwr_ndx or lon_tmp lt pon_lwr_ndx ).
lon_lwr_ndx = 1.
else.
lon_lwr_ndx = pon_lwr_ndx.
endif.
if ( 1 gt pon_upr_ndx or lon_tmp lt pon_upr_ndx ).
lon_upr_ndx = lon_tmp.
else.
lon_upr_ndx = pon_upr_ndx.
endif.
create display
if ( 0 eq lon_error ).
format: reset.
loop at pra_source[]
assigning <lof_source>
from lon_lwr_ndx
to lon_upr_ndx.
lon_tabix = syst-tabix.
loc_line = <lof_source>.
perform sub_cut_text_comment
using
loc_line
'X'
changing
loa_lines[].
loop at loa_lines[] assigning <lof_line>.
if ( 'X' eq <lof_line>-flag_newline ).
if ( 0 ne lon_tabix ).
write:
/(5) lon_tabix intensified color col_normal.
else.
write:
/(5) ' .' intensified color col_normal.
endif.
write at 6 ''.
lon_tabix = 0.
endif.
lon_Strlen = strlen( <lof_Line>-Text ).
if ( 'X' eq <lof_line>-flag_comment ).
write: at (lon_Strlen)
<lof_line>-text intensified no-gap.
else.
write: at (lon_Strlen)
<lof_line>-text no-gap.
endif.
endloop.
endloop.
endif.
the end
if ( 0 ne lon_error ).
prn_error = 1.
else.
prn_error = 0.
endif.
exit. " form
endform. "sub_dsp_source_lines
form : sub_chk_input
purp. : (en) validate input data
(de) validieren der eingabewerte
param : ---
rcode : ---
hist. : #00 - initial
form sub_dsp_help.
data declaration
data:
lon_error type i,
loa_tline type standard table of tline,
loc_docnam type syst-repid.
show help about ?
if ( 0 eq lon_error ). " Help
loc_docnam = sy-repid.
call function 'HELP_OBJECT_SHOW'
exporting
dokclass = 'RE'
dokname = loc_docnam
tables
links = loa_tline[]
exceptions
object_not_found = 1
sapscript_error = 2
others = 3.
if ( 0 ne sy-subrc ).
lon_error = 1.
message w777 with 'No Help Available'(w00).
sy-subrc = 0.
endif.
endif.
endform. "sub_dsp_help
form : sub_init
purp. : initializes the selection screen
param : ---
rcode : ---
hist. : #00 - KZI - created
form sub_init.
data declaration
data:
loc_memory(256) type c,
lon_memory type i.
memory id logic
" get prog
get parameter id gcr_rep-mem_prg field p_prgnam.
if ( 0 ne sy-subrc or '' eq p_prgnam ).
p_prgnam = sy-repid.
endif.
set parameter id gcr_rep-mem_prg field p_prgnam.
" get prog type ( keep in sync with parameters sub_check and
" sub_get_srcnam )
get parameter id gcr_rep-mem_typ field loc_memory.
condense loc_memory.
loc_memory = loc_memory(4).
if ( loc_memory co ' 0123456789' ).
lon_memory = loc_memory.
else.
lon_memory = gcr_rep-typ_prg.
endif.
clear:
p_typcla,
p_typfct,
p_typifc,
p_typmod,
p_typool,
p_typprg.
case lon_memory.
when gcr_rep-typ_prg.
p_typprg = 'X'.
when gcr_rep-typ_cla.
p_typcla = 'X'.
when gcr_rep-typ_ifc.
p_typifc = 'X'.
when gcr_rep-typ_fct.
p_typfct = 'X'.
when gcr_rep-typ_mod.
p_typmod = 'X'.
when gcr_rep-typ_pool.
p_typool = 'X'.
when others.
" default
p_typprg = 'X'.
endcase.
" get status ( keep in sync with sub check ).
get parameter id gcr_rep-mem_sta field p_state.
if ( 'A' ne p_state ).
" only 'I' or 'A' is allowed
p_state = 'I'.
endif.
set parameter id gcr_rep-mem_sta field p_state.
endform. "sub_init
form : sub_check
purp. : at the selection screen
param : ---
rcode : ---
hist. : #00 - KZI - created
form sub_check.
data declaration
data:
loc_memory(4) type c,
lon_rcode type i.
memory id handling
case p_state.
when 'A' or 'I'.
" ok
when others.
message e777 with
'Only ''A'' and ''I'' are allowed for state'(se1).
endcase.
set parameter id gcr_rep-mem_prg field p_prgnam.
set parameter id gcr_rep-mem_sta field p_state.
" multiple choice
" keep in sync with parameters and sub_check, sub_main
case 'X'.
when p_typprg.
loc_memory = gcr_rep-typ_prg.
when p_typcla.
loc_memory = gcr_rep-typ_cla.
when p_typifc.
loc_memory = gcr_rep-typ_ifc.
when p_typfct.
loc_memory = gcr_rep-typ_fct.
when p_typmod.
loc_memory = gcr_rep-typ_mod.
when p_typool.
loc_memory = gcr_rep-typ_pool.
when others.
" if bugfree this should never happen, sync source if you
" expierience this source to be executed
loc_memory = gcr_rep-typ_prg.
endcase.
if ( '' ne loc_memory ).
set parameter id gcr_rep-mem_typ field loc_memory.
endif.
endform. "sub_check
form : sub_split_comment
purp. : splits a line into a comment and command part.
param : poc_line to source line
poc_command the command part
poc_comment the comment part
rcode : <hide> name of occasional included files
hist. : #00 - KZI - created
form sub_split_comment
using
value(poc_line) type typ_source
changing
prc_command type typ_source
prc_comment type typ_source.
data declaration
data:
loc_First_Char(1) type c,
lon_len_old type i,
lon_len_new type i,
lon_pos_cmt type i,
loc_buf1 type string,
loc_buf2 type string,
loc_cmtbuf(240) type c.
init & precheck
clear:
prc_command,
prc_comment.
computation
loc_First_Char = poc_Line.
if ( '*' eq loc_First_Char ).
prc_command = ''.
prc_comment = poc_line.
else.
if ( poc_line ca '"' and poc_line np '''"''' ).
split poc_line at '"' into loc_buf1 loc_buf2.
if ( '' eq loc_buf1 ).
prc_command = ''.
prc_comment = poc_line.
else.
lon_len_old =
strlen( poc_line ).
lon_len_new =
strlen( loc_buf1 ) +
strlen( loc_buf2 ).
lon_pos_cmt = lon_len_old - lon_len_new - 2.
if ( 0 gt lon_pos_cmt or 240 lt lon_pos_cmt ).
lon_pos_cmt = 0.
endif.
loc_cmtbuf+lon_pos_cmt = '"'.
prc_command = loc_buf1.
concatenate loc_cmtbuf loc_buf2 into prc_comment.
endif.
else.
prc_command = poc_line.
prc_comment = ''.
endif.
endif.
the end
exit. " form
endform. "sub_split_comment
form : sub_cut_text_comment
purp. : splits a line into a comment and command part.
param : poc_line to source/text line
poc_cmt 'X' chk for comments
rcode : pra_lines filled with line info ( reset )
hist. : #00 - KZI - created
form sub_cut_text_comment
using
value(poc_line) type string
value(poc_cmt_check) type flag
changing
pra_lines type typ_line_tab.
data declaration
data:
loc_buf1 type string,
loc_buf2 type string,
loc_comment type string,
loc_command type string.
data:
loc_First_Char(1) type c,
loc_new_line type flag,
lon_cur_pos type i,
lon_new_pos type i.
init & precheck
clear:
pra_lines[],
loc_command,
loc_comment.
computation
loc_First_Char = poc_Line.
if ( '' eq poc_cmt_check or '' eq poc_line ).
loc_command = poc_line.
loc_comment = ''.
else.
if ( '*' eq loc_First_Char ).
loc_command = ''.
loc_comment = poc_line.
else.
if ( poc_line ca '"' and poc_line np '''"''' ).
split poc_line at '"' into loc_buf1 loc_buf2.
if ( '' eq loc_buf1 ).
loc_command = ''.
loc_comment = poc_line.
else.
loc_command = loc_buf1.
concatenate '"' loc_buf2 into loc_comment.
endif.
else.
loc_command = poc_line.
loc_comment = ''.
endif.
endif.
endif.
cvt text
lon_cur_pos = 0.
loc_new_line = 'X'.
if ( '' ne loc_command ).
perform sub_cut_text_width
using
loc_command
loc_new_line
lon_cur_pos
gcr_rep-max_width
changing
pra_lines[]
lon_new_pos.
lon_cur_pos = lon_new_pos.
loc_new_line = ''.
endif.
if ( '' ne loc_comment ).
perform sub_cut_text_width
using
loc_comment
loc_new_line
'X'
lon_cur_pos
gcr_rep-max_width
changing
pra_lines[]
lon_new_pos.
lon_cur_pos = lon_new_pos.
loc_new_line = ''.
endif.
if ( '' ne loc_new_line ).
perform sub_cut_text_width
using
loc_new_line
lon_cur_pos
gcr_rep-max_width
changing
pra_lines[]
lon_new_pos.
lon_cur_pos = lon_new_pos.
loc_new_line = ''.
endif.
the end
exit. " form
endform. "sub_cut_text_comment
form : sub_cut_text_width
purp. : splits text info into several lines to make them
fit to a max-width
param : poc_line to source/text line
poc_cmt 'X' chk for comments
rcode : pra_lines appended ( no reset ) line info.
hist. : #00 - KZI - created
form sub_cut_text_width
using
value(poc_text) type string
value(poc_new_line) type flag
value(poc_typ_cmt) type flag
value(pon_cur_pos) type i
value(pon_max_width) type i
changing
pra_lines type typ_line_tab
prn_new_pos type i.
data declaration
data:
lor_text_info type typ_line_info,
lon_cnt_loop type i,
lon_tmp type i,
lon_pos_cur type i,
lon_len_cur type i,
loc_buf_cur type string,
loc_new_line type flag.
init & precheck
loc_buf_cur = poc_text.
loc_new_line = poc_new_line.
lon_pos_cur = pon_cur_pos.
do.
if ( '' eq loc_buf_cur and '' eq loc_new_line or
1000 lt lon_cnt_loop ).
exit. " do
else.
lon_cnt_loop = lon_cnt_loop + 1.
clear:
lor_text_info.
lor_text_info-flag_comment = poc_typ_cmt.
if ( '' ne loc_new_line ).
loc_new_line = ' '.
lor_text_info-flag_newline = 'X'.
lon_pos_cur = 0.
endif.
lon_len_cur = strlen( loc_buf_cur ).
lon_tmp = lon_pos_cur + lon_len_cur.
if ( lon_tmp le pon_max_width ).
" all fits in currentline
lor_text_info-text = loc_buf_cur.
loc_buf_cur = ''.
lon_pos_cur = lon_pos_cur + lon_len_cur.
else.
" we need to split
lon_tmp = pon_max_width - lon_pos_cur.
if ( 0 gt lon_tmp ).
" should not happen
lor_text_info-text = loc_buf_cur.
loc_buf_cur = ''.
else.
lor_text_info-text = loc_buf_cur(lon_tmp).
loc_buf_cur = loc_buf_cur+lon_tmp.
endif.
lon_pos_cur = 0.
loc_new_line = 'X'.
endif.
append lor_text_info to pra_lines[].
endif.
enddo.
the end
prn_new_pos = lon_pos_cur.
exit. " form.
endform. "sub_cut_text_width
[/code] -
Forward Declaration in Class Builder
Hi All,
In the Class Builder (SE24)when i create a new Class, There is an option of Forward declaration in the Property Tab. In this, we can add Type Group Interface and Class. What is the Purpose of this forward declaration?
The F1 help does not provide any help.
Regards,
Kapil.in addition to above replies, it can be used for classes and interfaces in that case Forward declaration is equivalent to
CLASS <class_name> DEFINITION LOAD.
interface <interface_name> load
statements which are normally used in Program ( case for local classes )
use of Load from SAP docu
... LOAD
Effect
The variant with the LOAD addition loads a global class class from the Class Library. This statement was needed before Release 6.20 if you wanted to access one of the static components of class from within a program, or to declare an event handler for class before class had been loaded automatically. From Release 6.20 onwards, the LOAD addition is only needed if the compilation of an ABAP program fails because it includes recursive accesses of a globa l class. In such cases, you may be able to make the program compilable by explicitly loading the class before recursion.
Thanks,
kranthi. -
How to Implement Abap Object and Access Key for se24 developers.
Hi every One,
This is Abdul Rahman, Started Learning Abap Objects i want a simple program to be executed i.e. in Local class (Abap program)and as well in global class(class builder).
Also i would like to know When ,Were and Why Abap Object should be used.
prob to Me :- When i wanted execute F8 a Class in se24 Class Builder it is asking me AcessKey , plz if this is required plz any one send Me.
I have this key 36687663221261278694 it is already used in Abap editor , it is not accepting in se24 .
plz help Me , waiting for response ..
thankyou so much
Abdul Rahman.Hello Abdul
Here are my answers to your questions:
(1) <b>Local classes</b>: <i>Do not use them.</i>
- As long as your class is rather small (few attributes and methods), local classes are ok yet as soon as they become larger you will loose the overview
(2) <b>Global classes</b>: <i>Do use them.</i>
- Make use of global classes even if they are only used for your training. The big advantage over local classes is that you will get used to the classe builder (SE24) which has a plethora of functions.
(3) <b>Executing global classes</b>: <i>Can be done if you have defined an OO-transaction.</i>
- An OO-transaction has a class and one of its public methods as parameters (similar like report transactions). When you all the OO-transaction an instance of you class is created and the public method is called.
(4) <b>Where and Why use ABAP Objects?</b> <i>Everywhere. Anytime.</i>
- ABAP objects is about stability, maintainability and re-usability of coding. These developer aims can be much more fulfilled using ABAP OO means than in classical programming.
Regards
Uwe
PS: There are situations where local classes are quite appropriate and, using ABAP Unit testing, are obligatory. -
How to throw and handle event defined in component interface
Hi folks,
I have defined a component interface with an event 'open_info'
I have some sub components which are implementing that component interface. I also get the two events generated (the interface check box is not marked)
I use those sub components and try to handle the event. but unfortunately the event is not handled.
I'm not sure if I do everything right. I checked the interface checkbox at the events tab of the controller of the sub component. I then may handle the event in the embedding main component. but it appears to be a different event.
probably I eed to access the interface controller and throw the event there, but I don't know how.
I couldn't fnd documentation or wdr* components which deal with that issue. do you have any suggestions?
regards
stefanHi Stefan,
Do the following in the component being used:
say component name is ZCMP_01
go to COMPONENTCONTROLLER
Create an Event with necessary parameters if needed, say Event name is EVNT_01 and has an importing parameter, say PARAM_01 type char10,
Make sure you have set the interface check box. Now this event is available in the INTERFACECONTROLLER.
Say ZCMP_01 has a view with a button, on click of the button, call a method in the COMPONENTCONTROLLER.
Perform all the required operations, At the required point, fire EVNT_01
wd_this->fire_EVNT_01_evt(
PARAM_01 = 'sample' ).
Now the other component that has to use ZCMP_01, say ZCMP_02
In the component properties od ZCMP_02, add usage for ZCMP_01, say USG_CMP_01
Go to the view in ZCMP_02 where you wish to handle the event EVNT_01 of ZCMP_01,
Go to Methods tab, create an event hadler, say EVNT_01_HNDLR ... method type = Event Handler,
Event = EVNT_01, Controller = INTERFACECONTROLLER, Component Use, USG_CMP_01.
Now your event handler will have foll parametrs: WDEVENT .. type ref to CL_WD_CUSTOM_EVENT,
PARAM_01 type CHAR10
Handle the event as required.
Regards,
Reema. -
How in ABAP do you develop a class to publish an event externally
Hi all,
I am trying to publish equipment information to multiple systems using ECC 6.0 and PI 7.1
Here are two articles which I have read which were very useful
http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/800e2826-718c-2a10-f680-d6b29f0dce18
http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/a0334534-aa28-2b10-a3a2-9ed4135727ed
High level overview of what I've done is as follows.
PI
- I developed a generic Service Interface called Asset_Sync and mapped this to a non SAP backend system to persist the equipment information (this all works fine).
- I also published the Sender Agreement for Asset_Sync to ESR
ECC 6.0
- I generated a client proxy ZEFI_CO_ASSET_SYNC from the ESR entry for Asset_Sync
- I used transaction SWF_BAM and have created an event linkage for object type EQUI event Changed
Here is where I am stuck
I now need to define the Proxy object to publish the equipment information to PI.
I am not sure if I have to extend the object EQUI to ZZEQUI and whether I need to create a method execute-synchronous.
I am really looking for some sample code of how to create the Proxy object and link it to the event.
Regards,
John
P.S.
I have coded a test program which calls the proxy and sends the information to PI and then to the third party system it looks as follows and works fine, it is just a shell right now once I have finished linking it to the event I will enhance the message interface and pass real values (for now my mapping in PI just hardcodes enough data so the publish to the back end system works). Basically althugh this works I need to execute this automatically from the event being triggered and hence need to move this into a proxy with event linkage.
FORM CREATE_ENTITLEMENT .
DATA: lv_assset_sync_req TYPE ZEFI_ASSET_SYNC_REQUEST,
lv_assset_sync_resp TYPE ZEFI_WSRESPONSE1.
CREATE OBJECT lv_asset_sync_proxy
EXPORTING
LOGICAL_PORT_NAME = 'ASSET_SYNC_DX3'.
*TRY.
*TRY.
CALL METHOD LV_ASSET_SYNC_PROXY->ASSET_SYNC
EXPORTING
OUTPUT = lv_assset_sync_req
IMPORTING
INPUT = lv_assset_sync_resp.
Write :/ 'Status : ', lv_assset_sync_resp-WSRESPONSE-STATUS.
WRite :/ 'Code : ', lv_assset_sync_resp-WSRESPONSE-CODE.Hi all,
I thought I'd give an update.
After reading a number of articles and documentation (see below).
It appears it may be easier to create a new class using SE24 rather than extending the Business Object in SWO1.
I've done the following which works via a user-exit.
a. Create Class ZZEQUI
b. Create an Instance Dependent Object to Publish the Entitlement
c. Leverage User Exit MV50AFZ1 - FORM USEREXIT_SAVE_DOCUMENT_PREPARE
d. Created Include ZSDI_DELIVERY_PUBLISH
i. Loops through serial numbers
ii. Create Object LV_ASSET EXPORTING EQUNR = LV_EQUNR
iii. CALL LV_ASSET->Publish.
If I add the Interface IF_WORKFLOW to my class then I may be able to be trigger it from SWF_BAM.
The solution I have is working, if I decide to go with BAM and have additional questions I'll raise this in either the workflow or ABAP Objects forums.
Regards,
John
Addtional articles and documentation
i. Business Object Macros http://help.sap.com/saphelp_nw04/helpdata/en/c5/e4ad23453d11d189430000e829fbbd/frameset.htm
ii. Integrating Abap Objects with Workflow http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/b0409e6c-d213-2d10-3cb6-c12d417626c1
iii. Why Use ABAP OO with workflow /people/jocelyn.dart/blog/2006/06/19/why-use-abap-oo-with-workflow
iv. ABAPOO for WUG http://wiki.sdn.sap.com/wiki/display/HOME/2.Designand+Development#2.DesignandDevelopment-HowcanIuseABAPOOClassesinWorkflow%3F
Maybe you are looking for
-
Adding New table to the existing page
Hi, i have a task i.e i have to create a new UI(consista table structure) and add to the existing page.How can do this one.If any one knows please respond asap. This is urgent requirement. Thanks in advance. Bye Palakondaiah
-
TV out problem, rolling back to earlier firmwares
I went and bought a component video cable from Apple, so I could improve my video output to TV (I've got a composite video cable, as well) Well, get back from the Apple store, hook up my cable to test it and -- nothing plays back, absolutely nothing.
-
Where can I buy a charger?
Where can I buy a charger for this model number tablet? I want a OEM Sony Charger Sony Xperia Z SGP311U1/B
-
Cannot Open Attachments within a pdf document
Dear Staff, In my windows 7 netbook I can open files attached to PDF documents is there a reason why I cannot open these files within windows 8.1 RT with the adobe Reader Touch? is there any setting to adjust to have this function active or Adobe Re
-
For XI-3.0 Latest SP18 but for PI-7.0 SP12(for Nweaver2004s).why
for XI-3.0 Latest SP18 but for PI-7.0 SP12(for Nweaver2004s).SP18 is latest one....right.but for 2004s SP12 is prefered.why?what is main difference