Drilling into XML with JS

1. I am using an xml file with the following basic structure:
<investor level="500">
<membership>6 month Café
Membership</membership>
<perks>
<perk>Free regular/decaf coffee, tea or café
Americano everyday for 6 months</perk>
<perk>One Free baked good every week</perk>
<perk>1 free drink of choice each month for 6
months</perk>
<perk>1 free pound of coffee during the 6
months</perk>
</perks>
</investor>
etc. (no problem with the xml, etc.)
2. Am setting the datasource with:
var dsInvests = new
Spry.Data.XMLDataSet("Investors/investorPerks.xml",
"investors/investor");
Am outputting the various levels and then when click on a
level, pass the RowNumber to a JS Function. Proper number is being
passed.
3. My JS script has 2 functions:
function handleInvestClick(id) {
var myData = dsInvests.getData()[id];
setInfo(myData);
then
function setInfo(info) {
var myInfo = "";
var infoArea = document.getElementById('investArea');
var hd = var hd = '($ ' + info['@level'] + ') ' +
info.membership;
myInfo += hd;
infoArea.innerHTML = myInfo;
The above works fine.
HOWEVER, I can't seem to find the syntax to go further into
the xml.
I want to get the number of perk nodes (children of the perks
node), loop through those, and get the perk data for each node.
But, if I do something like the followings, I just undefined:
info.perks
info.perks.length
info.perks.perk[0]
(The latter 2 must produced an error, because I get no
results).
Not sure if I'm trying to do something impossible, or just
not doing it right.
Since the "membership" node shows, I'd think I could get to
the others.
Sorry for so much code, hard to explain without it...hard to
explain with it, too!
Appreciate any help.
Keith

Thanks, Kin. Nice to know that it's a limitation of the
nested structure right now, not my thinking!
I had gotten something to work along the lines of what you
had. Although, with yours, I kept getting a failed to establish
context so didn't get any of the detail area.
I *like* being able to do a lot of the manipulation through
JS, especially so can not necessarily show the detail for first set
automatically and be able to change css and innerText.
However, here is what I got to do what I wanted (other than
it does show the first detail automatically.
my ds sets:
var dsInvests = new
Spry.Data.XMLDataSet("Investors/investorPerks.xml",
"investors/investor");
var dsInvestPerks = new
Spry.Data.XMLDataSet("Investors/investorPerks.xml",
"investors/investor[@level = '{dsInvests::@level}']/perks/perk")
// this is quite like yours, but I went further into the xml.
Also, used ' ' at the dsInvests==. Added that to yours, but it
didn't help.
Here are the two output areas:
<h2>Investment Levels</h2>
<div id="levelWrap" spry:region="dsInvests" align="center"
class="spryHiddenRegion">
<table id="interestLevel" cellspacing="0">
<tr class="spryHiddenRegion">
<td spry:repeat="dsInvests">
<span id="r_{ds_RowNumber}"
onclick="handleInvestClick('{ds_RowNumber}');" title="Click for
details">${@level}</span>
</td>
</tr>
</table>
<div id="levExp">Click other investment levels above
for details on that level</div>
</div>
<div id="investArea">
<div id="invHead" spry:detailRegion="dsInvests">
<div><strong><span id="detLevel">(
${@level} investment)</span>
{membership}</strong></div>
</div>
<div spry:region="dsInvestPerks"><ol><li
spry:repeat="dsInvestPerks">{perk}</li></ol></div>
</div>
finally, the extra JS for the click handler in level list:
function setCells() {
var currRow = dsInvests.getCurrentRow().ds_RowID;
var rows = dsInvests.getData().length;
for(var i = 0; i< rows; i++){
var myID = document.getElementById("r_" + i);
if(i != currRow){
myID.className = "liveLevel";
myID.title = "Click for details on this level";
} else {
myID.className = "deadLevel";
myID.title = "Level currently shown below";
Spry.Data.Region.addObserver("levelWrap", function(nType,
notifier, data) {
if (nType == "onPostUpdate")
setCells();
function handleInvestClick(id) {
//var myData = dsInvests.getData()[id];
//setInfo(myData, id);
dsInvests.setCurrentRow(id);
setCells();
This all works, although seems a bit convuluted. (Although
does show the first set's detail region at start.)
This Spry stuff is great! I'm enjoying working with it and
looking forward to further evolution. Nice alternative when
Flash/Flex seems overkill for what is needed.
I combined some Spry with ColdFusion to do a couple parts in
a site that I'm developing. It's on the Directions and Investors
pages in:
http://64.118.70.228/
In the directions page, I use CF to read my xml to get the
templates of various directions to CFInclude. Then the spry click
on the area handles setting the CSS display properties to show the
proper directions. (Would be nice if there was a way to include an
html page in a page like we include pictures. Then wouldn't need
the CF step!
Thanks for help!
Keith

Similar Messages

  • Problems embedding HTML into XML with CVIXMLSetElementValue - unwanted &lt and &gt

    I'm using the CVI XML functions. When I try to insert some pre-exsting HTML as the element value with CVIXMLSetElementValue, it dutifuly converts all the HTMLangle brackets into &lt and &gt, which is NOT what I want.
    (I can protect the XML integrity by wrapping it in [CDATA[ ....]] but that does not solve the conversion issue here.)
    Any suggestions?
    Thanks,
    Ian
    Solved!
    Go to Solution.

    To explain a bit further, below is a code snippet and the unwanted result that I see. Does this behavior - even with CDATA - make good design sense?
    From my perspective CVIXMLSetElementValue should respect CDATA elements. Am I right? Or just biased?
    stat = CVIXMLSetElementValue (test1_element, "Hello");
    stat = CVIXMLSetElementValue (test2_element, "<p>Hello</p>");
    stat = CVIXMLSetElementValue (test3_element, "<! [CDATA[<p>Hello</p>]] >");
    // Problematic Output:
    // <?xml version="1.0"?>
    // <root>
    // <test1>Hello</test1>
    // <test2>&lt;p&gt;Hello&lt;/p&gt;</test1>
    // <test3>&lt;! [CDATA[&lt;p&gt;Hello&lt;/p&gt;]] &gt;</test1>
    // </root>

  • Select XML with XMLFOREST into CLOB

    Hi,
    i am trying to select a XMLFOREST expression into a table with a clob column using oracle 10.2.0.4.0.
    The query "select xmlforest(e.last_name) from employees e where e.employee_id = 100" returns <LAST_NAME>King</LAST_NAME>. The result is returned as a clob, but i get an error (ora-06550 inconsistent datatypes) if i try to select the query result into a clob.
    So i wrote this code fragment to insert the result:
    DECLARE
      cl CLOB := NULL;
      chCTX DBMS_XMLGEN.CTXHANDLE;
    BEGIN
      chCTX :=  dbms_xmlgen.newContext ('SELECT XMLFOREST(e.last_name)  FROM employees e WHERE e.employee_id = 100');
      dbms_xmlgen.getxml(chCTX,cl );
      INSERT INTO TEMP_XML_CLOB(XML_CLOB)VALUES(cl);
      COMMIT;
    END;The plsql block is executed without an error but and inserts a row in the table, but the clob contains no data. So please give me advice how to store the result set in a clob in a proper way.
    Thanks in advance
    Matthias

    Do you really need to store it as a CLOB? Oracle provides an XMLTYPE for storing XML which is far better.
    Try using XMLTYPE and something like:
    DECLARE
      xml XMLTYPE;
    BEGIN
      SELECT XMLFOREST(e.last_name)
      INTO xml
      FROM employees e
      WHERE e.employee_id = 100;
       INSERT INTO TEMP_XML(XML) VALUES (xml);
      COMMIT;
    END;(untested)
    Obviously you'll want to expand on the SELECT statement to ensure you get all the tags you want and your table will need changing too to cater for XMLTYPE.
    I won't ask why you've got a table called "TEMP...", you must know that's just wrong in so many ways.

  • How to insert into table from a xml with XDE for java?

    want to insert into the oracle tables from the xml with XDE for java, some sample better. thank you.

    XML Document may be stored in a SQL database with XML SQL Utility.
    http://download-west.oracle.com/docs/cd/B13789_01/appdev.101/b10794/adx08xsu.htm#i1008168
    XML Document may be stored in a SQL database with Oracle XML DB.
    http://download-west.oracle.com/docs/cd/B13789_01/appdev.101/b10790/xdb03usg.htm#CEGFECFH

  • How to convert text file into xml file format with and check that with DTD

    I have an text file with | seperator . I have to convert this to an xml file and check with DTD present with me..
    plz help me out

    can i get some code that how to compare the xml with dtd or just give the DTD name with an XML

  • Using XML with Flex - Best Practice Question

    Hi
    I am using an XML file as a dataProvider for my Flex
    application.
    My application is quite large and is being fed a lot of data
    – therefore the XML file that I am using is also quite large.
    I have read some tutorials and looked thorough some online
    examples and am just after a little advice. My application is
    working, but I am not sure if I have gone about setting and using
    my data provider in the best possible (most efficient) way.
    I am basically after some advice as to weather I am going
    about using (accessing) my XML and populating my Flex application
    is the best / most efficient way???
    My application consists of the main application (MXML) file
    and also additional AS files / components.
    I am setting up my connection to my XML file within my main
    application file using HTTPService :
    <mx:HTTPService
    id="myResults"
    url="
    http://localhost/myFlexDataProvider.xml"
    resultFormat="e4x"
    result="myResultHandler(event)" />
    and handling my results with the following function:
    public function myResultHandler(event:ResultEvent):void
    myDataFeed = event.result as XML;
    within my application I am setting my variable values by
    firstly delacring them:
    public var fName:String;
    public var lName:String;
    public var postCode:string;
    public var telNum:int;
    And then, giving them a value by “drilling” into
    the XML, E;g:
    fName = myDataFeed.employeeDetails.contactDetails.firstName;
    lName = myDataFeed.employeeDetails.contactDetails.lastName;
    postCode =
    myDataFeed.employeeDetails.contactDetails.address.postcode;
    telNum = myDataFeed.employeeDetails.contactDetails.postcode;
    etc…
    Therefore, for any of my external (components in a different
    AS file) components, I am therefore referencing there values using
    Application:
    import mx.core.Application;
    And setting the values / variables within the AS components
    as follows:
    public var fName:String;
    public var lName:String;
    fName =
    Application.application.myDataFeed.employeeDetails.contactDetails.firstName;
    lName =
    Application.application.myDataFeed.employeeDetails.contactDetails.lastName;
    As mentioned this method seems to work, however, is it the
    best way to do it??? :
    - Connect to my XML file
    - Set up my application variables
    - Give my variables values from the XML file ……
    Bearing in mind that in this particular application there are
    many variable that need to be set and there for a lot of lines of
    code just setting up and assigning variables values from my XML
    file.
    Could someone Please advise me on this one????
    Thanks a lot,
    Jon.

    I don't see any problem with that.
    Your alternatives are to skip the instance variables and
    query the XML directly. If you use the values in a lot of places,
    then the Variables will be easier to use and maintain.
    Also, instead of instance variables, you colld put the values
    in an "associative array" (object/hashtable), or in a dictionary.
    Tracy

  • Drill into a Dataset from a url

    Hello,
    I have a page which makes use of the tabbed panel spry
    widget. Within that I have a tab that uses a spry master detail
    widget with its content generated using xmldata. The first
    recordset fills this page. Now I want to get to this page and this
    tab but to a record that I specify on a url which is on a different
    page - to drill into the xml data and return recordset 2.
    My pseudo code for the url would be as follows;
    <a
    href="pages/pro_students/stu1test.htm?panel=2#mytabs&dsprofessions.setCurrentRow=2'"
    class="pagecontentdarkblue">audiology</a>
    Is this a tall order that is not possible to achieve ?

    Hello Don,
    After much head scratching I have succeeded in drilling into
    the data contained on a page, from a tabbed panel and returning
    specific data from an xml datasource !! You can see it at work
    here.
    http://www.healthcare.leeds.ac.uk
    Click on a page link in paragraph 2 to cardiology for
    example, or alternatively click on the main navigation,
    'Prospective Students'. All of the tabbed content is one page
    (stu1.htm) and you can see in the undergraduate section how I
    needed that extra ability to navigate and drill into data.
    NOTE: It seemed important to ensure that the hash reference
    was stated at the end of the url string as in
    ....stu1.htm?row=4&product=midwifery&panel=2#mytabs
    Many thanks for your pointers :)
    Bruce.

  • Problem in creatinga sales order idoc into XML file in the same appl server

    Hai....friends....
    I am tring to send an  sales order as iDOC  to a xml port in the same application server....
    1. have created a xml port with path..\usr\sap\RRM\SYS\global\.
    2. assigned it to logical system.
    3.Have a RFC destination of TCP/ip(LOCAL_EXEC)
    but in bd64 after creating  model view when i am generating partner profiles  a tRFC PORT has been automatically created.
    then finally the IDOc has been created but its saying....IDOC CANNOT OR SHOULD NOT BE SENT...
    Pls help me regarding this...
    thx,
    ram

    Hi Thanks for your updates,
    But I got the same error, while pass the data from abap into XML.
    error message,what I am getting is
    The XML page cannot be displayed
    Cannot view XML input using style sheet. Please correct the error and then click the Refresh button, or try again later.
    Invalid at the top level of the document. Error processing resource 'file:///C:/tempcustomers.xml'. Line 1, Position 1
    #<?xml version="1.0" encoding="utf-16"?>
    Thanks
    Gowrishankar

  • Reading String (Name-Value) from text file into XML

    Hi,
    I have a requirement for reading a text file and converting each entry of that text file into XML format. I have not came across such thing yet so looking for some ideas. I am using SQL Server 2005 and here is a sample entry from my source text file,
    Jun 4 14:31:00 zzzz64x02 fff:
    INPUT(ty=XYZ,Prefix=15063,dn=78787878787878,sgk=100.139.201.48,xxn=87878,ani=656565656565,ogrp=F7ZX05,ogtxt=NNNNN,ogx=NNNNN,oci=0xe00ac,ogi={NOA=INT,BC=1,SIG-TYPE=ZIP});
    PROCESS(ty=0x100000,cu=32880,Name=XOXOXOX,pc=88017,pd=24,dd=880175,pk=880175,rd=115472,ca=BGD,reg=RW,cdp=1,ai=245359,grp=2648,sl=9);
    OUTPUT(ty=XXXX,ret=0,rl=
    {i=1,su=99999,rizID=61084,skid=06,truckgp=1084,dd=8801,dn=78787878787878}
    I will get multiple entries like this in my source text file which I have to convert into XML (using TSQL).
    Any help will be useful.
    Regards.
    'In Persuit of Happiness' and ..... learning SQL.

    And I'm telling you that this is a bad option. You would use the vaccum cleaner to wash the dishes, would you?
    If you for some reason would do this task in SQL Server, you would implement it as a CLR stored procedure, but from what you have said I don't understand why you would do this server-side at all.
    What's wrong with the current C# solution?
    Erland Sommarskog, SQL Server MVP, [email protected]
    Got it.  I was just looking for the available options, nothing wrong with my C# solution. And yes, I don't use vacuum cleaner to wash dishes.
    'In Persuit of Happiness' and ..... learning SQL.

  • Issue while saving the project plans into XML

    Hi,
    Could anyone of you please help me here.
    We are having one custom field(Type: Text) in the project level(Custom field name: ProjectComments) and end users are entering the data against this custom field more than 200 characters.
    The problem here is when we are saving the project plans into XML and opening the same file again thorugh MPP, the data for this custom field(ProjectComments)  is showing till 129 Characters only. Seems to be the data is truncating till 129 charachers.
    Could anyone suggest me how to resolve this issue without trucnating the characters in the custom fields.
    Thanks in advance!
    Regards,
    Venkat

    Hi,
    I cannot reproduce this issue with Project Pro 2010 SP2. Which SP do you have? How is configured your custom field?
    Hope this helps,
    Guillaume Rouyre, MBA, MVP, MCP |

  • Exception while drilling into data object values

    Hi everyone,
    I get the following exception : String was not recognized as a valid DateTime, when drilling into data values. This occurs specifically when drilling into reports that have datetime series or groups on the non-data axis. More specifically, the error doesnt occur when I drill into the report to show all values. It occurs when I drill into the report to show values for a particular time period (say, all sales in the month of Jan) instead of drilling to show details of all sales.
    The following is the relevant stack trace obtained from WebApps.txt.
    2007-08-08 16:43:56,272 [AsyncPageThreadPool (static 10)] DEBUG - ReportEngine WebPage.ReportException. oException.Message=String was not recognized as a valid DateTime., oException.StackTrace= at System.DateTimeParse.ParseISO8601(DateTimeRawInfo raw, __DTString str, DateTimeStyles styles)
    at System.DateTimeParse.Parse(String s, DateTimeFormatInfo dtfi, DateTimeStyles styles)
    at System.DateTime.Parse(String s, IFormatProvider provider, DateTimeStyles styles)
    at System.DateTime.Parse(String s, IFormatProvider provider)
    at System.Convert.ToDateTime(String value, IFormatProvider provider)
    at Oracle.BAM.Middleware.ActiveDataCache.ModifierFactory.ConvertValueFromTypeAndString(DataTypes eDataType, String strValue)
    at Oracle.BAM.Middleware.ActiveDataCache.ModifierFactory.BuildTwoEntryFilter(XmlNode xnExpression, ComparisonOperator eComparisonOperator, String strXmlSchema)
    at Oracle.BAM.Middleware.ActiveDataCache.ModifierFactory.GetFilterEntryComparisonExpression(XmlNode xnExpression, String strXmlSchema)
    at Oracle.BAM.Middleware.ActiveDataCache.ModifierFactory.GetFilterExpression(XmlNode xnExpression, String strXmlSchema)
    at Oracle.BAM.Middleware.ActiveDataCache.ModifierFactory.GetFilterExpression(XmlNode xnExpression, String strXmlSchema)
    at Oracle.BAM.Middleware.ActiveDataCache.ModifierFactory.GetFilterExpression(XmlNode xnExpression, String strXmlSchema)
    at Oracle.BAM.Middleware.ActiveDataCache.ModifierFactory.AddFilters(XmlDocument oXmlModifier, Modifier oAdcModifier, String strXmlSchema)
    at Oracle.BAM.Middleware.ActiveDataCache.ModifierFactory.GetAdcModifier(String strXmlModifier, String strXmlSchema, Boolean bIgnoreRecordFields, Boolean bGroupsInOneLevel, XmlDocument oXmlProperties)
    at Oracle.BAM.Middleware.ActiveDataCache.ModifierFactory.GetAdcModifier(String strXmlModifier, String strXmlSchema, Boolean bIgnoreRecordFields, Boolean bGroupsInOneLevel)
    at Oracle.BAM.ReportServer.Chart.GetChartAdcModifier(ViewSet oViewSet)
    at Oracle.BAM.ReportServer.Chart.RenderChart(String strXmlModifier, String strXmlProperties, String strActive, String strClientWidth, String strClientHeight, String strBrowserTimezoneOffset, Boolean bEMail, String strUserName)
    The following data might be useful for reproducing the exception by any BAM developer.
    The modifier xml is:
    <Modifier dataset="_ImportLCIssuanceDataObject" id="0" bAggregate="false"><FieldRefs></FieldRefs><Filter><Branch type="ALL"><Branch type="ALL"><Entry type="EQ"><Node type="COLUMN">ContractCurrency</Node><Node type="STRING">USD</Node></Entry></Branch><Branch type="ALL"><Entry type="GE"><Node type="COLUMN" bDrilling="true">IssueDate</Node><Node type="DATETIME">2000-07-01T00:00:00.0000000+05:30</Node></Entry><Entry type="LE"><Node type="COLUMN" bDrilling="true">IssueDate</Node><Node type="DATETIME">2000-07-31T23:59:59.0000000+05:30</Node></Entry></Branch></Branch></Filter><Groups><Group level="0"/><Group eTimeUnit="DAYOFMONTH" iQuantity="1" zeroFill="true" isTimeline="true" level="1" datasetField="IssueDate"><Aggregate operandDatasetField="_ContractAmount" operation="SUM"/></Group></Groups></Modifier>
    The relevant properties are:
    <Properties ContentType="ThreeDBarChart" datasetId="_ImportLCIssuanceDataObject"><Title display="true" color="#ffffff" font-family="Tahoma" font-weight="Bold" font-size="11" underline="false" overline="false" line-through="false" capitalize="false" uppercase="false" lowercase="false" background-color="#7B97C0" text-align="left"><Text bUseViewName="false">Total%20value%20of%20LCs%20issued</Text></Title><ChartTitle display="false" font-family="tahoma" font-weight="Bold" font-size="11" color="#000000" underline="false" overline="false" line-through="false" capitalize="false" uppercase="false" lowercase="false" bCheckField="true" ModifierID="0"></ChartTitle><DataAxis auto="true" min="" max="" major="" minor="" font-family="tahoma" font-size="11" color="#ffffff" underline="false" overline="false" line-through="false" capitalize="false" uppercase="false" lowercase="false" bShowGridlines="true"/><NonDataAxis font-family="tahoma" font-size="11" color="#ffffff" underline="false" overline="false" line-through="false" capitalize="false" uppercase="false" lowercase="false" bAllowDiagonal="true" bShowGroupLabels="true"/><Legend display="false" font-family="tahoma" font-size="11" color="#000000" underline="false" overline="false" line-through="false" capitalize="false" uppercase="false" lowercase="false" location="bottom"/><ColorPalette selected="101"/><ActiveData showColor="true" newColor="#FFE299" newTimeSeconds="1000"/><Groups bynumber="false"/><SeriesValues font-family="tahoma" font-size="11" color="#ffffff" underline="false" overline="false" line-through="false" capitalize="false" uppercase="false" lowercase="false"/><ErrorMessage font-family="tahoma" font-size="11" color="#ffffff" underline="false" overline="false" line-through="false" capitalize="false" uppercase="false" lowercase="false"/><HorizontalAxisLabel showlabel="false" labelpos="onside" font-family="tahoma" font-size="11" color="#ffffff" underline="false" overline="false" line-through="false" capitalize="false" uppercase="false" lowercase="false" bCheckField="true" ModifierID="0"></HorizontalAxisLabel><VerticalAxisLabel showlabel="false" labelpos="atend" font-family="tahoma" font-size="11" color="#ffffff" underline="false" overline="false" line-through="false" capitalize="false" uppercase="false" lowercase="false" bCheckField="true" ModifierID="0">LC%20Amount</VerticalAxisLabel><Target bUseTarget="false" fTargetValue="" bShowValue="true" strTargetLabel="" eDashStyle="solid" strTargetColor="" iDashThickness="1" font-family="tahoma" font-size="11" color="#000000" underline="false" overline="false" line-through="false" capitalize="false" uppercase="false" lowercase="false"/><Empty display="true" text="No%20Values"/><ThreeDOptions fBackDepth="25"/><Body background-color="transparent"><Border color="#000000" width="1px" style="solid"/><Margin><top width="0"/><left width="0"/><bottom width="0"/><right width="0"/></Margin></Body><Series datasetField="_ContractAmount" dataType="FLOAT" bShowValue="true" bShowPercent="false" bShowSeriesName="false" bShowAggFunction="true" ModifierID="0" aggregate="SUM" include="true" chartType="ThreeDBarChart" order="0" color="#E2CBFF" marker="none" borderColor=""><Format category="Number" decimals="2" color="red" use_thous_separator="true" negative_style="2" bRound="true" strRoundSeperator="," strRoundSuffix="K">#,0,.00K;[Red]#,0,.00K</Format></Series><Drilling ModifierID="0" bAllowDrillThrough="true" strDrillThroughViewType="UpdatingOrderedList"><DrillThroughField ID="_ContractReferenceNo"/><DrillThroughField ID="_ProductType"/><DrillThroughField ID="_Applicant"/><DrillThroughField ID="_Beneficiary"/><DrillThroughField ID="_ContractAmount"/><DrillThroughField ID="_ContractCurrency"/></Drilling><TopN active="false" quantity="1"/><SurfacePrompts><GoButton background-color="#E7E7E7" color="#000000" font-size="11px" font-family="Tahoma" display="DisplayInViewTitle" text="Refresh"><Border color="#4C4C4C" width="1px" style="solid"/></GoButton><ViewSurfacePrompt id="7" display="DisplayInViewTitle"><Input background-color="#FFFFFF" color="#000000" font-size="11px" font-family="Tahoma"><Border color="#000000" width="1px" style="solid"/></Input><DropDownSelectedLine background-color="#4A598C" color="#ffffff" font-size="11px" font-family="Tahoma"/><PromptTitle color="#ffffff" font-size="11px" font-family="Tahoma" font-weight="Bold"/></ViewSurfacePrompt><ViewSurfacePrompt id="8" display="DisplayInReportLevel"><Input background-color="#FFFFFF" color="#000000" font-size="11px" font-family="Tahoma"><Border color="#000000" width="1px" style="solid"/></Input><DropDownSelectedLine background-color="#4A598C" color="#ffffff" font-size="11px" font-family="Tahoma"/><PromptTitle color="#ffffff" font-size="11px" font-family="Tahoma" font-weight="Bold"/></ViewSurfacePrompt></SurfacePrompts><DrillPath><Hierarchy ModifierID="0" ID="320873a2918f48ddb2925519dfd8cfd0"><Field ID="_IssueDate" number="0" type="Year" name="Year"/><Field ID="_IssueDate" number="0" type="Quarter" name="Quarter"/><Field ID="_IssueDate" number="0" type="MonthNumber" name="Month"/><Field ID="_IssueDate" number="0" type="DayoftheMonth" name="Day of the Month"/><Field ID="_IssueDate" number="0" type="WeekdayNumber" name="Day of the Week"/></Hierarchy></DrillPath><GroupLevel datasetField="_IssueDate" dataType="DATETIME" eTimeUnit="DAYOFMONTH" iQuantity="1" isTimeline="true" zeroFill="true" fieldID="DAYOFMONTH__IssueDate"/></Properties>

    Fixed!! The timezone on the BAM server was changed to GMT, and that somehow solved the problem. Seems like the GMT offset should be zero while executing a drill down query.
    FYI, the modifier XML now sent is :
    <Modifier dataset="_ImportLCIssuanceDataObject" id="0" bAggregate="false"><FieldRefs></FieldRefs><Filter><Branch type="ALL"><Branch type="ALL"><Branch type="ALL"><Entry type="EQ"><Node type="COLUMN"><![CDATA[_ContractCurrency]]></Node><Node type="STRING">USD</Node></Entry></Branch><Branch type="ALL"/></Branch><Branch type="ALL"><Entry type="GE"><Node type="COLUMN" bDrilling="true"><![CDATA[_IssueDate]]></Node><Node type="DATETIME"><![CDATA[2000-07-01T00:00:00.0000000-00:00]]></Node></Entry><Entry type="LE"><Node type="COLUMN" bDrilling="true"><![CDATA[_IssueDate]]></Node><Node type="DATETIME"><![CDATA[2000-09-30T23:59:59.0000000-00:00]]></Node></Entry></Branch></Branch></Filter><Groups><Group level="0"/><Group eTimeUnit="MONTH" iQuantity="1" zeroFill="true" isTimeline="true" level="1" datasetField="_IssueDate"><Aggregate operandDatasetField="_ContractAmount" operation="SUM"/></Group></Groups></Modifier>

  • Error while downloading data from internal table into XML file

    hi all,
    i developed a program to download data from into internal table to xml file like this.
    tables: mara.
    parameters: p_matnr like mara-matnr.
    data: begin of itab_mara occurs 0,
                matnr like mara-matnr,
                ernam like mara-ernam,
                aenam like mara-aenam,
                vpsta like mara-vpsta,
          end of itab_mara.
    data: lv_field_seperator type c,     " value 'X',
          lv_xml_doc_name(30) type c,    " string value ‘my xml file’,
          lv_result type i.
          lv_field_seperator = 'x'.
          lv_xml_doc_name = 'my xml file'.
    types: begin of truxs_xml_line,
              data(256) type x,
          end of truxs_xml_line.
    types:truxs_xml_table type table of truxs_xml_line.
    data:lv_tab_converted_data type truxs_xml_line,
         lt_tab_converted_data type truxs_xml_table.
    data: lv_xml_file type rlgrap-filename value 'c:\simp.xml'.
    select matnr ernam aenam vpsta from mara into table itab_mara up to 5
           rows where matnr = p_matnr.
    CALL FUNCTION 'SAP_CONVERT_TO_XML_FORMAT'
    EXPORTING
       I_FIELD_SEPERATOR          = lv_field_seperator
      I_LINE_HEADER              =
      I_FILENAME                 =
      I_APPL_KEEP                = ' '
       I_XML_DOC_NAME             = lv_xml_doc_name
    IMPORTING
       PE_BIN_FILESIZE            = lv_result
      TABLES
        I_TAB_SAP_DATA             = itab_mara
    CHANGING
       I_TAB_CONVERTED_DATA       = lt_tab_converted_data
    EXCEPTIONS
      CONVERSION_FAILED          = 1
      OTHERS                     = 2
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    open dataset lv_xml_file for output in binary mode.
    loop at lt_tab_converted_data into lv_tab_converted_data.
    transfer lv_tab_converted_data to lv_xml_file.
    endloop.
    close dataset lv_xml_file.
    this program is syntactically correct and getting executed, but when i open the target xml file it is showing the following error.
    The XML page cannot be displayed
    Cannot view XML input using style sheet. Please correct the error and then click the Refresh button, or try again later.
    XML document must have a top level element. Error processing resource 'file:///C:/simp.xml'.
    will anyone show me the possible solution to rectify this error
    thanks and regards,
    anil.

    Hi,
    Here is a small sample program to convert data in an internal table into XML format and display it.
    DATA: itab  TYPE TABLE OF spfli,
          l_xml TYPE REF TO cl_xml_document.
    * Read data into a ITAB
    SELECT * FROM spfli INTO TABLE itab.
    * Create the XML Object
    CREATE OBJECT l_xml.
    * Convert data in ITAB to XML
    CALL METHOD l_xml->create_with_data( name = 'Test1'
                                         dataobject = t_goal[] ).
    * Display XML Document
    CALL METHOD l_xml->display.
    Here are some other sample SAP programs to handle XML in ABAP:
    BCCIIXMLT1, BCCIIXMLT2, and BCCIIXMLT3.
    Hope this helps,
    Sumant.

  • Why we need to conver Context  Node data into XML file----Export to Excel

    Hi All,
    Let me clarify my dought........today i have gone through the concept of  "Exporting Context Data Using the Webdynpro Binary cache" in SAP Online Help.
    From the SAP Online Help pdf document, i have found that, the context node data has been converted first in to XML file,after that file had been stored in the web dynpor binary cache...bla....bla.........
    Here my qtn is why they had converted context node data into XML file. With out doing that can not we export context node data to excel file..?
    Regards
    Seshu
    Edited by: Sesshanna D on Dec 19, 2007 7:25 AM

    Hi Sesshanna,
    it is not neccessary to do that but xml has the advantage, that it can be easily transformed into every output format that might occur in later project stages.
    If it's simply about blowing out some Excel, I suggest using an OSS library such as jexcelAPI or Jakarta POI and building the Excel how you need it.
    regards,
    Christian

  • Data transfer using ALE/IDOC into XML.

    Dear All,
    I have to transfer FI document data (FB01) from the sap system ,convert it into XML and dump it in 1 of the file servers.I want to do this using ALE/IDOC.Is it possible to do the same and how.Similarly i want to do the same for Vendor and Customer master i.e sending the data in XML format.
    Kindly Suggest how do i go about doin the same..Its very urgent.Please help.
    Thanks & Regards,
    Lailu Philip.

    In continuation:
    Example Purchasing & Selling scenario
    We will develop a custom IDoc to carry the billing number from the Service Receiver’s system to the Service Provider’s system. We will populate the IDoc in a user exit on the sending side and we will process the transaction on the receiving side using a custom function module and a BDC transaction call.
    No rule conversion, segment filtering or version conversion will be implemented in the model as described in Figure 1.
    Requirements
    • Working ALE environment - See ALE Basis Configuration Guide;
    • ALE scenario design together with the business requirement;
    • Development access; and
    • ALE configuration access.
    NOTES:
    1. All IMG references to transactions are located in the transaction SALE which is the ALE portion of the IMG
    2. This is one way of developing a scenario where no message control exists. If message control exist (EG. On purchase orders) then NAST can be used to call an outbound function module that would create the required IDocs.
    3. Extensive knowledge of IDocs and ALE basis configuration is required in order to understand this guide.
    2. OUTBOUND PROCESSING
    2.1. Create IDoc type (WE30) Client independent
    The IDoc type refers to the IDoc structure that you will require for your development. In our case the IDoc type is called ZINVRV01. This IDoc type will have 1 segment called Z1INVRV with 2 fields, LIFNR & XBLNR, in this segment. If you require many segments or nested segments then they are also created using the same procedure.
    We will create the IDoc of the following structure:
    ZINVRV01
    Purchasing and Selling - Invoice receipt reversal
    Z1INVRV P&S - Segment 1
    Segment fields
    LIFNR Vendor account number
    XBLNR Reference document number
    Figure 3: IDoc type ZINVRV01
    To create the IDoc type, follow these next few steps:
    • Enter transaction WE30 (ALE -> Extensions -> IDoc types -> Maintain IDoc type)
    • Type in ZINVRV01 and click on Basic IDoc type, click the Create icon
    • Click on Create new (we are creating an IDoc from scratch but you may want to copy another IDoc if it is similar to your requirements) and enter a description, and press enter
    • Click on ZINVRV01 and then on the Create icon
    • Enter Z1INVRV as the segment type (must start with Z1), check mandatory if the segment must exist (in this case check it), enter 1 in minimum number and 1 as maximum number. (Make the maximum number 9999999999 if there are going to be many of these segments in each IDoc. IE. When line items are passed via IDocs), click on Segment editor
    • Enter a description for your segment type and create
    • Enter a description for your segment, enter each field required in your IDoc, in our case type LIFNR across for Field name, DE structure and DE documentation, repeat for XBLNR and press enter to validate.
    • Save and generate, press back
    • To release the segment choose Goto, Release from the menu
    • Check the box on the line of your new segment
    • Save, back and enter
    • Your IDoc type structure should be displayed with your new segment
    • Save and back
    • To release the IDoc type choose Extras, Release type from the menu and Yes
    Your IDoc is now ready for use. If you need to add fields or segments to your IDoc type, you will need to cancel the release of the IDoc type as well as the segment release using a similar procedure followed above (except now you uncheck the release box for the segment and you choose cancel release for the IDoc type).
    2.2. Create message type (WE81) Client independent
    To create a new message type, follow these next few steps:
    • Enter transaction WE81 (ALE -> Extensions -> IDoc types -> Maintain message type for intermed. Structure -> Create logical message type)
    • Choose Create logical message type by double clicking on it
    • Click on change icon to enter change mode
    • Click on New entries to add a new type
    • Enter the required message type, in our case it is ZINVRV and an appropriate description
    • Save and exit.
    Your message type has now been created. The next step will be to link it to the IDoc.
    2.2.1. Link message to IDoc type (WE82 & BD69) Client independent
    To link the message type to the IDoc type follow these next few steps:
    • Enter transaction WE82 (ALE -> Extensions -> IDoc types -> Maintain message type for intermed. Structure -> EDI: Message Types and Assignment to IDoc Types)
    • Click on change icon to enter change mode
    • Click on New entries to create the link
    • Enter the message type ZINVRV and the BasicIDoc type as ZINVRV01
    • Save and exit
    • Enter transaction BD69 (ALE -> Extensions -> IDoc types -> Maintain message type for intermed. Structure -> Assign message type to IDoc for ALE)
    • Click on change icon to enter change mode
    • Click on New entries to create the link
    • Enter the message type ZINVRV and the BasicIDoc type as ZINVRV01
    • Save and exit
    Your IDoc is now linked to your message type. We still need to link object types and add the message to the model before we can use the message.
    2.2.2. Maintain object type for message type (BD59) Client independent
    The ALE objects are used to create links between IDocs and applications objects, to control the serialisation, to filter messages in the customer model and to use listings.
    For our own message type and IDoc you must maintain object types for the links.
    If you want to check the serialisation for the message type, then you must maintain object types for the serialisation. If no serialisation object has been maintained for a given message type, then the serialisation will not be checked for this message type.
    To add an object type to our message type, follow these next few steps:
    • Enter transaction BD59 (ALE -> Extensions -> ALE object maintenance -> Maintain object types)
    • Type in your message type ZINVRV and press enter
    • Click on New entries
    • Enter your object type, LIFNR (We need to use the vendor as a filter object), the segment name where LIFNR resides, Z1INVRV, a number 1 for the sequence followed by the actual field name LIFNR
    • Save and exit.
    You have now created an object that we’ll use as a filter object in the customer model to direct the flow of messages to the various logical systems based on the vendors in the filter of the message type ZINVRV.
    We now need to add our new message type to the distribution model.
    2.3. Configuring the Distribution Model
    This task is performed on your ALE reference client.
    2.3.1. Manual Configuration (BD64) Client dependent
    To manually configure the customer distribution model, read the ALE configuration procedure, and follow these steps:
    • Perform the Maintain customer distribution model directly function. (ALE -> Distribution customer model -> Maintain customer distribution model directly)
    • Specify the customer model you want to maintain and the logical system that is to be the sender of the messages OR create a new model. (Create model ALE with logical system ALELS1C400)
    • Choose the receiving systems to which the sending system must forward message type ZINVRV to.
    • For each receiving logical system allocate the message type necessary for communication to the receiving systems as per ALE configuration procedure.
    • Create filter objects (in our case LIFNR as the object type with the associated vendor number, 0000018001 with leading zeros, in the object area) for the message types.
    • Save the entries.
    NOTES:
    You cannot maintain a message type between the same sender and receiver in more than one customer distribution model.
    Only the owner is authorised to modify the model.
    To change the owner of a model, choose the 'Maintain ownership of customer distribution model' function. Make sure that all changes will be distributed to all systems that know the corresponding model. To do so, you can use the correction and transport system.
    To transport the customer distribution model you should use the Distribute customer model function of the IMG as described below.
    2.3.2. Distribute customer model (BD71) Client dependent
    After the customer model has been created centrally, it must be distributed to the other remote systems. This entails first of all setting up the communication for the distributed systems and then sending the model.
    2.3.2.1. Distribute Model (BD71) Client dependent
    This task is performed on your ALE reference client. To distribute the customer distribution model, read the ALE configuration procedure and follow these steps:
    • Make the settings for the communication with the other decentral systems, you have not set them yet.
    • Define the RFC destination for R/3 connections whose names correspond to the name of the corresponding logical system.
    • Create the output partner profile.
    • Distribute the customer model
    • Specify the name of the customer model.
    • You must specify the target system to which you want to distribute the customer model.
    • You must repeat this function for every distributed logical system.
    2.3.2.2. Maintain sending system partner profile (WE20) Client dependent
    With this function, you define the partner profiles for all outbound and inbound messages on the basis of the customer distribution model.
    After you have defined and distributed the customer model, you will have to maintain the partner profiles locally. To do this read the ALE configuration procedure.
    • Enter the output mode (background, immediately) and the package size for outbound processing.
    Requirements
    • The customer model must be maintained.
    • RFC destinations must be maintained.
    • The customer model must be distributed.
    • To ensure that the appropriate persons in charge are informed if a processing error occurs, you must make settings in: Error processing Maintain organisational units.
    2.4. Populate & distribute IDoc using ABAP
    An IDoc consists of a control record with structure edidc and one or more data records with structure edidd. The control record contains the sender and recipient of the IDoc, as well as information on the type of message.
    To be able to pass an IDoc to the ALE layer, you must set up a field string with structure edidc and an internal table with structure edidd. They are used to call function module master_idoc_distribute, which performs the save to the database and triggers the dispatch if necessary.
    2.4.1. Example code
    The code displayed below does the following:
    • populates our IDoc segment Z1INVR with the 2 fields XBLNR and LIFNR, populates the segment name and appends this to an internal table used to store the IDoc data;
    • populates the control record info with the message type and IDoc type; and
    • calls the MASTER_IDOC_DISTRIBUTE function module which distributes the IDoc as configured in the customer distribution model.
    Data declaration statements
    DATA: C_INVREV_SEGNAME(7) TYPE C VALUE 'Z1INVRV',
    C_INVREV_MESTYPE(6) TYPE C VALUE 'ZINVRV',
    C_INVREV_IDOC_TYPE(8) TYPE C VALUE 'ZINVRV01',
    Z1INVRV LIKE Z1INVRV,
    C_INVREV_DOCTYPE LIKE BKPF-BLART VALUE 'YY',
    IDOC_CONTROL LIKE EDIDC,
    T_COMM_CONTROL LIKE EDIDC OCCURS 0 WITH HEADER LINE,
    IDOC_DATA LIKE EDIDD OCCURS 0 WITH HEADER LINE.
    Move the document header into a structure
    LOOP AT DOC_HEAD_TAB INTO DOC_HEAD.
    ENDLOOP.
    Move the document item data into a structure
    LOOP AT DOC_ITEM_TAB INTO DOC_ITEM WHERE NOT ( LIFNR IS INITIAL ).
    ENDLOOP.
    Populate the IDoc segment’s field with the required data
    CLEAR Z1INVRV.
    Z1INVRV-LIFNR = DOC_ITEM-LIFNR. “Store vendor number for filter
    Z1INVRV-XBLNR = DOC_HEAD-XBLNR. “Billing number
    IDOC_DATA-SEGNAM = C_INVREV_SEGNAME. “Segment name
    IDOC_DATA-SDATA = Z1INVRV. “Segment data
    APPEND IDOC_DATA. “Populate IDoc internal table
    Move the control data info required for the distribution
    IDOC_CONTROL-MESTYP = C_INVREV_MESTYPE.
    IDOC_CONTROL-DOCTYP = C_INVREV_IDOC_TYPE.
    Call the distribute function with the required parameters
    CALL FUNCTION 'MASTER_IDOC_DISTRIBUTE' IN UPDATE TASK
    EXPORTING
    MASTER_IDOC_CONTROL = IDOC_CONTROL
    TABLES
    COMMUNICATION_IDOC_CONTROL = T_COMM_CONTROL
    MASTER_IDOC_DATA = IDOC_DATA
    EXCEPTIONS
    ERROR_IN_IDOC_CONTROL = 1
    ERROR_WRITING_IDOC_STATUS = 2
    ERROR_IN_IDOC_DATA = 3
    SENDING_LOGICAL_SYSTEM_UNKNOWN = 4
    OTHERS = 5.
    Figure 4: Outbound processing example code
    NOTE:
    For debugging purposes, use transaction WE05 (IDoc overview) to see check your IDoc status, or to see whether an IDoc was created/
    3. INBOUND PROCESSING
    3.1. Create Function Module
    This function module is called when a message type, of type ZINVRV, comes into the receiving system. This needs to be configured and is dealt with later in this section. The function module is passed the IDoc as a parameter.
    Example parameters
    Import parameters Reference field Opt Y/N
    INPUT_METHOD BDWFAP_PAR-INPUTMETHD N
    MASS_PROCESSING BDWFAP_PAR-MASS_PROC N
    Export Parameters Reference field Opt Y/N
    WORKFLOW_RESULT BDWFAP_PAR-RESULT N
    APPLICATION_VARIABLE BDWFAP_PAR-APPL_VAR N
    IN_UPDATE_TASK BDWFAP_PAR-UPDATETASK N
    CALL_TRANSACTION_DONE BDWFAP_PAR-CALLTRANS N
    Table Parameters Reference field Optional Y/N
    IDOC_CONTRL EDIDC
    IDOC_DATA EDIDD
    IDOC_STATUS BDIDOCSTAT
    RETURN_VARIABLES BDWFRETVAR
    SERIALIZATION_INFO BDI_SER
    Exceptions
    WRONG_FUNCTION_CALLED
    Example code
    The code displayed below does the following:
    • populates a BDC table with the IDoc info;
    • calls the transaction via a BDC call; and
    • updates the IDoc status according to the BDC error status.
    EXTRACT FROM: Z_IDOC_INPUT_ZINVRV
    Declaration of local variables
    DATA: C_SEGNAM(10) TYPE C VALUE 'Z1INVRV'.
    *-Loop through the IDOCs
    LOOP AT IDOC_CONTRL.
    *---Loop through the data for the IDOC
    LOOP AT IDOC_DATA WHERE DOCNUM = IDOC_CONTRL-DOCNUM.
    CASE IDOC_DATA-SEGNAM.
    WHEN C_SEGNAM.
    Here we get the info from the idoc table
    IT_Z1INVRV = IDOC_DATA-SDATA.
    ENDCASE.
    PERFORM REV_INV.
    ENDLOOP.
    PERFORM UPDATE_IDOC_STATUS.
    ENDLOOP.
    FORM REV_INV "Reverse invoice form
    Local variables & constants
    DATA: C_TCODE LIKE BKPF-TCODE VALUE 'VF11'. "BDC transaction code
    Now we can build the bdc table to call the reversal transaction start of screen 109
    CLEAR BDC_TAB.
    BDC_TAB-PROGRAM = 'SAPMV60A'.
    BDC_TAB-DYNPRO = '109'.
    BDC_TAB-DYNBEGIN = 'X'.
    APPEND BDC_TAB.
    Document number
    CLEAR BDC_TAB.
    BDC_TAB-FNAM = 'KOMFK-VBELN(01)'.
    BDC_TAB-FVAL = IT_Z1INVRV-XBLNR. "Billing document number
    APPEND BDC_TAB.
    OK Code for screen 109
    CLEAR BDC_TAB.
    BDC_TAB-FNAM = 'BDC_OKCODE'.
    BDC_TAB-FVAL = 'SICH'.
    APPEND BDC_TAB.
    Now we can call transaction 'VF11' with the populated bdc table. The transaction is called inside the idoc-contrl loop, so a transaction will be called for every idoc (journal). the transaction is called in no-display mode ('N') because this code runs in background as it is called by ale. The update is specified to be synchronous ('S') because we have to wait for the result to update the idoc status correctly.
    CALL TRANSACTION C_TCODE USING BDC_TAB MODE 'N' UPDATE 'S'.
    Store the return code for use in another form (status update)
    RETURN_CODE = SY-SUBRC.
    Here we check the return code, if there was an error, we put the transaction in a bdc session for the user to review and correct.
    IF SY-SUBRC NE 0.
    CALL FUNCTION 'BDC_OPEN_GROUP'
    EXPORTING
    CLIENT = SY-MANDT
    GROUP = 'ZINVRV'
    USER = C_ALE_USER
    KEEP = 'X'.
    CALL FUNCTION 'BDC_INSERT'
    EXPORTING
    TCODE = C_TCODE
    TABLES
    DYNPROTAB = BDC_TAB.
    CALL FUNCTION 'BDC_CLOSE_GROUP'
    EXCEPTIONS
    NOT_OPEN = 1
    QUEUE_ERROR = 2
    OTHERS = 3.
    ELSE. "No problems
    C_EXISTS = 'N'.
    Select from the billing document table to get sales doc number
    SELECT * FROM VBRP WHERE VBELN = IT_Z1INVRV-XBLNR.
    Select from the sales document table to get user status number
    SELECT SINGLE * FROM VBAP WHERE VBELN = VBRP-AUBEL AND
    POSNR = VBRP-AUPOS.
    Select from the status table to change the user status to pending
    SELECT * FROM JEST WHERE OBJNR = VBAP-OBJNR AND
    STAT LIKE C_USER_STATUS.
    IF JEST-STAT = C_US_PENDING. "User status is pending
    JEST-INACT = C_UNCHECKED. "Make pending the active status
    UPDATE JEST.
    C_EXISTS = 'Y'. "I.E. An entry is already in table
    ELSEIF JEST-INACT = C_UNCHECKED AND JEST-STAT NE C_US_PENDING.
    JEST-INACT = C_CHECKED. "Make everything else inactive
    UPDATE JEST.
    ENDIF.
    ENDSELECT.
    IF C_EXISTS = 'N'. "I.E. Pending has never been a status before
    JEST-OBJNR = VBAP-OBJNR.
    JEST-STAT = C_US_PENDING.
    JEST-INACT = C_UNCHECKED. "Make pending the active status
    INSERT JEST.
    ENDIF.
    ENDSELECT. "Select from VBRP (Billing document table)
    ENDIF.
    ENDFORM. " REV_INV
    FORM UPDATE_IDOC_STATUS.
    Now we check the CALL TRANSACTION return code and set IDOC status
    CLEAR IDOC_STATUS.
    IF RETURN_CODE = 0.
    WORKFLOW_RESULT = '0'.
    IDOC_STATUS-DOCNUM = IDOC_CONTRL-DOCNUM.
    IDOC_STATUS-STATUS = '53'.
    IDOC_STATUS-UNAME = SY-UNAME.
    IDOC_STATUS-REPID = SY-REPID.
    IDOC_STATUS-MSGTY = SY-MSGTY.
    IDOC_STATUS-MSGID = SY-MSGID.
    IDOC_STATUS-MSGNO = SY-MSGNO.
    IDOC_STATUS-MSGV1 = SY-MSGV1.
    IDOC_STATUS-MSGV2 = SY-MSGV2.
    IDOC_STATUS-MSGV3 = SY-MSGV3.
    IDOC_STATUS-MSGV4 = SY-MSGV4.
    RETURN_VARIABLES-WF_PARAM = 'Processed_IDOCs'.
    RETURN_VARIABLES-DOC_NUMBER = IDOC_CONTRL-DOCNUM.
    APPEND RETURN_VARIABLES.
    ELSE.
    WORKFLOW_RESULT = '99999'.
    IDOC_STATUS-DOCNUM = IDOC_CONTRL-DOCNUM.
    IDOC_STATUS-STATUS = '51'.
    IDOC_STATUS-UNAME = SY-UNAME.
    IDOC_STATUS-REPID = SY-REPID.
    IDOC_STATUS-MSGTY = SY-MSGTY.
    IDOC_STATUS-MSGID = SY-MSGID.
    IDOC_STATUS-MSGNO = SY-MSGNO.
    IDOC_STATUS-MSGV1 = SY-MSGV1.
    IDOC_STATUS-MSGV2 = SY-MSGV2.
    IDOC_STATUS-MSGV3 = SY-MSGV3.
    IDOC_STATUS-MSGV4 = SY-MSGV4.
    RETURN_VARIABLES-WF_PARAM = 'ERROR_IDOCS'.
    RETURN_VARIABLES-DOC_NUMBER = IDOC_CONTRL-DOCNUM.
    APPEND RETURN_VARIABLES.
    ENDIF.
    APPEND IDOC_STATUS.
    ENDFORM. " UPDATE_IDOC_STATUS
    Figure 5: Inbound processing example code
    3.1.1. Debugging inbound FM
    Use transaction WE19 to test inbound function module in debugging mode. Also use WE05 to view the IDocs and their statuses.
    3.2. Maintain ALE attributes
    The inbound function module needs to be linked to the message type and the message type needs to be linked to the appropriate inbound process code at the partner profile level before the scenario is enabled. These steps are described below in detail.
    3.2.1. Link Message Type to Function Module (WE57) Client independent
    To link a message (ZINVRV) type to a function module (Z_IDOC_INPUT_ZINVRV) follow these steps:
    • Enter transaction WE57 (ALE -> Extensions -> Inbound -> Allocate function module to logical message)
    • Select an entry (EG. IDOC_INPUT_ORDERS) and copy
    • Type in module name Z_IDOC_INPUT_ZINVRV
    • Type in basic IDoc type as ZINVRV01
    • Type in message type as ZINVRV
    • Type object type as IDOCINVOIC (Invoice document) - Used for workflow
    • Direction should be set to 2 for inbound
    • Enter and save
    3.2.2. Define FM settings (BD51) Client independent
    • Enter transaction BD51 (ALE -> Extensions -> Inbound -> Define settings for input modules)
    • Click on New entries
    • Type in the name of the new function module Z_IDOC_INPUT_ZINVRV
    • Enter 0 for mass processing in the output column
    • Save and Exit
    3.2.3. Maintain process codes (WE42) Client dependent
    A process code needs to be maintained on each client. It then needs to be linked to the message via the partner profiles on each client. This allows the various clients to use a unique function module for the same message type.
    To maintain the process code follow these steps:
    • Log on to the appropriate receiving system client
    • Execute WE42 (ALE -> Extensions -> Inbound -> Maintaining process codes inbound)
    • Choose Inbound with ALE service
    • Choose Processing with function module
    • Click on Processing with function module and choose create icon
    • Click on New Entries
    • Type in process code ZINR and give it a description and save
    • Now you are asked to Please maintain codes added in ALE entry methods, enter and choose Z_IDOC_INPUT_FIRVSL and copy it. You should choose a FM similar to your one.
    • Enter your process code ZINR
    • Enter your function module Z_IDOC_INPUT_ZINVRV
    NOTE: The next 6 steps are used in workflow error handling.
    • Enter IDPKFIDCMT in object type
    • Enter MASSINPUTFINISHED in End event
    • Enter IDOCINVOIC in IDoc object type
    • Enter INPUTERROROCCURREDFI in IDoc start event
    • Enter INPUTFINISHEDFI in IDoc End event
    • Enter IDOCINVOIC in Application object type
    You will need to determine the task associated with object IDOCINVOIC, and then assign the appropriate position to it. This position will then receive the application error messages via workflow.
    To set up the workflow area please consult the Workflow config guide.
    3.3. Create inbound partner profile
    For each message type you need to maintain the inbound partner profiles.
    3.3.1. Maintain receiving system partner profile (WE20) Client dependent
    To maintain inbound partner profiles read the document ALE configuration procedure:
    • Add the message type ZINVRV with process code ZINR.
    • Enter the output mode (background, immediately) for inbound processing and NO message code.
    • Enter the position S and choose the ALE administrator 50000085. This position will then receive all the technical ALE errors via workflow.
    3.4. Test
    Once the inbound function module has been debugged the scenario should be ready to test in its entirety. If problems occur, read through the relevant areas of this document to check your configuration or code.
    Hope this will help you,
    If you  want me to explain more, you can give me your email id.
    Reward with points incase you are satisfied.
    Regards,
    Sushama

  • XSLT Mapping to convert u201C.CSVu201D file into XML Structure.

    Hi All,
    I wanted to know can we use XSLT Mapping to convert u201C.CSVu201D file into XML Structure.
    I am communicating between two XI Systems. First XI system is going to give u201C.CSVu201D file as main document. I need to post IDOC Corresponding to this. So what I want to do is read this u201C.CSVu201D file (Main document in payload) and first convet it into XML and then use second mapping which will convert XML to IDOC.
    I know this is possible with JAVA Mapping but just wanted to confirm can we do this with XSLT mapping as well?
    Regards,
    Gouri

    Hi Amit,
    I know this way it shd work as i am able see other XSLT files. But this particular file is not visible.
    I am copying following code only in sample.xslt file.
    <xsl:stylesheet
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      xmlns:fn="fn"
      xmlns:xs="http://www.w3.org/2001/XMLSchema"
      version="2.0" exclude-result-prefixes="xs fn">
    <xsl:output indent="yes" encoding="US-ASCII" />
    <xsl:param name="pathToCSV" select="'file:///c:/csv.csv'" />
    <xsl:function name="fn:getTokens" as="xs:string+">
        <xsl:param name="str" as="xs:string" />
        <xsl:analyze-string select="concat($str, ',')" regex='(("["]*")+|[,]*),'>
            <xsl:matching-substring>
            <xsl:sequence select='replace(regex-group(1), "^""|""$|("")""", "$1")' />
            </xsl:matching-substring>
        </xsl:analyze-string>
    </xsl:function>
    <xsl:template match="/" name="main">
        <xsl:choose>
        <xsl:when test="unparsed-text-available($pathToCSV)">
            <xsl:variable name="csv" select="unparsed-text($pathToCSV)" />
            <xsl:variable name="lines" select="tokenize($csv, ' ')" as="xs:string+" />
            <xsl:variable name="elemNames" select="fn:getTokens($lines[1])" as="xs:string+" />
            <root>
            <xsl:for-each select="$lines[position() &gt; 1]">
                <row>
                <xsl:variable name="lineItems" select="fn:getTokens(.)" as="xs:string+" />
                <xsl:for-each select="$elemNames">
                    <xsl:variable name="pos" select="position()" />
                    <elem name="{.}">
                    <xsl:value-of select="$lineItems[$pos]" />
                    </elem>
                </xsl:for-each>
                </row>
            </xsl:for-each>
            </root>
        </xsl:when>
        <xsl:otherwise>
            <xsl:text>Cannot locate : </xsl:text><xsl:value-of select="$pathToCSV" />
        </xsl:otherwise>
        </xsl:choose>
    </xsl:template>
    </xsl:stylesheet>
    Is this correct?
    -Gouri

Maybe you are looking for