Displaying checkbox using Class interface
Hi,
Is it possible to display a checkbox in top-of-page for an ALV report using the class interface "cl_dd_document"?
Note: I have already tried the method "add_icon" but it doesnt seem to be working. So the procedure along with sample coding would be more helpful.
To get the configuration for one particular service from ConfigurationService:
String PID_MQTT_DATA_TRANSPORT = "org.eclipse.kura.core.data.transport.mqtt.MqttDataTransport";
ComponentConfiguration mqttConfiguration = m_configurationService.getComponentConfiguration(PID_MQTT_DATA_TRANSPORT);
Map<String,Object> mqttConfigurationProperties = mqttConfiguration.getConfigurationProperties();
This will get the MqttDataTransportService configuration, you can ask the configuration of any service registered providing its PID.
This means you need the ConfigurationService available in your service. Just ask OSGi to inject it.
public class YourService implements ConfigurableComponent {
private ConfigurationService m_configurationService;
public void setConfigurationService(ConfigurationService configurationService) {
m_configurationService = configurationService;
public void unsetConfigurationService(ConfigurationService configurationService) {
m_configurationService = null;
// Your methods here ...
In your OSGI-INF/yourservice.xml
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0"
name="your.Service"
activate="activate"
deactivate="deactivate"
enabled="true"
immediate="true"
configuration-policy="ignore">
<implementation class="your.ServiceImpl"/>
<property name="service.pid" type="String" value="your.Service"/>
<service>
<provide interface="your.Service"/>
</service>
<reference name="ConfigurationService"
policy="static"
bind="setConfigurationService"
unbind="unsetConfigurationService"
cardinality="1..1"
interface="org.eclipse.kura.configuration.ConfigurationService"/>
</scr:component>
Hope this small example will be helpful.
Similar Messages
-
Some commonly used Class interfaces
Hi,
Can anyone provide me some commonly used class interfaces list.
Regards,
ThanigaiHi,
the 6 different Class interfaces are
Importing
Exporting
Changing
Reternig
Receiving
Raising
Regards,
Anirban -
How many columns can be display if use Class cl_gui_alv_grid?
Hi,
I have a fieldcat table which contains 200 items. But it only shows about 90 columns in my alv display.
I use function: LVC_FIELDCATALOG_MERGE to build fieldcatory and I found there are 200 records in my fieldcatory internal table when I debug it.
Can anyone give me some advise to show full culomns in my alv display?
Thanks a lot~Hi,
In Debug mode check check the NO_OUT field for each entry in the Field Catalog. If it has the value X for some fields then those fields will not be displayed.
Or check is there any Layout Variant is passed to the IS_VARIANT parameter. -
HOW TO USE Class Interface CL_GUI_FRONTEND_SERVICES
Dear All,
I am working to get output of SMARTFORMS through report into PDF file.Following code i am using inside LOOP.
*CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_SAVE_DIALOG
EXPORTING
WINDOW_TITLE =
DEFAULT_EXTENSION = 'PDF'
DEFAULT_FILE_NAME = 'PAYSLIP.pdf'
WITH_ENCODING =
FILE_FILTER =
INITIAL_DIRECTORY =
PROMPT_ON_OVERWRITE = 'X'
CHANGING
FILENAME = W_FILE_NAME
PATH = W_FILE_PATH
FULLPATH = W_FULL_PATH
USER_ACTION =
FILE_ENCODING =
EXCEPTIONS
CNTL_ERROR = 1
ERROR_NO_GUI = 2
NOT_SUPPORTED_BY_GUI = 3
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.
*CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
BIN_FILESIZE = W_BIN_FILESIZE
FILENAME = W_FILE_NAME
FILETYPE = 'BIN'
TABLES
DATA_TAB = T_PDF_TAB.
*IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
*ENDIF.
I am getting proper output through the above coding.
But problem is,if there will be a multiple PDF output it always ask the path to save each PDF file as i am using "FILE_SAVE_DIALOG"
I want all PDF files to save at once by giving default path of PC.
How can i do this, is there any other method i can use please
let me know...
Regards,
AnkurHi,
I have used following code..
CALL METHOD cl_gui_frontend_services=>gui_download
EXPORTING
bin_filesize =
filename =
filetype = 'ASC'
append = SPACE
write_field_separator = SPACE
header = '00'
trunc_trailing_blanks = SPACE
write_lf = 'X'
col_select = SPACE
col_select_mask = SPACE
dat_mode = SPACE
confirm_overwrite = SPACE
no_auth_check = SPACE
codepage = SPACE
ignore_cerr = ABAP_TRUE
replacement = '#'
write_bom = SPACE
trunc_trailing_blanks_eol = 'X'
wk1_n_format = SPACE
wk1_n_size = SPACE
wk1_t_format = SPACE
wk1_t_size = SPACE
IMPORTING
filelength =
changing
data_tab = T_PDF_TAB
but the error it is giving that "T_PDF_TAB is not a compatible type". -
List display for ALV using class and methods
Hi friends
I want the list display for the ALV using Class and methods
which class and methods i can use.
Here we can't use the REUSE_ALV_LIST_DISPLAY and also GRID
I was done GRID display using class and methods but i want only list display for using class.
plz Give me sample code of list display not for grid.
Thanks
Nani.hi
please check with this code...
declare grid and container.
DATA : o_alvgrid TYPE REF TO cl_gui_alv_grid,
o_dockingcontainer TYPE REF TO cl_gui_docking_container,
i_fieldcat TYPE lvc_t_fcat,"fieldcatalogue
w_layout TYPE lvc_s_layo."layout
If any events like double click,etc., are needed we have to add additional functionality.
call the screen in program.
Then , create the container as follows
IF cl_gui_alv_grid=>offline( ) IS INITIAL.
CREATE OBJECT o_dockingcontainer
EXPORTING
ratio = '95'
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5
others = 6.
ENDIF.
CREATE OBJECT o_alvgrid
EXPORTING
i_parent = o_dockingcontainer.
Build the fieldcatalog
create a output structure in SEll for the ALV output
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = <alv output>
CHANGING
ct_fieldcat = i_fieldcat[]
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE i030."Error in building the field catalogue
LEAVE LIST-PROCESSING.
ENDIF.
*If you need to modify the field catalog,modify it using field sysmbols
*setting the layout
w_layout-grid_title = title.
w_layout-zebra = 'X'.
then displaying the output
CALL METHOD o_alvgrid->set_table_for_first_display
EXPORTING
i_save = 'A'
is_layout = w_layout
CHANGING
it_outtab = i_output[]
it_fieldcatalog = i_fieldcat[]
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE i032 ."Error in Displaying
LEAVE LIST-PROCESSING.
ENDIF.
*After that in PAI of the screen, you need to free the *object while going back from the screen(according to *your requirement)
MODULE user_command_9001 INPUT.
CASE sy-ucomm.
WHEN 'EXIT' OR 'CANC'.
PERFORM f9600_free_objects:
USING o_alvgrid 'ALV' text-e02,
USING o_dockingcontainer 'DOCKING'
text-e01.
LEAVE PROGRAM.
ENDCASE.
ENDMODULE. " USER_COMMAND_9001 INPUT
*in the program, write the follwoing code
FORM f9600_free_objects USING pobject
value(ptype)
value(ptext).
DATA: l_objectalv TYPE REF TO cl_gui_alv_grid.
CASE ptype.
WHEN 'ALV'.
l_objectalv = pobject.
IF NOT ( l_objectalv IS INITIAL ).
CALL METHOD l_objectalv->free
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
OTHERS = 3.
CLEAR: pobject, l_objectalv.
PERFORM f9700_error_handle USING ptext.
ENDIF.
WHEN 'DOCKING'.
DATA: lobjectdock TYPE REF TO cl_gui_docking_container.
lobjectdock = pobject.
IF NOT ( lobjectdock IS INITIAL ).
CALL METHOD lobjectdock->free
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
OTHERS = 3.
CLEAR: pobject, lobjectdock.
PERFORM f9700_error_handle USING ptext.
ENDIF.
WHEN 'CONTAINER'.
DATA: lobjectcontainer TYPE REF TO cl_gui_container.
lobjectcontainer = pobject.
IF NOT ( lobjectcontainer IS INITIAL ).
CALL METHOD lobjectcontainer->free
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
OTHERS = 3.
CLEAR: pobject, lobjectcontainer.
PERFORM f9700_error_handle USING ptext.
ENDIF.
WHEN OTHERS.
sy-subrc = 1.
PERFORM f9700_error_handle USING
text-e04.
ENDCASE.
ENDFORM. " f9600_free_objects
FORM f9700_error_handle USING value(ptext).
IF sy-subrc NE 0.
CALL FUNCTION 'POPUP_TO_INFORM'
EXPORTING
titel = text-e03
txt2 = sy-subrc
txt1 = ptext.
ENDIF.
endform.
also check with this
http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCSRVALV/BCSRVALV.pdf
Hope this helps
if it helped, you can acknowledge the same by rewarding
regards
dinesh -
Questions on using classes inside BSP pages
Hi Group,
I have a few questions on how to use classes,interfaces,parameters in classes,
and etc., relating to OOPs concepts that can be implemented in BSPs.
Pls send me some link wherein I can explore things and use it in BSPs.
Thanks & Regards,
Vishnu.Hi Raja,
I am facing issues like this:
1) When I use the code in my BSP as under:
<%
class ZCL_MODEL_03 definition load.
data ref1 type ref to ZCL_MODEL_03.
data cust_id type c value "1000".
data c_id type c.
create object ref1.
c_id = cust_id.
call method ref1->CHECK_CUSTOMER changing cid = cust_id.
%>
Cannot we define variables in the Scriptlet?? or we need to do only in the attributes sections only?? or in both??
2)I am not able to use both exporting & importing things in my method call.
eg.,call method ref1->GET_CUSTOMER
exporting cid = cust_id
importing c_id = eid.
In the method definition, I am only using simply logic like, I was trying to send a value into the "cid" defined in the method and putting that value into "eid" which was defined exporting, but, still I could not get the value into "c_id" that I have defined in the BSP page.
Note: in both the things(in BSP and class definition as well, I am using the same
type for defining the attributes.
3)When can we define a "Returning" option in the Class method's parameter
Definition? and how can I use it with an example?
Thanks in advance.
Regards,
Vishnu. -
How to call a method from class interface
Hi ,
I want to call a method from a 'class interface' in a BADI .
Class Interface -- /SAPSRM/CL_PDO_DO_BASE
Method -- /SAPSRM/IF_PDO_DO_PARTNER_BASE~UPDATE_ITEM_PARTNERS
Please let me know how can I call this method in my BADI.
Thanks-Hi Harmeet,
Follow these simple steps.
1. Create an instance of class interface /SAPSRM/CL_PDO_DO_BASE if method /SAPSRM/IF_PDO_DO_PARTNER_BASE~UPDATE_ITEM_PARTNERS is instance method and
call instance -> /SAPSRM/IF_PDO_DO_PARTNER_BASE~UPDATE_ITEM_PARTNERS
2.if method /SAPSRM/IF_PDO_DO_PARTNER_BASEUPDATE_ITEM_PARTNERS is static method ,call directly using class interface like /SAPSRM/CL_PDO_DO_BASE=> /SAPSRM/IF_PDO_DO_PARTNER_BASEUPDATE_ITEM_PARTNERS.
If you feel any dificulty in declaring instances and call methods,
Goto EDIT-> Pattern ->ABAP Object Patterns, Give class name , instance name and method, you got the required code.
Thanks,
Prasad. -
Hi,
I have created a Class using SE80 using Class/Interface option. Can anybody please explain me what will be difference between
RFC and Class Interface. Whether Class Interface can be used as same RFC?
If yes how class can be accessed from other legacy systems?
Whether we need to right a wrapper RFC for this class to access?.
I heard BAPI's also global classes that have BOR entries.How these BAPI are accessing from legacy?
I am very new to ABAP
Thanks
SARPlease don't double post your questions....
RFC Vs Class/Interface
Sorry that I can't answer you question, but haven't work with Class/Interface yet....
Greetings,
Blag. -
How to display icons on selection screen ,without using classes.
Hi Experts,
How can we display icons on the selection-screen ..?
one of the methods i heard frm my frnds was to use ->cl_gui_picture_viewer
but as a begginer i am not tht comfortable with classes .So is there a way around to display icons on my selection screen without using classes .
Thanx in Advance,
Regards ,
Rajesh .Hi,
here a short example:
REPORT Z_TEST2.
TABLES: SSCRFIELDS. "Felder auf Selektionsbildern
INCLUDE .
SELECTION-SCREEN: BEGIN OF BLOCK A01 WITH FRAME TITLE MELDUNG1.
SELECTION-SCREEN: SKIP 2.
SELECTION-SCREEN: BEGIN OF LINE.
SELECTION-SCREEN: COMMENT 10(04) T_ICON.
SELECTION-SCREEN: END OF LINE.
SELECTION-SCREEN: SKIP.
SELECTION-SCREEN: BEGIN OF LINE.
SELECTION-SCREEN: COMMENT 01(34) T_AUFSD.
PARAMETERS: P_AUFSD AS CHECKBOX DEFAULT 'X'.
SELECTION-SCREEN: END OF LINE.
SELECTION-SCREEN: BEGIN OF LINE.
SELECTION-SCREEN: COMMENT 01(34) T_AUFCO.
PARAMETERS: P_AUFCO AS CHECKBOX DEFAULT ' '.
SELECTION-SCREEN: PUSHBUTTON 45(04) PB01 USER-COMMAND SALL.
SELECTION-SCREEN: PUSHBUTTON 50(04) PB02 USER-COMMAND DALL.
SELECTION-SCREEN: END OF LINE.
SELECTION-SCREEN: BEGIN OF LINE.
SELECTION-SCREEN: COMMENT 01(34) T_AUFCS.
PARAMETERS: P_AUFCS AS CHECKBOX DEFAULT ' '.
SELECTION-SCREEN: END OF LINE.
SELECTION-SCREEN: BEGIN OF LINE.
SELECTION-SCREEN: COMMENT 01(34) T_AUFPP.
PARAMETERS: P_AUFPP AS CHECKBOX DEFAULT 'X'.
SELECTION-SCREEN: PUSHBUTTON 45(15) PB03 USER-COMMAND INIT.
SELECTION-SCREEN: END OF LINE.
SELECTION-SCREEN: SKIP 2.
SELECTION-SCREEN: BEGIN OF LINE.
SELECTION-SCREEN: PUSHBUTTON 45(15) PB04 USER-COMMAND ONLI.
SELECTION-SCREEN: END OF LINE.
SELECTION-SCREEN: SKIP 2.
SELECTION-SCREEN: END OF BLOCK A01.
AT SELECTION-SCREEN.
IF SSCRFIELDS-UCOMM = 'SALL'. "alle selektieren
P_AUFSD = 'X'.
P_AUFCO = 'X'.
P_AUFCS = 'X'.
P_AUFPP = 'X'.
ENDIF.
IF SSCRFIELDS-UCOMM = 'DALL'. "alle deselektieren
P_AUFSD = ' '.
P_AUFCO = ' '.
P_AUFCS = ' '.
P_AUFPP = ' '.
ENDIF.
IF SSCRFIELDS-UCOMM = 'INIT'. "initialisiern
P_AUFSD = 'X'.
P_AUFCO = ' '.
P_AUFCS = ' '.
P_AUFPP = 'X'.
ENDIF.
INITIALIZATION.
MELDUNG1 = 'Datenbankselektion'.
T_ICON = ICON_PRINT.
T_AUFSD = 'Kundenauftrag'.
T_AUFCO = 'Innenauftrag'.
T_AUFCS = 'Serviceauftrag'.
T_AUFPP = 'Fertingungsauftrag'.
PB01 = ICON_SELECT_ALL.
PB02 = ICON_DESELECT_ALL.
CONCATENATE ICON_REFRESH 'Initial' INTO PB03.
CONCATENATE ICON_EXECUTE_OBJECT 'Ausführen' INTO PB04.
START-OF-SELECTION.
write: / 'Test'.
END-OF-SELECTION.
Regards, Dieter -
RE: Hide a column in web report using table interface class
Hi,
I want to hide first column in web template using table interface class. Following is the code i used in CAPTION_CELL and CHARACTERISTIC_CELL. Is this correct?
method CAPTION_CELL.
*First column
if i_x = 1.
add comment tag
move '<!-- ' to C_CELL_CONTENT.
endif.
endmethod.
method CHARACTERISTIC_CELL
First column
if i_x = 1.
save start-time column
move I_CHAVL_EXT to L_STARTTIME.
add comment tag
move '<!-- ' to C_CELL_CONTENT.
endif.
endmethod.
When i execute the web template it is still displaying the first column. Do i have to code in any other method?
Thank you,
Mala VenkateshHi , the implementation should look like...
method CAPTION_CELL .
*CALL METHOD SUPER->CAPTION_CELL
EXPORTING
I_X =
I_Y =
I_IS_EMPTY =
I_IOBJNM_ROW =
I_ATTRINM_ROW =
I_TEXT_ROW =
I_IOBJNM_COLUMN =
I_ATTRINM_COLUMN =
I_TEXT_COLUMN =
I_IS_REPETITION =
I_COLSPAN =
I_ROWSPAN =
CHANGING
C_CELL_ID =
C_CELL_CONTENT =
C_CELL_STYLE =
C_CELL_TD_EXTEND =
First column
if i_x = 1.
add comment tag
move '<!-- ' to C_CELL_CONTENT.
endif.
Second column
if i_x = 2.
close comment tag
concatenate '--> '
C_CELL_CONTENT
into C_CELL_CONTENT.
endif.
endmethod.
method CHARACTERISTIC_CELL .
*CALL METHOD SUPER->CHARACTERISTIC_CELL
EXPORTING
I_X =
I_Y =
I_IOBJNM =
I_AXIS =
I_CHAVL_EXT =
I_CHAVL =
I_NODE_IOBJNM =
I_TEXT =
I_HRY_ACTIVE =
I_DRILLSTATE =
I_DISPLAY_LEVEL =
I_USE_TEXT =
I_IS_SUM =
I_IS_REPETITION =
I_FIRST_CELL = RS_C_FALSE
I_LAST_CELL = RS_C_FALSE
I_CELLSPAN =
I_CELLSPAN_ORT =
CHANGING
C_CELL_ID =
C_CELL_CONTENT =
C_CELL_STYLE =
C_CELL_TD_EXTEND =
First column
if i_x = 1.
save document-item number
move I_CHAVL_EXT to l_docitem.
add comment tag
move '<!-- ' to C_CELL_CONTENT.
endif.
Second column
if i_x = 2.
close comment tag
concatenate '--> '
C_CELL_CONTENT
l_docitem
into C_CELL_CONTENT
separated by space.
endif.
endmethod.
Activate the methods/class and add this in the Web Template!
for example:
<param name="MODIFY_CLASS" value="ZHCOLAPP">
ZHCOLAPP is the table interface class in this case.
Best,
Michael -
Error in field catalog in ALV grid display using classes at do_sum = "X'.
Hi,
I'm using classes in ALV Grid display.
the code for the field catalog is going to dump because of the statement in the field catalog for field 'netwr',do_sum = 'X'.
that do_sum = 'X' is not working and going to dump when executed.with out that do_sum it is working fine. the error in dump analysys is showing sap standard incude LSLVCF01.
assign component
<ls_fieldcat>-fieldname of structure rt_data to <g_field>.
if sy-subrc ne 0.
message x000(0k).
endif.
sy-subrc is 4 when the program is being executed.
CODE:
FORM prepare_field_catalog CHANGING pt_fieldcat TYPE lvc_t_fcat.
DATA ls_fcat TYPE lvc_s_fcat.
ls_fcat-fieldname = 'VBELN1'.
ls_fcat-ref_field = 'VBELN'.
ls_fcat-ref_table = 'VBRK'.
ls_fcat-coltext = 'Invoice No'.
ls_fcat-seltext = 'Invoice No'.
APPEND ls_fcat TO pt_fieldcat.
CLEAR ls_fcat.
ls_fcat-fieldname = 'BUDAT'.
ls_fcat-ref_table = 'BKPF'.
ls_fcat-coltext = 'Invoice Date'.
ls_fcat-seltext = 'Invoice Date'.
APPEND ls_fcat TO pt_fieldcat.
CLEAR ls_fcat.
ls_fcat-fieldname = 'NETWR'.
ls_fcat-ref_field = 'NETWR'.
ls_fcat-ref_table = 'VBRK'.
ls_fcat-coltext = 'Value of Invoice'.
ls_fcat-seltext = 'Value of Invoice'.
ls_fcat-datatype = 'CURR'.
ls_fcat-do_sum = 'X'.
APPEND ls_fcat TO pt_fieldcat.
CLEAR ls_fcat.
ENDFORM.
can u please look in the code and rectify the error,
would appeciate ur response.
regards,
veera.Hi,
try this..
ls_fcat-fieldname = 'NETWR'.
ls_fcat-ref_field = 'NETWR'.
ls_fcat-ref_table = 'VBRK'.
ls_fcat-coltext = 'Value of Invoice'.
ls_fcat-seltext = 'Value of Invoice'.
ls_fcat-datatype = 'CURR'.
ls_fcat-do_sum = 'X'.
<b>ls_fcat-cfieldname = 'WAERS'.</b>
APPEND ls_fcat TO pt_fieldcat.
CLEAR ls_fcat.
Regards
vijay -
How to disable the run-time popup menu in the sequence display on TestStand Operator Interface, that allow the use to skip the test?
Hello,
Regarding the skip/force pass/force fail options, when I set the ControlExecFlow to True in Teststand 3.1 and 3.5, in the Sequence Editor the menu options for skip/force pass/force fail are not active for Technician but, when I launch the Operator Interface logged with Technician the options are active. The problem is that if the technician sets one step to one of these options, and change the user to Operator, the test step remains skip/force pass.
Is there any possibility without modifying the Operator Interface (at programming level), to reload default values of the steps when changing the user to Operator?
Thank you,
Best regards,
paio -
ALV grid using classes(displaying subtotals groupwise in ALV grid control)
Hello ,
please can any body help me its urgent tome.
displaying subtotals groupwise ..say for ex..
cost group costelement amount
10 101 100.00
10 102 200.00
10 103 300.00
20 104 400.00
20 105 500.00
20 106 600.00
101 100.00
102 200.00
103 300.00
10 600.00
104 400.00
105 500.00
106 600.00
20 1500.00
In ALV grid control using classes.
Thanks in AdvanceHi alson,
MODULE pbo OUTPUT.
SET PF-STATUS 'MAIN100'.
IF g_custom_container IS INITIAL.
CREATE OBJECT g_custom_container
EXPORTING container_name = g_container.
CREATE OBJECT grid1
EXPORTING i_parent = g_custom_container.
<b>CALL METHOD grid1->set_table_for_first_display
EXPORTING IS_LAYOUT = it_LAY
CHANGING it_fieldcatalog = fieldcat
it_sort = it_sort
it_outtab = itab[].</b>
ENDIF.
ENDMODULE. " PBO OUTPUT
keep the below code
<b>CALL METHOD grid1->set_table_for_first_display
EXPORTING IS_LAYOUT = it_LAY
CHANGING it_fieldcatalog = fieldcat
it_sort = it_sort
it_outtab = itab[].</b>
here
IF pdel = 'X'.
*BEGIN OF CHANGES BY VINAY DASARI
PERFORM get_data.
<b>CALL METHOD grid1->set_table_for_first_display
EXPORTING IS_LAYOUT = it_LAY
CHANGING it_fieldcatalog = fieldcat
it_sort = it_sort
it_outtab = itab[].</b>
ENDIF. -
Understanding the use of interface class?
Hello,
This question referes to java servlets, but the questions is about java design.
My wrox java server pages text, includes an example where some user data is posted to servlet.
To process the data posted and store this, they created a interface class and another class AdminManager which implements the interface.
In the servlet they create an object from the interface class, and call the AdminManager methods through the interface object.
In the book this was the only example which used a interface. And I wondered if this design approach was often used, or should an interface normally be used if several classes would implement the interface.
ThanksIt depends. You might want to create an interface even if you only have a single implementation of that interface in mind, because you want to make it easy to create more implemenations later.
Also keep in mind that not all implementations of an interface are strictly for production use. For example, you might want to define an interface, define an implementation of that interface for production use, but then also define a "mock" version of that interface for testing, prototyping, etc.
Generally I feel that if you have a sufficiently complex set of types and relationships between those types, it makes a lot of sense to express those relationships purely as interfaces, on a high level. Then provide implemenations as a separate step in the programming process. -
Unusual use of interface defining static factory class with getInstance
This question is prompted by a recent New to Java forum question ask about the differences between Interfaces and Abstract classes. Of course one of the standard things mentioned is that interfaces cannot actually implement a method.
One of my past clients, one of the 500 group, uses interfaces as class factories. The interface defines a pubic static class with a public static method, getInstance, that is called to generate instances of a class that implements the interface.
This architecture was very object-oriented, made good use of polymorphism and worked very well. But I haven't seen this architecture used anywhere else and it seemed a little convoluted.
Here is a 'pseudo' version of the basic interface template and use
-- interface that defines public static factory class and getInstance method
public interface abc {
public static class FactoryClass
public static abc getInstance ()
return (abc) FactoryGenerator(new abcImpl(), abc.class);
-- call of interface factory to create an instance
abc myABC = abc.Factory.getInstance();1. Each main functional area ('abc' in the above) has its own interface factory
2. Each main functional area has its own implementation class for that interface
3. There is one generator (FactoryGenerator) that uses the interface class ('abc.class') to determine which implementation class to instantiate and return. The generator class can be configured at startup to control the actual class to return for any given interface.
I should mention that the people that designed this entire architecture were not novices. They wrote some very sophisticated multi-threaded code that rarely had problems, was high performance and was easy to extend to add new functionality (interfaces and implementing classes) - pretty much plug-n-play with few, if any, side-effects that affected existing modules.
Is this a best-practices method of designing factory classes and methods? Please provide any comments about the use of an architecture like this.Thanks for the feedback.
>
I don't see how 'the generator class can be configured at startup to control the actual class to return for any given interface' can possibly be true given this pseudo-code.
>
I can see why that isn't clear just from what is posted.
The way it was explained to me at the time is that the interface uses standard naming conventions and acts like a template to make it easy to clone for new modules: just change 'abc' to 'def' in three places and write a new 'defImpl' class that extends the interface and the new interface and class can just 'plug in' to the framework.
The new 'defImpl' class established the baseline functionality that must be supported. This line
return (abc) FactoryGenerator(new abcImpl(), abc.class);uses the initial version of the new class that was defined, 'abcImpl()', when calling the FactoryGenerator and it acted as a 'minimum version supported'. The generator class could use configuration information, if provided, to provide a newer class version that would extend this default class. Their reasoning was that this allowed the framework to use multiple versions of the class as needed when bugs got fixed or new functionality was introduced.
So the initial objects would be an interface 'abc' and a class 'abcImpl'. Then the next version (bug fixes or enhancements) would be introduced by creating a new class, perhaps 'abcImpl_version2'. A configuration parameter could be passed giving 'abcImpl' as the base class to expect in the FactoryGenerator call and the generator would actually create an instance of 'abcImpl_version2' or any other class that extended 'abcImpl'.
It certainly go the job done. You could use multiple versions of the class for different environments as you worked new functionality from DEV, TEST, QA and PRODUCTION environments without changing the basic framework.
I've never seen any Java 'pattern' that looks like that or any pattern where an interface contained a class. It seemed really convoluted to me and seems like the 'versioning' aspect of it could have been accomplished in a more straightforward manner.
Thanks for the feedback. If you wouldn't mind expanding a bit on one comment you made then I will mark this ANSWERED and put it to rest.
>
I don't mind interfaces containing classes per se when necessary
>
I have never seen this except at this one site. Would you relate any info about where you have seen or used this or when it might be necessary?
Maybe you are looking for
-
My iPhone 5 won't allow me to download ANY apps.
I click in the purchase icon, the blue circle comes up like its loading but then a minute later a msg pops up saying "unable to purchase, (app I'm trying to download) could not be purchased at this time. Please try again later". But every time I try
-
I can not load gmail properly. It refuses to load and suggests loading Basic HTML for slow connections. I do not have a slow connection and have no problem loading gmail in Explorer. This is happening on both Firefox and Firefox Developer. The Firefo
-
I recently upgraded to a G5 and Logic Pro 8. My previous system was a Power Mac 7200 with Logic Platinum 3.5.3. I can not open the old song files unless they are first saved in Logic 6 or 7. Where do I get a dongle for Logic 7?
-
Hello...this is my firt post...
i need your help in this one...im doing a palindrome program... "application that reads in a five-digit integers and determines whether or not it is a palindrome. if the number is not a five-digits long. displays an error message dialog indicating th
-
Document flow is not updated in outbound delivery
Hi, I have issue at my client side that We create Transfer order and it is not updating in outbound delivery document flow. Update without delay is check in shipping configuration. Can somebody please provide the reason, Configuration missing or so