Dynamic type problem
I have a dynamic text box call "color.txt" and two Movie clip
buttons one called Red and one called Yellow.
When I press the button the name of the button is passed to
the text box. When I press the second button the
name is not replaced. Do I have to create a seperate function
to do this or is there an eaiser way?
Thanks,
_root.red.onPress = function(){
_root.colorTxt.text = "Red";
_root.yellow.onPress = function(){
_root.colorTxt.text = "Yellow";
}
Got it working with this. Thanks
var colors:Array = ["red", "yellow"];
var currentColor:Number;
function changeButton(newColor:Number) {
currentColor = newColor;
_root.colorTxt.text = updateText();
_root.red.onPress = function(){
changeButton(0);
_root.yellow.onPress = function(){
changeButton(1);
function updateText():String {
var newText:String;
newText = colors[currentColor];
return newText;
}
Similar Messages
-
Hi All,
I get a short dump while generating a proxy in the backend.I give the package and the prefix and end up with a short dump.
Does any one know why this mught come up
"Dynamic type conflict during the assignment of references."
background: I imported a WSDl provided by legacy into PI and created service interfaces and then trying to generate a proxy class while i get this error.
Thanks.Hi Shyamsundar,
I will explain a problem that I usually see in some developments:
XSD originally: XSD transformed:
Root -> Root
Tag 1 type int -> Tag 1 type int
Tag2 type string -> Tag2 type string
Tag3 type any - Tag3 type string
Normally the tag3 should have a XML inside. Then the ABAPers have to construct the tag3 with a CDATA structure (CDATA is used to put in an XML tag more XML tags inside like a text and no to be interpreted).
Later in SAP PI you can extract the cdata with an XSL, you can find some examples in the SCN.
I don’t like to convert the whole XML in only one string tag, because this makes difficult the develop for the ABAPers, although the work inside the PI is very easy because with an XSL you can extract the whole message easily. (You can find some examples in the SCN)
Regards. -
Error Dynamic type conflict when assigning references in EHP4
Hi Experts,
We are facing problem while customizing application wizard in EHP4.
Based on our requirement, we need to create one more tab named "Notes" to add instructions for applicants while applying for Job. It contains only instruction. To achieve this, we have done below set up.
1. We have created new WD component (WD window), OTR Alias
2. Created one more additional steps in T77RCF_RM_STEP called "Notes" and maintained step 1 information
3. In table T77RCF_RM_SEQ, under Application wizard (employee), we have added notes in sequence 1.
Now our new tab "Notes" is reflecting in application wizard. But while cliking on send application, we are getting error "The following error text was processed in the system GEG : Dynamic type conflict when assigning references".
Error Details:-
u2022 The following error text was processed in the system GEG : Dynamic type conflict when assigning references
u2022 The error occurred on the application server sapgeg_GEG_59 and in the work process 0 .
u2022 The termination type was: RABAX_STATE
u2022 The ABAP call stack was:
Can anybody guide what we are doing wrong?
It would be great help.
Regards,
purnimaHi Rajasekhar,
Facing the same issue, can you please let me know how you solved the above issue.
Best Regards,
Laxman -
Xml conversion of data refs with dynamic type
Hi Colleagues,
I have to create an XML from a TYPE REF TO DATA, where this data is created using a dynamic internal table. By dynamic internal table i mean that the internal table is created dynamically using the class method cl_alv_table_create=>create_dynamic_table.
Now the problem that i face is when i use the statement:
CALL TRANSFORMATION id
SOURCE jsag_data = im_context_b64
RESULT XML lv_xml
OPTIONS data_refs = 'embedded'
value_handling = 'move'.
to generate the XML i get a dump of type CX_XSLT_SERIALIZATION_ERROR saying "The ABAP data cannot be serialized."
I found a solution to avoid the dump by adding the additional option " TECHNICAL_TYPES = 'ignore' " to the CALL TRANSFORMATION statement, like
CALL TRANSFORMATION id
SOURCE jsag_data = im_context_b64
RESULT XML lv_xml
OPTIONS data_refs = 'embedded'
value_handling = 'move'
TECHNICAL_TYPES = 'ignore'.
But, using this addition the dynamic type ref to data part is totally ignored from the XML generation.
If I use a specific DDIC table type to create the data, we do not face this issue and the XML is generated as desired
Does anyone have a solution to this problem as it has become a sort of blockade for our development?
Thanks and Cheers,
Gaurav.Hello,
I reached same problem with dynamic data references, the only solution I got is to used global DDIC types (also for table types !!) when creating data which needs to be serialized.
The options technical_types = 'ignore' doesn't solve the problem - it just instructs the parser to skip data references without global ddic type. The options value_handling = 'move' is very helpful as XML serialization is very picky about values beeing serialized.
Here is summary of my observations:
- Global DDIC type has to be associated with data reference, otherwise only technical type is there and this is not supported (you can use OPTIONS TECHNICAL_TYPES = u2018IGNOREu2019 but this will just skip the data to be serialized to XML) u2026
- The above means that if you are serializing data reference to table then you have to have also global DDIC type for the table-type !! Unfortunatelly there is no default table type available for transparent tables u2026. They are treated as structures not as table-types u2026 thus:
- CREATE DATA lr_data TYPE <global_ddic_structure> - can be serialized
- CREATE DATA lr_data TYPE STANDARD TABLE OF <global_ddic_structure> - cannot be serialized
- CREATE DATA lr_data TYPE <global_ddic_table_type> - can be serialized
- !! Unfortunatelly !! CREATE DATA lr_data TYPE <type_pool_ddic_structure/ type_pool_table_type> - also cannot be serialized u2013 this is pitty u2026 this should be supported u2026. -
Can we dynamically type-cast an object reference passed to Object Clss to that specific class?
Here is what I want to do.
I am going to pass an object reference to a method, which has Object class as parameter to it, as shown below. Using getClass() or some other way, I want to dynamically typecast this reference to the original Class and call some method of this Class.
void test (Object ref1){
((ref1.getClass())ref1).writeLog();
By doing this, am I violating the basic Object Orineted rules?I mean, consider an hypothetical case (which is wrong
from OO point of view) that there are suppose 10
classes in my system. None of them related to each
other, all are independent classes. But each one has a
method called, writeLog(). Now I want to write one
method which will be called by each of these classes
(in some 11th class), which will have "Object" as a
parameter. Now using the actual reference I want to
call the corresponding writeLog() method.
1 - Point out to management that the design is now officially broken.
2 - Point out that if the design is not fixed then any solution that impliments the changes will cost more to maintain in the future and will likely lead to instabilities in the system (due to complexity.)
3 - Implement one of the suggested solutions and make sure that you put in a lot of error checking and logging in the hacked solution.
4 - Produce extensive documentation about the impact of changing any of the objects that you are relying on. Push it to anyone and everyone that might ever touch or even suggest changes to the code.
Doing all of the above allows you to live stress free when the next revision breaks because someone didn't understand the implications of your hacked solution. You will be able to find the problem quickly and point out that it had nothing to do with your code but rather because someone else did not follow the complete documentation that you produced. And then when they complain that your solution was a hack you can point out that you explained that previously as well. -
ErroruFF1A Dynamic type conflict when assigning references
hi all,
I have one node ,name is :forloop
under this node ,there is a attribute ,its type is string ,its name is attf
now ,I write code as below in action,but it show a error" Dynamic type conflict when assigning references "
someone can tell me the reason?thanks
data :
for_loop type ref to if_wd_context_node,
t_var type standard table of string.
append 'a' to t_var.
append 'b' to t_var.
append 'c' to t_var.
for_loop = wd_context->get_child_node( name = wd_this->wdctx_forloop ).
for_loop->bind_elements( t_var ).
thanksHi,
The problem is the internal table you are using is not match with the attribute u created.
Node name : forloop
Cardinality : 0-n.
selection : 0-1
attr name : attf
Use the below code.
DATA forloop TYPE REF TO if_wd_context_node.
DATA t_var TYPE table of wd_this->element_forloop.
data : wa_tar like line of t_var.
wa_tar-attf = 'a'.
append wa_tar to t_var.
wa_tar-attf = 'b'.
append wa_tar to t_var.
wa_tar-attf = 'c'.
append wa_tar to t_var.
navigate from <CONTEXT> to <FORLOOP> via lead selection*
forloop = wd_context->get_child_node( name = wd_this->wdctx_forloop ).
forloop->bind_elements( EXPORTING
new_items = t_var
Regards.
Ragu.
Edited by: Ragu Prasad on Feb 6, 2009 10:39 AM -
Dynamic type conflict when assigning references - Dump
Hi All,
I am getting the dump "Dynamic type conflict when assigning references". In my application I have used a table control inside which I have input field, text view and text edit.
I guess the text edit is creating the issue. The error analysis report is below :
If anyone have any idea about the issue, please help.
Error analysis
An exception occurred that is explained in detail below.
The exception, which is assigned to class 'CX_SY_MOVE_CAST_ERROR', was not
caught in
procedure "IF_WDR_VIEW_ELEMENT_ADAPTER~SET_CONTENT" "(METHOD)", nor was it
propagated by a RAISING clause.
Since the caller of the procedure could not have anticipated that the
exception would occur, the current program is terminated.
The reason for the exception is:
It was tried to assign a reference to a rereference variable using the
'CAST' operation ('?=' or 'MOVE ?TO').
However, the current content of the source variable does not fit into
the target variable.
source type: "\CLASS-POOL=/1WDA/L0STANDARD\CLASS=CL_TEXT_EDIT"
target type: "\INTERFACE=/1WDA/VTABLE_CELL_EDITOR"
Information on where terminated
Termination occurred in the ABAP program "/1WDA/L3STANDARD==============CP" -
in "IF_WDR_VIEW_ELEMENT_ADAPTER~SET_CONTENT".
The main program was "SAPMHTTP ".
In the source code you have the termination point in line 2290
of the (Include) program "/1WDA/L3STANDARD==============CCIMP".
The termination is caused because exception "CX_SY_MOVE_CAST_ERROR" occurred in
procedure "IF_WDR_VIEW_ELEMENT_ADAPTER~SET_CONTENT" "(METHOD)", but it was
neither handled locally nor declared
in the RAISING clause of its signature.
The procedure is in program "/1WDA/L3STANDARD==============CP "; its source
code begins in line
2034 of the (Include program "/1WDA/L3STANDARD==============CCIMP ".
2265 if va__CONTENT_READONLY is bound and
2266 va__CONTENT_READONLY->IFUR_NW5__CONTROL~_IID <> ifur_nw5_invisible=>_iid_invisible.
2267 IFUR_NW5_SAPTABLECELL~HASCONTENT = abap_true.
2268 else.
2269 IFUR_NW5_SAPTABLECELL~HASCONTENT = abap_false.
2270 endif.
2271 endif.
2272
2273 * >> ProvideCONTENT
2274
2275 IF mv_CONTENT_READONLY <> va__CONTENT_READONLY.
2276 finalize_adapter( mv_CONTENT_READONLY ).
2277 mv_CONTENT_READONLY ?= va__CONTENT_READONLY.
2278 ENDIF.
2279
2280 * >> property-Aggregation mv_CONTENT_EDITABLE
2281 DATA va__CONTENT_EDITABLE TYPE REF TO /1WDA/VTABLE_CELL_EDITOR. "#EC NEEDED
2282 * >> UCA STANDARD|TABLE_CELL|CONTENT_EDITABLE
2283 data adp_uielement type ref to /1WDA/VUIELEMENT. "#EC NEEDED
2284 if mv_CONTENT_READONLY is not bound and
2285 mv_WD_TABLE_CELL_EDITOR is bound.
2286 va__CONTENT_EDITABLE ?= mv_CONTENT_EDITABLE.
2287 IF va__CONTENT_EDITABLE is bound and va__CONTENT_EDITABLE->m_view_element = mv_WD_TABLE_
2288 ELSE.
2289
>>>>> va__CONTENT_EDITABLE ?= create_by_view_element(
2291 view_element = mv_WD_TABLE_CELL_EDITOR
2292 parent = me
2293 ).Hi Everyone,
Thanks for your replies.
We raised an OSS call for the same and got the below response.
Dear Customer,
I've analized your actual problem and found out that you are using a notallowed combination of text edit as cell editor within table for
clasical Web Dynpro ABAP rendering. The text edit as cell editor work in701 releases when the lightspeed rendering is enabled. However in case
that you want to used
lightspeed rendering, I would suggest to upgrade on a higher
SP level than SP4 as for technical reason we can only deliver
corrections for Unified Rendering first from SP04. -
Dynamic types with CL_ABAP_TYPEDESCR
Hi,
I have a problem. I want to read out the output_length of dynamic types to evaluate inputs. I do something like the code below.
DATA type_ref TYPE REF TO cl_abap_typedescr.
DATA elem_descr TYPE REF TO cl_abap_elemdescr.
DATA struc_descr TYPE REF TO cl_abap_structdescr.
type_ref = cl_abap_typedescr=>describe_by_data( <fs_lsinto> ).
elem_descr ?= type_ref.
elem_descr->output_length
But sometimes type_ref give back a CL_ABAP_STRUCTDESCR and I get a dump at '?='.
How I can solve my Problem?
SinanHow about something like this.
report zrich_0001.
data type_ref type ref to cl_abap_typedescr.
data elem_descr type ref to cl_abap_elemdescr.
data struc_descr type ref to cl_abap_structdescr.
data comp_tab type abap_compdescr_tab.
data comp_wa like line of comp_tab.
parameters: p_name(30) type c.
type_ref = cl_abap_typedescr=>describe_by_name( p_name ).
if type_ref->type_kind = 'u'. " <- Structure
struc_descr ?= type_ref.
loop at struc_descr->components into comp_wa.
catch system-exceptions move_cast_error = 1.
data: tab_component type string.
concatenate p_name comp_wa-name into comp_wa-name separated by '-'.
elem_descr ?= cl_abap_typedescr=>describe_by_name( comp_wa-name ).
endcatch.
write:/ comp_wa-name, comp_wa-length, elem_descr->output_length.
endloop.
else.
elem_descr ?= type_ref.
write:/ p_name, elem_descr->output_length.
endif.
Regards,
Rich Heilman -
Hi all, I am new to xmldb and XQuery. Having trouble with relational xmltable quering... Any help is appriciated.
I want the following output
id info loc
4 stuff2 1
5 stuff3 1
6 stuff1 1
7 stuff4 2
etc....
The problem if feel is loc does not have a relation to transaction in the data. But I get an error "XQuery dynamic type mismatch"....
I have created a basic example below:
SELECT a.*
FROM "testTable",
XMLTABLE('/root/org/transaction'
PASSING testTable.column
COLUMNS
id varchar2(2) PATH '@id',
info varchar2(50) PATH '/info',
loc varchar2(2) PATH '@loc'
) a
<root>
<org loc="1">
<Transaction id="4"><info>stuff2</info></Transaction>
<Transaction id="5"><info>stuff3</info></Transaction>
<Transaction id="6"><info>stuff1</info></Transaction>
</org>
<org loc="2">
<Transaction id="7"><info>stuff4</info></Transaction>
<Transaction id="8"><info>stuff5</info></Transaction>
</org>
<org loc="3">
<Transaction id="9"><info>stuff6</info></Transaction>
<Transaction id="10"><info>stuff7</info></Transaction>
</org>
</root>
Thanks again for any help.
Edited by: user8820504 on Jan 14, 2010 2:27 PMYou need two distinct tables, one that maps Transactions and one that maps Orgs. Then join them on id. Something like this:
SQL> with testTable as (
2 select xmltype('<root>
3 <org loc="1">
4 <Transaction id="4"><info>stuff2</info></Transaction>
5 <Transaction id="5"><info>stuff3</info></Transaction>
6 <Transaction id="6"><info>stuff1</info></Transaction>
7 </org>
8 <org loc="2">
9 <Transaction id="7"><info>stuff4</info></Transaction>
10 <Transaction id="8"><info>stuff5</info></Transaction>
11 </org>
12 <org loc="3">
13 <Transaction id="9"><info>stuff6</info></Transaction>
14 <Transaction id="10"><info>stuff7</info></Transaction>
15 </org>
16 </root>') doc
17 from dual)
18 SELECT id, info, loc
19 FROM testTable,
20 XMLTABLE('/root/org/Transaction'
21 PASSING testTable.doc
22 COLUMNS
23 id varchar2(2) PATH '@id',
24 info varchar2(50) PATH 'info',
25 tr xmltype PATH '.'
26 ) trans ,
27 XMLTABLE('/root/org'
28 PASSING testTable.doc
29 COLUMNS
30 loc varchar2(2) PATH '@loc',
31 trs xmltype PATH 'Transaction'
32 ) orgs
33 where extractValue(orgs.trs,'/Transaction[@id="'||id||'"]/@id') is not null ;
ID INFO LO
4 stuff2 1
5 stuff3 1
6 stuff1 1
7 stuff4 2
8 stuff5 2
9 stuff6 3
10 stuff7 3
Selezionate 7 righe.Max
[My Italian Oracle blog|http://oracleitalia.wordpress.com/2010/01/10/crittografia-in-plsql-utilizzando-dbms_crypto/] -
Hello,
How can I improve the XQuery below in order to obtain a minimised return to escape from both errors ORA-19279 and ORA-01706?
XQUERY for $book in fn:collection("oradb:/HR/TB_XML")//article let $cont := $book/bdy where $cont [ora:contains(text(), "(near((The,power,Love),10, TRUE))") > 0] return $book
ERROR:
ORA-19279: XPTY0004 - XQuery dynamic type mismatch: expected singleton sequence
- got multi-item sequence
XQUERY for $book in fn:collection("oradb:/HR/TB_XML")//article let $cont := $book/bdy where $cont [ora:contains(., "(near((The,power,Love),10, TRUE))") > 0] return $book//bdy
/*ERROR:
ORA-01706: user function result value was too large
Regards,
Daianebelow query works for 1 iteration . but for multiple sets i am getting following error .
When you want to present repeating groups in relational format, you have to extract the sequence of items in the main XQuery expression.
Each item is then passed to the COLUMNS clause to be further shredded into columns.
This should work as expected :
select x.*
from abc t
, xmltable(
xmlnamespaces(
default 'urn:swift:xsd:fin.970.2011'
, 'urn:swift:xsd:mtmsg.2011' as "ns0"
, '/ns0:FinMessage/ns0:Block4/Document/MT970/F61a/F61'
passing t.col1
columns F61ValueDate Varchar(40) Path 'ValueDate'
, DebitCreditMark Varchar(40) Path 'DebitCreditMark'
, Amount Varchar(40) Path 'Amount'
, TransactionType Varchar(40) Path 'TransactionType'
, IdentificationCode Varchar(40) Path 'IdentificationCode'
, ReferenceForTheAccountOwner Varchar(40) Path 'ReferenceForTheAccountOwner'
, SupplementaryDetails Varchar(40) Path 'SupplementaryDetails'
) x ; -
So I have the iphone 4 with the latests update ios7.
So I went on settings > general > accessibility > larger type.
And I clicked "on" for "larger dynamic type"
Now my font is so big I can't even see apps that I have and such
I want to turn it "off" but my screen orientation is locked! (I can't move my phone horizontally) I think if I can move my phone horizontally I'll be able to see the on/off button for larger dynamic type.
I tried sliding the bottom upwards to turn off screen lock orientation but it's not on my screen because my font is set to a really big size that the "screen orientation lock button" didn't make it to the screenTurning on Dynamic type and increasing it shold not have that effect.
Try a reset: Simultaneously hold down the Home and On buttons until the device shuts down. Ignore the off slider if it appears. Once shut down is complete, if it doesn't restart on it own, turn the device back on using the On button. In some cases it also helps to double click the Home button and close all apps BEFORE doing the reset. -
Hi ,
I executed the below query in database version 11.2.0.3.0, it throws the error like "ORA-19279: XPTY0004 - XQuery dynamic type mismatch: expected singleton sequence - got multi-item sequence"
with PAYMENT_XML as (
select XMLTYPE(
'<Document>
<pain.002.001.02>
<GrpHdr>
<MsgId>CITIBANK/20091204-PSR/4274</MsgId>
<CreDtTm>2009-12-04T09:36:00</CreDtTm>
</GrpHdr>
<OrgnlGrpInfAndSts>
<OrgnlMsgId>10002</OrgnlMsgId>
<OrgnlMsgNmId>pain.001.001.02</OrgnlMsgNmId>
<OrgnlNbOfTxs>20</OrgnlNbOfTxs>
<OrgnlCtrlSum>7000</OrgnlCtrlSum>
<GrpSts>PART</GrpSts>
<StsRsnInf>
<AddtlStsRsnInf>ACK - FILE PARTIALLY SUCCESSFUL</AddtlStsRsnInf>
</StsRsnInf>
</OrgnlGrpInfAndSts>
<OrgnlGrpInfAndSts>
<OrgnlMsgId>10001</OrgnlMsgId>
<OrgnlMsgNmId>pain.001.001.02</OrgnlMsgNmId>
<OrgnlNbOfTxs>202</OrgnlNbOfTxs>
<OrgnlCtrlSum>9000</OrgnlCtrlSum>
<GrpSts>PART</GrpSts>
<StsRsnInf>
<AddtlStsRsnInf>ACK - FILE PARTIALLY SUCCESSFUL</AddtlStsRsnInf>
<AddtlStsRsnInf>Formated</AddtlStsRsnInf>
</StsRsnInf>
</OrgnlGrpInfAndSts>
</pain.002.001.02>
</Document>') as OBJECT_VALUE1
from dual
select R.*
from PAYMENT_XML,
XMLTABLE(
'for $COMP in $COMPANY/Document/pain.002.001.02
for $DEPT at $DEPTIDX in $COMP/OrgnlGrpInfAndSts
return <RESULT>
<NAME>{fn:data($COMP/GrpHdr/MsgId)}</NAME>
$DEPT/OrgnlMsgId,
$DEPT/OrgnlNbOfTxs,
$DEPT/OrgnlCtrlSum,
$DEPT/GrpSts,
$DEPT/StsRsnInf/AddtlStsRsnInf
</RESULT>'
passing OBJECT_VALUE1 as "COMPANY"
columns
NAME VARCHAR(10) path 'NAME',
OrgnlMsgId VARCHAR2(24) path 'OrgnlMsgId',
ORGNLNBOFTXS VARCHAR2(24) path 'OrgnlNbOfTxs',
ORGNLCTRLSUM NUMBER path 'OrgnlCtrlSum',
GRPSTS VARCHAR2(24) path 'GrpSts',
ADDTLSTSRSNINF VARCHAR2(40) path 'AddtlStsRsnInf'
) r
Errors comes this part :
<StsRsnInf>
<AddtlStsRsnInf>ACK - FILE PARTIALLY SUCCESSFUL</AddtlStsRsnInf>
<AddtlStsRsnInf>Formated</AddtlStsRsnInf>
</StsRsnInf>
if i put the single statement for this xml element <AddtlStsRsnInf> it works fine if more than one element comes it raised the error.
i want the output like the below format : want to merge the element value with (, comma) delimiter with single coloumn value
NAME
ORGNLMSGID
ORGNLNBOFTXS
ORGNLCTRLSUM
GRPSTS
ADDTLSTSRSNINF
CITIBANK/2
10002
20
7,000
PART
ACK - FILE PARTIALLY SUCCESSFUL
CITIBANK/2
10001
202
9,000
PART
ACK - FILE PARTIALLY SUCCESSFUL, Formated
Thanks is advance for reply
Thanks,
ChidamTry with XQuery string-join() function :
ADDTLSTSRSNINF VARCHAR2(40) path 'string-join(AddtlStsRsnInf, ", ")' -
Type problem with InDesign, especially CC.
Hi. I'm experiencing a type problem with InDesign, especially CC. When I open a type box, the cursor appears in the top right hand corner. I can correct that by selecting 'range left' but when I paste or type in my copy, the final period of each paragraph appears at the beginning of the last line. This is drivning me up the wall as I can find a way of correcting it.
Any ideas to solve this problem?
ThanksAre you using a MENA (Middle East North Africa, Hebrew, Arabic, Farsi, …) version? Then restting woul not help.
If not, you have to create a new document with the same Paragraph, Character and Object Styles (name should be identical) and import them into the other document to overwrite these style oddities.
If you are working without styles? Create correct new styles and apply them.
I doubt that resetting preferences will change here anything as paragraph properties from any existing document will not be changed when working with new preferences. -
Dynamic Type Checking... Is this possible?
I want to do a dynamic check for objec types in a datastructure. Something very similar to instanceof but using dynamic type parameter.
Syntactically speaking...
Instead of writing several methods like
public boolean isOfTypeXYZ( )
return ( this instanceof XYZ);
public boolean isOfTypeABC()
return ( this instanceof ABC);
...I want one single method like
public isOfType ( Class a_type)
return (this ***isoftype**** a_type);
}Where isoftype can somehow dynamically figure out if the object is of given type (class)
For those who want to know why I'd need this kind of contrived behaviour let me give a simple example (similar to my real issue).
Suppose I have a swing GUI application which has several laid out components like Containers, JPanels, JToolBars, JMenuItems, JButtons, JToggleButtons, JRadioButtons etc.
Now starting from the JFrame in this containment hierarchy, I want to find all instances of JButtons or say all instances of JRadioButtons or say all instances of JMenuItem or all instances of JComponents ...
I do not want to write a special method for each possible type I might encounter.
I want a more generic method like
searchComponents( Class a_class) that I can invoke by just changing its argument to convey the type.
Unfortunately getClassName() will not work as that gives the most derived type of the object. I want something very much like instanceof wherein I can check for an intermediate super class as well. (eg. All RadioButtons are AbstractButton and should return true for either type).
I tried to search for this in the forums but couldn't find something close to this. (There are several discussions about dynamic type casting which are different).Is this what you want?
searchComponents( Class a_class) {
// browse components
if (a_class.isInstance(component)) {
// do something
} -
Dynamic type variable creation
I want to create a variable with a pre-defined TYPE, but the latter will only be known at runtime.
For instance:
Consider that I my DEFINITIONS1 include file is:
TYPES: BEGIN OF type1,
field1 TYPE i,
field2 TYPE i,
field3 TYPE i,
END OF type1,
BEGIN OF cust_type_A,
INCLUDE TYPE type1.
TYPES: erdat TYPE vbak-erdat,
END OF cust_type_A,
BEGIN OF cust_type_B,
INCLUDE TYPE type1.
TYPES: fkdat TYPE vbrk-fkdat,
END OF cust_type_B.
Than I have the following code (assume "letter" is a character parameter I receive, either 'A' or 'B'):
INCLUDE definitions1.
DATA: z TYPE REF to data.
FIELD-SYMBOLS: <fs> TYPE ANY.
DATA str type string.
CONCATENATE 'MY_CUST_TYPE_' letter INTO str.
CREATE DATA z TYPE (str).
* ASSIGN z->* TO <fs>.
Why is that that the CREATE DATA z TYPE (str) statement fails ?
How, then, I create a variable/field symbol from a specific type, which will only be known at runtime ?
Thanks
AvrahamCheck this code to create a dynamic type at run time using the RTTS - Run Time Type Services.
DATA: lo_struct TYPE REF TO cl_abap_structdescr,
lo_element TYPE REF TO cl_abap_elemdescr,
lo_new_type TYPE REF TO cl_abap_structdescr,
lo_data TYPE REF TO data,
lt_comp TYPE cl_abap_structdescr=>component_table,
lt_tot_comp TYPE cl_abap_structdescr=>component_table,
la_comp LIKE LINE OF lt_comp.
DATA: lc_num TYPE char10.
* field symbols to access the dynamic table
FIELD-SYMBOLS: <f_line> TYPE ANY,
<f_field> TYPE ANY.
PARAMETERS: p_a RADIOBUTTON GROUP rd1,
p_b RADIOBUTTON GROUP rd1.
START-OF-SELECTION.
DO 3 TIMES.
lc_num = sy-index.
CONDENSE lc_num.
* Element Description
lo_element ?= cl_abap_elemdescr=>describe_by_name( 'INT4' ).
* Field name
CONCATENATE 'FIELD' lc_num INTO la_comp-name.
* Field type
la_comp-type = cl_abap_elemdescr=>get_p(
p_length = lo_element->length
p_decimals = lo_element->decimals ).
* Filling the component table
APPEND la_comp TO lt_tot_comp.
CLEAR: la_comp.
ENDDO.
IF p_a = 'X'.
* Element Description
lo_element ?= cl_abap_elemdescr=>describe_by_name( 'ERDAT' ).
* Field name
la_comp-name = 'ERDAT'.
* Field type
la_comp-type = cl_abap_elemdescr=>get_p(
p_length = lo_element->length
p_decimals = lo_element->decimals ).
* Filling the component table
APPEND la_comp TO lt_tot_comp.
CLEAR: la_comp.
ELSEIF p_b = 'X'.
* Element Description
lo_element ?= cl_abap_elemdescr=>describe_by_name( 'FKDAT' ).
* Field name
la_comp-name = 'FKDAT'.
* Field type
la_comp-type = cl_abap_elemdescr=>get_p(
p_length = lo_element->length
p_decimals = lo_element->decimals ).
* Filling the component table
APPEND la_comp TO lt_tot_comp.
CLEAR: la_comp.
ENDIF.
* 3. Create a New Type
lo_new_type = cl_abap_structdescr=>create( lt_tot_comp ).
* 5. data to handle the new table type
CREATE DATA lo_data TYPE HANDLE lo_new_type.
* 6. New internal table in the fieldsymbols
ASSIGN lo_data->* TO <f_line>.
Regards,
Naimesh Patel
Maybe you are looking for
-
Will Flash Builder 4 also be able to publish AS3 based projects -> iPhone native apps as well or is this only going to be limited to Flash CS5.
-
Pictures are being saved as firefox document i need them as jpeg image
since installing firefox, i click on a picture which is jpeg image and the save turns it into firefox document. it took a while to get it to save but i can not find where to change this item. i don't know why it changes they come in in the right form
-
HT1414 when changing a battery on 3gs is it really an APN no required of the old battery?
Hi I have changed a battery on my 3gs iphone three months ago but now it it started to play up it shuts down prematurely is it anything to do with APN please see the staement below five different batteries used Apn 616.0431 apn 616.0432
-
Getting rid of my photo in upper right (mail)
i suppose i should post this in mail but can anybody help me with this problem i have... i just loaded leopard from my tiger OS and when i email people my small little photo of me is in the upper right again ..... how do i get rid of it again? ....
-
Updating to Mavericks - can I download the MacBook Pro retina 10.9.1 version?
Hi, I have a late 2013 MacBook Pro with retina display. I saw that there's a specific version of Mavericks for my computer: http://support.apple.com/kb/DL1712 My question: it's called an UPGRADE. So is this link only for those who are already running