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?
Sinan
How 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
Similar Messages
-
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. -
Executing dynamic procedure with record type
Hi,
I have a small issue...I'm not attaching any tables / data..etc...I just want to know how to pass the record type to a procedure (which are actually obtained from a table) dynaically..Unable to form the sql statement..
I get an error saying that "wrong number or types of arguments in call to ||"...
-- see ** below where I'm getting an error.
.Need to pass the whole record type "l_shl_order_msg"
CREATE OR REPLACE PROCEDURE CM_BUILD_MSG_PRC (P_IN_BLD_MSG_CURSOR IN SYS_REFCURSOR,
P_OUT_BLD_MSG_CURSOR OUT SYS_REFCURSOR)
IS
l_shl_order_msg CRAE_INTERFACE.GLB_VAR_PKG.deid_SHELL_order_typ;
V_MSG_SHELL_NAME VARCHAR2(1000);
V_MESG_TEXT_SEGMENT VARCHAR2(1000);
V_TEXT VARCHAR2(1000);
V_MSG_TEXT VARCHAR2(4000);
V_MSG_FINAL_TEXT VARCHAR2(4000);
V_MSG_PROC VARCHAR2(1000);
V_SQL VARCHAR2(4000);
V_CNT NUMBER;
L_STATUS VARCHAR2(100);
L_REASON VARCHAR2(1000);
BEGIN
LOOP
FETCH P_IN_BLD_MSG_CURSOR
INTO l_shl_order_msg;
EXIT WHEN P_IN_BLD_MSG_CURSOR%NOTFOUND;
END LOOP;
Select mesg_shell_text, mesg_dynamic_var_count
into V_MSG_TEXT, V_CNT
from CRAE_MESG_MASTER
where mesg_shell_name = l_shl_order_msg.SHELL_ID;
For i in 1..V_CNT
LOOP
SELECT MESG_SHELL_NAME, MESG_TEXT_SEGMENT, PROCEDURE_NAME
INTO V_MSG_SHELL_NAME, V_MESG_TEXT_SEGMENT, V_MSG_PROC
FROM CRAE_MESG_MASTER_DETAIL
WHERE I = MESG_SEQ_NUMBER
AND mesg_shell_name = l_shl_order_msg.SHELL_ID;
V_SQL:= 'BEGIN '||V_MSG_PROC||'(''' || l_shl_order_msg|| ''',' ||
'''' || V_MSG_SHELL_NAME || ''',' || '''' || V_MESG_TEXT_SEGMENT
|| ''', CRAE_INTERFACE.GLB_VAR_PKG.V_TEXT );'||'END;';
DBMS_OUTPUT.PUT_LINE(V_SQL);
EXECUTE IMMEDIATE (V_SQL);
V_TEXT := CRAE_INTERFACE.GLB_VAR_PKG.V_TEXT;
IF I = 1
THEN
V_MSG_TEXT := REPLACE(V_MSG_TEXT,V_MESG_TEXT_SEGMENT,V_TEXT);
V_MSG_FINAL_TEXT := V_MSG_TEXT;
ELSE
V_MSG_FINAL_TEXT := REPLACE(V_MSG_FINAL_TEXT,V_MESG_TEXT_SEGMENT,V_TEXT);
END IF;
END LOOP;
DBMS_OUTPUT.PUT_LINE(V_MSG_FINAL_TEXT);
-- L_STATUS := CRAE_INTERFACE.GLB_VAR_PKG.V_STATUS;
-- L_REASON := CRAE_INTERFACE.GLB_VAR_PKG.V_REASON;
OPEN P_OUT_BLD_MSG_CURSOR
FOR
SELECT l_shl_order_msg.MESSAGE_DATE_TIME,
l_shl_order_msg.MASKED_ID,
l_shl_order_msg.OFFSET_DATE,
l_shl_order_msg.PATIENT_ACCOUNT_NUMBER,
l_shl_order_msg.ORDER_CONTROL,
l_shl_order_msg.PLACER_ORDER_NUMBER,
l_shl_order_msg.QUANTITY,
l_shl_order_msg.INTERVAL,
l_shl_order_msg.DURATION,
l_shl_order_msg.START_DATE_TIME,
l_shl_order_msg.END_DATE_TIME,
l_shl_order_msg.PRIORITY,
l_shl_order_msg.ORDERING_DATE,
l_shl_order_msg.ENTERED_BY_ID,
l_shl_order_msg.ENTERED_BY_FAMILY_NAME,
l_shl_order_msg.ENTERED_BY_GIVEN_NAME,
l_shl_order_msg.ORDERED_BY_ID,
l_shl_order_msg.ORDERED_BY_FAMILY_NAME,
l_shl_order_msg.ORDERED_BY_GIVEN_NAME,
l_shl_order_msg.REPEAT_PATTERN,
l_shl_order_msg.DRUG_CODE,
l_shl_order_msg.DRUG_DESCRIPTION,
l_shl_order_msg.REQUESTED_GIVE_AMOUNT,
l_shl_order_msg.REQUESTED_GIVEN_UNIT,
l_shl_order_msg.SIG,
l_shl_order_msg.ALLOW_SUBSTITUTION,
l_shl_order_msg.REQUESTED_DISPENSE_AMOUNT,
l_shl_order_msg.REQUESTED_DISPENSE_UNIT,
l_shl_order_msg.REFILLS,
l_shl_order_msg.ROUTE,
l_shl_order_msg.STATUS,
l_shl_order_msg.REASON,
V_MSG_FINAL_TEXT,
T.COMP_ID,
T.PROC_ID,
T.Procedure_Desc
FROM CRAE_MESG_rule_MASTER T
WHERE MSG_SHELL_NAME = l_shl_order_msg.SHELL_ID;
-- dbms_output.put_line (l_shl_order_msg.MESSAGE_DATE_TIME);
END;** I get an error saying that "wrong number or types of arguments in call to ||"...
Not sure how to pass record type dynamically...sb,
declare
l_shl_order_msg CRAE_INTERFACE.GLB_VAR_PKG.deid_SHELL_order_typ;
V_MSG_SHELL_NAME VARCHAR2(1000);
V_MESG_TEXT_SEGMENT VARCHAR2(1000);
V_SQL VARCHAR2(4000);
V_MSG_PROC VARCHAR2(1000);
begin
V_SQL := 'BEGIN '||V_MSG_PROC||'(l_shl_order_msg)'||'END;';
DBMS_OUTPUT.PUT_LINE(V_SQL);
end;when I execute this...l_shl_order_msg is passed as variable..but instead I want to pass all columns in the recordtype to be passed..
ex : l_shl_order_msg.id, l_shl_order_msg.name....etc..
This is what is being passed :
BEGIN ATTRIBUTE_PRC( l_shl_order_msg ,'CDS_1','text-1', CRAE_INTERFACE.GLB_VAR_PKG..V_TEXT );
ATTRIBUTE_PRC has already been defines as record type with i/p parameter..
Edited by: user7431648 on Jul 26, 2012 8:25 AM
Edited by: user7431648 on Jul 26, 2012 8:27 AM -
Creating context node with dynamic type
When we are creating context node thru wizard, Dictionary type must be filled. I'm trying to create Context node manually.Did any one tried created Context node class with Dynamic type.
Hi Prasad,
I have a similar requirement.
Can you please share with me how did you create context node with dynamic table data?
Thanks
Vicky -
Dynamic programming using cl_abap_typedescr
I have created a field catalog for an ALV grid dynamically using cl_alv_table_create=>create_dynamic_table (I am on 46B and cannot use the new version). How do I create the structure and therefore internal table to pass into the it_outtab parameter of the ALV grid set_table_for_first_display
method? I can create a blank table with the correct dynamic columns but now wish to populate it without much success! I am retrieving the type using cl_abap_typedescr=>describe_by_data and can cycle through the key but how do I just obtain the structure?
Cheers
Ian
cl_abap_typedescr to retrieve the column names of a dynamic table I have created for using with an ALV gridHi,
Use ASSIGN r_dyn_table->* TO <t_dyn_table> to get access to the dynamic table. To append rows to it, you should use ASSIGN COMPONENT idx/name OF STRUCTURE struc TO <fs>.
Example:
data: tab_fields like table of wa_fields,
r_dyn_table TYPE REF TO data,
r_wa_dyn_table TYPE REF TO data,
f_int type i.
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = F_TAB_FCAT
IMPORTING
ep_table = r_dyn_table
EXCEPTIONS
generate_subpool_dir_full = 1
OTHERS = 2.
ASSIGN r_dyn_table->* TO <t_dyn_table>.
CREATE DATA r_wa_dyn_table LIKE LINE OF <t_dyn_table>.
ASSIGN r_wa_dyn_table->* TO <wa_dyn_table>.
DESCRIBE TABLE tab_fields lines f_int.
do f_int times.
READ TABLE tab_fields INDEX sy-index into wa_fields.
ASSIGN wa_fields-field TO <w_field1>.
check1 = sy-subrc.
ASSIGN COMPONENT sy-index
OF STRUCTURE <wa_dyn_table> TO <w_field2>.
check2 = sy-subrc.
if check1 = 0 and check2 = 0.
<w_field2> = <w_field1>.
endif.
enddo.
Svetlin -
Dynamic action with set value on date field
Hi,
I'm using APEX 4.02
I'm trying to calculate the age based on the date of birth dynamically on a form. I'm trying to do this with a (advanced)dynamic action with set value.
I'm able to get this kind of action working based on a number field etc, but NEVER on a date field.
I've read all posts on this subject but so far no solution. Even if I try to simply copy the value over to another date field or typecast it to a string ( to_char function ) it does not work. So for me the problem seems to be in the source field being a date field.
I've tried using the source value as is in a select statement :
select :P33_GEBOORTEDATUM from dual;
and also type casted based on the date format :
select TO_DATE(:P33_GEBOORTEDATUM,'DD-MON-YYYY') from dual
but still no luck.
On the same form I don't have any issues as long as the calculation is based on number fields, but as soon as I start using dates all goes wrong.
Any suggestions would be greatly appreciated. If you need any extra info just let me know.
Cheers
Bas
b.t.w My application default date format is DD-MON-YYYY, maybe this has something to do with the issue .... ?
Edited by: user3338841 on 3-apr-2011 7:33Hi,
Create a dynamic action named "set age" with following values.
Event: Change
Selection Type: Item(s)
Item(s): P1_DATE_OF_BIRTH
Action: Set value
Fire on page load: TRUE
Set Type: PL/SQL Expression
PL/SQL Expression: ROUND( (SYSDATE - :P1_DATE_OF_BIRTH)/365.24,0)
Page items to submit: P1_DATE_OF_BIRTH
Selection Type: Item(s)
Item(s): P1_AGE
Regards,
Kartik Patel
http://patelkartik.blogspot.com/
http://apex.oracle.com/pls/apex/f?p=9904351712:1 -
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. -
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. -
Dynamic table with dynamic drop-down list values
Hi,
I need to display a dynamic table with 2 columns on an interactive form.
My Context is defined as below:
Root
StudentData 0..n
StudentName
StudentCourses 0..n
Text
Value
The 1st column should display student name, 2nd column should display student courses. The courses will be different for each student. I populated the context properly. I checked it by printing them. My DDL is bound to "Student Courses".
When there is one row -> The DDL is populated with the courses of student 1 (as there is only one).
When there are more rows -> The DDLs for all the students are populated with all the courses of all the students.
I want to see the data populated like:
TEXTFIELD DROP-DOWN LIST
Student 1------Student1-Course1
Student1-Course2
Student1-Course3
Student 2------Student2-Course1
Student2-Course2
Student2-Course3
I tried to do this in plain web dynpro using SVS.. it is also working similarly.
I have set the singleton property of nodes "StudentData" and "StudentCourses" to false.
Could any one tell me where I am going wrong?
Thanks
RamRam,
I'm not sure how much this will help, but I know I had the same problem as you when I tried to get a similar thing working, but I can't remember which of the many changes I made fixed the problem, so I'll just show you my code and perhaps you can see if anything is different than yours.
Here's where I'm creating my dropdown - in my case EastNew_RegOut is the same as your StudentData, and RateTypeDropValues is the same as your StudentCourses (the comments in the code are not meant to sound bossy to you, this is actually an example piece of code that other developers in my company "steal", so I have to put very specific instructions in there!):
int nodeSize = wdContext.nodeEastNew_RegOut().size();
for (int i = 0; i < nodeSize; i++) {
//create an element called "table", that's the element at i. So, basically it's a row. Maybe I should have
//called it "row" instead of table.
IPublicDeviceExchange.IEastNew_RegOutElement table = (IPublicDeviceExchange.IEastNew_RegOutElement)wdContext.nodeEastNew_RegOut().getElementAt(i);
//this line of code just executes an rfc that finds out what rates need to be in the dropdown for this particular row
executeRateTypeDropdown(rateCategory, table.getNum(), wdContext.currentEastNew_MeterOutElement().getReggrp());
//clear out what's already in there before we re-populate it.
table.nodeRateTypeDropValues().invalidate();
//now, I'm looping through all the values in the *actual* rate type dropdown (the one that's an RFC, populated by the above "execute" method)
for (int j = 0; j < wdContext.nodeEastRatetype_DropdownOut().size(); j++) {
//for each element in the *actual* Rate type dropdown, I'm going to create an element in my node that I created
//and set the values from the *actual* one as the values in my node.
IPublicDeviceExchange.IRateTypeDropValuesElement element = wdContext.createRateTypeDropValuesElement();
IPublicDeviceExchange.IEastRatetype_DropdownOutElement rateTypeOut = (IPublicDeviceExchange.IEastRatetype_DropdownOutElement)wdContext.nodeEastRatetype_DropdownOut().getElementAt(j);
element.setText(rateTypeOut.getText());
element.setValue(rateTypeOut.getRatetype());
//here's another key - notice how I don't say wdContext.nodeRateTypeDropValues() - it's the one that's
//directly off that table I created earlier - the thing that's essentially a row in my newReg table.
//So, what I'm doing here is adding that new element I created to the dropdown FOR THAT ROW!
//(btw, if you're trying to duplicate this, and this method does not exist for your "table" object, it's
//probably because you didn't listen to me above and you didn't create your node with the singleton property
//set to false.)
table.nodeRateTypeDropValues().addElement(element);
As for my layout... my table is bound to the EastNew_RegOut node, and the column with the dropdown is bound to RateTypeDropValues.Value (that's probably obvious, but there you have it anyway)
Finally, in my context, EastNew_RegOut is singleton = true (I was surprised about this, actually, I would have assumed it was false) with a selection of 0..1 and RateTypeDropValues has singleton set to false with a selection of 0..1
I hope that helps to some degree!
Jennifer -
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, ", ")' -
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. -
Dynamic sql with dynamic bulk collection variable
Hi,
I am facing the issue while bulk collecting dynamic sql query data into dynamic variable.
Eg:
query1:= << dynamic select query>>
Execute immediate query1 bulk collect into Dynamic_varibale;
here dynamic_varible is pl/sql table type with 1 column.
How do i declare "dynamic_variable" here????
please suggest...create type t_id is table of number
SQL> create type t_id is table of number
2 /
Type created.
SQL> declare
2
3 v_tid t_id;
4 v_results sys_refcursor;
5
6 v_employee_id number;
7 v_name varchar2(100);
8
9 v_sql varchar2(1000);
10
11
12 begin
13 v_tid := t_id(7902,7934);
14
15 --
16
17
18 v_sql := 'select empno, ename from scott.emp ' ||CHR(10)
19 || 'where empno in (select column_value from table(cast(:v_tid as
t_id)))';
20
21 dbms_output.put_line(v_sql);
22 dbms_output.put_line('----------');
23
24 open v_results for v_sql using v_tid;
25
26
27 IF v_results IS NOT NULL
28 THEN
29 LOOP
30 FETCH v_results
31 INTO v_employee_id, v_name;
32
33 EXIT WHEN (v_results%NOTFOUND);
34 dbms_output.put_line(v_name);
35 END LOOP;
36
37 IF v_results%ISOPEN
38 THEN
39 CLOSE v_results;
40 END IF;
41 END IF;
42
43 end;
44 /
select empno, ename from scott.emp
where empno in (select column_value from
table(cast(:v_tid as t_id)))
FORD
MILLER -
Dynamic table with radio buttons
I need to load a dynamic table with radio buttons that allow
the user to select an item in the table. I need to have it add a
radio button with a unique identifier for each table item.
For example: the table will load all of the seminars
locations available in a certain state, the radio button will allow
the user to select the city in which they would like to attend and
that value will get passed to the registration page. The value of
each radio button would be equal to the location_id in the database
for each of the locations in the table (The table includes the
date, day, venue, address, hotel info, etc. details for each city.)
When I add dynamic radio buttons and set the value to the
location_id in the database, it allows the user to select multiple
radio buttons. I cannot find any information on how to
resolve.....??
Any help is appreciated.beanieboo wrote:
> I need to load a dynamic table with radio buttons that
allow the user to select
> an item in the table. I need to have it add a radio
button with a unique
> identifier for each table item.
>
> For example: the table will load all of the seminars
locations available in a
> certain state, the radio button will allow the user to
select the city in which
> they would like to attend and that value will get passed
to the registration
> page. The value of each radio button would be equal to
the location_id in the
> database for each of the locations in the table (The
table includes the date,
> day, venue, address, hotel info, etc. details for each
city.)
>
> When I add dynamic radio buttons and set the value to
the location_id in the
> database, it allows the user to select multiple radio
buttons. I cannot find
> any information on how to resolve.....??
> Any help is appreciated.
Give each radio button the same name
<input type="radio" name=theLocation" value="<?php
$recordset['location_id'] ?>">
Mick -
Hello everybody,
im tried to create a dynamic table with cl_alv_table_create=>create_dynamic_table, but that doesnt work for the table i need. I need a table with a changing number of columns of type "type ref to CL_DD_INPUT_ELEMENT", but the fieldcat only takes normal Data-Types.
So my question is, is there any way to create a dynamic table or structure with components of type ref to CL_DD_INPUT_ELEMENT?
Thank you very much for any help.
CheersI generally use Factory methods of RTTS classes to create dynamic tables. Check my reply (Step 1) in this thread getting column headers dynamically from input parameters in alv..
-
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
-
Hi, I currently have a macbook and am subscribed to creative cloud (student). I am looking at buying a second machine (desktop) and want to know if I can use CC on two machines under my one membership? Obviously I am a single user and will not be usi
-
I am having the same issue with Verizon, just switched to the Jet Pack with them a month ago, I have upgraded to 10 GB and after 6 days it said I was at 75%. 75%! That is ridiculous, I have 10 GB. They seem to give the same answer to everyone, shu
-
Problem in including a defined schema
Hi : I am trying to register a schema using dbms_xmlschema.registerSchema(). I have registered one schema already and now I am trying to register another schema which has an "include" statement to refer the already registered schema. I do this by hav
-
Hi Guys I have been encountering the problem while creating Excise Invoice for Factory Sales, only BED condition type is calculated and reflected in excise invoice J1IIN, whereas all the conition types releated with excise are comming in customer inv
-
Trying move iPhoto library, won't copy to new home
So I'm trying to move my iPhoto library from a newer MacBook Pro to an older Macbook, where there is more space for it, using an external hard drive. When I try to copy the library from the hard drive to the Macbook, I get a 'not enough space' error,