Accessing impl class attribute
Hi Experts,
if i declare one variable in controller class of a view and how can access the variable in contex naode .
Hi srinivas.yangal,
You can access the View implementation Class Attributes in Context.
1] Go to Context Node Implementation Class
2] Create a attribute GV_VIEW_CONTROLLER in Impl class of Context Node.
DATA : GV_VIEW_CONTROLLER TYPE REF TO CL_BSP_WD_VIEW_CONTROLLER .
3] Go to INIT method of Context Node.
4] Assign instance LV_VIEW_CONTROLLER to GV_VIEW_CONTROLLER of Context Node Impl. Class.
GV_VIEW_CONTROLLER = LV_VIEW_CONTROLLER.
Then you can access your Instance attributes defined in View Impl. class inside the context node through GV_VIEW_CONTROLLER attribute as follows.
ABC = GV_VIEW_CONTROLLER->XYZ.
Reward points if useful.
Kind Regards,
Dhananjay.
Edited by: Dhananjay SAP CRM on Nov 24, 2011 12:56 PM
Similar Messages
-
Access to class-attribute by Interface-reference
Hi OO-Gurus,
I use an implementation of BADI ME_PROCESS_REQ_CUST to fill and handle user-defined fields in the MM-Purchase-Requisition, method IF_EX_ME_PROCESS_REQ_CUST~OPEN.
There I use a reference variable which refers to an interface (type ref to IF_PURCHASE_REQUISITION_ITEM) to access the item-object. My problem is that I need to have access to the class-attribute my_state. The corresponding class lcl_req_item is defined locally (LMEREQF01). So I cant use a reference variable with reference to this class (so widening cast using the interface-reference is not possible) .. Does anyone know a trick how to access the class-attribute anyway?
Coding:
data: l_item_list TYPE MMPUR_REQUISITION_ITEMS,
l_item TYPE MMPUR_REQUISITION_ITEM,
l_item_akt TYPE mereq_item,
l_item_ref TYPE ref to IF_PURCHASE_REQUISITION_ITEM.
l_item_list = im_header->get_items().
loop at l_item_list into l_item.
l_item_akt = l_item-item->get_data( ).
l_item_ref = l_item-item.
endloop.
(Debugging the code, I manage by doubleclicking the fieldcontent of l_item_ref (e.g ) to show the content of the class-attribute my_state. This works only if the field Interface in the Debugger is empty because then I see the attributes of the class. If the field Interface is filled with IF_PURCHASE_REQUISITION_ITEM, there arent any attributes shown.)
Thanks in advance for your kind help!!
NicoleHello Nicole
The following sample coding shows you how to solve your problem. Please do not ask me how I came across this solution.
However, if you are studying it carefully you may stumble across a most beautiful property of field-symbols as I did.
METHOD if_ex_me_process_req_cust~open.
DATA: l_item_list TYPE mmpur_requisition_items,
l_item TYPE mmpur_requisition_item,
l_item_akt TYPE mereq_item,
l_item_ref TYPE REF TO if_purchase_requisition_item.
DATA:
ld_attr TYPE string,
lo_obj TYPE REF TO object.
FIELD-SYMBOLS:
<lo_lcl> TYPE ANY,
<ls_item> TYPE mereq_item,
<ls_itemx> TYPE mereq_itemx.
l_item_list = im_header->get_items( ).
LOOP AT l_item_list INTO l_item.
l_item_akt = l_item-item->get_data( ).
l_item_ref = l_item-item.
lo_obj ?= l_item-item. " casting to root object !!!!!
ld_attr = 'MY_STATE'.
ASSIGN lo_obj->(ld_attr) TO <lo_lcl>.
ld_attr = 'MY_STATE->ITEM'.
ASSIGN lo_obj->(ld_attr) TO <ls_item>.
" ASSIGN l_item_ref->(ld_attr) TO <ls_item>. " does not work...
ld_attr = 'MY_STATE->ITEMX'.
ASSIGN lo_obj->(ld_attr) TO <ls_itemx>.
ENDLOOP.
" NOTE: data definition of local class lcl_req_item_state (fg MEREQ)
** DATA: item TYPE mereq_item,
** itemx TYPE mereq_itemx,
** header TYPE REF TO lcl_req_header,
** ref_item TYPE REF TO lcl_req_item,
** acct_container TYPE REF TO lcl_acct_container,
** source TYPE REF TO cl_source_of_supply_mm,
** release_state TYPE REF TO cl_release_state_mm,
** text_manager TYPE REF TO lcl_text_manager,
** bom TYPE REF TO lcl_bom,
** funds_mgt_active TYPE mmpur_bool VALUE mmpur_no,
** aktyp TYPE aktyp,
** no_auth TYPE mmpur_bool VALUE mmpur_no,
** release_op type mmpur_bool value mmpur_no,
** persistent TYPE mmpur_bool VALUE mmpur_no,
** checked TYPE mmpur_bool VALUE mmpur_no,
** manual_configuration TYPE mmpur_bool,
** input_buffer_changed TYPE mmpur_bool VALUE mmpur_no,
** changed TYPE mmpur_bool,
** broken_rules TYPE lty_mask,
** referenced_rules TYPE lty_mask,
** chp_changes TYPE mmchp_chp_list,
** dcm_manager TYPE REF TO if_revision_manager_dcm,
** "DCM Retrofit
** rel_state_after_release TYPE REF TO cl_release_state_mm,
** "DCM Retrofit
** chdoc_container TYPE REF TO lcl_chdoc_container,
** "DCM Retrofit
** service_changed TYPE mmpur_bool,
** "DCM Retrofit
** determinants TYPE lty_item_determinants.
ENDMETHOD.
Regards
Uwe -
Access to class attributs by coding in its mother class method definition
Hi all,
How can I retrieve information about a class attributs by coding?
And is it possible to access to the attributs of the Child class from the Mother class?
REPORT ztest_method.
****** CLASS mother DEFINITION
CLASS mother DEFINITION.
PUBLIC SECTION.
METHODS: get_data.
ENDCLASS. "mother DEFINITION
****** CLASS child DEFINITION
CLASS child DEFINITION inheriting from mother.
ENDCLASS. "child DEFINITION
******* CLASS mother IMPLEMENTATION
CLASS mother IMPLEMENTATION.
METHOD get_data.
***Can I access to child class attributs here?
ENDMETHOD. "get_data
ENDCLASS. "mother IMPLEMENTATION
DATA oref TYPE REF TO CHILD.
DATA: method TYPE string.
DATA: cla_name(20).
START-OF-SELECTION.
CREATE OBJECT oref .
CALL METHOD oref->method). "Here I want to access to this class's attribut without redefine itHi,
a very easy way is to define an attribute TYPE REF TO DATA in the super class and write generic access methods which work with it by dereferencing it and assigning a field symbol. This might even save you the effort of creating a class hierarchy, because one class may be able to handle all the data objects whose types are only known at run-time.
In the below example, the only specific thing about the sub class is the constructor in which the data object is created and typed:
REPORT ztesta.
* CLASS lcl_mother DEFINITION
CLASS lcl_mother DEFINITION.
PUBLIC SECTION.
METHODS get_data EXPORTING es_data TYPE any.
METHODS set_data IMPORTING is_data TYPE any.
PROTECTED SECTION.
DATA mr_data TYPE REF TO data.
ENDCLASS. "lcl_mother DEFINITION
* CLASS lcl_child1 DEFINITION
CLASS lcl_child1 DEFINITION INHERITING FROM lcl_mother.
PUBLIC SECTION.
METHODS constructor.
ENDCLASS. "lcl_child1 DEFINITION
DATA:
lr_child TYPE REF TO lcl_mother,
ls_but000_in TYPE but000,
ls_but000_out type but000.
START-OF-SELECTION.
CREATE OBJECT lr_child TYPE lcl_child1.
ls_but000_in-partner = '0000004711'.
lr_child->set_data( ls_but000_in ).
lr_child->get_data( IMPORTING es_data = ls_but000_out ).
write: / ls_but000_out-partner.
* CLASS lcl_mother IMPLEMENTATION
CLASS lcl_mother IMPLEMENTATION.
METHOD get_data.
FIELD-SYMBOLS:
<fs_data> TYPE ANY.
ASSIGN mr_data->* TO <fs_data>.
MOVE-CORRESPONDING <fs_data> TO es_data.
ENDMETHOD. "get_data
METHOD set_data.
FIELD-SYMBOLS:
<fs_data> TYPE ANY.
ASSIGN mr_data->* TO <fs_data>.
MOVE-CORRESPONDING is_data TO <fs_data>.
ENDMETHOD. "set_data
ENDCLASS. "lcl_mother IMPLEMENTATION
* CLASS lcl_child1 IMPLEMENTATION
CLASS lcl_child1 IMPLEMENTATION.
METHOD constructor.
super->constructor( ).
CREATE DATA mr_data TYPE but000.
ENDMETHOD. "constructor
ENDCLASS. "lcl_child1 IMPLEMENTATION
Another variant would be to define an attribute MV_DATA which is typed individually in each sub class and program dynamically against it in the super class using field symbols.
*& Report ZTESTA
REPORT ztesta.
* CLASS lcl_mother DEFINITION
CLASS lcl_mother DEFINITION.
PUBLIC SECTION.
METHODS get_data EXPORTING es_data TYPE any.
METHODS set_data IMPORTING is_data TYPE any.
ENDCLASS. "lcl_mother DEFINITION
* CLASS lcl_child1 DEFINITION
CLASS lcl_child1 DEFINITION INHERITING FROM lcl_mother.
PUBLIC SECTION.
DATA: ms_data TYPE but000.
METHODS constructor.
ENDCLASS. "lcl_child1 DEFINITION
* CLASS lcl_child2 DEFINITION
CLASS lcl_child2 DEFINITION INHERITING FROM lcl_mother.
PUBLIC SECTION.
DATA: ms_data TYPE t000.
METHODS constructor.
ENDCLASS. "lcl_child1 DEFINITION
DATA:
lr_child1 TYPE REF TO lcl_mother,
lr_child2 TYPE REF TO lcl_mother,
ls_but000 TYPE but000,
ls_t000 TYPE t000.
START-OF-SELECTION.
CREATE OBJECT lr_child1 TYPE lcl_child1.
lr_child1->get_data( IMPORTING es_data = ls_but000 ).
WRITE: / ls_but000-partner.
CREATE OBJECT lr_child2 TYPE lcl_child2.
lr_child2->get_data( IMPORTING es_data = ls_t000 ).
WRITE: / ls_t000-mwaer.
* CLASS lcl_mother IMPLEMENTATION
CLASS lcl_mother IMPLEMENTATION.
METHOD get_data.
FIELD-SYMBOLS:
<fs_data> TYPE ANY.
ASSIGN ('MS_DATA') TO <fs_data>.
es_data = <fs_data>.
ENDMETHOD. "get_data
METHOD set_data.
FIELD-SYMBOLS:
<fs_data> TYPE ANY.
ASSIGN ('MS_DATA') TO <fs_data>.
<fs_data> = is_data.
ENDMETHOD. "set_data
ENDCLASS. "lcl_mother IMPLEMENTATION
* CLASS lcl_child1 IMPLEMENTATION
CLASS lcl_child1 IMPLEMENTATION.
METHOD constructor.
super->constructor( ).
SELECT SINGLE * FROM but000 INTO ms_data.
ENDMETHOD. "constructor
ENDCLASS. "lcl_child1 IMPLEMENTATION
* CLASS lcl_child2 IMPLEMENTATION
CLASS lcl_child2 IMPLEMENTATION.
METHOD constructor.
super->constructor( ).
SELECT SINGLE * FROM t000 INTO ms_data.
ENDMETHOD. "constructor
ENDCLASS. "lcl_child2 IMPLEMENTATION
I hope this helps!
Regards,
Thorsten -
Error accessing constnt public attribute of a class in an overwrite method.
Hi Gurus,
I am facing an error while accessing a constant public attribute while using it in the overwrite-exit of a methods.
The constant which is declared as public in the attribute section of the class is not available in the overwrite-exit of the method.
Please suggest me how to access the public attributes in the overwtire exits of the methods.
Thanks.Hi Ramneek,
Let me explain you the entire scenario:
Actually we are trying to ehance the SAP standard class : CL_FITV_POWL_FEEDER_TRIPS in ECC 6.0 EHP 5 .
We tried to create and overwrite-exit of the method "IF_POWL_FEEDER~GET_ACTIONS".
Overwrite-exit of a method is just like a method which will be called instead of the standard method : IF_POWL_FEEDER~GET_ACTIONS.
But the problem which we are facing here is that the Attributes which are defined in the class CL_FITV_POWL_FEEDER_TRIPS, are getting accessed from the overwrite-exit method.
Becuase of this we are not able to implement our custom logic. -
Accessing Managed Bean Variables in Entity Impl Class
How can I access managed bean variables in the entity Impl class .
While inserting a new record in DB , i want to set few entity properties values . The values of those properties are available in the managed bean .
How can i access those values from Managed Bean and set them the entity Impl class to override the create method.
Or is there any better recommended approaches ?
Jdev - 11.1.1.5>
While inserting a new record in DB , i want to set few entity properties values .
>
you can user CreateWithparams
http://www.oracle.com/technetwork/developer-tools/adf/learnmore/13-create-with-params-169140.pdf
http://andrejusb.blogspot.com/2011/02/createwithparams-operation-for-oracle.html -
Global Attribute Usage in IMPL class
Hi,
Can I declare an attirbute in the IMPL class and use it in two different context nodes of the same component?
Actually, my requirement is to retrieve the value of an attribute in CN1 and use it in the GET_I_ method of an attribute in CN2.
The approach that I'm following is to retrieve the value of attib1, pass it into the global attribute, and then use this global attribute in GET_I_ method of attrib2 in CN2.
Is this feasible?
Any pointers to this would be highly appreciated.
TIA.
Regards,
RichaYour approach is feasible !
Thanks
Allot points if this helps! -
I need to emulate several ActiveX functions in my client's web application. I have located several Mozilla web pages that describe how to do the things I need, and I have attempted to implement those instructions. However, I can't seem to get past the first line of code. In my web page, I am calling a JavaScript function using the onLoad attribute of the <body> tag. I am using the Navigator object to determine that the browser is Firefox. I then attempt to access the extension classes using the following code on lines 51 and 52 of the Download.js file:
var C = Components;
var CC = C.classes;
The Web Console gives me these two messages:
[13:51:55.621] The Components object is deprecated. It will soon be removed. @ http://distribution:781/NewDDI/DownLoad.js:51
[13:51:55.621] Error: Permission denied to access property 'classes' @ http://distribution:781/NewDDI/DownLoad.js:52
How do I enable adequate permission to be able to access the Components classes?I think Components is available only in extensions (or otherwise privileged code) and not in ordinary web pages.
-
How to call a method in IMPL class from one context node
Hi, I´ve been only study the posibility to access a method in the IMPL class from one context node class...CN## without using events, is there a way to call it ??? I don´t have it as requierement just learning thanks !.
Hi,
Try this by following this you can get the custom controller instacne in the view context nodes, for your requirement you can keep the view implementation class instance instead of cuco..
To get the custom controller instance in Context node getter/setter method:
1. Declare Cuco instance reference variable in ctxt class..
2. Set this cuco ref. in the Create context node method of ctxt class:
try.
gr_cucoadminh ?= owner->get_custom_controller( 'ICCMP_BTSHEAD/cucoadminh' ). "#EC NOTEXT
catch cx_root.
endtry.
you can avoid this step as this is not needed in case of view isntance
3. Assign this instance to the respective context node Create method using:
BTStatusH->gr_cuco ?= gr_cucoadminh. " here assign the view implementation ref. " me" instead of gr_cucoadminh
Here gr_cuco is the ref. variable of custom controller in the respective context node for eg. BtstatusH
Sample implementation of this can be found in
ICCMP_BTSHEAD/BTSHeader ->context node BTACTIVITYH-> attr ->GR_CUCO(instance of cuco)
Cheers,
Sumit Mittal -
Binding ABAP Class Attribute with BUS2038 in a Standard WF task
Hi,
I need help as mentioned in the subject line.
In my standard task I am capturing event for BUS2038. In the General tab I have a ABAP class which has implemented IF_WORKFLOW. From BUS2038 I just need notification number.
Since my source is a BO and my target is a class. How do I make this conversion and pass the data to my class?
I know there are several solution but none have solved my concern.
Thanks,
Sridhar Karra.Hi,
If you want to access teh attributes of the BOR inside a class emthod then you have to make use of teh MACROS.
1. include INCLUDE CNTN01_SWC in the class local macros section. and in the type groupsof the class include SWC0.
2. Now if you know the key of the BOR instance then create a BOR object inside the class method as below
DATA lo_object TYPE SWC0_OBJECT.
SWC0_CREATE_OBJECT lo_object '<BUSXXXX>' '<Key of the BOR>.
the above line will create the instance of the bor inside the class method
now inorder to access the attributes of the BOR use the below code
DATA lv_notif_no TYPE <type of the notification>.
SWC0_GET_PROPERTY lo_object '<ATTRIBUTE NAME> lv_notif
In this way you can access the BOR attributes inside a class method.
Regards
Pavan
Edited by: Pavan Bhamidipati on Dec 15, 2011 11:01 PM -
any body tell me what is modelled only field in class attributes.
when we check that field ??Hi
you cannot access the components at the run time in other way you cannot execute them.
Regards
Pavan -
Getting JPA class attributes inside Visual JSFs
Hi,
I'm new her, so I'm deeply sorry if I'm writing this on the wrong place. But I have a small issue with the Visual JFSs in Netbeans.
I have created a project where a person can log in and see some data, all is done using Java persistence API. I was able to get the JPA attributes into a normal JSP. by doing something like this.
<body>
<f:view>
<h1><h:outputText value="You are now logged in" /></h1>
Welcome ${user.email} You've been loggedin successfully.
<h:form>
<h:commandButton id="logout" value="Logout" action="#{usermanager.logout}"/>
</h:form>
</f:view>
</body>it works fine and displays the correct result. But when I go and do this inside a Visual JSF, it does NOT give me any compiler errors. But it wont display anything. Just a blank screen. If I remove that particular code and put some label or text there, then it works. But NOT when I try to access the JPA attributes.
Why is this happening?. I basically need a way to retrieve the bean information which is stored in a Entity class which was created from the database. Can't I do it using this ${user.email} kind of notation. If so, then how to do it. Can someone please help me.
Thanks a lot.Source is empty, But I checked the app server log after you suggested. It says something like this (among other things).
Caused by: javax.servlet.jsp.JspException: Can't write content above <f:view> tag Illegal to flush within a custom tag
so I tried out something like this.
<jsp:root version="2.1" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:jsp="http://java.sun.com/JSP/Page" xmlns:webuijsf="http://www.sun.com/webui/webuijsf">
<jsp:directive.page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"/>
<f:view>
<webuijsf:page id="page1">
<webuijsf:html id="html1">
<webuijsf:head id="head1">
<webuijsf:link id="link1" url="/resources/stylesheet.css"/>
</webuijsf:head>
<webuijsf:body id="body1" style="-rave-layout: grid">
<webuijsf:form id="form1">
<webuijsf:label binding="#{user.email}" id="label1" style="position: absolute; left: 120px; top: 72px" text="Label"/>
</webuijsf:form>
</webuijsf:body>
</webuijsf:html>
</webuijsf:page>
</f:view>
</jsp:root>but still it doesn't work. There was a conversion error where #{user.email} returns a String but it could not be assigned to a label. so I tried it this way as well.
<webuijsf:body id="body1" style="-rave-layout: grid">
<webuijsf:form id="form1">
<webuijsf:staticText id="staticText1" binding="#{user.email}" style="position: absolute; left: 72px; top: 72px"/>
</webuijsf:form>
</webuijsf:body> Now there were no errors, But still it doesn't work.
I ONLY need a way to get the information inside the entity classes which was created from the database using Object Relational Mapping. My problem is this works fine inside regular JSP but not inside Visual JSF. ??? :( -
Instance of IMPL class in custom controller
Hi,
I have a requirement where i need a instance of view controller class(impl) in custom controller class. When i am trying to create an instance attribute of impl class in cuco and trying to use in one of the cuco methods then it is not getting initialized. Let me know how to do achieve this.
Thanks a lot.
Regards,
LishaHi Lisha,
This would be because the corresponding view is in viewset which in turn is in the window.
In that case you will have to drill down the viewset and then get the view.
Sample code :
DATA:
lr_window TYPE REF TO cl_bsp_wd_window,
lr_viewset TYPE REF TO cl_bsp_wd_view_controller,
lr_bpexcp_view TYPE REF TO CL_BP_EXCEP_BPEXCPTNRESUL_IMPL.
lr_window ?= me->get_subcontroller_by_viewname( 'BPExceptionSearch.MainWindow' ).
if lr_window IS BOUND.
lr_viewset ?= lr_window->get_subcontroller_by_viewname( 'BP_EXCEPTION/BPExcptnSearchViewSet' ).
if lr_viewset IS BOUND.
lr_bpexcp_view ?= lr_viewset->get_subcontroller_by_viewname( 'BP_EXCEPTION/BPExcptnResult' ).
if lr_bpexcp_view IS BOUND.
TRY.
lr_bpexcp_view->GV_IS_NEW_CONTRACT = ABAP_TRUE. "#EC NOTEXT
CATCH cx_sy_dyn_call_error.
RETURN.
ENDTRY.
endif.
endif.
endif.
Regards
Leon
Edited by: Leon Limson on Jan 10, 2012 4:54 PM -
Hi Experts,
I have the requirement to show a warning that the user shall maintain a Partner "Enduser" in the Assignmentblock "Partners" when creating an Opportunity. The code for the warning is implemented in the Impl-Class of the View BTPARTNER/Partner (my Assignmentblock "Partners"). The problem is, that the Assignment Block is also used in other Scenarios, but the Waring shall only appear in the Opportunity View.
How can I check the current Scenario? I thought of getting the Object Type BT111_OPPT and check it.
Anyone know how to get the Object Type or any other solution for the problem?
Thanks and regards,
SebastianHi,
I think using the Object_type to display warning message in your case is fine and it should work. Now as you are looking how to get object_type here..my suggestion would be in View BTPARTNER/Partner you have a context node called 'BTPartnerSet' after getting the current entity (by using get_current() ) you can get the parent which would be BTAdminH and in this entity you have object_type as a attribute so you can easily call get_property or get_property_by_string () and can put your check.
Regards
Ajay -
Can we change the Super class attribute scope in Sub class
Hi.
I created a super class. In that i have 4 attributes. That attributes are PUBLIC.
I created a sub class. In that i got all super class attributes. I want to change that attributes as a Private. Is it possible.
If it is possible.Give me an Example with code or Pseudo code.
Regards.
Krishna.Hi Krishna,
It is not possible... If you declare the Attributes again in Subclass of the same name as that of Super class
then the way of accessing them would be different from that of attributes in the main class.
Hope this would help you
Good luck
Narin -
Access Application Class from Model Class in BSP
Hello,
I am developing a BSP Application based on MVC. Is there any way, I can access the Application Class's Attribute from a Method in the Model Class?
Thanksin Advance.
Regards
GladsonHello,
I solved it by passing the application class attribute to the model method, from the controller class.
Regards
Gladson
Maybe you are looking for
-
Need help with a few things in Photoshop CS4
1) When I change a photo, I click to save, up pops the JPEG Options box, which has been set to 12 since last year. Today, it suddenly changes itself to 6 for no good reason. Each and every photo I change, I have to now tell it 12, not 6. How do I get
-
[Solved] Haskell: cabal error
After some problems with arch-haskell repos, I decided to install pandoc and dependencies via cabal. So I removed all haskell packages, removed arch-haskell repos and run -Syy. Next, I installed ghc 7.6.1 and cabal-install 1.16, but when I ran "cabal
-
I need to hard reset my nokia 5800 xpress music Just wondering, after having it unlocked by code from my old network, will it become re-locked to their network after the reset.
-
Validation for BSED_WSTAT
Hi, How can I set validation for BSED_WSTAT İin OB28? There are only BKPF nad BSEG tables in OB28? Thanks.. Linlin Edited by: LIN LIN on Jul 8, 2009 3:48 PM
-
Itunes music library got corrupted
all my music in my iTunes are gone, is there a way to copy back the entire library on my iPod to my iTunes on my computer? RIght now, the only thing I could use the iTunes for is syncing the pics and and the apps with my iPhone, where can I find the