Need help in Bpel transformation
Hi
I am reading the xml data file through partnerlink , the receive activity is dispalying the xml record.
I want to transform that data into target xsd.The transform activity is not getting assigned.
Regards
mki
Hmmm.... That seems odd...
You should drop a transform activity after your receive, double click and open, the drop down on the left you should choose the output variable from the receive activity, and the right side you should select the target xsd schema.
Then on the bottom either select automapper or create mapping manually, both will open the xslt UI.
Similar Messages
-
Need help in message transformation.
I need help to resolve following error during message transformation.
........ BaseRuntimeException: RuntimeException in Message-Mapping transformation: Cannot produce target element /ns0:BankCheckRecon_Request_MT/Header. Check xml instance is valid for source xsd and target-field mapping fulfills requirements of target xsd at com.sap.aii.mappingtool.tf3.AMappingProgram.start.............
<b>Note </b> Message Map and Interface map are working correctly when tested separately in the Repository.
<b>Mapping Rules:</b>
/ns0:BankCheckRecon_Request_MT=/ns0:ComericaCheckRecon_Request_MT=
/ns0:BankCheckRecon_Request_MT/Header=/ns0:ComericaCheckRecon_Request_MT/Header=
/ns0:BankCheckRecon_Request_MT/Header/RecordID=const()
/ns0:BankCheckRecon_Request_MT/Header/HdrNumber=const()
/ns0:BankCheckRecon_Request_MT/Header/SenderBank=const()
/ns0:BankCheckRecon_Request_MT/Header/ReceiverBank=const()
/ns0:BankCheckRecon_Request_MT/Header/AcctNumber=/ns0:ComericaCheckRecon_Request_MT/Header/AcctNumber=
/ns0:BankCheckRecon_Request_MT/Header/PymtType=const()
/ns0:BankCheckRecon_Request_MT/Header/TapeDate=const()
/ns0:BankCheckRecon_Request_MT/Header/ISOCurr=const()
/ns0:BankCheckRecon_Request_MT/Item=ifWithoutElse(stringEquals(/ns0:ComericaCheckRecon_Request_MT/Detail/RecordID=, const()), /ns0:ComericaCheckRecon_Request_MT/Detail=)
/ns0:BankCheckRecon_Request_MT/Item/RecordID=const()
/ns0:BankCheckRecon_Request_MT/Item/ValueDate=currentDate()
/ns0:BankCheckRecon_Request_MT/Item/ChkNumber=/ns0:ComericaCheckRecon_Request_MT/Detail/ChkNumber=
/ns0:BankCheckRecon_Request_MT/Item/ChkAmount=/ns0:ComericaCheckRecon_Request_MT/Detail/ChkAmount=
/ns0:BankCheckRecon_Request_MT/Item/ReceiverBank=const()
/ns0:BankCheckRecon_Request_MT/Item/AcctNumber=const()
/ns0:BankCheckRecon_Request_MT/Item/EncashDate=TransformDate(/ns0:ComericaCheckRecon_Request_MT/Detail/ChkPaidDate=)
/ns0:BankCheckRecon_Request_MT/Item/TransCode=const()
/ns0:BankCheckRecon_Request_MT/Item/AcctNumber_1=/ns0:ComericaCheckRecon_Request_MT/Detail/AcctNumber=
<b>Test Data -</b>
<?xml version="1.0" encoding="UTF-8"?>
<ns0:ComericaCheckRecon_Request_MT xmlns:ns0="http://mazdausa.com/sapr3/fi/transdata/bankcheckrecon">
<Header>
<AcctNumber>2176975528</AcctNumber>
<Filler1> </Filler1>
<ReconDate>123105</ReconDate>
<Filler2> </Filler2>
<RecordID>H</RecordID>
<Filler3> </Filler3>
</Header>
<Detail>
<AcctNumber>2176975528</AcctNumber>
<Filler1> </Filler1>
<ChkNumber>0000200001</ChkNumber>
<Filler2> </Filler2>
<ChkPaidDate>121905</ChkPaidDate>
<Filler3> </Filler3>
<ChkAmount>0001020000</ChkAmount>
<RecordID>D</RecordID>
<Filler4> </Filler4>
</Detail>
<Detail>
<AcctNumber>2176975528</AcctNumber>
<Filler1> </Filler1>
<ChkNumber>0000200002</ChkNumber>
<Filler2> </Filler2>
<ChkPaidDate>121405</ChkPaidDate>
<Filler3> </Filler3>
<ChkAmount>0164840000</ChkAmount>
<RecordID>D</RecordID>
<Filler4> </Filler4>
</Detail>
<Trailer>
<AcctNumber>2176975528</AcctNumber>
<Filler1> </Filler1>
<ChksCount>0000000493</ChksCount>
<Filler2> </Filler2>
<TotalAmount>0766945400</TotalAmount>
<Filler3> </Filler3>
<RecordID>T</RecordID>
<Filler4> </Filler4>
</Trailer>
</ns0:ComericaCheckRecon_Request_MT>
Thanks
RajeshThanks Mohan for your quick response. I am working with File Adapter and here are <b>Message Structures:</b>
ComericaCheckRecon_Request_MT
Header
AcctNumber 10
Filler1 1
ReconDate 6
Filler2 22
RecordID 1
Filler3 40
Detail
AcctNumber 10
Filler1 1
ChkNumber 10
Filler2 1
ChkPaidDate 6
Filler3 1
ChkAmount 10
RecordID 1
Filler4 40
Trailer
AcctNumber 10
Filler1 1
ChksCount 10
Filler2 1
TotalAmount 10
Filler3 7
RecordID 1
Filler4 40
BankCheckRecon_Request_MT
Header
RecordID 1
HdrNumber 3
SenderBank 15
ReceiverBank 15
AcctNumber 18
PymtType 3
TapeDate 8
ISOCurr 3
Item
RecordID 1
ValueDate 8
ChkNumber 13
ChkAmount 11
ReceiverBank 15
AcctNumber 10
EncashDate 8
TransCode 3
AcctNumber 18 -
Need help with XML transformation
I am not sure this is the right place for this. But i will try it here. I am very troubled with my XSLT. Trying to transform a text Coupon which has the following html for it. So,
_1. INPUT is:_
<html>
<head>
</head>
<body>
<p>
This coupon is for a good guy whose first name is :
</p>
<p>
</p>
<p align="center">
Sadd
</p>
<p align="center">
</p>
<p align="right">
<b>also</b> whose <var>full_name</var> is Sadd Hossain
</p>
<p align="left">
</p>
<p align="left">
He is a <font size="3">software </font><font size="4">engineer for</font><font size="5">
S&H</font>
</p>
</body>
</html>
*2. output needed is:*
<?xml version="1.0" encoding="UTF-8"?>
<POSMESSAGE>
<TextMSG >
This coupon is for a good guy whose first name is :
</TextMSG>
<TextMSG >
</TextMSG>
<TextMSG align="center">
<emph>SADD</emph>
</TextMSG>
<TextMSG >
</TextMSG>
<TextMSG align="right" >
also whose full_name is Sadd Hossain
</TextMSG>
<TextMSG>
</TextMSG>
<TextMSG align="left" >
He is a software engineer
for S&H
</TextMSG>
</POSMESSAGE>
*3. XSLT for this*
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml"/>
<xsl:template match="body">
<POSMESSAGE>
<xsl:for-each select="p">
<TextMSG>
<!--xsl:if test="not[@align='']"-->
<xsl:attribute name="align"><xsl:value-of select="@align"/></xsl:attribute>
<!--/xsl:if-->
<xsl:attribute name="font"><xsl:value-of select="@size"/></xsl:attribute>
<xsl:value-of select="."/>
</TextMSG>
<xsl:for-each select="b">
<emph>
<xsl:value-of select="."/>
</emph>
</xsl:for-each>
</xsl:for-each>
</POSMESSAGE>
</xsl:template>
</xsl:stylesheet>
*4: the above xslt generating this output*
<?xml version="1.0" encoding="UTF-8"?>
<POSMESSAGE><TextMSG align="" font="">
This coupon is for a good guy whose first name is :
</TextMSG><TextMSG align="" font="">
</TextMSG><TextMSG align="center" font="">
SADD
</TextMSG><TextMSG align="center" font="">
</TextMSG><TextMSG align="right" font="">
also whose full_name is Sadd Hossain
</TextMSG><TextMSG align="left" font="">
</TextMSG><TextMSG align="left" font="">
He is a software engineer
for S&H
</
*5: Need help with this. what should my xslt look like to get the desired output???????????????*
any help or direction will be very much appreciated. Thank you_I have below suggestions:
1. Please use code option given in message editor toolbar for posting any formatted content like XML, Java code snippet etc.
2. replace & in your source XML with _& a m p ;_ (Without spaces, I have put spaces to make it visible here).
3. I have modified your XSLT according output XML you have given. I am not sure what you want to do with some elements like <b>, <font>, <var> etc. change below XSLT as you require for these elements.
Modified XSLT:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml"/>
<xsl:template match="body">
<POSMESSAGE>
<xsl:for-each select="p">
<TextMSG>
<xsl:if test=". != ''">
<xsl:for-each select="@align">
<xsl:attribute name="align">
<xsl:value-of select="."></xsl:value-of>
</xsl:attribute>
</xsl:for-each>
<xsl:value-of select="."/>
</xsl:if>
</TextMSG>
</xsl:for-each>
</POSMESSAGE>
</xsl:template>
</xsl:stylesheet>
OUTPUT:
<?xml version="1.0"?>
<POSMESSAGE>
<TextMSG>This coupon is for a good guy whose first name is :</TextMSG>
<TextMSG/>
<TextMSG align="center">Sadd</TextMSG>
<TextMSG/>
<TextMSG align="right">alsowhose full_name is Sadd Hossain</TextMSG>
<TextMSG/>
<TextMSG align="left">He is a softwareengineer forS&H</TextMSG>
</POSMESSAGE> -
Need help in XSL transformation
Hi, I have a requirement where a message is recieved on the BPEL service. The message is basically a list of 200 or less productids.
The requirement is to break the incoming message into smaller messages having a list of 50 productids each and then depending on the number of smaller messages call in parrallel a Proxy service in OSB.
I am not sure how to write an XSL transfor which could split the message into smaller messages.
I would highly appreciate if somebody could help or give any pointers.Hi,
By passing parameters you can solve your problem.
write an xsd like below.
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:p="http://schemas.oracle.com/service/bpel/common"
xmlns="http://schemas.oracle.com/service/bpel/common"
targetNamespace="http://schemas.oracle.com/service/bpel/common"
elementFormDefault="qualified">
<xsd:element name="parameters">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="item" minOccurs="1" maxOccurs="unbounded">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="name" type="xsd:string"/>
<xsd:element name="value" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
create an element say pramsVar of type parameters (Root element in above xsd)
Now take an assign activity and in copy select XML fragmentand do like below
In From
<parameters xmlns="http://schemas.oracle.com/service/bpel/common">
<item>
<name>beginIndex</name>
<value/>
</item>
<item>
<name>endIndex</name>
<value/>
</item>
</parameters>
assgn the above to paramsVar.
Now assign proper values to begin and endIndexes (In your case 0 and 50)
Now pass paramsVar to XSLT and create two paramters in XSLT say beginIndex and endIndex
You need to use position function in XSLT like below
*<xsl:if test="(position() > $beginIndex ) and (position() <= $endIndex)">*
In BPEL you need to increment the beginIndex and EndIndex in a while loop till you reached the last record(In your case 4 times bcoz 200 recs)
Regards
PavanKumar.M -
Need help in XSLT transformation
Hi,
I need to transform below input XML to output XML. Can you please provide any ideas for this
Input XML :
<?xml version="1.0" encoding="UTF-8" ?>
<GenericCollection ParamValue="ParamValue1" xmlns="http://www.example.org">
<Generic>
<store>Store1</store>
<metricName>Metric1</metricName>
<metricValue>1</metricValue>
</Generic>
<Generic>
<store>Store1</store>
<metricName>Metric2</metricName>
<metricValue>1</metricValue>
</Generic>
<Generic>
<store>Store2</store>
<metricName>Metric1</metricName>
<metricValue>1</metricValue>
</Generic>
<Generic>
<store>Store2</store>
<metricName>Metric1</metricName>
<metricValue>2</metricValue>
</Generic>
<Generic>
<store>Store2</store>
<metricName>Metric2</metricName>
<metricValue>1</metricValue>
</Generic>
<Generic>
<store>Store3</store>
<metricName>Metric1</metricName>
<metricValue>1</metricValue>
</Generic>
<Generic>
<store>Store3</store>
<metricName>Metric1</metricName>
<metricValue>2</metricValue>
</Generic>
</GenericCollection>
Output XML :
<?xml version = '1.0' encoding = 'UTF-8'?>
<ns4:EnterpriseDocument>
<ns4:DataSet>
<ns4:Dimension ref_name="bu_code" value="Store1">
<ns4:Metric ref_name="Metric1">
<ns4:Data value="1"/>
</ns4:Metric>
<ns4:Metric ref_name="Metric2">
<ns4:Data value="1"/>
</ns4:Metric>
</ns4:Dimension>
<ns4:Dimension ref_name="bu_code" value="Store2">
<ns4:Metric ref_name="Metric1">
<ns4:Data value="1"/>
<ns4:Data value="2"/>
</ns4:Metric>
<ns4:Metric ref_name="Metric2">
<ns4:Data value="1"/>
</ns4:Metric>
</ns4:Dimension>
<ns4:Dimension ref_name="bu_code" value="Store3">
<ns4:Metric ref_name="Metric1">
<ns4:Data value="1"/>
<ns4:Data value="2"/>
</ns4:Metric>
</ns4:Dimension>
</ns4:DataSet>
</ns4:EnterpriseDocument>
Thanks,
RameshHello Ramesh,
Nice puzzle
For this you need a transformation with XSLT 2.0. Use a two level grouping. First group on the store elements and the second on the metricName elements.
Transformation looks like this:
<?xml version="1.0"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<EnterpriseDocument>
<DataSet>
<!-- First group on the store elements
Each store will be grouped based on the element value
-->
<xsl:for-each-group select="/*[local-name() = 'GenericCollection']/*[local-name() = 'Generic']" group-by="./*[local-name() = 'store']">
<!-- For each store a Dimension element is needed -->
<Dimension ref_name="bu_code" value="{./*[local-name() = 'store']}">
<!-- Within a Dimension we need to group by metricName -->
<xsl:for-each-group select="current-group()" group-by="./*[local-name() = 'metricName']">
<Metric ref_name="{./*[local-name() = 'metricName']}">
<!-- Iterate over the metricName nodes and create a Data element -->
<xsl:for-each select="current-group()/*[local-name() = 'metricValue']">
<Data value="{.}"/>
</xsl:for-each>
</Metric>
</xsl:for-each-group>
</Dimension>
</xsl:for-each-group>
</DataSet>
</EnterpriseDocument>
</xsl:template>
</xsl:stylesheet>
Good luck!
Regards,
Melvin -
Need help on xslt transformation
Hi ,
I am working on a xslt transformation and I am finding it difficult to implement the transformation. The scenario is as below.
Input format :-
A
B
B
B
4
5
A
B
B
A
B
B
B
Output format :-
A
B
B
B (since after A there were 3 B’s before the next A)
A
B
B(since after A there were two B’s before the next A)
A
B
B
B
I don't need type 4,5 records in the output xml,output should have repetition of (A followed by B’s(till the next occurrences of A)).
if some one encountered a similar transformation kindly let me know.Hi,
You can use "Call" and "Apply" template.
1st thing to do:
e.g.
<xsl:template name="Check_Decimal">
<xsl:param name="Xpath"/>
<xsl:choose>
<xsl:when test="($Xpath) and ($Xpath)!='4'">
<xsl:value-of select="$Xpath"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="' ' '"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xml_Target_Element_1>
<xsl:call-template name="Check_Decimal">
<xsl:with-param name="Xpath"
select="/x/y/z/xml_Target_Element_1"/>
</xsl:call-template>
</xml_Target_Element_1>
This means, it will display the value in xpath if value is not equal to 4. And if it is equal to 4, it displays nothing.
2nd thing to do:
Apply for-each to xpath till the String element reaches to "A".
Regards,
Richa -
I am trying to create BPEL that acts as a message "fork" from one external public interface to two internal webapps (i.e. the received message is duplicated and sent to both webapps in parallel). The message is an array of user information that I want to register into both webapps.
I believe that I have created the public wsdl OK and can receive a message and store it in a local variable. Although both webapps define a similar message within their own wsdls, I am unclear how to transfer the information from the "receipt" variable into the "invoke webapp" variable. Stated another way, how can I transfer an array defined in one wsdl into a similar array defined in a second wsdl?
Can anyone help me?
Thanks in advance,
Stevexsd file i used,
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://xml.netbeans.org/schema/newXMLSchema"
xmlns:tns="http://xml.netbeans.org/schema/newXMLSchema"
elementFormDefault="qualified">
<xsd:element name="newElement">
<xsd:complexType>
<xsd:sequence maxOccurs="1">
<xsd:element name="Collection" maxOccurs="5">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="leafElement" type = "xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
wsdl file i used,
<?xml version="1.0" encoding="UTF-8"?>
<definitions targetNamespace="http://j2ee.netbeans.org/wsdl/repeatingNode"
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://j2ee.netbeans.org/wsdl/repeatingNode" name="repeatingNode" xmlns:ns="http://xml.netbeans.org/schema/newXMLSchema" xmlns:plink="http://schemas.xmlsoap.org/ws/2004/03/partner-link/">
<wsdl:types>
<xsd:schema targetNamespace="http://j2ee.netbeans.org/wsdl/repeatingNode">
<xsd:import xmlns="http://www.w3.org/2001/XMLSchema" namespace="http://xml.netbeans.org/schema/newXMLSchema" schemaLocation="repeatingNode.xsd"/>
</xsd:schema>
</wsdl:types>
<wsdl:message name="repeatingNodeOperationRequest">
<wsdl:part name="part1" element="ns:newElement"/>
</wsdl:message>
<wsdl:message name="repeatingNodeOperationReply">
<wsdl:part name="part1" element="ns:newElement"/>
</wsdl:message>
<wsdl:portType name="repeatingNodePortType">
<wsdl:operation name="repeatingNodeOperation">
<wsdl:input name="input1" message="tns:repeatingNodeOperationRequest"/>
<wsdl:output name="output1" message="tns:repeatingNodeOperationReply"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="repeatingNodeBinding" type="tns:repeatingNodePortType">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="repeatingNodeOperation">
<soap:operation/>
<wsdl:input name="input1">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="output1">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="repeatingNodeService">
<wsdl:port name="repeatingNodePort" binding="tns:repeatingNodeBinding">
<soap:address location="http://localhost:18181/repeatingNodeService/repeatingNodePort"/>
</wsdl:port>
</wsdl:service>
<plink:partnerLinkType name="repeatingNodePartner">
<!-- partnerLinkType are automatically generated when a new portType is added. partnerLinkType are used by BPEL processes.
In a BPEL process, a partner link represents the interaction between the BPEL process and a partner service. Each partner link is associated with a partner link type.
A partner link type characterizes the conversational relationship between two services. The partner link type can have one or two roles.-->
<plink:role name="repeatingNodePortTypeRole" portType="tns:repeatingNodePortType"/>
</plink:partnerLinkType>
</definitions>
BPEL file i used
<?xml version="1.0" encoding="UTF-8"?>
<process
name="repeatingNode"
targetNamespace="http://enterprise.netbeans.org/bpel/repeatingNode"
xmlns="http://schemas.xmlsoap.org/ws/2004/03/business-process/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:bpws="http://schemas.xmlsoap.org/ws/2004/03/business-process/"
xmlns:wsdlNS="http://enterprise.netbeans.org/bpel/repeatingNode" xmlns:ns1="http://j2ee.netbeans.org/wsdl/repeatingNode" xmlns:ns0="http://xml.netbeans.org/schema/newXMLSchema">
<bpws:import importType="http://schemas.xmlsoap.org/wsdl/" namespace="http://j2ee.netbeans.org/wsdl/repeatingNode" location="repeatingNode.wsdl"/>
<bpws:partnerLinks>
<bpws:partnerLink name="PartnerLink1" partnerLinkType="ns1:repeatingNodePartner" myRole="repeatingNodePortTypeRole"/>
</bpws:partnerLinks>
<bpws:variables>
<bpws:variable name="counter" type="xsd:int"/>
<bpws:variable name="RepeatingNodeOperationOut" messageType="ns1:repeatingNodeOperationReply"/>
<bpws:variable name="RepeatingNodeOperationIn" messageType="ns1:repeatingNodeOperationRequest"/>
</bpws:variables>
<sequence>
<bpws:receive name="Receive1" createInstance="yes" partnerLink="PartnerLink1" operation="repeatingNodeOperation" portType="ns1:repeatingNodePortType" variable="RepeatingNodeOperationIn"/>
<bpws:assign name="Assign2">
<bpws:copy>
<bpws:from>0</bpws:from>
<bpws:to variable="counter"/>
</bpws:copy>
</bpws:assign>
<bpws:while name="While1">
<bpws:condition> ( $counter < 6 ) </bpws:condition>
<bpws:assign name="Assign1">
<bpws:copy>
<bpws:from> ( $counter + 1 ) </bpws:from>
<bpws:to variable="counter"/>
</bpws:copy>
<bpws:copy>
<bpws:from>$RepeatingNodeOperationIn.part1/ns0:Collection[$counter]/ns0:leafElement</bpws:from>
<bpws:to>$RepeatingNodeOperationOut.part1/ns0:Collection[$counter]/ns0:leafElement</bpws:to>
</bpws:copy>
</bpws:assign>
</bpws:while>
<!--
<bpws:assign name="Assign3">
<bpws:copy>
<bpws:from variable="RepeatingNodeOperationIn" part="part1"/>
<bpws:to variable="RepeatingNodeOperationOut" part="part1"/>
</bpws:copy>
</bpws:assign>
-->
<bpws:reply name="Reply1" partnerLink="PartnerLink1" operation="repeatingNodeOperation" portType="ns1:repeatingNodePortType" variable="RepeatingNodeOperationOut"/>
</sequence>
</process>
input file
<soapenv:Envelope xsi:schemaLocation="http://schemas.xmlsoap.org/soap/envelope/ http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:new="http://xml.netbeans.org/schema/newXMLSchema">
<soapenv:Body>
<new:newElement>
<!--1 to 5 repetitions:-->
<new:Collection>
<new:leafElement>1</new:leafElement>
</new:Collection>
<new:Collection>
<new:leafElement>2</new:leafElement>
</new:Collection>
<new:Collection>
<new:leafElement>3</new:leafElement>
</new:Collection>
<new:Collection>
<new:leafElement>4</new:leafElement>
</new:Collection>
<new:Collection>
<new:leafElement>5</new:leafElement>
</new:Collection>
</new:newElement>
</soapenv:Body>
</soapenv:Envelope>
output file due to running the bpel
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://schemas.xmlsoap.org/soap/envelope/ http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns0="http://xml.netbeans.org/schema/newXMLSchema" xmlns="http://xml.netbeans.org/schema/newXMLSchema">
<SOAP-ENV:Header/>
<SOAP-ENV:Body>
<newElement xmlns="http://xml.netbeans.org/schema/newXMLSchema">
<ns0:Collection xmlns:ns0="http://xml.netbeans.org/schema/newXMLSchema">
<ns0:leafElement>1</ns0:leafElement>
</ns0:Collection>
<ns0:Collection xmlns:ns0="http://xml.netbeans.org/schema/newXMLSchema">
<ns0:leafElement>2</ns0:leafElement>
</ns0:Collection>
<ns0:Collection xmlns:ns0="http://xml.netbeans.org/schema/newXMLSchema">
<ns0:leafElement>3</ns0:leafElement>
</ns0:Collection>
<ns0:Collection xmlns:ns0="http://xml.netbeans.org/schema/newXMLSchema">
<ns0:leafElement>4</ns0:leafElement>
</ns0:Collection>
<ns0:Collection xmlns:ns0="http://xml.netbeans.org/schema/newXMLSchema">
<ns0:leafElement>5</ns0:leafElement>
</ns0:Collection>
</newElement>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope> -
Need help with XML TRANSFORMATION dump
HI Experts ,
I want to parse this XML file to abap internal table ,i use the ST below and i get dump .
The file is like that :
<Containers>
<Container workitemid="0000001" IsParent="X">
<Element name="__INITIATO" value="U295"/>
<Element name="_W_PRITY" value="5"/>
<Element name="_F_VERSION" value="0000"/>
</Container>
<Container workitemid="0000001">
<Element name="EXTENDED" value="X"/>
<Element name="NOTE_REFERENCE" value=""/>
</Container>
</Containers>
An exception occurred that is explained in detail below.
The exception, which is assigned to class 'CX_ST_MATCH_ELEMENT', was not caught
and
therefore caused a runtime error.
The reason for the exception is:
XML matching error
Expected was element-end: "Containers" [ ] Read was element-start: "Container"
this is the ciode that i put on the call transformation
<Containers>
<Container>
<tt:loop name="a" ref=".XML_TAB">
<Element >
<tt:attribute name="name" value-ref="$a.name"/>
<tt:attribute name="value" value-ref="$a.value"/>
</Element>
</tt:loop>
</Container>
</Containers> ->**the dump in the debugger is here .**
</tt:template>
</tt:transform>
the dump is because i don't refer to the </Container> in the middle
and when i try to add the tag container in the middle i get warning during complition
any idea please im stuck
Best Regards
Chris
Edited by: Chris Teb on Aug 14, 2009 6:25 PMI guess you'll better understand with the solution I found:
Simple transformation:
<?sap.transform simple?>
<tt:transform xmlns:tt="http://www.sap.com/transformation-templates">
<tt:root name="XML_TAB"/>
<tt:template>
<Containers>
<tt:loop name="b" ref=".XML_TAB">
<Container>
<tt:loop name="a" ref="$b.T_DATA">
<Element>
<tt:attribute name="name" value-ref="$a.name"/>
<tt:attribute name="value" value-ref="$a.value"/>
</Element>
</tt:loop>
</Container>
</tt:loop>
</Containers>
</tt:template>
</tt:transform>
Program :
data itab1 type string.
concatenate '<Containers>'
' <Container workitemid="0000001" IsParent="X">'
' <Element name="__INITIATO" value="U295"/>'
' <Element name="_W_PRITY" value="5"/>'
' <Element name="_F_VERSION" value="0000"/>'
'</Container>'
'<Container workitemid="0000001">'
' <Element name="EXTENDED" value="X"/>'
' <Element name="NOTE_REFERENCE" value=""/>'
' </Container>'
'</Containers>'
into itab1.
TYPES: BEGIN OF ty_data,
name TYPE string,
value TYPE string,
END OF ty_data.
DATA: lt_data TYPE TABLE OF ty_data.
TYPES: BEGIN OF ty_data2,
workitemid TYPE n LENGTH 7,
isparent TYPE flag,
t_data TYPE TABLE OF ty_data WITH DEFAULT KEY,
END OF ty_data2.
DATA: lt_data2 TYPE TABLE OF ty_data2.
DATA lo_st_error TYPE REF TO cx_st_error.
DATA message TYPE string.
TRY.
CALL TRANSFORMATION zext_file
SOURCE XML itab1
RESULT xml_tab = lt_data2.
CATCH cx_sy_conversion_data_loss .
* do something
CATCH cx_st_error INTO lo_st_error.
message = lo_st_error->get_text( ).
WRITE:/ message .
ENDTRY.
By the way, I don't know what ITAB1 is in your case, it was more simple in my case to define it as a string. Anyway, if it's something else, it should work the same. -
Hello there,
I need help with BPEL project.
i have created a table Employee in Database.
I did create application, BPEL project and connection to the database properly using Database Adapter.
I need to read the records from the database and convert into xml fomat and it should to go approval for BPM worklist.
Can someone please describe me step by step what i need to do.
Thanks,
DpsRead the Demo examples given with Oracle BPEL Process Manager.
I am now at a proficient level in BPEL in the past 1 year,
still need to reach the excellent mark.
Thanks & Regards,
Gopal D. Kalsekar
Sr. Software Developer
Business Solutions (eGroup)
M.H. Alshaya Company W.L.L.
www.alshaya.com
Jai Maharashtra
P :- (965) 224 3598
F :- (965) 224 2488
E :- [email protected] -
BPEL security, need help?
Folks,
We need help understanding how the following, that is done in JAVA can be done thru' BPEL
((Stub))._setProperty(Stub.ENDPOINT_ADDRESS_PROPERTY, mywsdlURL);
((Stub))._setProperty(Stub.USERNAME_PROPERTY, myLDAPUSERNAME);
((Stub))._setProperty(Stub.PASSWORD_PROPERTY,myLDAPPASSWORD)
It is a webservice that we are expected to invoke through BPEL. Invoking through JAVA works fine, however we do not know which properties should be used on BPEL to get it to work. We are either getting unable to access end point OR forbidden message. We tried setting these properties on partner link and on composite.
Thank you.see these threads for the username/password
http://biemond.blogspot.com/2010/08/http-basic-authentication-with-soa.html
Consume search.wsdl from BPEL 11g
BPEL to invoke Webservice secured with HTTP Basic authentication
the url will be added when you create the partnerlink to your webservice
if you want to use some sort of dynamic partnerlink construction ..you could use :
http://www.oracle.com/technology/architect/soa-suite-series/dynamic_endpoints.html
http://blogs.oracle.com/dasoa/2010/09/11g_dynamic_partnerlink_example.html
with this you can set the endpoint to your own values.
or use something like ant for deployment en replace the endpoint settings at deployment time. -
Error in Passing BPEL variable Contents to BPEL Transform (XSLT)
Hi,
Problem Statement:
· I want to Transform data, from schema1 to schema2.
· Schema1 is basically a collection lets say collection of A. in XML terms, it has multiple same type of child elements under the root element.
· Schema2 associated with each child element of Schema1.
· In the Loop, I want to iterate through the schema1 data and iteration count would be as much as number of child elements in it.
· Pick one child element (using index in XPATH) and use it to associate with Schema2 elements.
· In this process I wanted to pass 2 parameters to BPEL Transform activity using properties datatype. (ref: http://blogs.oracle.com/rammenon/2007/05/07)
· However it is not realizing the parameters passed to it.
Please also suggest me a location to upload the related code for any verification.
Please suggest the flaw in this and suggestions to rectify.
Thanks
Regards
JoyExample counting nodes.
ora:countNodes('Invoke_FileSyncRead_SynchronousRead_OutputVariable','Root-Element','/ns1:Root-Element/ns1:SiteInfo')
Set that to Integer variable $count.
Then set new variable type integer $interator = 1.
That will give you a proper loop counter for your payload.
AS far as mapping only certain elements, I would just transform 1st, then pick out what you need with an explicit assign activity to whatever you want to pass that to.
Hope that helps. -
Going to Australia and need help with Power converters
Facts:
US uses 110v on 60hz
Australia 220v on 50hz
Making sure I understood that correctly. Devices I plan on bringing that will use power are PS3 Slim, MacBook Pro 2008 model, and WD 1TB External HDD. My DS, and Cell are charging via USB to save trouble of other cables.
Ideas I've had or thought of:
1. Get a power converter for a US Powerstrip, and then plug in my US items into the strip and then the strip into an AUS Converter into Australian outlet. Not sure if this fixes the voltage/frequency change.
2. Get power converters for all my devices. But, not sure if my devices needs ways of lowering the voltage/increasing frequency or something to help with the adjustment.
3. Buy a universal powerstrip, which is extremely costly and I wouldn't be able to have here in time (I leave Thursday). Unless Best Buy carrys one.godzillafan868 wrote:
Facts:
US uses 110v on 60hz
Australia 220v on 50hz
Making sure I understood that correctly. Devices I plan on bringing that will use power are PS3 Slim, MacBook Pro 2008 model, and WD 1TB External HDD. My DS, and Cell are charging via USB to save trouble of other cables.
Ideas I've had or thought of:
1. Get a power converter for a US Powerstrip, and then plug in my US items into the strip and then the strip into an AUS Converter into Australian outlet. Not sure if this fixes the voltage/frequency change.
2. Get power converters for all my devices. But, not sure if my devices needs ways of lowering the voltage/increasing frequency or something to help with the adjustment.
3. Buy a universal powerstrip, which is extremely costly and I wouldn't be able to have here in time (I leave Thursday). Unless Best Buy carrys one.
Check the specs on input voltage/frequency of your power supplies.
Many laptop power supplies are "universal/global" and are specced something like 80-265 volts AC 50/60 Hz, but not all. These will just need a connector adapter.
Unsure about the PS3 Slim - if it isn't universal it could be difficult as you'll need a 110/220 transformer, one big enough (power-handling wise) for the PS3 will be very bulky.
For the external WD HDD, if it doesn't have a universal supply, you're probably best off just finding a new wallwart for it that is capable of running on 220/50.
*disclaimer* I am not now, nor have I ever been, an employee of Best Buy, Geek Squad, nor of any of their affiliate, parent, or subsidiary companies. -
Need help in creating a 16gray levels 4 bit IndexColorModel.
Hi ppl,
Really need help with the above mentioned. I have reduced a 256 gray level .PGM image to 16 gray level (not using JAI). However, I'm having lots of trouble trying to create the image. It always comes out too dark. Does anyone know what the problem may be? Could it be that I'm using the wrong ColorModel?
Am currently using the follow code
static {
grayPallete1=new byte[16] ;
for(int i=0; i<16; i++) grayPallete1=(byte)i ;
public ImageData(byte[] pmap, int r, int c){
bpels = pmap ; irow=r; icol=c;
int i = 0;
clrmdl= new IndexColorModel(4,16,grayPallete1,grayPallete1,grayPallete1) ;
Any help is greatly appreciated!
Rgds,
Dam
Message was edited by:
Damy
Message was edited by:
DamyHi Suman Sarkar,
I am a little confused about the layout of your waterfall chart, could you please post some dummy chart here, with a clear
understanding with the issue, we could give some solution or workarounds, the steps of uploading the picture are following:
1.
Upload the picture to a website
http://skydriver.live.com
2.
View the picture in the website.
3.
Right-click the picture, and then select “Copy”
4.
In reply window, select “Paste” to paste the picture into a post.
If you have any question about the steps, please feel free to ask.
Regards,
Challen Fu -
I need helping configuring RDP access to my local server from a remote location on my Cisco ASA 5505 Firewall.
I have attempted to configure rdp access but it does not seem to be working for me Could I please ask someone to help me modify my current configuration to allow this? Please do step by step as I could use all the help I could get.
I need to allow the following IP addresses to have RDP access to my server:
66.237.238.193-66.237.238.222
69.195.249.177-69.195.249.190
69.65.80.240-69.65.80.249
My external WAN server info is - 99.89.69.333
The internal IP address of my server is - 192.168.6.2
The other server shows up as 99.89.69.334 but is working fine.
I already added one server for Static route and RDP but when I try to put in same commands it doesnt allow me to for this new one. Please take a look at my configuration file and give me the commands i need in order to put this through. Also please tell me if there are any bad/conflicting entries.
THE FOLLOWING IS MY CONFIGURATION FILE
Also I have modified IP information so that its not the ACTUAL ip info for my server/network etc... lol for security reasons of course
Also the bolded lines are the modifications I made but that arent working.
ASA Version 7.2(4)
hostname ciscoasa
domain-name default.domain.invalid
enable password DowJbZ7jrm5Nkm5B encrypted
passwd 2KFQnbNIdI.2KYOU encrypted
names
interface Vlan1
nameif inside
security-level 100
ip address 192.168.6.254 255.255.255.0
interface Vlan2
nameif outside
security-level 0
ip address 99.89.69.233 255.255.255.248
interface Ethernet0/0
switchport access vlan 2
interface Ethernet0/1
interface Ethernet0/2
interface Ethernet0/3
interface Ethernet0/4
interface Ethernet0/5
interface Ethernet0/6
interface Ethernet0/7
ftp mode passive
dns server-group DefaultDNS
domain-name default.domain.invalid
object-group network EMRMC
network-object 10.1.2.0 255.255.255.0
network-object 192.168.10.0 255.255.255.0
network-object 192.168.11.0 255.255.255.0
network-object 172.16.0.0 255.255.0.0
network-object 192.168.9.0 255.255.255.0
object-group service RDP tcp
description RDP
port-object eq 3389
object-group service GMED tcp
description GMED
port-object eq 3390
object-group service MarsAccess tcp
description MarsAccess
port-object range pcanywhere-data 5632
object-group service MarsFTP tcp
description MarsFTP
port-object range ftp-data ftp
object-group service MarsSupportAppls tcp
description MarsSupportAppls
port-object eq 1972
object-group service MarsUpdatePort tcp
description MarsUpdatePort
port-object eq 7835
object-group service NM1503 tcp
description NM1503
port-object eq 1503
object-group service NM1720 tcp
description NM1720
port-object eq h323
object-group service NM1731 tcp
description NM1731
port-object eq 1731
object-group service NM389 tcp
description NM389
port-object eq ldap
object-group service NM522 tcp
description NM522
port-object eq 522
object-group service SSL tcp
description SSL
port-object eq https
object-group service rdp tcp
port-object eq 3389
access-list outside_1_cryptomap extended permit ip 192.168.6.0 255.255.255.0 object-group EMRMC
access-list inside_nat0_outbound extended permit ip 192.168.6.0 255.255.255.0 192.168.0.0 255.255.0.0
access-list inside_nat0_outbound extended permit ip 192.168.6.0 255.255.255.0 object-group EMRMC
access-list outside_access_in extended permit tcp 69.16.158.128 255.255.255.128 host 99.89.69.334 eq pcanywhere-data
access-list outside_access_in extended permit udp 69.16.158.128 255.255.255.128 host 99.89.69.334 eq pcanywhere-status
access-list outside_access_in extended permit tcp 69.16.158.128 255.255.255.128 host 99.89.69.334 object-group RDP
access-list outside_access_in extended permit tcp 69.16.158.128 255.255.255.128 192.168.6.0 255.255.255.0 eq ftp
access-list outside_access_in extended permit tcp 69.16.158.128 255.255.255.128 192.168.6.0 255.255.255.0 eq ldap
access-list outside_access_in extended permit tcp 69.16.158.128 255.255.255.128 192.168.6.0 255.255.255.0 eq h323
access-list outside_access_in extended permit tcp 69.16.158.128 255.255.255.128 192.168.6.0 255.255.255.0 eq telnet
access-list outside_access_in extended permit tcp 69.16.158.128 255.255.255.128 192.168.6.0 255.255.255.0 eq www
access-list outside_access_in extended permit tcp 69.16.158.128 255.255.255.128 host 99.89.69.334 object-group SSL
access-list outside_access_in extended permit tcp 69.16.158.128 255.255.255.128 192.168.6.0 255.255.255.0 object-group NM522
access-list outside_access_in extended permit tcp 69.16.158.128 255.255.255.128 192.168.6.0 255.255.255.0 object-group NM1731
access-list outside_access_in extended permit tcp 173.197.144.48 255.255.255.248 host 99.89.69.334 object-group RDP
access-list outside_access_in extended permit tcp any interface outside eq 3389
access-list outside_access_in extended permit tcp host 66.237.238.194 host 99.89.69.333
access-list outside_access_in extended permit tcp host 66.237.238.194 host 99.89.69.333 object-group rdp
access-list outside_access_in extended permit tcp any host 99.89.69.333 object-group rdp
access-list out_in extended permit tcp any host 192.168.6.2 eq 3389
pager lines 24
logging enable
logging asdm informational
mtu inside 1500
mtu outside 1500
icmp unreachable rate-limit 1 burst-size 1
asdm image disk0:/asdm-524.bin
no asdm history enable
arp timeout 14400
global (outside) 1 interface
nat (inside) 0 access-list inside_nat0_outbound
nat (inside) 1 0.0.0.0 0.0.0.0
static (inside,outside) tcp 99.89.69.334 3389 192.168.6.1 3389 netmask 255.255.255.255
static (inside,outside) tcp interface 3389 192.168.6.2 3389 netmask 255.255.255.255
access-group outside_access_in in interface outside
route outside 0.0.0.0 0.0.0.0 99.89.69.338 1
timeout xlate 3:00:00
timeout conn 1:00:00 half-closed 0:10:00 udp 0:02:00 icmp 0:00:02
timeout sunrpc 0:10:00 h323 0:05:00 h225 1:00:00 mgcp 0:05:00 mgcp-pat 0:05:00
timeout sip 0:30:00 sip_media 0:02:00 sip-invite 0:03:00 sip-disconnect 0:02:00
timeout sip-provisional-media 0:02:00 uauth 0:05:00 absolute
http server enable
http 192.168.6.0 255.255.255.0 inside
http 0.0.0.0 0.0.0.0 outside
no snmp-server location
no snmp-server contact
snmp-server enable traps snmp authentication linkup linkdown coldstart
crypto ipsec transform-set ESP-3DES-MD5 esp-3des esp-md5-hmac
crypto map outside_map 1 match address outside_1_cryptomap
crypto map outside_map 1 set peer 68.156.148.5
crypto map outside_map 1 set transform-set ESP-3DES-MD5
crypto map outside_map interface outside
crypto isakmp enable outside
crypto isakmp policy 10
authentication pre-share
encryption 3des
hash md5
group 1
lifetime 86400
crypto isakmp policy 30
authentication pre-share
encryption 3des
hash md5
group 2
lifetime 86400
telnet timeout 5
ssh timeout 5
console timeout 0
dhcpd auto_config outside
tunnel-group 68.156.148.5 type ipsec-l2l
tunnel-group 68.156.148.5 ipsec-attributes
pre-shared-key *
class-map inspection_default
match default-inspection-traffic
policy-map type inspect dns preset_dns_map
parameters
message-length maximum 512
policy-map global_policy
class inspection_default
inspect dns preset_dns_map
inspect ftp
inspect h323 h225
inspect h323 ras
inspect rsh
inspect rtsp
inspect esmtp
inspect sqlnet
inspect skinny
inspect sunrpc
inspect sunrpc
inspect xdmcp
inspect sip
inspect netbios
inspect tftp
service-policy global_policy global
prompt hostname context
Cryptochecksum:f47dfb2cf91833f0366ff572eafefb1d
: end
ciscoasa(config-network)#Unclear what did not work. In your original post you include said some commands were added but don't work:
static (inside,outside) tcp interface 3389 192.168.6.2 3389 netmask 255.255.255.255
and later you state you add another command that gets an error:
static (inside,outside) tcp 99.89.69.333 3389 192.168.6.2 3389 netmask 255.255.255.255
You also stated that 99.89.69.333 (actually 99.89.69.233, guessing from the rest of your config and other posts) is your WAN IP address.
The first static statement matches Cisco's documentation, which states that a static statement must use the 'interface' directive when you are trying to do static PAT utilizing the IP address of the interface. Since 99.89.69.333 is the assigned IP address of your WAN interface, that may explain why the second statement fails.
Any reason why you are using static PAT (including the port number 3389) instead of just skipping that directive? Static PAT usually makes sense when you need to change the TCP port number. In your example, you are not changing the TCP port 3389. -
Need Help With File Matching Records
I need help with my file matching program.
Here is how it suppose to work: FileMatch class should contain methods to read oldmast.txt and trans.txt. When a match occurs (i.e., records with the same account number appear in both the master file and the transaction file), add the dollar amount in the transaction record to the current balance in the master record, and write the "newmast.txt" record. (Assume that purchases are indicated by positive amounts in the transaction file and payments by negative amounts.)
When there is a master record for a particular account, but no corresponding transaction record, merely write the master record to "newmast.txt". When there is a transaction record, but no corresponding master record, print to a log file the message "Unmatched transaction record for account number ..." (fill in the account number from the transaction record). The log file should be a text file named "log.txt".
Here is my following program code:
// Exercise 14.8: CreateTextFile.java
// creates a text file
import java.io.FileNotFoundException;
import java.lang.SecurityException;
import java.util.Formatter;
import java.util.FormatterClosedException;
import java.util.NoSuchElementException;
import java.util.Scanner;
import org.egan.AccountRecord;
import org.egan.TransactionRecord;
public class CreateTextFile
private Formatter output1; // object used to output text to file
private Formatter output2; // object used to output text to file
// enable user to open file
public void openTransFile()
try
output1 = new Formatter("trans.txt");
catch (SecurityException securityException)
System.err.println("You do not have write access to this file.");
System.exit(1);
} // end catch
catch (FileNotFoundException filesNotFoundException)
System.err.println("Error creating file.");
System.exit(1);
} // end method openTransFile
// enable user to open file
public void openOldMastFile()
try
output2 = new Formatter("oldmast.txt");
catch (SecurityException securityException)
System.err.println("You do not have write access to this file.");
System.exit(1);
} // end catch
catch (FileNotFoundException filesNotFoundException)
System.err.println("Error creating file.");
System.exit(1);
} // end method openOldMastFile
// add transaction records to file
public void addTransactionRecords()
// object to be written to file
TransactionRecord record1 = new TransactionRecord();
Scanner input1 = new Scanner(System.in);
System.out.printf("%s\n%s\n%s\n%s\n\n",
"To terminate input, type the end-of-file indicator",
"when you are prompted to enter input.",
"On UNIX/Linux/Mac OS X type <ctrl> d then press Enter",
"On Windows type <ctrl> z then press Enter");
System.out.printf("%s\n%s",
"Enter account number (> 0) and amount.","? ");
while (input1.hasNext()) // loop until end-of-file indicator
try // output values to file
// retrieve data to be output
record1.setAccount(input1.nextInt()); // read account number
record1.setAmount(input1.nextDouble()); // read amount
if (record1.getAccount() > 0)
// write new record
output1.format("%d %.2f\n", record1.getAccount(), record1.getAmount());
} // end if
else
System.out.println("Account number must be greater than 0.");
} // end else
} // end try
catch (FormatterClosedException formatterClosedException)
System.err.println("Error writing to file.");
return;
} // end catch
catch (NoSuchElementException elementException)
System.err.println("Invalid input. Please try again.");
input1.nextLine(); // discard input so user can try again
} // end catch
System.out.printf("%s %s\n%s", "Enter account number (> 0) ",
"and amount.","? ");
} // end while
} // end method addTransactionRecords
// add account records to file
public void addAccountRecords()
// object to be written to file
AccountRecord record2 = new AccountRecord();
Scanner input2 = new Scanner(System.in);
System.out.printf("%s\n%s\n%s\n%s\n\n",
"To terminate input, type the end-of-file indicator",
"when you are prompted to enter input.",
"On UNIX/Linux/Mac OS X type <ctrl> d then press Enter",
"On Windows type <ctrl> z then press Enter");
System.out.printf("%s\n%s",
"Enter account number (> 0), first name, last name and balance.","? ");
while (input2.hasNext()) // loop until end-of-file indicator
try // output values to file
// retrieve data to be output
record2.setAccount(input2.nextInt()); // read account number
record2.setFirstName(input2.next()); // read first name
record2.setLastName(input2.next()); // read last name
record2.setBalance(input2.nextDouble()); // read balance
if (record2.getAccount() > 0)
// write new record
output2.format("%d %s %s %.2f\n", record2.getAccount(), record2.getFirstName(),
record2.getLastName(), record2.getBalance());
} // end if
else
System.out.println("Account number must be greater than 0.");
} // end else
} // end try
catch (FormatterClosedException formatterClosedException)
System.err.println("Error writing to file.");
return;
} // end catch
catch (NoSuchElementException elementException)
System.err.println("Invalid input. Please try again.");
input2.nextLine(); // discard input so user can try again
} // end catch
System.out.printf("%s %s\n%s", "Enter account number (> 0),",
"first name, last name and balance.","? ");
} // end while
} // end method addAccountRecords
// close file
public void closeTransFile()
if (output1 != null)
output1.close();
} // end method closeTransFile
// close file
public void closeOldMastFile()
if (output2 != null)
output2.close();
} // end method closeOldMastFile
} // end class CreateTextFile--------------------------------------------------------------------------------------------------
// Exercise 14.8: CreateTextFileTest.java
// Testing class CreateTextFile
public class CreateTextFileTest
// main method begins program execution
public static void main( String args[] )
CreateTextFile application = new CreateTextFile();
application.openTransFile();
application.addTransactionRecords();
application.closeTransFile();
application.openOldMastFile();
application.addAccountRecords();
application.closeOldMastFile();
} // end main
} // end class CreateTextFileTest-------------------------------------------------------------------------------------------------
// Exercise 14.8: TransactionRecord.java
// A class that represents on record of information
package org.egan; // packaged for reuse
public class TransactionRecord
private int account;
private double amount;
// no-argument constructor calls other constructor with default values
public TransactionRecord()
this(0,0.0); // call two-argument constructor
} // end no-argument AccountRecord constructor
// initialize a record
public TransactionRecord(int acct, double amt)
setAccount(acct);
setAmount(amt);
} // end two-argument TransactionRecord constructor
// set account number
public void setAccount(int acct)
account = acct;
} // end method setAccount
// get account number
public int getAccount()
return account;
} // end method getAccount
// set amount
public void setAmount(double amt)
amount = amt;
} // end method setAmount
// get amount
public double getAmount()
return amount;
} // end method getAmount
} // end class TransactionRecord -------------------------------------------------------------------------------------------------
// Exercise 14.8: AccountRecord.java
// A class that represents on record of information
package org.egan; // packaged for reuse
import org.egan.TransactionRecord;
public class AccountRecord
private int account;
private String firstName;
private String lastName;
private double balance;
// no-argument constructor calls other constructor with default values
public AccountRecord()
this(0,"","",0.0); // call four-argument constructor
} // end no-argument AccountRecord constructor
// initialize a record
public AccountRecord(int acct, String first, String last, double bal)
setAccount(acct);
setFirstName(first);
setLastName(last);
setBalance(bal);
} // end four-argument AccountRecord constructor
// set account number
public void setAccount(int acct)
account = acct;
} // end method setAccount
// get account number
public int getAccount()
return account;
} // end method getAccount
// set first name
public void setFirstName(String first)
firstName = first;
} // end method setFirstName
// get first name
public String getFirstName()
return firstName;
} // end method getFirstName
// set last name
public void setLastName(String last)
lastName = last;
} // end method setLastName
// get last name
public String getLastName()
return lastName;
} // end method getLastName
// set balance
public void setBalance(double bal)
balance = bal;
} // end method setBalance
// get balance
public double getBalance()
return balance;
} // end method getBalance
// combine balance and amount
public void combine(TransactionRecord record)
balance = (getBalance() + record.getAmount());
} // end method combine
} // end class AccountRecord -------------------------------------------------------------------------------------------------
// Exercise 14.8: FileMatch.java
import java.io.File;
import java.io.FileNotFoundException;
import java.lang.IllegalStateException;
import java.util.NoSuchElementException;
import java.util.Scanner;
import java.util.Formatter;
import java.util.FormatterClosedException;
import org.egan.AccountRecord;
import org.egan.TransactionRecord;
public class FileMatch
private Scanner inTransaction;
private Scanner inOldMaster;
private Formatter outNewMaster;
private Formatter theLog;
// enable user to open file
public void openTransFile()
try
inTransaction = new Scanner(new File("trans.txt"));
} // end try
catch (FileNotFoundException fileNotFoundException)
System.err.println("Error opening file.");
System.exit(1);
} // end catch
} // end method openTransFile
// enable user to open file
public void openOldMastFile()
try
inOldMaster = new Scanner(new File("oldmast.txt"));
} // end try
catch (FileNotFoundException fileNotFoundException)
System.err.println("Error opening file.");
System.exit(1);
} // end catch
} // end method openOldMastFile
// enable user to open file
public void openNewMastFile()
try
outNewMaster = new Formatter("newmast.txt");
catch (SecurityException securityException)
System.err.println("You do not have write access to this file.");
System.exit(1);
} // end catch
catch (FileNotFoundException filesNotFoundException)
System.err.println("Error creating file.");
System.exit(1);
} // end method openNewMastFile
// enable user to open file
public void openLogFile()
try
theLog = new Formatter("log.txt");
catch (SecurityException securityException)
System.err.println("You do not have write access to this file.");
System.exit(1);
} // end catch
catch (FileNotFoundException filesNotFoundException)
System.err.println("Error creating file.");
System.exit(1);
} // end method openLogFile
// update records
public void updateRecords()
TransactionRecord transaction = new TransactionRecord();
AccountRecord account = new AccountRecord();
try // read records from file using Scanner object
System.out.println("Start file matching.");
while (inTransaction.hasNext() && inOldMaster.hasNext())
transaction.setAccount(inTransaction.nextInt()); // read account number
transaction.setAmount(inTransaction.nextDouble()); // read amount
account.setAccount(inOldMaster.nextInt()); // read account number
account.setFirstName(inOldMaster.next()); // read first name
account.setLastName(inOldMaster.next()); // read last name
account.setBalance(inOldMaster.nextDouble()); // read balance
if (transaction.getAccount() == account.getAccount())
while (inTransaction.hasNext() && transaction.getAccount() == account.getAccount())
account.combine(transaction);
outNewMaster.format("%d %s %s %.2f\n",
account.getAccount(), account.getFirstName(), account.getLastName(),
account.getBalance());
transaction.setAccount(inTransaction.nextInt()); // read account number
transaction.setAmount(inTransaction.nextDouble()); // read amount
else if (transaction.getAccount() != account.getAccount())
outNewMaster.format("%d %s %s %.2f\n",
account.getAccount(), account.getFirstName(), account.getLastName(),
account.getBalance());
theLog.format("%s%d","Unmatched transaction record for account number ",transaction.getAccount());
} // end while
System.out.println("Finish file matching.");
} // end try
catch (NoSuchElementException elementException)
System.err.println("File improperly formed.");
inTransaction.close();
inOldMaster.close();
System.exit(1);
} // end catch
catch (IllegalStateException stateException)
System.err.println("Error reading from file.");
System.exit(1);
} // end catch
} // end method updateRecords
// close file and terminate application
public void closeTransFile()
if (inTransaction != null)
inTransaction.close();
} // end method closeTransFile
// close file and terminate application
public void closeOldMastFile()
if (inOldMaster != null)
inOldMaster.close();
} // end method closeOldMastFile
// close file
public void closeNewMastFile()
if (outNewMaster != null)
outNewMaster.close();
} // end method closeNewMastFile
// close file
public void closeLogFile()
if (theLog != null)
theLog.close();
} // end method closeLogFile
} // end class FileMatch-------------------------------------------------------------------------------------------------
// Exercise 14.8: FileMatchTest.java
// Testing class FileMatch
public class FileMatchTest
// main method begins program execution
public static void main( String args[] )
FileMatch application = new FileMatch();
application.openTransFile();
application.openOldMastFile();
application.openNewMastFile();
application.openLogFile();
application.updateRecords();
application.closeLogFile();
application.closeNewMastFile();
application.closeOldMastFile();
application.closeTransFile();
} // end main
} // end class FileMatchTest-------------------------------------------------------------------------------------------------
Sample data for master file:
Master file
Account Number Name Balance
100 Alan Jones 348.17
300 Mary Smith 27.19
500 Sam Sharp 0.00
700 Suzy Green -14.22Sample data for transaction file:
Transaction file Transaction
Account Number Amount
100 27.14
300 62.11
300 83.89
400 100.56
700 80.78
700 1.53
900 82.17 -------------------------------------------------------------------------------------------------
My FileMatch class program above has bugs in it.
The correct results for the newmast.txt:
100 Alan Jones 375.31
300 Mary Smith 173.19
500 Sam Sharp 0.00
700 Suzy Green 68.09The correct results for the log.txt:
Unmatched transaction record for account number 400Unmatched transaction record for account number 900------------------------------------------------------------------------------------------------
My results for the newmast.txt:
100 Alan Jones 375.31
300 Mary Smith 111.08
500 Sam Sharp 0.00
700 Suzy Green -12.69My results for the log.txt
Unmatched transaction record for account number 700-------------------------------------------------------------------------------------------------
I am not sure what is wrong with my code above to make my results different from the correct results.
Much help is appreciated. Please help.From the output, it looks like one problem is just formatting -- apparently you're including a newline in log entries and not using tabs for the newmast output file.
As to why the numbers are off -- just from glancing over it, it appears that the problem is when you add multiple transaction values. Since account.combine() is so simple, I suspect that you're either adding creating transaction objects incorrectly or not creating them when you should be.
Create test input data that isolates a single case of this (e.g., just the Mary Smith case), and then running your program in a debugger or adding debugging code to the add/combine method, so you can see what's happening in detail.
Also I'd recommend reconsidering your design. It's a red flag if a class has a name with "Create" in it. Classes represent bundles of independant state and transformations on that state, not things to do.
Maybe you are looking for
-
GMAIL no longer works in Apple Mail?
I can't receive GMAIL any Apple Mail any longer but I can access gmail and it functions propertly through their web site. I have double checked on the IMAP settings and can't figure it out.
-
Wireless Network/printing Newbie Questions....
Okay, first of all I love Airport and OSX Tiger on my new MacBook. I recieve a strong wireless internet connection in my Los Angeles apartment, and I have NO idea where it's coming from! (my neighbors? The police station across the street,? Just in t
-
How do I restore a custom item in the Search bar?
I have just bought a new comouter. One of the things I want to set up on it is the same set of options in the Firefox Search bar. In my old computer I set up the ARTFL Roget's Thesaurus as as one of the list of options for search engines. (This Thesa
-
How to Capitalize the First Letter in Every Word in Mysql
Hi, I have been trying to tidy up a massive database where visitors have been sloppy when entering text. The main thing I want to do is to Capitalize The First Letter In Every Word In Mysql. I have found the code below in PHP but it keeps finding an
-
ORG. Structure change.. Effect on Opportunities
Hello All, Our client wants to do a CRM Org. Restructure to map the HR structures in ECC. My query is : 1. What is the effect on Opportunities that already exist in our system if the org. structure changes.. 2. If we give a validity date of todays da