How to handle htmlb:inputField submitOnEnter
Hi Friends,
Iam using submitOnEnter = "true" in <htmlb:inputField> so that when I press enter in that input field some action should take place.
But Iam not sure how to handle that event.
When I use this it is giving page error.
Can anyone help me out how to handle this...
Regards,
Raju...
if you set submitOnEnter = "true" for an inputfield, pressing enter key when the cursor is in that inputfield would trigger server event.
in the oninputprocessing you can capture the event.
also please be aware that submitonenter doesnt work in some SPs as per this thread
htmlb:submitOnEnter at inputField
to capture the value of the inputfield in oninputprocessing you can write the following code
ATA: data TYPE REF TO cl_htmlb_inputfield.
data ?= cl_htmlb_manager=>get_data( request = runtime->server->request
name = 'inputField'
id = 'IP1'
IF data IS NOT INITIAL.
<variable> = data->value .
endif .
Regards
Raja
Similar Messages
-
How to fire an onblur event for htmlb:inputfield ?
Hi All,
I have a problem in creating in ONBLUR..for input field.
What i want is when i give input to the input it goes to DB and retriving some data and visible to next Dropdown.
For this if i give input to input field and press any key then it will goes to db and getting data.
I am stricking over here .
Please guide me for this.
Thanks
Nageswara.so what you need is a javscript function to get triggered onblur event and it should generate server event.
check out the following code sample.
<htmlb:inputField id = "test"
alignment = "LEFT"
size = "10"
type = "STRING" />
<bsp:htmlbEvent id = "myid"
onClick = "myonclick"
name = "ValueChanged" />
<script for="test" event=onblur type="text/javascript">
ValueChanged();
</SCRIPT>
Regards
Raja -
Javascript in the htmlb:inputField
Here is the brief description of the problem:
I have a table view in which i display the htmlb:inputField which are created in the iterator. I need to capture the ENTER Key event and set the focus to the next field in the next row.
I have seen examples of the normal input field but couldnn't somehow figure out a way to do it in the htmlb:inputField. Here is the sample code which i tried to play around with (for normal input fields.)..
<i>function enter(nextfield) {
if(window.event && window.event.keyCode == 13) {
nextfield.focus();
return false; }
else
return true; }
</script>
Field 1: <input type="text" name="field1"
onkeypress="return enter(document.demo.field2)"><br>
Field 2: <input type="text" name="field2" onkeypress="return enter(document.demo.field1)"><br></i>
<b>How do i use this code in the iterator for my htmlb:inputField ? i did try the following attributes
1) submitOnEnter
2) onValueHelp
3) doValidate
but none on them could help me..
</b>..
Any help would be appriciated.
Amandeep.Hi Alwyn,
<b>
Works fine when i place it indivisually on the BSP.
I have not been able to figure out a way to do it in the iterator..</b>
<i><%@page language="abap" %>
<%@extension name="htmlb" prefix="htmlb" %>
<%@extension name="bsp" prefix="bsp" %>
<script language = "javascript">
function func(nextfield)
if(window.event && window.event.keyCode == 13) {
nextfield.focus();
return false; }
else
return true;
</script>
<htmlb:content design="design2003" >
<htmlb:page title="detail " >
<htmlb:form>
<bsp:findAndReplace find = "<input"
replace = "<input onKeyPress=func(authorfname2);" >
<htmlb:inputField id = "authorfname1"
tooltip = "tooltip1"
value = "<%= authorfname %>" />
</bsp:findAndReplace>
<br>
<bsp:findAndReplace find = "<input"
replace = "<input onKeyPress=func(authorfname3);" >
<htmlb:inputField id = "authorfname2"
tooltip = "tooltip1"
value = "<%= authorfname %>" />
</bsp:findAndReplace>
<br>
<bsp:findAndReplace find = "<input"
replace = "<input onKeyPress=func(authorfname1);" >
<htmlb:inputField id = "authorfname3"
tooltip = "tooltip1"
value = "<%= authorfname %>" />
</bsp:findAndReplace>
</htmlb:form>
</htmlb:page>
</htmlb:content></i>
<b>in the iterator i am trying to do like this</b>
<i> MOVE: p_row_index TO l_rindx,
p_column_index TO l_cindx.
CONCATENATE 'INPUT_' l_cindx '_' l_rindx
INTO l_id.
CONDENSE l_id NO-GAPS.
IF gv_mode = 'P'.
CREATE OBJECT l_input.
l_input->width = '100%'.
l_input->style = 'celldesign:GROUP_LEVEL3'.
l_input->id = l_id.
l_input->cellvalue = 'X'.
l_input->maxlength = 11.
l_input->value = l_string.
p_isreadonly = 'X'.
p_style = 'celldesign:GROUP_LEVEL3'.
start test for the enter key
DATA: l_script TYPE string.
CONCATENATE ' "<input onKeyPress=func(' l_id ')"' INTO l_script.
CREATE OBJECT l_find_repl.
l_find_repl->find = '<input'.
l_find_repl->replace = l_script.
p_replacement_bee = l_find_repl.
end test for the enter key
p_replacement_bee = l_input.</i>
<b>and on the main page i have my same function but doesn't do anything..</b>
<i><script language = "javascript">
function func(nextfield)
if(window.event && window.event.keyCode == 13) {
nextfield.focus();
alert ('hello');
return false; }
else;
return true;
</script></i>
Any suggestions will be appriciated.
Thanks in advance
Amandeep. -
How to handle the exception in GP(Exception : Activity could not be read)
Hi all
we are getting the GP exceptions as 1) "Activity could not be read" 2) "Action has been stopped"
3) error while processing the item can not be displayed
Please let me know how to handle these exceptions in GP .
currently i got some documents in SDN on GP exceptions but those are related to manual exceptions for example if you enterd wrong data in the inputfield then we can handle those exceptions then it will allow to enter the new value but the exceptions which i mentioned above are new it seems
can you please let me know how to handle or solve those 3 exceptions
Thanks
binduHi Shikhil
Thanks for your reply
Please have a look below for exceptions which i am getting in GP and let me know how to handle these exceptions.
1) "Activity could not be read"
2) "Action has been stopped"
3) error while processing the item can not be displayed
if you give any idea/clue how to handle these exceptions then it would be great help to me
Thanks
Sunil -
How to Handle BARCODE related issues in WebDynpro ABAP
Hi All,
How to handle barcode related issues in WDA?
is it possible in WDA or not?
please provide information or any links related..
Thanks,
raj.Hi ,
You just need to install the software comes with the barcode scanner in the local PC and while reading you have to put the cursor on the field like inputfield . a barcode when interpreted by scanner is nothing but alphanumeric words.
Regards
Yash -
Handling HTMLB events in BSPs???
Hi all,
can anybody tell me the how to handel events in BSPs??Hi Aravind,
Follow the link /people/brian.mckellar/blog/2004/07/28/bsp-programming-handling-htmlb-events u can understand. -
HTMLb InputField ValueHelpContext
Hi,
Does anybody know how to use the ValueHelpContext (com.sapportals.htmlb.valuehelp.ValueHelpContext) related to an HTMLb InputField? I cannot find any documentation.
I like to develop an InputField for a material number with some kind of popup value help where a user can search a material by name.
Thanks in advance!
Best regards,
EricHi, have you done it?
-
How to handle type safety when using com.sap.typeservices.IProposalList
Hi,
I have been testing out the new features in Web Dynpro Java CE EHP1 using a scenario with BPM and SAP MDM. One of the new features I tested is the Ajax feature of using suggestion values. I have an InputField UI element which have bound to a context attribute (CountriesView/Country) which is of type string. The UI element has the "suggestValues" value set to true. I then use the IProposalList to produce a valueset. This will make the InputField UI appear as a combo box and allow the users to type in a few characters and utilize the Ajax framework to automatically search in the list of values.
The following code works perfectly ok but I don't understand how I should handle the compiler warning "IProposalList is a raw type. References to generic type IProposalList<T> should be parameterized"?
IProposalList proposalsCountry = wdContext.nodeCountriesView().getNodeInfo().getAttribute(IPrivateComp1.ICountriesViewElement.COUNTRY).getModifiableSimpleType().getSVServices().getProposals();
for(int i=0;i<bua.length;i++){
IPrivateComp1.ICountriesViewElement buaelement=wdContext.createCountriesViewElement();
buaelement.setCountry(bua<i>[0]);
buaelement.setCode(bua<i>[1]);
bualist.add(buaelement);
proposalsCountry.add(bua<i>[0]);
wdContext.nodeCountriesView().bind(bualist);
I don't have any issues handling this for other types such as ArrayList. Using the syntax "IProposalList<String> proposalsCountry ...." will handle the "proposalsCountry.add .." part but I still have a warning "Type safety: The expression of type IProposalList needs unchecked conversion to conform to IProposalList<String>"
Any ideas on how to handle this?
Thanks,
JohanHi,
Eventhough there are no replies to this thread I thought I should update with what I belive is an answer to my question. Excerpt from http://stackoverflow.com/questions/382/what-is-the-meaning-of-the-type-safety-warning-in-certain-java-generics-casts:
"This warning is there because Java is not actually storing type information at runtime in an object that uses generics. Thus, if 'object' is actually a List<String>, there will be no ClassCastException at runtime except until an item is accessed from the list that doesn't match the generic type defined in the variable. This can cause further complications if items are added to the list with this incorrect generic type information. Any code still holding a reference to the list but with the correct generic type information will now have an inconsistent list. To remove the warning, try:
List<?> list = (List<?>) object;However, note that you will not be able to use certain methods such as add because the compiler doesn't know if you are trying to add an object of incorrect type. The above will work in a lot of situations, but if you have to use add or some similarly restricted method, you will just have to suffer the yellow underline in Eclipse (or a SuppressWarning annotation)."
The last line explain the reason for my issue and the lack of a solution when using add method.
/Johan -
About HTMLB inputField value check....
I have one htmlb inputField in a bsp page.
this inputfield refer to numc(3) data element with fiexed value.
I wanna check input value automatically using fiexed value as domain....
How can I set this option?
How can I implement this function?
Regards etnaya.I would recommend you check into the doValidate feature of the inputField and check the examples under SBSPEXT_HTMLB in transaction SE80
-
Htmlb:inputField always uses encode="TRUE"
Hi,
I have a inputField using data binding. The model field contains "Česká republika", and this code
<htmlb:inputField id="InpSupl" value="//model/edit_wa.supplier" encode="FALSE"/>
Renders to
<input class="sapEdfTxtEnbl" size="60" maxlength="60" name="cont_INVEST_invest_edit_wa.supplier" id="cont_INVEST_InpSupl" value="&#268;eská republika">
How can I prevent this HTML-encoding?
Version 6.40 SP 12.
Thanks,
ThiloHmm, I don't understand all this.
Look here, this is my complete output (sorry about that) of your example.
And you can see, the ampersand is encoded, but I want the letter È (a upper sized C with a ^ on top).
Why does it work at your place?
<html><head><title> </title><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1" ><meta http-equiv="imagetoolbar" content="no"><script type="text/javascript" language="JavaScript" src="/sap/public/bsp/sap/htmlb/events.js"></script><script type="text/javascript" language="JavaScript" src="/sap/public/bsp/sap/htmlb/event_dictionary.js"></script><link id="urstyle" rel="stylesheet" type="text/css" href="/sap/public/bc/ur/Design2002/themes/sap_tradeshow/ur/ur_ie6.css"><link rel="stylesheet" type="text/css" href="/sap/public/bc/ur/Design2002/themes/sap_tradeshow/ur/ur_pop_ie6.css"><script type="text/javascript" language="JavaScript">var popup_emptydoc="/sap/public/bsp/sap/htmlb/domainRelaxOff.htm";var HTMLB_SECTION508 = false;</script><script type="text/javascript" language="JavaScript">var sapUrDomainRelaxing = {NONE:"NONE",MINIMAL:"MINIMAL",MAXIMAL:"MAXIMAL"};ur_system={doc:window.document ,mimepath:"/sap/public/bc/ur/Design2002/themes/sap_tradeshow/common/",stylepath:"/sap/public/bc/ur/Design2002/themes/sap_tradeshow/ur/",emptyhoverurl:"/sap/public/bc/ur/Design2002/themes/sap_tradeshow/common/emptyhover.html",is508:false,direction:"ltr",domainrelaxing:sapUrDomainRelaxing.NONE,browser_abbrev:"ie6",dateformat:1,firstdayofweek:0}</script><script type="text/javascript" language="JavaScript" src="/sap/public/bc/ur/Design2002/js/sapUrMapi_ie6.js"></script><script type="text/javascript" language="JavaScript" src="/sap/public/bc/ur/Design2002/js/popup_ie6.js"></script><script type="text/javascript" language="JavaScript" src="/sap/public/bc/ur/Design2002/js/languages/urMessageBundle_de.js"></script><script type="text/javascript" language="JavaScript" src="/sap/public/bsp/sap/htmlb/misc.js"></script></head><body class="urBdyStd" scroll="AUTO" style="margin-left:2;margin-right:2;margin-top:2;margin-bottom:2">
<input disabled type="hidden" id="htmlb_first_form_id" name="htmlb_first_form_id" value="htmlb_form_1"><form id="htmlb_form_1" name="htmlb_form_1" method="POST" autocomplete="off"><input type="hidden" name="htmlbScrollX"><input type="hidden" name="htmlbScrollY"><input type="hidden" name="htmlbevt_ty"><input type="hidden" name="htmlbdoc_id" value=""><input type="hidden" name="htmlbevt_frm" id="htmlbevt_frm" value="htmlb_form_1"><input type="hidden" name="htmlbevt_oid"><input type="hidden" name="htmlbevt_id"><input type="hidden" name="htmlbevt_cnt"><input type="hidden" name="htmlbevt_par1"><input type="hidden" name="htmlbevt_par2"><input type="hidden" name="htmlbevt_par3"><input type="hidden" name="htmlbevt_par4"><input type="hidden" name="htmlbevt_par5"><input type="hidden" name="htmlbevt_par6"><input type="hidden" name="htmlbevt_par7"><input type="hidden" name="htmlbevt_par8"><input type="hidden" name="htmlbevt_par9"><input type="hidden" name="onInputProcessing" value="htmlb"><input type="hidden" name="htmlb_form_1_complete" id="htmlb_form_1_complete" code="OK"><input type="hidden" name="sap-htmlb-design" id="sap-htmlb-design" value="">
<span id="InpSupl-r" class="urEdf2Whl"><input type="Text" class="urEdf2TxtEnbl" autocomplete="off" id="InpSupl" ct="InputField" name="InpSupl" st="" value="&#268;eská republika" onblur="sapUrMapi_InputField_Blur('InpSupl',event)" onkeydown="sapUrMapi_InputField_keydown('InpSupl',event)" onkeyup="sapUrMapi_InputField_KeyUp('InpSupl',event)" onfocus="sapUrMapi_InputField_focus('InpSupl',event)"></span>
</form>
<script language="JavaScript">
function sapArrErase(){if(typeof(sapUrMapi_PcTabSeq_Registry)=='undefined') return;sapUrMapi_PcTabSeq_Registry1=sapUrMapi_PcTabSeq_Registry;sapUrMapi_PcTabSeq_Registry=new Array();for(var p in sapUrMapi_PcTabSeq_Registry1){if(document.getElementById(p)!=null)sapUrMapi_PcTabSeq_Registry[p]=true;}}function sapOnResize(){sapArrErase();;}window.onresize=sapOnResize;window.attachEvent ('onload', sapOnResize);
</script><script language="JavaScript">sapUrMapi_initLinkStatus();</script><noscript><iframe style="position:absolute;top:0;left:0;width:100%;height:150%" src="?sap-bsp-exception=NO_JS"></iframe></noscript><script language="JavaScript">if(document.cookie==null||document.cookie.indexOf("sap-contextid")<0){location.assign("?sap-bsp-exception=NO_CK");}</script></body></html>
In my opinion the inputField always does a encode="TRUE" and I don't have a chance to set it to FALSE. -
Hi,
Does anyone know, how to change the default white background color of the inputField in htmlb?Hi,
I could do it only with java script.
<script language="JavaScript">
function set_textcolor(name, col)
document.getElementById(name).style.color = col; "textcolor
document.getElementById(name).style.backgroundColor = col;
</script>
if you want to change the field static you can do that in following way:
<htmlb:inputField id = "IN_SCAN_NR"
value = "xxx" />
<script language="JavaScript">
set_textcolor("IN_SCAN_NR","red");
</script>
for dynamic change I did following:
Table it_fields contains IDs of fields I wanted ot set to red color (filled by an check routine).
<%
data:
lv_script type string,
lv_string type string.
loop at it_fields into lv_string.
concatenate
lv_script
'set_textcolor("'
lv_string
'","red");'
into lv_script.
endloop.
concatenate
lv_script
'</script>'
into lv_script.
%>
<%= lv_script %> *** put scripting to html coding
I hope that helps,
sincerely yours .
Bernhard
null -
Need help with htmlb:inputField and Currency format
Hi all,
i'm looking in vain for the possibility to prepare a field with currency.
I have a local field in which an amount is available.
Unfortunately, the amount is spent but not formatted for currency.
current layout: 123456.78
requestet layout: 123.456,78
How do I get through it?
Here is my code:
DATA: ld_betrag TYPE ZBETR.
definition: the domain of "ZBETR" = 'WRTV7'
LOOP AT.....
ADD wa-betrag TO ld_betrag.
ENDLOOP.
The amount will be added in a loop.
<htmlb:inputField id = "betrag"
disabled = "TRUE"
value = "<%= ld_betrag %>" />
Output is via a htmlb:inputField
I have the same definition for a amount field in a htmlb:tableView...
in this tableView i get the correct layout for my amount. But I haven´t give a special formatting to the tableView...
Why the BSP works differently at htmlb:inputField and htmlb:tableView
Thanks 4 help.
Regards
MarkusHi,
the Domain of ZBETR = WRTV7 (it´s SAP Standard)
Data Type CURR 'Currency field, stored as DEC'
No. Characters 13
Decimal Places 2
Output Length 18
Convers. Routine
X Sign
SBSPEXT_HTMLB Helps
I forgot the attribute 'type'.
Thank you...now it works!
Regards
Markus -
How to handle exception CX_SY_REF_IS_INITIAL
hi experts,
im working on a test scenario for abap mapping in SAP XI im getting this error
An exception with the type CX_SY_REF_IS_INITIAL occurred, but was neither handled locally, nor declared in a RAISING clause Dereferencing of the NULL reference
i understand that i need to catch this exception in the abap coding but i'm not familiar with oops concepts
can any one please suggest me how to handle this exception for the following code...
method IF_MAPPING~EXECUTE.
break x1149.
* initialize iXML
TYPE-POOLS: ixml.
class cl_ixml definition load.
** Instances & Variable declaration =======================
* instance main factory
TYPES: BEGIN OF t_xml_line,
data(256) TYPE x,
END OF t_xml_line.
DATA: l_ixml TYPE REF TO if_ixml,
* instance input stream factory
l_streamfactory TYPE REF TO if_ixml_stream_factory,
* instance input stream
l_istream TYPE REF TO if_ixml_istream,
* instance input document
l_document TYPE REF TO if_ixml_document,
* instance parse input document
l_parser TYPE REF TO if_ixml_parser,
* instance for elements within the nodes
node TYPE REF TO if_ixml_node,
*instance of nodemap
nodemap TYPE REF TO if_ixml_named_node_map,
* instance for iterator
iterator TYPE REF TO if_ixml_node_iterator,
name TYPE string,
value TYPE string,
* instance main factory
o_ixml TYPE REF TO if_ixml,
* instance output document
o_document TYPE REF TO if_ixml_document,
* instance output stream
o_istream TYPE REF TO if_ixml_ostream,
* instance parse output document
o_parser TYPE REF TO if_ixml_parser,
* instance fot renderer
renderer type ref to if_ixml_renderer,
irc type i,
l_xml_size TYPE i,
*ROOT ELEMENT
l_element_MT_DEMANDTEC_COST TYPE REF TO if_ixml_element,
*NEXT CHILD ELEMENT FROM THE ABOVE PARENT
l_element_DT_DEMANDTEC TYPE REF TO if_ixml_element,
*CHILDREN1 ELEMENT FOR DT_DEMANDTEC
l_element_DT_WHSE TYPE REF TO if_ixml_element,
*CHILDREN2 ELEMENT FOR DT_DEMANDTEC
l_element_DT_DC TYPE REF TO if_ixml_element,
*CHILDREN3 ELEMENT FOR DT_DEMANDTEC
l_element_DT_PLANT TYPE REF TO if_ixml_element,
*CHILDREN4 ELEMENT FOR DT_DEMANDTEC
l_element_DT_QTY TYPE REF TO if_ixml_element.
*saving the xml document
DATA: l_xml_table TYPE TABLE OF t_xml_line.
types: begin of t_source,
whse(5),
dc(4) ,
plant(4),
qty type i,
end of t_source.
types: tt_source TYPE STANDARD TABLE OF t_source.
data: wa_source type t_source.
data: it_source TYPE tt_source,
ivalue type string.
* Procedures and business logic =======================================
* Creating the main iXML factory
l_ixml = cl_ixml=>create( ).
* Creating a stream factory
l_streamfactory = l_ixml->create_stream_factory( ).
* create input stream
l_istream = l_streamfactory->create_istream_xstring( source ).
* initialize input document
l_document = l_ixml->create_document( ).
* Create a Parser
l_parser = l_ixml->create_parser( stream_factory = l_streamfactory
istream = l_istream
document = l_document ).
* parse input document
l_parser->parse( ).
* Validate a document
l_parser->set_validating( mode = if_ixml_parser=>co_validate ).
* Parse the stream
IF l_parser->parse( ) NE 0.
IF l_parser->num_errors( ) NE 0.
DATA: parseerror TYPE REF TO if_ixml_parse_error,
str TYPE string,
i TYPE i,
count TYPE i,
index TYPE i.
count = l_parser->num_errors( ).
WRITE: count, ' parse errors have occured:'.
index = 0.
WHILE index < count.
parseerror = l_parser->get_error( index = index ).
i = parseerror->get_line( ).
WRITE: 'line: ', i.
i = parseerror->get_column( ).
WRITE: 'column: ', i.
str = parseerror->get_reason( ).
WRITE: str.
index = index + 1.
ENDWHILE.
ENDIF.
ENDIF.
* Process the document
IF l_parser->is_dom_generating( ) EQ 'X'.
refresh : it_source.
node ?= l_document.
CHECK NOT node IS INITIAL.
* create a node iterator
iterator = node->create_iterator( ).
* get current node
node = iterator->get_next( ).
* loop over all nodes
WHILE NOT node IS INITIAL.
CASE node->get_type( ).
WHEN if_ixml_node=>co_node_element.
* element node
name = node->get_name( ).
nodemap = node->get_attributes( ).
WHEN if_ixml_node=>co_node_text.
* text node
value = node->get_value( ).
if name eq 'DT_WHSE'.
wa_source-whse = value.
ELSEIF name eq 'DT_DC'.
wa_source-DC = value.
ELSEIF name eq 'DT_PLANT'.
wa_source-PLANT = value.
ELSEIF name eq 'DT_QTY'.
wa_source-QTY = value.
COLLECT wa_source INto it_source.
CLEAR wa_source.
ENDIF.
endcase.
node = iterator->get_next( ).
endwhile.
ENDIF.
loop at it_source into wa_source .
at first.
* Creating a ixml factory
o_ixml = cl_ixml=>create( ).
* Creating the dom object model
o_document = l_ixml->create_document( ).
endat.
* Build and Fill root node MT_DEMANDTEC_COST
AT FIRST.
l_element_MT_DEMANDTEC_COST =
O_document->create_simple_element(
name = 'MT_DEMANDTEC_COST'
parent = o_document ).
ENDAT.
* Build and Fill Child node DT_DEMANDTEC for parent
* MT_DEMANDTEC_COST
l_element_DT_DEMANDTEC = O_document->create_simple_element(
name = 'DT_DEMANDTEC'
parent = l_element_MT_DEMANDTEC_COST ).
* Build and Fill Child node1 DT_WHSE for parent DT_DEMANDTEC
ivalue = wa_source-WHSE.
l_element_DT_WHSE = O_document->create_simple_element(
name = 'DT_WHSE'
VALUE = ivalue
parent = l_element_DT_DEMANDTEC ).
* Build and Fill Child node2 DT_WHSE for parent DT_DEMANDTEC
ivalue = wa_source-DC.
l_element_DT_DC = O_document->create_simple_element(
name = 'DT_DC'
VALUE = ivalue
parent = l_element_DT_DEMANDTEC ).
* Build and Fill Child node3 DT_WHSE for parent DT_DEMANDTEC
ivalue = wa_source-PLANT.
l_element_DT_PLANT = O_document->create_simple_element(
name = 'DT_PLANT'
VALUE = ivalue
parent = l_element_DT_DEMANDTEC ).
* Build and Fill Child node4 DT_QTY for parent DT_DEMANDTEC
ivalue = wa_source-QTY.
l_element_DT_QTY = O_document->create_simple_element(
name = 'DT_QTY'
VALUE = ivalue
parent = l_element_DT_DEMANDTEC ).
endloop.
* render document ======================================================
* create output stream
o_istream = l_streamfactory->create_ostream_xstring( result ).
* Connect internal XML table to stream factory
o_istream = l_streamfactory->create_ostream_itable( table =
l_xml_table ).
renderer = o_ixml->create_renderer( ostream = o_istream
document = o_document ).
irc = renderer->render( ).
* how do i catch the exception for type CX_SY_REF_IS_INITIAL ...?
endmethod.
full reward points for answers.
Thanks & Regards,
Uday Kumar.
Edited by: UDAY on May 6, 2008 9:32 PMHi Uday,
Its occurs because you're trying to access a objects with null reference. Or you forgot to create an instance or an error occurs during the instance creation. So You should put all your "Procedures and business logic" inside a Try/catch block. as follow.
" Define a class exception object to get error message......
DATA o_exception TYPE REF TO cx_sy_ref_is_initial.
"// Use the statment Try block to catch the error.
TRY.
* Creating the main iXML factory
l_ixml = cl_ixml=>create( ).
* Creating a stream factory
l_streamfactory = l_ixml->create_stream_factory( ).
* create input stream
l_istream = l_streamfactory->create_istream_xstring( source ).
* initialize input document
l_document = l_ixml->create_document( ).
* Create a Parser
l_parser = l_ixml->create_parser( stream_factory = l_streamfactory
istream = l_istream
document = l_document ).
* parse input document
l_parser->parse( ).
* Validate a document
l_parser->set_validating( mode = if_ixml_parser=>co_validate ).
* Parse the stream
IF l_parser->parse( ) NE 0.
IF l_parser->num_errors( ) NE 0.
DATA: parseerror TYPE REF TO if_ixml_parse_error,
str TYPE string,
i TYPE i,
count TYPE i,
index TYPE i.
count = l_parser->num_errors( ).
WRITE: count, ' parse errors have occured:'.
index = 0.
WHILE index < count.
parseerror = l_parser->get_error( index = index ).
i = parseerror->get_line( ).
WRITE: 'line: ', i.
i = parseerror->get_column( ).
WRITE: 'column: ', i.
str = parseerror->get_reason( ).
WRITE: str.
index = index + 1.
ENDWHILE.
ENDIF.
ENDIF.
* Process the document
IF l_parser->is_dom_generating( ) EQ 'X'.
refresh : it_source.
node ?= l_document.
CHECK NOT node IS INITIAL.
* create a node iterator
iterator = node->create_iterator( ).
* get current node
node = iterator->get_next( ).
* loop over all nodes
WHILE NOT node IS INITIAL.
CASE node->get_type( ).
WHEN if_ixml_node=>co_node_element.
* element node
name = node->get_name( ).
nodemap = node->get_attributes( ).
WHEN if_ixml_node=>co_node_text.
* text node
value = node->get_value( ).
if name eq 'DT_WHSE'.
wa_source-whse = value.
ELSEIF name eq 'DT_DC'.
wa_source-DC = value.
ELSEIF name eq 'DT_PLANT'.
wa_source-PLANT = value.
ELSEIF name eq 'DT_QTY'.
wa_source-QTY = value.
COLLECT wa_source INto it_source.
CLEAR wa_source.
ENDIF.
endcase.
node = iterator->get_next( ).
endwhile.
ENDIF.
loop at it_source into wa_source .
at first.
* Creating a ixml factory
o_ixml = cl_ixml=>create( ).
* Creating the dom object model
o_document = l_ixml->create_document( ).
endat.
* Build and Fill root node MT_DEMANDTEC_COST
AT FIRST.
l_element_MT_DEMANDTEC_COST =
O_document->create_simple_element(
name = 'MT_DEMANDTEC_COST'
parent = o_document ).
ENDAT.
* Build and Fill Child node DT_DEMANDTEC for parent
* MT_DEMANDTEC_COST
l_element_DT_DEMANDTEC = O_document->create_simple_element(
name = 'DT_DEMANDTEC'
parent = l_element_MT_DEMANDTEC_COST ).
* Build and Fill Child node1 DT_WHSE for parent DT_DEMANDTEC
ivalue = wa_source-WHSE.
l_element_DT_WHSE = O_document->create_simple_element(
name = 'DT_WHSE'
VALUE = ivalue
parent = l_element_DT_DEMANDTEC ).
* Build and Fill Child node2 DT_WHSE for parent DT_DEMANDTEC
ivalue = wa_source-DC.
l_element_DT_DC = O_document->create_simple_element(
name = 'DT_DC'
VALUE = ivalue
parent = l_element_DT_DEMANDTEC ).
* Build and Fill Child node3 DT_WHSE for parent DT_DEMANDTEC
ivalue = wa_source-PLANT.
l_element_DT_PLANT = O_document->create_simple_element(
name = 'DT_PLANT'
VALUE = ivalue
parent = l_element_DT_DEMANDTEC ).
* Build and Fill Child node4 DT_QTY for parent DT_DEMANDTEC
ivalue = wa_source-QTY.
l_element_DT_QTY = O_document->create_simple_element(
name = 'DT_QTY'
VALUE = ivalue
parent = l_element_DT_DEMANDTEC ).
endloop.
* render document ======================================================
* create output stream
o_istream = l_streamfactory->create_ostream_xstring( result ).
* Connect internal XML table to stream factory
o_istream = l_streamfactory->create_ostream_itable( table =
l_xml_table ).
renderer = o_ixml->create_renderer( ostream = o_istream
document = o_document ).
irc = renderer->render( ).
" The Statement CATCH define a block that catches the exceptions of the
" exception class cx_sy_ref_is_initial
CATCH cx_sy_ref_is_initial INTO o_exception.
" If you need to get the error message text do as follow
DATA errorMsg type string.
" Get the message text
errorMsg = o_exception->GET_TEXT( ).
" Display the error information
MESSAGE errorMsg TYPE 'I'.
ENDTRY.
The TRY block defines a guarded area whose class-based exceptions can be caught in the subsequent CATCH blocks. If no exception occurs in the TRY block and it reaches its end, the system continues the processing after ENDTRY. If a class-based exception occurs in the TRY block, the system searches for an exception handler in the same or an external TRY control structure.
Font: SAP Help
You can see a how to create and use an exception in this example [ ABAP Objects - Defining a Class-based exceptions|https://wiki.sdn.sap.com/wiki/x/19w] .
Best Regards.
Marcelo Ramos -
How to handle null values in RTF templates
Hi - I have two groups in a report for different SQL and two formulas for each group, CF_ELE_CNT and CF_ELE_CNT1. In the template I use the below code to print or not print a section.
<?if:number(CF_ELE_CNT +CF_ELE_CNT1) >0?>
The problem is when there is no data in the second group its not creating the XML tag for CF_ELE_CNT1, though CF_ELE_CNT has 13, it still does not print that partucular section. If I remove CF_ELE_CNT1 from the condition it works fine. I was wondering how to handle this.
Any help would be appreciated!!
Thanks,
RavHey Rav,
You can add a check to identify it the element/tag is present or not
<?if:(CF_ELE_CNT1)?> will give true, if the element is present otherwise falsesince you are adding the two elements, you have to add a or condition.
<?if:(CF_ELE_CNT and number(CF_ELE_CNT) >0 ) or ( CF_ELE_CNT1 and CF_ELE_CNT1 >0)?> -
How to handle file on application server without coading?
HI all,
can anybody tell me How to handle file on application server without coading? Is there any solution?
Thanks in advance.> can anybody tell me How to handle file on application server without coading? Is there any solution?
what is that you want to handle. what you do if you don't code ...
Maybe you are looking for
-
How can I edit a saved file in adobe reader?
I just want to delete a sentence and replace it with a new one.... Should I just start over in word? This is so confusing and frustrating!
-
ITunes window would not open after upgrade
Just upgraded to OS 10.4.7, and iTunes 6.0.5. All my software is fully up to date with all the latest. After the upgrade when launching iTunes I have two problems: 1. Intially the program launched. Now iTunes window does not open. Only the Equalizer
-
Calculated key figures are returning the word "ERROR"
Hi All, the calculated key figures which i used in one query are displaying the word "ERROR" at the end of the results as part of each cells formatting.But when i copied the same query to my system then its not showing the word error and even i crea
-
Problems Converting to Outlook And/Or Importing
HELP! My business future is in your hands. I have been a Palm user for many years and my entire contact, todo, etc... lists are on the 4.0.1 version of the desktop. I just got a new Windows 7 computer and you know the rest...the Palm desktop won't wo
-
Going from .java source files to a .jar
If my source files are .java, how can I make a .jar out of them from the command line? I have 4 main files, each a class with plenty of inner classes...how do I turn those files into something jar.exe wants? And if/when I get the .jar archive created