Includes in global Class
Hi all,
I have a global class (created in SE24 - Class builder) and need to use constants and types in its methods, that are defined in an include.
In functional development we just put a "INCLUDE includename." in the function group top-include.
Where can I put that include in the global class?
I tried the "local types" source file, but it doesnt accept the constant definitions inside my include.
hi, Frank Besler
If you want to add global (constant)value and type definantion, you can add them in the LXXXXTOP file, the XXXX is the function group name.
if you don't want all of the defination added only one file, you can create a file, named LXXXXFYYY, XXXX is still function group, YYY is the random string you set.
and add the 'include LXXXXFYYY' into the SAPLXXXX. (XXXX is still function group name). SAPLXXXX is the main program for the function group, you can find its name in the 'Attributes' tab 'Program name' fields in se37.
click the SAPLXXXX, you can see a example like this:
* System-defined Include-files. *
INCLUDE LATSVTOP. " Global Data
INCLUDE LATSVUXX. " Function Modules
* User-defined Include-files (if necessary). *
* INCLUDE LATSVF... " Subprograms
* INCLUDE LATSVO... " PBO-Modules
* INCLUDE LATSVI... " PAI-Modules
* add your include file here
include LATSVF01.
Please aware the your include file name can't be set random, you must follow the rule, otherwise the compile will failed.
Similar Messages
-
Access global data of report in global class methods?
Hi all,
I have defined one global class in SE24 and i am using methods of this class in report program.
Can i access global data of my report program in class methods directly without declaring it as IMPORT
parameter?
Thanks,
ApitaHi,
Well, now you did confuse me: first you asked about using global data of a report program in global class (created in SE24), and the answer is: no, you can't directly access the global data of another program in a method of global class (yes, you should pass them via importing parameters), and you shouldn't even consider using indirect means of doing so via special form of ASSIGN statement reserved for internal use by SAP. The ASSIGN will not work if someone reuses the global class elsewhere in the system without loading your report. Don't ever program such atrocious dependencies in global class...
And now you ask about the use "in method implementation in report program"..? Just to be sure - you can't program the implementation of a global class method in a report program.
You can program a local class inheriting from a global class and redefine/re-implement methods of such global super-class in a report program. Global data of report program, including the selection screen, would be directly accessible to such local class. It would still not be a good idea to use this access:
Conversely, within an encapsulated unit, that is, within a class, you should avoid accessing more global data directly. Within methods, you should generally modify attributes of the class only. Write access to global data outside the class is not recommended. Accessing data in this way should only be done using specially marked methods, if at all. The use of methods of a class should not evoke any side effects outside the class itself.
cheers
Jānis
Message was edited by: Jānis B -
Hi everybody.
I want export a global class (SE24, Object Builder) to a local class in a INCLUDE, but unfortunally the Object Builder has no export function.
Does anybody know a way to change a global class to a local class?
Thx.There's no easy way. I'm at a bit of a loss why you'd want to replace a global class witha local class that you include in your programs. What do you gain?
But if you insist, you can always cut and paste the public/private/protected sections of your class (making suitable modifications and assuming you're not on an old SAP version), and then you'd have to cut and paste the method implementations in as well.
Printing a class to a the spool is a fairly good way of getting all its details. Another alternative is to search these forums for where the includes that actually make up the class are - it should be fairly simple to write a program that would take that source code and construct local classes from it. But I still don't see the point. -
Hi Friends,
Can a local class make friend with global class???
for example i have a local class in se38 editor and this local class should access the private attribute of global class which is there in se24.
DeepakHI Deepak
Yo can define your ABAP Unit test class as a friend of the global class to be tested in the local class definition include of your global class. So, you have to add a line of code like
CLASS <name of global class to be tested> DEFINITION LOCAL FRIENDS <name of local ABAP Unit class> in the include where the definition of local ABAP Unit Class is in. Then you can call the private methods of your global class in the local abap unit class methods.
just refer these links
http://help.sap.com/saphelp_nw2004s/helpdata/en/ec/d9ab291b0b11d295400000e8353423/content.htm
local class -> global class
Regards Rk -
SE24 Global class transportation failed
Hi,
I have created one global class with two methods in it (Development server). When i checked the syntax errors in these methods there are no errors. But when i transported this global class to quality system, the transportaion failed and when i checked the syntax errors of these methods in quality system , it is giving one error saying that 'include report 'zcl_pricing============cl' not found.
this zcl_pricing is the global class created in development server.are you sure that class and methods are in same transport? Check object entry.
If class and method are in same transport, go to quality system (SE24) and check if class is available. Maybe all you have to do is activate it in quality system. -
Local class as a friend of a global class
Hi guys,
I'm just wondering if I could make a local class which is defined in the local section of a global class to its friend. I need this to check private attriutes and methods with abap unit.
Regards ChristianHi Christian,
Yo can define your ABAP Unit test class as a friend of the global class to be tested in the local class definition include of your global class. So, you have to add a line of code like
CLASS in the include where the definition of local ABAP Unit Class is in. Then you can call the private methods of your global class in the local abap unit class methods.
Regards,
Sükrü -
Saving global classes / packages
Hi,
I created a package inside se80 with global classes and I want to save this package or/and the global classes to disc (for other projects).
How can I achieve this?
I know the report REPTRAN but this tool saves all my global classes (in all packages) with odd filenames. Is it possible to do this without using the transport organizer and without copy/paste the hole code by hand?
Cu
AlexI suggest that you should read this New to Java material, as these forums are an especially inefficient way of learning the basics of Java. Most people (including myself) are not willing to write in sufficient detail for the material to be understandable by someone who doesn't have any knowledge of Java.
http://java.sun.com/learning/new2java/index.html -
Error while usind Private Method of a global class
HI All..
I created a global class (ZLINE_GLOBAL) which has TOT_DATA private method. I have to call this private method in my report, I know that using Friend class we can do this.
But it is not working and showing the same error " METHOD "TOT_DATA" is unknown or Private or Public..
code i tried is
CLASS c2 DEFINITION DEFERRED.
CLASS ZLINE_GLOBAL DEFINITION FRIENDS c2.
PUBLIC SECTION.
METHODS : m1.
PRIVATE SECTION.
METHODS: m2.
ENDCLASS.
CLASS ZLINE_GLOBAL IMPLEMENTATION .
METHOD m1.
WRITE : 'Public Method C1'.
ENDMETHOD. "M1
METHOD m2.
WRITE : 'Private Method C1'.
ENDMETHOD.
ENDCLASS.
CLASS c2 DEFINITION FRIENDS ZLINE_GLOBAL. "my friends are here, allow them access to my (C2's) private components
PUBLIC SECTION.
METHODS :m3.
ENDCLASS.
CLASS c2 IMPLEMENTATION.
METHOD m3.
DATA : obj TYPE REF TO ZLINE_GLOBAL.
CREATE OBJECT obj.
CALL METHOD obj->TOT_DATA. "here Iam calling Private method of global class
ENDMETHOD. "M3
ENDCLASS.
START-OF-SELECTION.
DATA obj_c2 TYPE REF TO c2.
CREATE OBJECT obj_c2.
obj_c2->m3( ).
can anybody help me on this..
MurthyHi Murthy,
Replace TOT_DATA with M2, you do not have any method by name "TOT_DATA" in your code.
CLASS c2 DEFINITION DEFERRED.
CLASS ZLINE_GLOBAL DEFINITION FRIENDS c2.
PUBLIC SECTION.
METHODS : m1.
PRIVATE SECTION.
METHODS: m2.
ENDCLASS.
CLASS ZLINE_GLOBAL IMPLEMENTATION .
METHOD m1.
WRITE : 'Public Method C1'.
ENDMETHOD. "M1
METHOD m2.
WRITE : 'Private Method C1'.
ENDMETHOD.
ENDCLASS.
CLASS c2 DEFINITION FRIENDS ZLINE_GLOBAL. "my friends are here, allow them access to my (C2's) private components
PUBLIC SECTION.
METHODS :m3.
ENDCLASS.
CLASS c2 IMPLEMENTATION.
METHOD m3.
DATA : obj TYPE REF TO ZLINE_GLOBAL.
CREATE OBJECT obj.
CALL METHOD obj->M2. "here Iam calling Private method of global class
ENDMETHOD. "M3
ENDCLASS.
START-OF-SELECTION.
DATA obj_c2 TYPE REF TO c2.
CREATE OBJECT obj_c2.
obj_c2->m3( ).
Regards,
Chen -
Creation of Material using BDC Session method & global class
Hi
Creation of Material using BDC Session method & global class by using oops.
can anyone plz help me outHi,
it looks like it's not possible to call this BAPI wihtout material number. Here is a quote from BAPI documentation.
When creating material master data, you must transfer the material
number, the material type, and the industry sector to the method. You
must also enter a material description and its language.
Cheers -
Export global classes to a local file
Hi,
is it possible to export a global class with all of its attributes, types, methods and more to a local file for archiving purposes?
We are currently using ECC 6.0, btw.
MichaelSure, via [SAPlink|http://code.google.com/p/saplink/]
Regards
Marcin -
Download Global Class attributes
Hi...
I want to download the global class attributes into an excel. when i checked the menu there is no such option.. Is that possible to do.. Can anyone guide me...
Thanks in advance.
Kalpanashri Rajendran.Hi,
Assuming you are asking specifically about the global class "Attributes" and not all information about the global class itself. To get the "Attributes" in a spreadsheet you can try this work-around:
1. Run transaction SE84 Repository Info System.
2. Expand the "Class Library" branch.
3. Double-click the "Attributes" node.
4. Enter your global class name and run the search.
5. Once the list of attributes is displayed, choose menu path System -> List -> Save -> Local File.
6. Choose "Spreadsheet" format in the popup.
7. Give a file path and name for your spreadsheet.
8. You should now have a spreadsheet with all the "Attributes" of your global class.
Best Regards,
Jamie -
Include rt.jar class files in my own jar file to run 1.2+ applets on MS JVM
My problem is this. I'm writing an applet (which includes 1.2 classes) for my organization (over 2000 NT workstations) in which no one has administrative privelages to install Sun's JRE 1.2 or greater. The target browser is IE 5. Our NT admins are having problems pushing the JRE out so my only two options are to rewrite everything as 1.1 or somehow include the missing class files from rt.jar.
I really do not want to rewrite it all!
I was able to extract the missing class files (i.e. /java/util/HashMap.class) but I cannot figure out how to get the IE JVM to use them. Things I have tried:
1. jarred up all my class files along with the missing classes from rt.jar.
$ jar cvf test.jar *.class java
added manifest
adding: ArrayObj.class(in = 731) (out= 448)(deflated 38%)
adding: DivMonGrid.class(in = 1509) (out= 812)(deflated 46%)
adding: GridLayout2.class(in = 2720) (out= 1514)(deflated 44%)
adding: Item.class(in = 317) (out= 232)(deflated 26%)
adding: Row.class(in = 588) (out= 365)(deflated 37%)
adding: Screen.class(in = 672) (out= 416)(deflated 38%)
adding: Site.class(in = 545) (out= 360)(deflated 33%)
adding: divmonDash.class(in = 12506) (out= 6892)(deflated 44%)
adding: java/(in = 0) (out= 0)(stored 0%)
adding: java/util/(in = 0) (out= 0)(stored 0%)
adding: java/util/HashMap.class(in = 6668) (out= 3461)(deflated 48%)
adding: java/util/HashMap$1.class(in = 931) (out= 513)(deflated 44%)
adding: java/util/HashMap$2.class(in = 800) (out= 454)(deflated 43%)
adding: java/util/HashMap$3.class(in = 1608) (out= 904)(deflated 43%)
adding: java/util/HashMap$EmptyHashIterator.class(in = 592) (out= 358)(deflated 39%)
adding: java/util/HashMap$Entry.class(in = 1505) (out= 775)(deflated 48%)
adding: java/util/HashMap$HashIterator.class(in = 1814) (out= 1096)(deflated 39%)
$ jar -tf test.jar
META-INF/
META-INF/MANIFEST.MF
ArrayObj.class
DivMonGrid.class
GridLayout2.class
Item.class
Row.class
Screen.class
Site.class
divmonDash.class
java/
java/util/
java/util/HashMap.class
java/util/HashMap$1.class
java/util/HashMap$2.class
java/util/HashMap$3.class
java/util/HashMap$EmptyHashIterator.class
java/util/HashMap$Entry.class
java/util/HashMap$HashIterator.class
RESULT: IE JVM complains classnotfoundexception (its complaining about not finding HashMap.class)
2. Tried to just place missing *.class files in same directory as my class files
RESULT: Compiler error (complaining about file not be in correct path package) I understand this because when it was created the package statement has the class file in java/util/.
If anyone has done this before or knows how to do it, please help me out.
Thanks!When the collection classes first came out, I think they were available in a separate jar (although the package name may be slightly different). If it's just collection classes, that might be worthwhile looking at.
The MS JVM may be spewing because the class format is too new; you may try with rt.jar classes from an older JVM (such as JDK 1.2), or try to recompile them from source using -target 1.1. -
Major global classes used in abap objects
Hi,
I am new to the abap objects and till now i am to understand that the role of the global classes are important in the abap object program. I had tried to search on the net but i was not able to get the desired result.
I want to know which are the major global classes which are used in the ABAP objects.
Plzz provide me guidelines for it.Ricx,
It depends on your requirement.
For alv's we use these global classes. For Webdynpro related alv we use different global classes.
CL_GUI_ALV_GRID (List Viewer)
CL_GUI_ALV_GRID_BASE (Basis Class for ALV grid)
CL_GUI_ALV_TREE (ALV Tree Control)
CL_GUI_ALV_TREE_SIMPLE (Simple ALV Tree)
CL_ALV_TABLE_CREATE (Dynamic Creation of ALV Data Table)
CL_ALV_TREE_BASE (Basis Class ALV Tree Control)
CL_CK_ALVTREE_NKEY_2_OBJECT (Converter Node Key Object)
CL_ALV_EVENT_DATA (Changing Data Container for Events)
CL_ALV_EVENT_TOOLBAR_SET (ALV Context menu)
Regards,
Arun. -
Event handling in global class (abap object)
Hello friends
I have 1 problem regarding events in abap object... how to handel an event in global class in se24 .
Regards
Reema jain.
Message was edited by:
Reema JainHello Reema
The following sample report shows how to handle event in principle (see the § marks)..
The following sample report show customer data ("Header"; KNB1) in the first ALV list and sales areas ("Detail"; KNVV) for the selected customer (event double-click) in the second ALV list.
*& Report ZUS_SDN_TWO_ALV_GRIDS
REPORT zus_sdn_two_alv_grids.
DATA:
gd_okcode TYPE ui_func,
go_docking TYPE REF TO cl_gui_docking_container,
go_splitter TYPE REF TO cl_gui_splitter_container,
go_cell_top TYPE REF TO cl_gui_container,
go_cell_bottom TYPE REF TO cl_gui_container,
go_grid1 TYPE REF TO cl_gui_alv_grid,
go_grid2 TYPE REF TO cl_gui_alv_grid,
gs_layout TYPE lvc_s_layo.
DATA:
gt_knb1 TYPE STANDARD TABLE OF knb1,
gt_knvv TYPE STANDARD TABLE OF knvv.
"§1. Define and implement event handler method
" (Here: implemented as static methods of a local class)
* CLASS lcl_eventhandler DEFINITION
CLASS lcl_eventhandler DEFINITION.
PUBLIC SECTION.
CLASS-METHODS:
handle_double_click FOR EVENT double_click OF cl_gui_alv_grid
IMPORTING
e_row
e_column
es_row_no
sender.
ENDCLASS. "lcl_eventhandler DEFINITION
* CLASS lcl_eventhandler IMPLEMENTATION
CLASS lcl_eventhandler IMPLEMENTATION.
METHOD handle_double_click.
* define local data
DATA:
ls_knb1 TYPE knb1.
CHECK ( sender = go_grid1 ).
READ TABLE gt_knb1 INTO ls_knb1 INDEX e_row-index.
CHECK ( ls_knb1-kunnr IS NOT INITIAL ).
CALL METHOD go_grid1->set_current_cell_via_id
EXPORTING
* IS_ROW_ID =
* IS_COLUMN_ID =
is_row_no = es_row_no.
* Triggers PAI of the dynpro with the specified ok-code
CALL METHOD cl_gui_cfw=>set_new_ok_code( 'DETAIL' ).
ENDMETHOD. "handle_double_click
ENDCLASS. "lcl_eventhandler IMPLEMENTATION
START-OF-SELECTION.
SELECT * FROM knb1 INTO TABLE gt_knb1
WHERE bukrs = '1000'.
* 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 splitter container
CREATE OBJECT go_splitter
EXPORTING
parent = go_docking
rows = 2
columns = 1
* NO_AUTODEF_PROGID_DYNNR =
* NAME =
EXCEPTIONS
cntl_error = 1
cntl_system_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.
* Get cell container
CALL METHOD go_splitter->get_container
EXPORTING
row = 1
column = 1
RECEIVING
container = go_cell_top.
CALL METHOD go_splitter->get_container
EXPORTING
row = 2
column = 1
RECEIVING
container = go_cell_bottom.
* Create ALV grids
CREATE OBJECT go_grid1
EXPORTING
i_parent = go_cell_top
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.
"§2. Set event handler (after creating the ALV instance)
SET HANDLER: lcl_eventhandler=>handle_double_click FOR go_grid1. " Or:
" SET HANDLER: lcl_eventhandler=>handle_double_click FOR all instances.
CREATE OBJECT go_grid2
EXPORTING
i_parent = go_cell_bottom
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.
* Display data
gs_layout-grid_title = 'Customers'.
CALL METHOD go_grid1->set_table_for_first_display
EXPORTING
i_structure_name = 'KNB1'
is_layout = gs_layout
CHANGING
it_outtab = gt_knb1
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.
gs_layout-grid_title = 'Customers Details (Sales Areas)'.
CALL METHOD go_grid2->set_table_for_first_display
EXPORTING
i_structure_name = 'KNVV'
is_layout = gs_layout
CHANGING
it_outtab = gt_knvv " empty !!!
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.
* NOTE: dynpro does not contain any elements
CALL SCREEN '0100'.
* Flow logic of dynpro (does not contain any dynpro elements):
*PROCESS BEFORE OUTPUT.
* MODULE STATUS_0100.
*PROCESS AFTER INPUT.
* MODULE USER_COMMAND_0100.
END-OF-SELECTION.
*& Module STATUS_0100 OUTPUT
* text
MODULE status_0100 OUTPUT.
SET PF-STATUS 'STATUS_0100'. " contains push button "DETAIL"
* SET TITLEBAR 'xxx'.
* Refresh display of detail ALV list
CALL METHOD go_grid2->refresh_table_display
* EXPORTING
* IS_STABLE =
* I_SOFT_REFRESH =
EXCEPTIONS
OTHERS = 2.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
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.
* User has pushed button "Display Details"
WHEN 'DETAIL'.
PERFORM entry_show_details.
WHEN OTHERS.
ENDCASE.
CLEAR: gd_okcode.
ENDMODULE. " USER_COMMAND_0100 INPUT
*& Form ENTRY_SHOW_DETAILS
* text
* --> p1 text
* <-- p2 text
FORM entry_show_details .
* define local data
DATA:
ld_row TYPE i,
ls_knb1 TYPE knb1.
CALL METHOD go_grid1->get_current_cell
IMPORTING
e_row = ld_row.
READ TABLE gt_knb1 INTO ls_knb1 INDEX ld_row.
CHECK ( syst-subrc = 0 ).
SELECT * FROM knvv INTO TABLE gt_knvv
WHERE kunnr = ls_knb1-kunnr.
ENDFORM. " ENTRY_SHOW_DETAILS
Regards
Uwe -
Hi,
I want to add one data dictionary field as select option in a global class. I am trying to declare as table type. But i missed out something and it is not working. Could anybody help me out in this.
Regards,
Krishna.Hello Krishna
You may have a look at table type RSELOPTION (line type RSDSSELOPT).
Alternatively, you can use a trick to "import" select-options for a selection screen into your class:
How to pass a select-options to a class method
Passing select-options value in method
Regards
Uwe
Maybe you are looking for
-
Hello Xperts, Can someone please let me know the steps of doing ABC analysis in BW. Thanks Rohit Parti
-
Adjusting Automatically Generated Document Properties?
Background: I create documents with Word Perfect X4. I then print to PDF using a printer called "Adobe PDF." I also have a program installed on my computer called Adobe Distiller that I think may be involved. I've notice recently that my PDF files
-
Internal Flash Not Mounting as Mass Storage Device
I just switched from a Storm to a Tour. In Mass Storage Device Mode, the Storm would mount as two drives -- Blackberry1 for device memory and Blackberry2 for the SD card. The Tour only mounts Blackberry2. Anybody know why the difference or if this
-
UDF: Conversion for all units into Days
Hi Experts, I am working on MATMAS05 to Legacy system Interface. I have the following requirement. MATMAS05/IDOC/E1MARAM-MHDHB (Value) MATMAS05/IDOC/E1MARAM-IPRKZ (Indicator) Take one example: MHDHB is having value like '10'. IF IPRKZ is not having a
-
Slice transparency on save single slice / background color for artboard
Hi, I know, I am missing something obvious in Illustrator CS5 here: - how do I set the transparency for a slice(e.g. for a red background color)? - how do I set the background color for a particular artboard? Greetings Michael Kastner