Hw to use hashrow and reader in sap b1
hi
ii saved few values in a column of the table. Now i want to read the values one by one based on one condition
Edited by: hareeshKR on Jul 22, 2011 1:17 PM
hai,
just try this,
Dim recordset As SAPbobsCOM.Recordset
recordset= ocompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecords
qry = "SELECT columnname FROM tablename WHERE Code='1'" 'Give ur condition here
recordset.DoQuery(qry)
recordset.MoveFirst()
While recordset.EoF = False
dim value as string = recordset.Fields.Item("columnname ").Value
recordset.MoveNext()
End While
Thanks.
Similar Messages
-
How to Use CMOD and SMOD in SAP using ABAP Code
Hello anyone,
Please help me How to use CMOD and SMOD in SAP using ABAP code.
Give Me Some Sample Example.
Mail ID: [email protected]
Thanks,
Regards,
S.Muthu,
SAP Developer.Hi,
User Exits.
http://www.erpgenie.com/sap/abap/code/abap26.htm
http://www.sap-img.com/abap/a-short-tutorial-on-user-exits.htm
http://www.sapgenie.com/abap/code/abap26.htm
http://www.sap-img.com/abap/what-is-user-exits.htm
http://wiki.ittoolbox.com/index.php/HOWTO:Implement_a_screen_exit_to_a_standard_SAP_transaction
http://www.easymarketplace.de/userexit.php
http://www.sap-img.com/abap/a-short-tutorial-on-user-exits.htm
http://www.sappoint.com/abap/userexit.pdfUser-Exit
customer exits
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/f1a7e790-0201-0010-0a8d-f08a4662562d
Menu Exit.
http://www.sappoint.com/abap/spmp.pdf
http://www.sappoint.com/abap/userexit.pdf
http://www.sapdevelopment.co.uk/enhance/mod_sapmenu.htm
http://www.sapdevelopment.co.uk/enhance/enhancehome.htm
USER EXIT
http://www.sap-img.com/abap/a-short-tutorial-on-user-exits.htm
http://www.sapgenie.com/abap/code/abap26.htm
http://www.sap-img.com/abap/what-is-user-exits.htm
http://wiki.ittoolbox.com/index.php/HOWTO:Implement_a_screen_exit_to_a_standard_SAP_transaction
http://www.easymarketplace.de/userexit.php
http://www.sap-img.com/abap/a-short-tutorial-on-user-exits.htm
http://www.sappoint.com/abap/userexit.pdfUser-Exit
http://www.sap-img.com/ab038.htm
http://help.sap.com/saphelp_46c/helpdata/en/64/72369adc56d11195100060b03c6b76/frameset.htm
http://www.sap-img.com/abap/a-short-tutorial-on-user-exits.htm
http://www.sap-img.com/abap/what-is-user-exits.htm
http://expertanswercenter.techtarget.com/eac/knowledgebaseAnswer/0,295199,sid63_gci982756,00.html -
How to Use IDOC and ALE in SAP?
Hi anybody,
I want Use Idoc and ALE in sap ABAP. What is inbound and outbout process of IDOC?
Please give me sample code for Idoc . and Sample code for ALE.
anybody Please tell me.
Thanks
Regards,
S.Muthu.
IT Dept.hi,
Follow the link for step by step ALE/IDOC tutorials.
http://www.sapmaterial.com/idoc_sample.html
http://www.****************/Tutorials/ALE/ALEMainPage.htm
An IDoc is not a process.
The term IDoc stands for intermediate document. It is simply a data container used to exchange information between any two processes that can understand the syntax and semantics of the data. An IDoc is created as a result of executing an outbound ALE or EDI process. In an inbound ALE or EDI process, an IDoc serves as input to create an application document.
IDocs are stored in the database.
In the SAP system, they are stored in database tables. Several utilities are available to display the information contained in an IDoc and present it in different ways. For details, refer to Chapter 11, "Monitoring the Interface."
Every IDoc has a unique number.
When an IDoc is generated in the system, a unique number is assigned to it. This number is unique within a client.
IDocs are independent of the sending and receiving systems. They can be used for SAP-to-SAP and SAP to non-SAP process communication as long as the participating processes can understand the syntax and semantics of the data.
IDocs are based on EDI standards, ANSI ASC X12 and EDIFACT, but are closer to the EDIFACT standards. The size and format of data elements in an IDoc type are derived from these standards wherever applicable. For example, if a material number is represented by 20 characters in an EDIFACT message, the corresponding data element in the IDoc is also 20 characters. If there is a conflict in data size between standards, the one with greater length is adopted. This approach ensures compatibility with most standards.
IDocs are independent of the direction of data exchange. An inbound and an outbound process can use an IDoc. For example, the ORDERS01 IDoc is used by the Purchasing module to send a purchase order, and is also used by the Sales and Distribution module to accept a sales order. Using this technique avoids creating redundant IDoc types for the same information.
IDocs can be viewed in a text editor and do not contain any binary data. Data is stored in character format. When transferred to the operating system, an IDoc is stored in a file in text format and can be viewed using a regular text editor. However, the contents make sense only if you understand the structure and format of the data in that IDoc. In the Appendix, "FAQs, User Exits, and Miscellaneous Resources," you will find an example of an IDoc file.
Hope this helps, Do reward.
Edited by: Runal Singh on Mar 5, 2008 6:09 PM -
How to import a csv file and read in sap ui5?
Hi,
I want to import a file and read it contents to bind it to table.How to do it?
Thanks in advance.I tried to do this all from within the application but found it easier to just start with a JSON file. But, you can use a JS library to convert your CSV into JSON from within the application like this one:
archan937/csonv.js · GitHub
I just converted my CSV to JSON. Once you have that, all you need to do is instantiate a model for it and bind to table.
onInit: function () {
var oModel = new sap.ui.model.json.JSONModel("PATH TO YOUR JSON FILE");
this.getView().setModel(oModel);
<Table id="idProductsTable"
inset="false"
items="{
path: '/ProductCollection',
sorter: {
path: 'Name'
}">
The UI5 demo kit is a good resource. I believe it'll be same/similar for SAPUI5:
OpenUI5 SDK - Demo Kit
See here for example of defining your model and binding to a table:
sap.m Explored -
Plugin issue after using SignPlugin and Reader-enabling
Hi all,
I would like to ask for a help with plugin that we have developed for Adobe Reader.
We are running into an issue with the plug-in and I was hoping that you can help me out. It looks like plug-in works perfectly in the Acrobat but we have an issue with getting it to work with Reader as described below. I would greatly appreciate your help.
We have a problem with plugin after signing it using RIKLA certificate provided by Adobe and Reader-enabling.
Our plugin has been developed to allow users to sign PDF XML data from Reader user interface using custom library (sign library) and msxml3.dll library ( to transform PDF form XML into custom XML format). Plugin target is Adobe Reader 9 and it has been tested using Adobe Acrobat 9 earlier. Recently we received RIKLA certification key and after we tried to sign plugin and use it in Reader we started to have problems.
Plug-in, compiled directly from source code and installed in Adobe Acrobat 9 is working correctly. We haven’t experienced any issues and everything seems to be working properly.
The same plug-in signed using SignPlugin tools from Acrobat SDK 9.1 (command SignPlugin -kp keypairFileName -cf Reader_Integrated_Key_FileName MyPlugin.api) and RIKLA key is not working correctly in Adobe Reader 9.
The problem appears when plugin is trying to access external library msxml3.dll and execute createProcessor() function. The same function work properly in Adobe Acrobat 9 before sing plug-in with RIKLA key.
Below there is fragment with code that doesn’t work in Adobe Reader after reader-enabling but works in Adobe Acrobat.
Plug-in crushes in line pProcessor = pTemplate->createProcessor();.
try{
pProcessor = pTemplate->createProcessor();
} catch(_com_error &e) {
printf("Error setting XSL style sheet : %s\n",
(const char*)_bstr_t(e.Description()));
AVAlertNote("Error setting XSL style sheet");
AVAlertNote(e.Description());
exit(-1);
Code that we use in catch() block lets us know that error source is “msxml3.dll” library.
As we have discovered problem occurs only after Reader-enabling .api plugin file. Clear compiled .api file works properly in Adobe Acrobat 9 without any problems.
We would like to know if you have experienced any similar issues? If yes, what have caused them?
Why same plugin is working in Acrobat 9 before signing and after signing using provided certificate it stops working?
Are there any restrictions of using external libraries in Reader that are not working there, and these restrictions are not obeyed in Acrobat?
Any help would be greatly appreciated.Hi Irosent,
Is there a way that Acrobat and Reader differentiate between library initialization?
Would it be useful if I place any part of code or project configuration for you so maybe you will be able to help?
Libraries that we use (our own dll files) we place in windows/system32 folder (there also exists msxml3.dll file that we use).
Here are preprocessor definitions that we have defined:
_AFXDLL
_USERDLL
READER_PLUGIN
NDEBUG
WIN_PLATFORM
WIN32
_WINDOWS
WIN_ENV
ACRO_SDK_LEVEL=0x00090000
As for library msxml3.dll that we use in code we have:
#import <msxml3.dll> named_guids
using namespace MSXML2;
MSXML2::IXMLDOMDocumentPtr
pXml(MSXML2::CLSID_DOMDocument);
MSXML2::IXMLDOMDocumentPtr
pXslt(CLSID_FreeThreadedDOMDocument);
IXSLTemplatePtr pTemplate(CLSID_XSLTemplate);
IXSLProcessorPtr pProcessor;
Later there is a part of code that I have posted in first post and where plugin crashes.
I would really appreciate your help. -
Interruptions when I use "Write" and "Read" in the same vi.
When I use "Port Write" and "Port Read" together in the same vi and I set the output to be high level, the signal becomes oscillatory. I have read one anterior message about similar problem (using "Write to Digital Line" and "Read from Digital Line" instead of "Port Write" and "Port Read") and I proceeded as the solution suggested in the answer. However, it didn´t work.
Attached, I am sending the vi I used to test the solution.
How can I fix this problem?
Attachments:
IO.vi 35 KBHi Spencer!
The device I am using is a PCI6024-E board. I have contacted the NI Suport and now I see what I was doing wrong: in fact, I was calling a DIO Port Config.vi for each of the ports ("Port Read" and "Port "Write"), but it was done inside of a While loop (usually, most of the applications here in the lab are recursive, so it´s common for us to use big while loops for the whole program). Putting them outside (as you said, at the beginning of the program), it worked! Actually, I can´t see any reason for the program to work when the calling is outside the loop, but the important is that now it´s running properly.
Thanks a lot, Spencer! -
Using CR and Xcelsius with SAP BW - what is the minimal installation?
Hi,
If this question is allready asked and answered several times i appologize.. but I'm having a hard time finding the correct information.
Our situation is that we run an SAP ERP and SAP BW solution with a federated SAP Enterprise Portal on top. The users require more graphical solutions for both static reporting and dynamic dashboards. So we want to use Crystal Reports and Xcelsius to provide frontend interface, but we want to do as little as possible backend, i.e avoid installing a full BO server with roles etc.
I appriciate that we need SAP NW EhP 1 SPS 5 to load data directly into Xcelsius and the BO integration kit transports have to be loaded into the BW system for full CR connectivity.
The problem that I'm having a hard time finding anwsers to is if this setup is capable of storing and and distributing the CR reports and dashboards to endusers? Can CR reports be stored on the BW server? Or can the CR reports and the dashboards be stored in the KW part of the portal?
Another partly related question, what desktop tool does the enduser need to run CR reports that updates with data from the BW server?
Alot of customers will have an SAP environment without any BO server/tools. Naturally we want to change as little as possible. A guide to what is needed for each BO BI tool to be implemented on SAP BW would be appriciated.Hi
for the CR reports you need a BO Enterprise (or BO Edge) installation. The access to the BOBJ server is done transparently for your SAP BW users (they are able to start their reports in SAP GUI) but the reports are not stored on the SAP system rather in the BO repository.
Regards,
Stratos -
Using forms6i and reading data from MS SQL server 7
Hi!
I have been given a new task to connect to Microsoft SQL SERVER 7 with Oracle 6/6i development with ODBC and extract specific data.
I am realy stuck with this I hope some one will help me with this as soon as possible.
thankaI did a similar thing with developer 2000 (Form 4.5) and SQL server6.5.
There are lots of things involved and there will be issues that need to be resolved in you application but you can take one thing at a time and you should be able to do it.
-First make sure that your SQL server is up and running.
-Then make a client machine that connects to SQL server.
-On the client install your Form6 or 6i.
-Install ODBC manager on your Client Machine.
-Get the Oracle ODBC driver for SQL server.
-There is a document available with developer 2000 for open data source. It should be with your Form6/6i documentation. It has got a section for connection with SQL server.
Start with this and where ever you get stuck ask away question on the forum.
Hope this help -
Creating an applescript to place a call and read me my new email!
I was wondering if anyone could help me. I have been trying to put together an applescript that could call me using skype and read me my new important email messages (apple mail). I have been able to find two scripts on the internet in various other forums that have been super helpful but I am new to applescripting and have been unable to combine them to make one beautiful fully functioning script.
Read my email script:
http://discussions.apple.com/thread.jspa?threadID=1838078
using terms from application "Mail"
on perform mail action with messages theSelectedMessages for rule theRule
repeat with eachMessage in theSelectedMessages
-- Process the current message
-- first get the text of the message:
set messageBody to content of eachMessage
-- now speak it
say messageBody
end repeat
end perform mail action with messages
end using terms from
I have tested this script by making it a mail rule, and it will successfully read my new email message to me.
Skype Script:
http://forum.skype.com/index.php?showtopic=318781
tell application "Skype"
activate
set theScript to "My script"
set theStartingTime to current date
send command "CALL echo123" script name theScript --replace echo123 with another phone number
set theCallID to the second word of the result
set myResult to "OK"
set theStatus to "nothing"
repeat until (((current date) - theStartingTime) > 60) or ¨
(theStatus is equal to "FINISHED")
set theCommand to "GET CALL " & theCallID & " STATUS"
send command theCommand script name theScript
set theStatus to the last word of the result
display dialog the result giving up after 1
if theStatus is equal to "INPROGRESS" then
delay 8 --I'm not sure how you'd detect an answering machine here
say "This is the message I'm trying to send."
--This is how to end the call and let the repeat loop finish.
set theCommand to "SET CALL " & theCallID & " STATUS FINISHED"
send command theCommand script name theScript
end if
end repeat
end tell
I have also been able to successfully use this script to place a phone call to a landline or skype user account. This script focuses on just using a standard preset message. I am trying to write a script that will eventually call me on my cellphone and read new important email messages to me. I understand how to use the mail rules to accomplish this, but I am lacking in the scripting end.
I would really appreciate anyone who could shed some light on how to do this.
Thanks in advance for any help.
Respectfully,
MichaelHungry Joe,
Thanks for all your help on this. I was amazed at the "answer detection" script. I hadn't even thought of that at all. Over the weekend, I was more focused on waiting a specific time, versus when the actual call was answered. I like your approach much better.
I tweaked with it all for quite a while tonight but felt like I didn't get far enough. I was able to consolidate everything down to three scripts. I was really hoping for two scripts, or to somehow make an "application bundle" or "script bundle." I just couldn't figure out how you write the main script. I have only written one other application bundle.
So far this what I have:
Mail Rule #1 Triggers this script, this is a combination of the simple call script but with your answer detection capabilities. I was never able to get the code right for the timeout option. It kept kicking back an error.
tell application "Skype"
send command "CALL echo123" script name "My Script"
set isConnected to false
repeat while not isConnected
repeat with thisWindow in windows
set theTitle to name of thisWindow
-- // Call windows have the title [time] | Call with FooBar
if theTitle contains "Call with echo123" then
-- // You might also want to append your phone number or skype name
-- // to make sure that it's you who is connected to the call
set isConnected to true
exit repeat
end if
end repeat
if isConnected then exit repeat
delay 1
end repeat
end tell
Mail Rule #2 triggers this slightly cheesy but functional script:
on performmailaction(info)
tell application "System Events" to set volume 6
tell application "Mail"
set the_messages to |SelectedMessages| of info
repeat with a_message in the_messages
set the_sender to extract name from sender of a_message
if (junk mail status of a_message) is not true then
say "Hi this is mac you have new mail from " & the_sender
end if
end repeat
end tell
end performmailaction
Mail Rule #3 triggers the final script which reads the email:
using terms from application "Mail"
on perform mail action with messages theSelectedMessages for rule theRule
repeat with eachMessage in theSelectedMessages
-- Process the current message
-- first get the text of the message:
set messageBody to content of eachMessage
-- now speak it
delay 7
say messageBody
end repeat
end perform mail action with messages
end using terms from
I spent a couple hours tonight, trying to incorporate the last two scripts into one, but I wasn't successful. I also came across this script in the my applescripts folder that comes with leopard. I tried to adjust it so that it joined one of the other scripts above but wasn't able to get it to go. It kept giving me syntax errors.
Speak Sender and Subject
Copyright © 2003-2006 Apple Computer, Inc.
You may incorporate this Apple sample code into your program(s) without
restriction. This Apple sample code has been provided "AS IS" and the
responsibility for its operation is yours. You are not permitted to
redistribute this Apple sample code as "Apple sample code" after having
made changes. If you're going to redistribute the code, we require that
you make it clear that the code was descended from Apple sample code,
but that you've made changes.
This script speaks the sender and subject of each selected message.
tell application "Mail"
set selectedMessages to selection
set selectionCount to (count of selectedMessages)
if selectionCount is greater than 1 then
set speakString to "There are " & selectionCount & " selected messages." & return
else if selectionCount is equal to 1 then
set speakString to "There is " & selectionCount & " selected message." & return
else -- selectionCount is less than or equal to 0
set speakString to "There are no selected messages."
end if
repeat with messageNumber from 1 to selectionCount
set theMessage to item messageNumber of selectedMessages
set theSubject to subject of theMessage
set theSender to extract name from (sender of theMessage)
set speakString to speakString & "Message " & (messageNumber as string) & " From: " & theSender & ", Subject: " & theSubject & ". " & return
end repeat
end tell
say speakString
I was never able to get it go. It would be nice to have 1 simple script that handles all of the mail function.
Is it just a dream to have 2 scripts?
Thanks again for everything.
Michael~
PS Where did you learn applescript? -
Reading XML file using BAPI and then uploading that xml file data into SAP
I am getting a xml file from Java server. I need to take
data from this file using BAPI and need to upload into SAP using SAP.
Please tell me how to read XML files using BAPI's.<b>SDIXML_DATA_TO_DOM</b> Convert SAP data (elementary/structured/table types) into DOM (XML
<b>SDIXML_DOM_TO_XML</b> Convert DOM (XML) into string of bytes that can be downloaded to PC or application server
<b>SDIXML_DOM_TO_SCREEN</b> Display DOM (XML)
<b>SDIXML_DOM_TO_DATA</b>
data: it_table like t001 occurs 0.
data: l_dom TYPE REF TO IF_IXML_ELEMENT,
m_document TYPE REF TO IF_IXML_DOCUMENT,
g_ixml TYPE REF TO IF_IXML,
w_string TYPE XSTRING,
w_size TYPE I,
w_result TYPE I,
w_line TYPE STRING,
it_xml TYPE DCXMLLINES,
s_xml like line of it_xml,
w_rc like sy-subrc.
start-of-selection.
select * from t001 into table it_table.
end-of-selection.
initialize iXML-Framework ****
write: / 'initialiazing iXML:'.
class cl_ixml definition load.
g_ixml = cl_ixml=>create( ).
check not g_ixml is initial.
write: 'ok'.
create DOM from SAP data ****
write: / 'creating iXML doc:'.
m_document = g_ixml->create_document( ).
check not m_document is initial.
write: 'ok'.
write: / 'converting DATA TO DOM 1:'.
CALL FUNCTION 'SDIXML_DATA_TO_DOM'
EXPORTING
NAME = 'IT_TABLE'
DATAOBJECT = it_table[]
IMPORTING
DATA_AS_DOM = l_dom
CHANGING
DOCUMENT = m_document
EXCEPTIONS
ILLEGAL_NAME = 1
OTHERS = 2.
if sy-subrc = 0. write 'ok'.
else. write: 'Err =', sy-subrc.
endif.
check not l_dom is initial.
write: / 'appending DOM to iXML doc:'.
w_rc = m_document->append_child( new_child = l_dom ).
if w_rc is initial. write 'ok'.
else. write: 'Err =', w_rc.
endif.
visualize iXML (DOM) ****
write: / 'displaying DOM:'.
CALL FUNCTION 'SDIXML_DOM_TO_SCREEN'
EXPORTING
DOCUMENT = m_document
EXCEPTIONS
NO_DOCUMENT = 1
OTHERS = 2.
if sy-subrc = 0. write 'ok'.
else. write: 'Err =', sy-subrc.
endif.
convert DOM to XML doc (table) ****
write: / 'converting DOM TO XML:'.
CALL FUNCTION 'SDIXML_DOM_TO_XML'
EXPORTING
DOCUMENT = m_document
PRETTY_PRINT = ' '
IMPORTING
XML_AS_STRING = w_string
SIZE = w_size
TABLES
XML_AS_TABLE = it_xml
EXCEPTIONS
NO_DOCUMENT = 1
OTHERS = 2.
if sy-subrc = 0. write 'ok'.
else. write: 'Err =', sy-subrc.
endif.
write: / 'XML as string of size:', w_size, / w_string.
describe table it_xml lines w_result.
write: / 'XML as table of', w_result, 'lines:'..
loop at it_xml into s_xml.
write s_xml.
endloop.
write: / 'end of processing'.
end of code
Hope this will be useful.
regards
vinod -
End to end scenario using Webservic and SAP XI
Hi Experts,
I have read many blogs regarding Integrating XI using WebService, SOAP, HTTP for many scenarios but I am still confused and no blogs were clearly saying about the end to end scenario what happens where and how?
My question is could any one please please please explain me why we are using Webservice if you explain me with an CREDIT CHECK scenario using XI and Webservice that would be very fare.
Thanks in advance,
Cheers!!!!Hi
Did you get to check this article,
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/9030d1ca-cf07-2b10-8b9c-f027fbc91ffd
regards
Sameer -
Using join and batch reading in the same query
Hi,
I wonder if it is possible to use "Joining" and "batch reading" in the same query.
For example I Have
A -> 1-1 B
A -> 1-1 B
B -> 1-M C
This is the case where I have two separate 1-1 relationships to the same class B from A. Toplink 10.0.3 can manage it nicely through joining.
Now, I would like to read a set of As (with its 2 Bs) and all Cs for each B.
It seems that the following configuration does not work:
A -> 1-1 B (use joining)
A -> 1-1 B (use joining)
B -> 1-M C (Batch read)
Any help would be greatly appreciated
Tony.James,
Would you be so kind to look at the following code?
Am I formulating it correctly to achieve my desired behavior?
Trip.class -> 1-1 PickupStop
Trip.class -> 1-1 DropoffStop
PickupStop and DropoffStop extend Stop and use same table (STOP)
Stop -> 1-M StopEvents
I would like to fetch all Trips, with their Stops and all StopEvents in 2 queries:
1. Trip joined with Stop
2. Batchread StopEvents
Code:
ReadAllQuery raq = new ReadAllQuery(Trip.class);
Expression qexp1 = new ExpressionBuilder();
Expression qexp2 = new ExpressionBuilder();
raq.addJoinedAttribute("pickupStop");
raq.addJoinedAttribute("dropoffStop");
raq.addBatchReadAttribute(qexp1.get("pickupStop").get("vStopEvents"));
raq.addBatchReadAttribute(qexp2.get("dropoffStop").get("vStopEvents")); -
Organization announcements Using CRM and SAP portal
Dear Gurus,
I am trying to build functionality for an organization to do their announcements using CRM 7.0, Once the announcement is published it should be visible on the SAP Portal. I am planning to do like this:
1) Create a campaign using mail form (Announcement content) and target group
2) Select the communication method as e-mail and I have done settings in SPRO to create the activity for an outgoing mail
3) Release the campaign and execute the campaign
4) Upon execution the CRM system will create the activity for an outgoing email (announcement)
4) Create an iView in portal
5) Pull the activities created on CRM and display on the portal iView
My questions are:
1) Is there any standard iView to do this
2) Is there any other standard functionality available to do this announcement using CRM and Portal
3) What are the lining table between Campaign activity and mail forms (e-mail content for announcement) - When I go activity search on CRM WEB UI I can see these activities and also I can see these activities on CRMD_orderadm_h, but unable to get the link tables between this activity and outgoing mail forms.
Thank you in advance and appreciate your help.
Regards,
ReddyDear Gurus,
I am trying to build functionality for an organization to do their announcements using CRM 7.0, Once the announcement is published it should be visible on the SAP Portal. I am planning to do like this:
1) Create a campaign using mail form (Announcement content) and target group
2) Select the communication method as e-mail and I have done settings in SPRO to create the activity for an outgoing mail
3) Release the campaign and execute the campaign
4) Upon execution the CRM system will create the activity for an outgoing email (announcement)
4) Create an iView in portal
5) Pull the activities created on CRM and display on the portal iView
My questions are:
1) Is there any standard iView to do this
2) Is there any other standard functionality available to do this announcement using CRM and Portal
3) What are the lining table between Campaign activity and mail forms (e-mail content for announcement) - When I go activity search on CRM WEB UI I can see these activities and also I can see these activities on CRMD_orderadm_h, but unable to get the link tables between this activity and outgoing mail forms.
Thank you in advance and appreciate your help.
Regards,
Reddy -
Problem with writing and reading using serialization
I am having a problem with writing and reading an object that has another object in it. The purpose of the class is to write a order that has multiple items in it. And there will be several orders. This is for an IB project, where one of the requirements is to utilize a hierarchical composite data structure. That is, it is "one that contains more than one element and at least one of the elements is a composite data structure. Examples are, an array or linked list of records, a record that has one field that is another record, or an array". The code is shown below:
The error produced is
java.lang.NullPointerException
at SamsonRubberIndustries.CustomerOrderDetails.createCustOrdDetailsScreen(CustomerOrderDetails.java:150)
at SamsonRubberIndustries.CustomerOrderDetails$1.run(CustomerOrderDetails.java:78)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
public class CustOrdObject implements Serializable {
public int CustID;
public int CustOrderID;
public Object OrderDate;
public InnerCustOrdObject[] innerCustOrdObj;
public float GrandTotal;
public int MaxItems;
public CustOrdObject() {}
public CustOrdObject(InnerCustOrdObject[] innerCustOrdObj,
int CustID, int CustOrderID, Object OrderDate,
float GrandTotal, int innerarrlength, int innerarrpos, int MaxItems) {
this.CustID = CustID;
this.CustOrderID = CustOrderID;
this.OrderDate = OrderDate;
this.GrandTotal = GrandTotal;
this.MaxItems = MaxItems;
this.innerCustOrdObj = new InnerCustOrdObject[MaxItems];
public InnerCustOrdObject[] getInnerCustOrdObj() {
return innerCustOrdObj;
public void setInnerCustOrdObj(InnerCustOrdObject[] innerCustOrdObj) {
this.innerCustOrdObj = innerCustOrdObj;
public int getCustID() {
return CustID;
public void setCustID(int custID) {
CustID = custID;
public int getCustOrderID() {
return CustOrderID;
public void setCustOrderID(int custOrderID) {
CustOrderID = custOrderID;
public Object getOrderDate() {
return OrderDate;
public void setOrderDate(Object orderDate) {
OrderDate = orderDate;
public void setGrandTotal(float grandTotal) {
GrandTotal = grandTotal;
public float getGrandTotal() {
return GrandTotal;
public int getMaxItems() {
return MaxItems;
public void setMaxItems(int maxItems) {
MaxItems = maxItems;
public class InnerCustOrdObject implements Serializable{
public int ItemNumber;
public float UnitPrice;
public int QuantityRequired;
public float TotalPrice;
public InnerCustOrdObject() {}
public InnerCustOrdObject(int ItemNumber, float
UnitPrice, int QuantityRequired, float TotalPrice){
this.ItemNumber = ItemNumber;
this.UnitPrice = UnitPrice;
this.QuantityRequired = QuantityRequired;
this.TotalPrice = TotalPrice;
public int getItemNumber() {
return ItemNumber;
public void setItemNumber(int itemNumber) {
ItemNumber = itemNumber;
public int getQuantityRequired() {
return QuantityRequired;
public void setQuantityRequired(int quantityRequired) {
QuantityRequired = quantityRequired;
public float getTotalPrice() {
return TotalPrice;
public void setTotalPrice(float totalPrice) {
TotalPrice = totalPrice;
public float getUnitPrice() {
return UnitPrice;
public void setUnitPrice(float unitPrice) {
UnitPrice = unitPrice;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.swing.*;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.DefaultTableModel;
public class CustomerOrderDetails extends CommonFeatures{
//TODO
private static int MAX_ORDERS = 200;
private static int MAX_ORDERITEMS = 100;
private static int MaxRecord;
private static int CurrentRecord = 1;
private static int currentItem;
private static int MaxItems;
private static boolean FileExists, recFileExists;
private static CustOrdObject[] orderDetails = new CustOrdObject[MAX_ORDERS];
private static InnerCustOrdObject[] innerCustOrdObj = new InnerCustOrdObject[MAX_ORDERITEMS];
private static File OrderDetailsFile = new File("CustOrdDetails.dat");
private static File OrdRecordNumStore = new File("OrdRecordNumStore.txt");
private static PrintWriter writeFile;
private static BufferedReader readFile;
private static ObjectOutputStream objOut;
private static ObjectInputStream objIn;
//Set format for date
SimpleDateFormat simpleDF = new SimpleDateFormat("dd MM yyyy");
//--<BEGINNING>--Declaring Interface Variables------------------------------------------//
private JPanel innertoppanel, innercenterpanel, innerbottompanel, innerrightpanel, innerleftpanel;
private JLabel CustIDLbl, CustOrderIDLbl, OrderedDateLbl, GrandTotLbl, ItemNumberLbl,UnitPriceLbl, QuantityReqLbl, TotPriceLbl;
private JTextField CustIDTxt, CustOrderIDTxt, OrderedDateTxt, GrandTotTxt, ItemNumberTxt, UnitPriceTxt, QuantityReqTxt, TotPriceTxt;
private JButton addrecordbtn, savebtn, externalprevbtn, externalnextbtn, internalprevbtn, internalnextbtn, gotorecordbtn, additemreqbtn;
//--<END>--Declaring Interface Variables------------------------------------------------//
public static void main(String[] args) {
final CustomerOrderDetails COD = new CustomerOrderDetails();
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
try {
UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
COD.createCustOrdDetailsScreen();
} catch (Exception eb) {
eb.printStackTrace();
//--<BEGINNING>--Creating CustomerOrderDetails Screen---------------------------------------//
public JFrame createCustOrdDetailsScreen() {
createDefaultFrame();
mainframe.setSize(800,500);
createContainerPanel();
containerpanel.add(createCustOrdDetailsTitle(), BorderLayout.NORTH);
containerpanel.add(createCustOrdDetailsMainPanel(), BorderLayout.CENTER);
//containerpanel.add(createCustOrdDetailsLeftNavButtons(), BorderLayout.WEST);
//containerpanel.add(createCustOrdDetailsRightNavButtons(), BorderLayout.EAST);
containerpanel.add(createCustOrdDetailsButtons(), BorderLayout.SOUTH);
mainframe.setContentPane(containerpanel);
mainframe.setLocationRelativeTo(null);
mainframe.setVisible(true);
//--<BEGINNING>--Checks to see whether CRecordNumberStore file exists-------------------------------//
if (OrdRecordNumStore.exists() == true) {
recFileExists = true;
}else {
recFileExists = false;
if (recFileExists == true) {
MaxRecord = readRecordNumber();
CurrentRecord = MaxRecord;
//readOrder();
//readInnerOrderRecord(CurrentRecord);
System.out.println("Current Record " +CurrentRecord);
System.out.println("Max Record " +MaxRecord);
}else{
MaxRecord = 1;
writeRecordNumber(MaxRecord);
CustOrderIDTxt.setText(""+MaxRecord);
System.out.println("Current Record " +CurrentRecord);
System.out.println("Max Record " +MaxRecord);
//--<END>--Checks to see whether CRecordNumberStore file exists--------------------------------------//
if(readOrder() != null){
orderDetails = (CustOrdObject[]) readOrder();
innerCustOrdObj = orderDetails[CurrentRecord].getInnerCustOrdObj();
MaxItems = orderDetails[CurrentRecord].getMaxItems();
if(CurrentRecord > 1 && CurrentRecord < MaxRecord){
externalnextbtn.setEnabled(true);
externalprevbtn.setEnabled(true);
if(CurrentRecord >= MaxRecord){
externalnextbtn.setEnabled(false);
getFieldText(CurrentRecord-1);
}else{
orderDetails[CurrentRecord] = new CustOrdObject();
currentItem = 1;
return mainframe;
//--<END>--Creating CustomerOrderDetails Screen---------------------------------------------//
public JPanel createCustOrdDetailsTitle(){
createTitlePanel();
titlepanel.setBackground(TxtfontColor);
label.setText("- Customer Order Details -");
labelpanel.setBackground(TxtfontColor);
label.setForeground(Color.white);
createbuttonpanel();
buttonpanel.setBackground(TxtfontColor) ;
buttonpanel.add(createReturnToMainMenuButton());
titlepanel.add(labelpanel, BorderLayout.WEST);
titlepanel.add(buttonpanel, BorderLayout.EAST);
return titlepanel;
public JPanel createCustOrdDetailsMainPanel(){
createmainpanel();
mainpanel.setBackground(TxtfontColor);
mainpanel.setLayout(new BorderLayout());
mainpanel.setBorder(BorderFactory.createTitledBorder(""));
mainpanel.add(createInnerTopPanel(), BorderLayout.NORTH);
mainpanel.add(createInnerCenterPanel(), BorderLayout.CENTER);
mainpanel.add(createInnerBottomPanel(), BorderLayout.SOUTH);
mainpanel.add(createInnerRightPanel(), BorderLayout.EAST);
mainpanel.add(createInnerLeftPanel(), BorderLayout.WEST);
return mainpanel;
public JPanel createInnerTopPanel(){
innertoppanel = new JPanel(new GridBagLayout());
innertoppanel.setBackground(TxtfontColor);
GridBagConstraints GBC = new GridBagConstraints();
GBC.fill = GridBagConstraints.HORIZONTAL;
//Setting Font Type and Size
Font font = new Font("Arial", Font.BOLD, 11);
CustIDLbl = new JLabel("Customer ID");
CustIDLbl.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
CustIDLbl.setFont(font);
CustIDLbl.setForeground(LblfontColor);
GBC.gridx = 1;
GBC.gridy = 1;
innertoppanel.add(CustIDLbl, GBC);
CustIDTxt = new JTextField(20);
CustIDTxt.setEditable(true);
GBC.gridx = 2;
GBC.gridy = 1;
innertoppanel.add(CustIDTxt, GBC);
GBC.gridx = 3;
GBC.gridy = 1;
innertoppanel.add(Box.createHorizontalStrut(220), GBC);
OrderedDateLbl = new JLabel("Order Date");
OrderedDateLbl.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
OrderedDateLbl.setFont(font);
OrderedDateLbl.setForeground(LblfontColor);
GBC.gridx = 4;
GBC.gridy = 1;
innertoppanel.add(OrderedDateLbl, GBC);
//Get today's date
Date todaydate = new Date();
OrderedDateTxt = new JTextField(simpleDF.format(todaydate), 20);
OrderedDateTxt.setHorizontalAlignment(JTextField.CENTER);
OrderedDateTxt.setEditable(false);
GBC.gridx = 5;
GBC.gridy = 1;
innertoppanel.add(OrderedDateTxt, GBC);
CustOrderIDLbl = new JLabel("Customer Order ID");
CustOrderIDLbl.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
CustOrderIDLbl.setFont(font);
CustOrderIDLbl.setForeground(LblfontColor);
GBC.gridx = 1;
GBC.gridy = 2;
innertoppanel.add(CustOrderIDLbl, GBC);
CustOrderIDTxt = new JTextField(20);
CustOrderIDTxt.setEditable(false);
GBC.gridx = 2;
GBC.gridy = 2;
innertoppanel.add(CustOrderIDTxt, GBC);
return innertoppanel;
public JPanel createInnerCenterPanel(){
innercenterpanel = new JPanel(new GridBagLayout());
innercenterpanel.setBackground(TxtfontColor);
innercenterpanel.setBorder(BorderFactory.createLoweredBevelBorder());
GridBagConstraints GBC = new GridBagConstraints();
GBC.fill = GridBagConstraints.HORIZONTAL;
//Setting Font Type and Size
Font font = new Font("Arial", Font.BOLD, 11);
ItemNumberLbl = new JLabel("Item Number");
ItemNumberLbl.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
ItemNumberLbl.setFont(font);
ItemNumberLbl.setForeground(LblfontColor);
GBC.gridx = 1;
GBC.gridy = 1;
innercenterpanel.add(ItemNumberLbl, GBC);
ItemNumberTxt = new JTextField(20);
GBC.gridx = 2;
GBC.gridy = 1;
innercenterpanel.add(ItemNumberTxt, GBC);
UnitPriceLbl = new JLabel("Unit Price");
UnitPriceLbl.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
UnitPriceLbl.setFont(font);
UnitPriceLbl.setForeground(LblfontColor);
GBC.gridx = 1;
GBC.gridy = 2;
innercenterpanel.add(UnitPriceLbl, GBC);
UnitPriceTxt = new JTextField(20);
//UnitPriceTxt.setEditable(false);
GBC.gridx = 2;
GBC.gridy = 2;
innercenterpanel.add(UnitPriceTxt, GBC);
QuantityReqLbl = new JLabel("Quantity Required");
QuantityReqLbl.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
QuantityReqLbl.setFont(font);
QuantityReqLbl.setForeground(LblfontColor);
GBC.gridx = 1;
GBC.gridy = 3;
innercenterpanel.add(QuantityReqLbl, GBC);
QuantityReqTxt = new JTextField(20);
//QuantityReqTxt.setEditable(false);
GBC.gridx = 2;
GBC.gridy = 3;
innercenterpanel.add(QuantityReqTxt, GBC);
TotPriceLbl = new JLabel("Total Price");
TotPriceLbl.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
TotPriceLbl.setFont(font);
TotPriceLbl.setForeground(LblfontColor);
GBC.gridx = 1;
GBC.gridy = 4;
innercenterpanel.add(TotPriceLbl, GBC);
TotPriceTxt = new JTextField(20);
//TotPriceTxt.setEditable(false);
GBC.gridx = 2;
GBC.gridy = 4;
innercenterpanel.add(TotPriceTxt, GBC);
return innercenterpanel;
public JPanel createInnerBottomPanel(){
innerbottompanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
innerbottompanel.setBackground(TxtfontColor);
//Setting Font Type and Size
Font font = new Font("Arial", Font.BOLD, 11);
GrandTotLbl = new JLabel("Grand Total");
GrandTotLbl.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
GrandTotLbl.setFont(font);
GrandTotLbl.setForeground(LblfontColor);
innerbottompanel.add(GrandTotLbl);
innerbottompanel.add(Box.createHorizontalStrut(30));
GrandTotTxt = new JTextField(20);
innerbottompanel.add(GrandTotTxt);
return innerbottompanel;
public JPanel createInnerRightPanel(){
innerrightpanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
innerrightpanel.setBackground(TxtfontColor);
innerrightpanel.setLayout(new BoxLayout(navrightpanel, BoxLayout.Y_AXIS));
innerrightpanel.setBorder(BorderFactory.createLoweredBevelBorder());
innerrightpanel.setLayout(new GridBagLayout());
GridBagConstraints GBC = new GridBagConstraints();
GBC.fill = GridBagConstraints.HORIZONTAL;
internalnextbtn = new JButton(createNextButtonIcon());
GBC.gridx = 1;
GBC.gridy = 1;
internalnextbtn.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent evt){
//getInnerFieldText(currentItem);
internalprevbtn.setEnabled(true);
if(currentItem < MaxItems){
++CurrentRecord;
//readOrder();
//readInnerOrderRecord(CurrentRecord);
setInnerFieldText(currentItem);
System.out.println(CurrentRecord);//Checking RECORD_NUM
if(currentItem == MaxItems){
internalnextbtn.setEnabled(false);
innerrightpanel.add(internalnextbtn, GBC);
return innerrightpanel;
public JPanel createInnerLeftPanel(){
innerleftpanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
innerleftpanel.setBackground(TxtfontColor);
innerleftpanel.setBorder(BorderFactory.createLoweredBevelBorder());
innerleftpanel.setForeground(Color.BLACK);
innerleftpanel.setLayout(new GridBagLayout());
GridBagConstraints GBC = new GridBagConstraints();
GBC.fill = GridBagConstraints.HORIZONTAL;
internalprevbtn = new JButton(createPreviousButtonIcon());
GBC.gridx = 1;
GBC.gridy = 1;
internalprevbtn.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent evt){
//getInnerFieldText(currentItem);
internalnextbtn.setEnabled(true);
if(currentItem == 1){
internalprevbtn.setEnabled(false);
if(currentItem > 0){
--currentItem;
//readOrder();
setInnerFieldText(currentItem);
innerleftpanel.add(internalprevbtn, GBC);
return innerleftpanel;
public JPanel createCustOrdDetailsButtons(){
createbuttonpanel();
buttonpanel.setBackground(TxtfontColor);
externalprevbtn = new JButton(createPreviousButtonIcon());
externalprevbtn.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent evt){
getFieldText(CurrentRecord);
externalnextbtn.setEnabled(true);
if(CurrentRecord == 1){
externalprevbtn.setEnabled(false);
if(CurrentRecord > 0){
--CurrentRecord;
setFieldText(CurrentRecord);
System.out.println(CurrentRecord);//Checking RECORD_NUM
buttonpanel.add(externalprevbtn);
addrecordbtn = new JButton("Add Record", createAddButtonIcon());
addrecordbtn.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent evt){
try{
MaxRecord = readRecordNumber();
MaxRecord++;
writeRecordNumber(MaxRecord);
//--<BEGINNING>--Clear Fields-------------------------------------------------------//
CustIDTxt.setText("");
CustOrderIDTxt.setText(""+MaxRecord);
//Get today's date
Date todaydate = new Date();
OrderedDateTxt.setText(""+simpleDF.format(todaydate));
ItemNumberTxt.setText("");
UnitPriceTxt.setText("");
QuantityReqTxt.setText("");
TotPriceTxt.setText("");
GrandTotTxt.setText("");
//--<END>--Clear Fields-------------------------------------------------------------//
externalnextbtn.setEnabled(false);
externalprevbtn.setEnabled(true);
System.out.println(MaxRecord);
} catch(Exception ec){ec.printStackTrace();}
buttonpanel.add(addrecordbtn);
savebtn = new JButton("Save Data", createSaveButtonIcon());
savebtn.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent evt){
setFieldText(CurrentRecord);
writeOrder();
writeRecordNumber(MaxRecord);
System.out.println(CurrentRecord);
System.out.println(MaxRecord);
buttonpanel.add(savebtn);
java.net.URL imageURL_AddRowIcon = CommonFeatures.class.getResource("Icons/edit_add.png");
ImageIcon AddRowIcon = new ImageIcon(imageURL_AddRowIcon);
additemreqbtn = new JButton("Add Item", AddRowIcon);
additemreqbtn.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent evt){
try{
//--<BEGINNING>--Clear Fields-------------------------------------------------------//
ItemNumberTxt.setText("");
UnitPriceTxt.setText("");
QuantityReqTxt.setText("");
TotPriceTxt.setText("");
//--<END>--Clear Fields-------------------------------------------------------------//
//CurrentRecord = MaxRecord;
currentItem++;
setInnerFieldText(currentItem);
internalnextbtn.setEnabled(false);
internalprevbtn.setEnabled(true);
System.out.println(MaxRecord);
} catch(Exception ec){ec.printStackTrace();}
buttonpanel.add(additemreqbtn);
externalnextbtn = new JButton(createNextButtonIcon());
externalnextbtn.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent evt){
getFieldText(CurrentRecord);
externalprevbtn.setEnabled(true);
if(CurrentRecord < MaxRecord){
++CurrentRecord;
setFieldText(CurrentRecord);
System.out.println(CurrentRecord);//Checking RECORD_NUM
if(CurrentRecord == MaxRecord){
externalnextbtn.setEnabled(false);
buttonpanel.add(externalnextbtn);
return buttonpanel;
//TODO
public void setFieldText(int orderID){//TODO
orderDetails[orderID].setCustID(Integer.parseInt(CustIDTxt.getText()));
orderDetails[orderID].setCustOrderID(Integer.parseInt(CustOrderIDTxt.getText()));
orderDetails[orderID].setOrderDate(OrderedDateTxt.getText());
orderDetails[orderID].setInnerCustOrdObj(innerCustOrdObj);
orderDetails[orderID].setMaxItems(MaxItems);
setInnerFieldText(currentItem);
orderDetails[orderID].setGrandTotal(Float.parseFloat(GrandTotTxt.getText()));
public void setInnerFieldText(int currentItem){//TODO
innerCustOrdObj[currentItem] = new InnerCustOrdObject();
innerCustOrdObj[currentItem].setItemNumber(Integer.parseInt(ItemNumberTxt.getText()));
innerCustOrdObj[currentItem].setUnitPrice(Float.parseFloat(UnitPriceTxt.getText()));
innerCustOrdObj[currentItem].setQuantityRequired(Integer.parseInt(QuantityReqTxt.getText()));
innerCustOrdObj[currentItem].setTotalPrice(Float.parseFloat(TotPriceTxt.getText()));
public void getFieldText(int orderID){
CustIDTxt.setText(Integer.toString(orderDetails[orderID].getCustID()));
CustOrderIDTxt.setText(Integer.toString(orderDetails[orderID].getCustOrderID()));
OrderedDateTxt.setText(""+orderDetails[orderID].getOrderDate());
currentItem = orderDetails[orderID].getMaxItems();
System.err.println("currentItem" + currentItem);
getInnerFieldText(currentItem);
GrandTotTxt.setText(Float.toString(orderDetails[orderID].getGrandTotal()));
public void getInnerFieldText(int currentItem){
ItemNumberTxt.setText(Integer.toString(innerCustOrdObj[currentItem].getItemNumber()));
UnitPriceTxt.setText(Float.toString(innerCustOrdObj[currentItem].getUnitPrice()));
QuantityReqTxt.setText(Integer.toString(innerCustOrdObj[currentItem].getQuantityRequired()));
TotPriceTxt.setText(Float.toString(innerCustOrdObj[currentItem].getTotalPrice()));
public void writeOrder(){//TODO
try {
objOut = new ObjectOutputStream(new FileOutputStream(OrderDetailsFile));
objOut.writeObject(orderDetails);
System.out.println("WORKING!");
objOut.flush();
objOut.close();
} catch (IOException e) {
e.printStackTrace();
public Object readOrder(){
Object temporaryObj;
try{
objIn = new ObjectInputStream(new FileInputStream(OrderDetailsFile));
temporaryObj = objIn.readObject();
CustOrdObject[] blah = (CustOrdObject[]) temporaryObj;
System.out.println("Outer: "+blah[1].getCustID());
InnerCustOrdObject[] whee = blah[1].getInnerCustOrdObj();
System.out.println("Inner: "+whee[1].getItemNumber());
objIn.close();
System.out.println("Read Worky!");
return temporaryObj;
}catch(Exception e){
e.printStackTrace();
System.out.println("Read No Worky!");
return null;
public void writeRecordNumber(int MaxRecord){
try{
objOut = new ObjectOutputStream(new FileOutputStream(OrdRecordNumStore));
objOut.writeObject(MaxRecord);
System.out.println("WORKING!");
objOut.flush();
objOut.close();
}catch(Exception e){e.printStackTrace();}
public int readRecordNumber() {
try {
objIn = new ObjectInputStream(new FileInputStream(OrdRecordNumStore));
int temporaryObj = Integer.parseInt(objIn.readObject().toString());
objIn.close();
System.out.println("Read Number Worky!");
return temporaryObj;
} catch (Exception e) {
e.printStackTrace();
System.out.println("Read Number No Worky!");
return -1;
}Message was edited by:
Kilik07
Message was edited by:
Kilik07ok i got reading to work to a certain extent... but the prob is i cnt seem to save my innerCustOrdObj proprly...when ever i look for a record using the gotorecordbtn, the outerobject, which is the orderDetails, seems to change but the innerCustOrdObj remains the same... heres the new code..
public class CustomerOrderDetails extends CommonFeatures{
//TODO
private static int MAX_ORDERS = 200;
private static int MAX_ORDERITEMS = 100;
private static int MaxRecord;
private static int CurrentRecord = 1;
private static int currentItem;
private static int MaxItems = 1;
private static boolean FileExists, recFileExists;
private static boolean RecordExists;
private static CustOrdObject[] orderDetails = new CustOrdObject[MAX_ORDERS];
private static InnerCustOrdObject[] innerCustOrdObj = new InnerCustOrdObject[MAX_ORDERITEMS];
private static File OrderDetailsFile = new File("CustOrdDetails.ser");
private static File OrdRecordNumStore = new File("OrdRecordNumStore.txt");
private static PrintWriter writeFile;
private static BufferedReader readFile;
private static ObjectOutputStream objOut;
private static ObjectInputStream objIn;
//Set format for date
SimpleDateFormat simpleDF = new SimpleDateFormat("dd MM yyyy");
//--<BEGINNING>--Declaring Interface Variables------------------------------------------//
private JPanel innertoppanel, innercenterpanel, innerbottompanel, innerrightpanel, innerleftpanel;
private JLabel CustIDLbl, CustOrderIDLbl, OrderedDateLbl, GrandTotLbl, ItemNumberLbl,UnitPriceLbl, QuantityReqLbl, TotPriceLbl;
private JTextField CustIDTxt, CustOrderIDTxt, OrderedDateTxt, GrandTotTxt, ItemNumberTxt, UnitPriceTxt, QuantityReqTxt, TotPriceTxt;
private JButton addrecordbtn, savebtn, externalprevbtn, externalnextbtn, internalprevbtn, internalnextbtn, gotorecordbtn, additemreqbtn;
//--<END>--Declaring Interface Variables------------------------------------------------//
public static void main(String[] args) {
final CustomerOrderDetails COD = new CustomerOrderDetails();
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
try {
UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
COD.createCustOrdDetailsScreen();
} catch (Exception eb) {
eb.printStackTrace();
//--<BEGINNING>--Creating CustomerOrderDetails Screen---------------------------------------//
public JFrame createCustOrdDetailsScreen() {
createDefaultFrame();
mainframe.setSize(800,500);
createContainerPanel();
containerpanel.add(createCustOrdDetailsTitle(), BorderLayout.NORTH);
containerpanel.add(createCustOrdDetailsMainPanel(), BorderLayout.CENTER);
//containerpanel.add(createCustOrdDetailsLeftNavButtons(), BorderLayout.WEST);
//containerpanel.add(createCustOrdDetailsRightNavButtons(), BorderLayout.EAST);
containerpanel.add(createCustOrdDetailsButtons(), BorderLayout.SOUTH);
mainframe.setContentPane(containerpanel);
mainframe.setLocationRelativeTo(null);
mainframe.setVisible(true);
//--<BEGINNING>--Checks to see whether CRecordNumberStore file exists-------------------------------//
if (OrdRecordNumStore.exists() == true) {
recFileExists = true;
}else {
recFileExists = false;
if (recFileExists == true) {
MaxRecord = readRecordNumber();
CurrentRecord = MaxRecord;
//readOrder();
//readInnerOrderRecord(CurrentRecord);
System.out.println("Current Record " +CurrentRecord);
System.out.println("Max Record " +MaxRecord);
}else{
MaxRecord = 1;
writeRecordNumber(MaxRecord);
CustOrderIDTxt.setText(""+MaxRecord);
System.out.println("Current Record " +CurrentRecord);
System.out.println("Max Record " +MaxRecord);
//--<END>--Checks to see whether CRecordNumberStore file exists--------------------------------------//
if(readOrder() != null){
orderDetails = (CustOrdObject[]) readOrder();
//CurrentRecord--;
//System.out.println("Current Rec Here"+CurrentRecord);
if(orderDetails[CurrentRecord] == null){
System.err.println("CustomerOrderObj 1 is null !!");
}else{
System.err.println("CustomerOrderObj 1 is not null !!");
if(orderDetails[CurrentRecord].getInnerCustOrdObj() == null){
System.err.println("InnerCustomerOrderObj is null !!");
}else{
System.err.println("InnerCustomerOrderObj is not null !!");
innerCustOrdObj = orderDetails[CurrentRecord].getInnerCustOrdObj();
MaxItems = orderDetails[CurrentRecord].getMaxItems();
if(CurrentRecord > 1 && CurrentRecord < MaxRecord){
externalnextbtn.setEnabled(true);
externalprevbtn.setEnabled(true);
if(CurrentRecord >= MaxRecord){
externalnextbtn.setEnabled(false);
getFieldText(CurrentRecord);
getInnerFieldText(MaxItems);
}else{
orderDetails[CurrentRecord] = new CustOrdObject();
currentItem = 1;
return mainframe;
//--<END>--Creating CustomerOrderDetails Screen---------------------------------------------//
public JPanel createCustOrdDetailsTitle(){
createTitlePanel();
titlepanel.setBackground(TxtfontColor);
label.setText("- Customer Order Details -");
labelpanel.setBackground(TxtfontColor);
label.setForeground(Color.white);
createbuttonpanel();
buttonpanel.setBackground(TxtfontColor) ;
buttonpanel.add(createReturnToMainMenuButton());
titlepanel.add(labelpanel, BorderLayout.WEST);
titlepanel.add(buttonpanel, BorderLayout.EAST);
return titlepanel;
public JPanel createCustOrdDetailsMainPanel(){
createmainpanel();
mainpanel.setBackground(TxtfontColor);
mainpanel.setLayout(new BorderLayout());
mainpanel.setBorder(BorderFactory.createTitledBorder(""));
mainpanel.add(createInnerTopPanel(), BorderLayout.NORTH);
mainpanel.add(createInnerCenterPanel(), BorderLayout.CENTER);
mainpanel.add(createInnerBottomPanel(), BorderLayout.SOUTH);
mainpanel.add(createInnerRightPanel(), BorderLayout.EAST);
mainpanel.add(createInnerLeftPanel(), BorderLayout.WEST);
return mainpanel;
public JPanel createInnerTopPanel(){
innertoppanel = new JPanel(new GridBagLayout());
innertoppanel.setBackground(TxtfontColor);
GridBagConstraints GBC = new GridBagConstraints();
GBC.fill = GridBagConstraints.HORIZONTAL;
//Setting Font Type and Size
Font font = new Font("Arial", Font.BOLD, 11);
CustIDLbl = new JLabel("Customer ID");
CustIDLbl.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
CustIDLbl.setFont(font);
CustIDLbl.setForeground(LblfontColor);
GBC.gridx = 1;
GBC.gridy = 1;
innertoppanel.add(CustIDLbl, GBC);
CustIDTxt = new JTextField(20);
CustIDTxt.setEditable(true);
GBC.gridx = 2;
GBC.gridy = 1;
innertoppanel.add(CustIDTxt, GBC);
GBC.gridx = 3;
GBC.gridy = 1;
innertoppanel.add(Box.createHorizontalStrut(220), GBC);
OrderedDateLbl = new JLabel("Order Date");
OrderedDateLbl.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
OrderedDateLbl.setFont(font);
OrderedDateLbl.setForeground(LblfontColor);
GBC.gridx = 4;
GBC.gridy = 1;
innertoppanel.add(OrderedDateLbl, GBC);
//Get today's date
Date todaydate = new Date();
OrderedDateTxt = new JTextField(simpleDF.format(todaydate), 20);
OrderedDateTxt.setHorizontalAlignment(JTextField.CENTER);
OrderedDateTxt.setEditable(false);
GBC.gridx = 5;
GBC.gridy = 1;
innertoppanel.add(OrderedDateTxt, GBC);
CustOrderIDLbl = new JLabel("Customer Order ID");
CustOrderIDLbl.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
CustOrderIDLbl.setFont(font);
CustOrderIDLbl.setForeground(LblfontColor);
GBC.gridx = 1;
GBC.gridy = 2;
innertoppanel.add(CustOrderIDLbl, GBC);
CustOrderIDTxt = new JTextField(20);
//CustOrderIDTxt.setEditable(false);
GBC.gridx = 2;
GBC.gridy = 2;
innertoppanel.add(CustOrderIDTxt, GBC);
return innertoppanel;
public JPanel createInnerCenterPanel(){
innercenterpanel = new JPanel(new GridBagLayout());
innercenterpanel.setBackground(TxtfontColor);
innercenterpanel.setBorder(BorderFactory.createLoweredBevelBorder());
GridBagConstraints GBC = new GridBagConstraints();
GBC.fill = GridBagConstraints.HORIZONTAL;
//Setting Font Type and Size
Font font = new Font("Arial", Font.BOLD, 11);
ItemNumberLbl = new JLabel("Item Number");
ItemNumberLbl.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
ItemNumberLbl.setFont(font);
ItemNumberLbl.setForeground(LblfontColor);
GBC.gridx = 1;
GBC.gridy = 1;
innercenterpanel.add(ItemNumberLbl, GBC);
ItemNumberTxt = new JTextField(20);
GBC.gridx = 2;
GBC.gridy = 1;
innercenterpanel.add(ItemNumberTxt, GBC);
UnitPriceLbl = new JLabel("Unit Price");
UnitPriceLbl.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
UnitPriceLbl.setFont(font);
UnitPriceLbl.setForeground(LblfontColor);
GBC.gridx = 1;
GBC.gridy = 2;
innercenterpanel.add(UnitPriceLbl, GBC);
UnitPriceTxt = new JTextField(20);
//UnitPriceTxt.setEditable(false);
GBC.gridx = 2;
GBC.gridy = 2;
innercenterpanel.add(UnitPriceTxt, GBC);
QuantityReqLbl = new JLabel("Quantity Required");
QuantityReqLbl.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
QuantityReqLbl.setFont(font);
QuantityReqLbl.setForeground(LblfontColor);
GBC.gridx = 1;
GBC.gridy = 3;
innercenterpanel.add(QuantityReqLbl, GBC);
QuantityReqTxt = new JTextField(20);
//QuantityReqTxt.setEditable(false);
GBC.gridx = 2;
GBC.gridy = 3;
innercenterpanel.add(QuantityReqTxt, GBC);
TotPriceLbl = new JLabel("Total Price");
TotPriceLbl.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
TotPriceLbl.setFont(font);
TotPriceLbl.setForeground(LblfontColor);
GBC.gridx = 1;
GBC.gridy = 4;
innercenterpanel.add(TotPriceLbl, GBC);
TotPriceTxt = new JTextField(20);
TotPriceTxt.setEditable(false);
TotPriceTxt.addFocusListener(new FocusAdapter(){
public void focusGained(FocusEvent evt){
TotPriceTxt.setText(""+Integer.parseInt(UnitPriceTxt.getText())*Integer.parseInt(QuantityReqTxt.getText()));
GBC.gridx = 2;
GBC.gridy = 4;
innercenterpanel.add(TotPriceTxt, GBC);
return innercenterpanel;
public JPanel createInnerBottomPanel(){
innerbottompanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
innerbottompanel.setBackground(TxtfontColor);
//Setting Font Type and Size
Font font = new Font("Arial", Font.BOLD, 11);
GrandTotLbl = new JLabel("Grand Total");
GrandTotLbl.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
GrandTotLbl.setFont(font);
GrandTotLbl.setForeground(LblfontColor);
innerbottompanel.add(GrandTotLbl);
innerbottompanel.add(Box.createHorizontalStrut(30));
GrandTotTxt = new JTextField(20);
innerbottompanel.add(GrandTotTxt);
return innerbottompanel;
public JPanel createInnerRightPanel(){
innerrightpanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
innerrightpanel.setBackground(TxtfontColor);
innerrightpanel.setLayout(new BoxLayout(navrightpanel, BoxLayout.Y_AXIS));
innerrightpanel.setBorder(BorderFactory.createLoweredBevelBorder());
innerrightpanel.setLayout(new GridBagLayout());
GridBagConstraints GBC = new GridBagConstraints();
GBC.fill = GridBagConstraints.HORIZONTAL;
internalnextbtn = new JButton(createNextButtonIcon());
GBC.gridx = 1;
GBC.gridy = 1;
internalnextbtn.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent evt){
getInnerFieldText(currentItem);
internalprevbtn.setEnabled(true);
if(currentItem < MaxItems){
++currentItem;
orderDetails[CurrentRecord].getInnerCustOrdObj();
setInnerFieldText(currentItem);
System.out.println("Current Item" + currentItem);
if(currentItem == MaxItems){
internalnextbtn.setEnabled(false);
innerrightpanel.add(internalnextbtn, GBC);
return innerrightpanel;
public JPanel createInnerLeftPanel(){
innerleftpanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
innerleftpanel.setBackground(TxtfontColor);
innerleftpanel.setBorder(BorderFactory.createLoweredBevelBorder());
innerleftpanel.setForeground(Color.BLACK);
innerleftpanel.setLayout(new GridBagLayout());
GridBagConstraints GBC = new GridBagConstraints();
GBC.fill = GridBagConstraints.HORIZONTAL;
internalprevbtn = new JButton(createPreviousButtonIcon());
GBC.gridx = 1;
GBC.gridy = 1;
internalprevbtn.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent evt){
getInnerFieldText(currentItem);
internalnextbtn.setEnabled(true);
if(currentItem == 1){
internalprevbtn.setEnabled(false);
if(currentItem > 0){
--currentItem;
orderDetails[CurrentRecord].getInnerCustOrdObj();
setInnerFieldText(currentItem);
System.out.println("Current Item" + currentItem);
innerleftpanel.add(internalprevbtn, GBC);
return innerleftpanel;
public JPanel createCustOrdDetailsButtons(){
createbuttonpanel();
buttonpanel.setBackground(TxtfontColor);
externalprevbtn = new JButton(createPreviousButtonIcon());
externalprevbtn.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent evt){
getFieldText(CurrentRecord);
externalnextbtn.setEnabled(true);
if(CurrentRecord == 1){
externalprevbtn.setEnabled(false);
if(CurrentRecord > 0){
--CurrentRecord;
setFieldText(CurrentRecord);
System.out.println("Current Record " + CurrentRecord);//Checking RECORD_NUM
buttonpanel.add(externalprevbtn);
addrecordbtn = new JButton("Add Record", createAddButtonIcon());
addrecordbtn.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent evt){
try{
MaxRecord = readRecordNumber();
MaxRecord++;
CurrentRecord = MaxRecord;
orderDetails[CurrentRecord] = new CustOrdObject();
writeRecordNumber(MaxRecord);
MaxItems = 1;
innerCustOrdObj[MaxItems] = new InnerCustOrdObject();
//--<BEGINNING>--Clear Fields-------------------------------------------------------//
CustIDTxt.setText("");
CustOrderIDTxt.setText(""+MaxRecord);
//Get today's date
Date todaydate = new Date();
OrderedDateTxt.setText(""+simpleDF.format(todaydate));
ItemNumberTxt.setText("");
UnitPriceTxt.setText("");
QuantityReqTxt.setText("");
TotPriceTxt.setText("");
GrandTotTxt.setText("");
//--<END>--Clear Fields-------------------------------------------------------------//
externalnextbtn.setEnabled(false);
externalprevbtn.setEnabled(true);
System.out.println(MaxRecord);
} catch(Exception ec){ec.printStackTrace();}
buttonpanel.add(addrecordbtn);
savebtn = new JButton("Save Data", createSaveButtonIcon());
savebtn.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent evt){
setFieldText(CurrentRecord);
setInnerFieldText(MaxItems);
writeOrder();
writeRecordNumber(MaxRecord);
System.out.println(CurrentRecord);
System.out.println(MaxRecord);
buttonpanel.add(savebtn);
java.net.URL imageURL_AddRowIcon = CommonFeatures.class.getResource("Icons/edit_add.png");
ImageIcon AddRowIcon = new ImageIcon(imageURL_AddRowIcon);
additemreqbtn = new JButton("Add Item", AddRowIcon);
additemreqbtn.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent evt){
try{
//--<BEGINNING>--Clear Fields-------------------------------------------------------//
ItemNumberTxt.setText("");
UnitPriceTxt.setText("");
QuantityReqTxt.setText("");
TotPriceTxt.setText("");
//--<END>--Clear Fields-------------------------------------------------------------//
//CurrentRecord = MaxRecord;
MaxItems++;
innerCustOrdObj[MaxItems] = new InnerCustOrdObject();
System.out.println("Max Items "+MaxItems);
currentItem = MaxItems;
orderDetails[CurrentRecord].setMaxItems(MaxItems);
///setInnerFieldText(currentItem);
internalnextbtn.setEnabled(false);
internalprevbtn.setEnabled(true);
} catch(Exception ec){ec.printStackTrace();}
buttonpanel.add(additemreqbtn);
externalnextbtn = new JButton(createNextButtonIcon());
externalnextbtn.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent evt){
getFieldText(CurrentRecord);
externalprevbtn.setEnabled(true);
if(CurrentRecord < MaxRecord){
++CurrentRecord;
setFieldText(CurrentRecord);
System.out.println(CurrentRecord);//Checking RECORD_NUM
if(CurrentRecord == MaxRecord){
externalnextbtn.setEnabled(false);
buttonpanel.add(externalnextbtn);
gotorecordbtn = new JButton("Go To Record", createGotoButtonIcon());
gotorecordbtn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt){
* The text from the GotorecordTxt textfield will be taken and assigned
* to a temporary integer variable called Find.
int Find = Integer.parseInt(CustOrderIDTxt.getText());
for(int j=1; j <= MaxRecord; j++){
* Using a for loop, each record can be read using the readCustRecord
* method.
getFieldText(j);
* An if condition is utilized to check whether the temporary stored variable, Find,
* matches a field in a record. If this record is found, then using the RecordExists
* which was declared at the top, either a true or false statement can be assigned
* If the record exists, then a true statement will be assigned, if not a false
* statement will be assigned.
if(orderDetails[j].getCustOrderID() == Find){
RecordExists = true;
break;
}else{
RecordExists = false;
if(RecordExists == false){
* If the RecordExists is assigned a false statement, then a message will be
* displayed to show that the record does not exist.
JOptionPane.showMessageDialog(null, "Record Does Not Exist!", "Error Message", JOptionPane.ERROR_MESSAGE, createErrorIcon());
}else{
getFieldText(Find);
buttonpanel.add(gotorecordbtn);
return buttonpanel;
//TODO
public void setFieldText(int orderID){//TODO
orderDetails[orderID].setCustID(Integer.parseInt(CustIDTxt.getText()));
orderDetails[orderID].setCustOrderID(Integer.parseInt(CustOrderIDTxt.getText()));
orderDetails[orderID].setOrderDate(OrderedDateTxt.getText());
orderDetails[orderID].setInnerCustOrdObj(innerCustOrdObj);
orderDetails[orderID].setMaxItems(MaxItems);
setInnerFieldText(currentItem);
orderDetails[orderID].setGrandTotal(Float.parseFloat(GrandTotTxt.getText()));
public void setInnerFieldText(int currentItem){//TODO
innerCustOrdObj[currentItem] = new InnerCustOrdObject();
innerCustOrdObj[currentItem].setMaxItems(MaxItems);
innerCustOrdObj[currentItem].setItemNumber(Integer.parseInt(ItemNumberTxt.getText()));
innerCustOrdObj[currentItem].setUnitPrice(Float.parseFloat(UnitPriceTxt.getText()));
innerCustOrdObj[currentItem].setQuantityRequired(Integer.parseInt(QuantityReqTxt.getText()));
innerCustOrdObj[currentItem].setTotalPrice(Float.parseFloat(TotPriceTxt.getText()));
public void getFieldText(int orderID){
CustIDTxt.setText(Integer.toString(orderDetails[orderID].getCustID()));
CustOrderIDTxt.setText(Integer.toString(orderDetails[orderID].getCustOrderID()));
OrderedDateTxt.setText(""+orderDetails[orderID].getOrderDate());
currentItem = orderDetails[orderID].getMaxItems();
orderDetails[orderID].getInnerCustOrdObj();
System.err.println("currentItem" + currentItem);
//getInnerFieldText(currentItem);
GrandTotTxt.setText(Float.toString(orderDetails[orderID].getGrandTotal()));
public void getInnerFieldText(int currentItem){
ItemNumberTxt.setText(Integer.toString(innerCustOrdObj[currentItem].getItemNumber()));
UnitPriceTxt.setText(Float.toString(innerCustOrdObj[currentItem].getUnitPrice()));
QuantityReqTxt.setText(Integer.toString(innerCustOrdObj[currentItem].getQuantityRequired()));
TotPriceTxt.setText(Float.toString(innerCustOrdObj[currentItem].getTotalPrice()));
public void writeOrder(){//TODO
try {
objOut = new ObjectOutputStream(new FileOutputStream(OrderDetailsFile));
objOut.writeObject(orderDetails);
System.out.println("WORKING!");
objOut.flush();
objOut.close();
} catch (IOException e) {
e.printStackTrace();
public Object readOrder(){
Object temporaryObj;
try{
objIn = new ObjectInputStream(new FileInputStream(OrderDetailsFile));
temporaryObj = objIn.readObject();
CustOrdObject[] blah = (CustOrdObject[]) temporaryObj;
/* System.out.println("Outer: "+blah[1].getCustID());
InnerCustOrdObject[] whee = blah[1].getInnerCustOrdObj();
System.out.println("Inner: "+whee[1].getItemNumber());*/
objIn.close();
System.out.println("Read Worky!");
return temporaryObj;
}catch(Exception e){
e.printStackTrace();
System.out.println("Read No Worky!");
return null;
public void writeRecordNumber(int MaxRecord){
try{
objOut = new ObjectOutputStream(new FileOutputStream(OrdRecordNumStore));
objOut.writeObject(MaxRecord);
System.out.println("WORKING!");
objOut.flush();
objOut.close();
}catch(Exception e){e.printStackTrace();}
public int readRecordNumber() {
try {
objIn = new ObjectInputStream(new FileInputStream(OrdRecordNumStore));
int temporaryObj = Integer.parseInt(objIn.readObject().toString());
objIn.close();
System.out.println("Read Number Worky!");
return temporaryObj;
} catch (Exception e) {
e.printStackTrace();
System.out.println("Read Number No Worky!");
return -1;
}Message was edited by:
Kilik07 -
How use PHP to read image files from a folder and display them in Flex 3 tilelist.
Hello. I need help on displaying images from a folder dynamically using PHP and display it on FLEX 3 TileList. Im currently able to read the image files from the folder but i don't know how to display them in the TileList. This is my current code
PHP :
PHP Code:
<?php
//Open images directory
$imglist = '';
$dir = dir("C:\Documents and Settings\april09mpsip\My Documents\Flex Builder 3\PHPTEST\src\Assets\images");
//List files in images directory
while (($file = $dir->read()) !== false)
if (eregi("gif", $file) || eregi("jpg", $file) || eregi("png", $file))
echo "filename: " . $file . "\n";
$dir->close();
?>
FLEX 3 :
Code:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="pic.send();">
<mx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.events.FlexEvent;
import mx.rpc.events.FaultEvent;
import mx.events.ItemClickEvent;
import mx.rpc.events.ResultEvent;
public var image:Object;
private function resultHandler(event:ResultEvent):void
image = (event.result);
ta1.text = String(event.result);
private function faultHandler(event:FaultEvent):void
ta1.text = "Fault Response from HTTPService call:\n ";
]]>
</mx:Script>
<mx:TileList x="31" y="22" initialize="init();" dataProvider = "{image}" width="630" height="149"/>
<mx:String id="phpPicture">http://localhost/php/Picture.php</mx:String>
<mx:HTTPService id="pic" url="{phpPicture}" method="POST"
result="{resultHandler(event)}" fault="{faultHandler(event)}"/>
<mx:TextArea x="136" y="325" width="182" height="221" id="ta1" editable="false"/>
<mx:Label x="136" y="297" text="List of files in the folder" width="182" height="20" fontWeight="bold" fontSize="13"/>
</mx:Application>
Thanks. Need help as soon as possbile. URGENT.i have made some changes, in the php part too, and following is the resulting code( i tried it, and found that it works.):
PHP Code:
<?php
echo '<?xml version="1.0" encoding="utf-8"?>';
?>
<root>
<images>
<?php
//Open images directory
$dir = dir("images");
//List files in images directory
while (($file = $dir->read()) !== false)
if (eregi("gif", $file) || eregi("jpg", $file) || eregi("png", $file))
echo "<image>" . $file . "</image>"; // i expect you to use the relative path in $dir, not C:\..........
//$dir->close();
?>
</images>
</root>
Flex Code:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute"
creationComplete="callPHP();">
<mx:Script>
<![CDATA[
import mx.rpc.http.HTTPService;
import mx.controls.Alert;
import mx.events.FlexEvent;
import mx.rpc.events.FaultEvent;
import mx.events.ItemClickEvent;
import mx.collections.ArrayCollection;
import mx.rpc.events.ResultEvent;
[Bindable]
private var arr:ArrayCollection = new ArrayCollection();
private function callPHP():void
var hs:HTTPService = new HTTPService();
hs.url = 'Picture.php';
hs.addEventListener( ResultEvent.RESULT, resultHandler );
hs.addEventListener( FaultEvent.FAULT, faultHandler )
hs.send();
private function resultHandler( event:ResultEvent ):void
arr = event.result.root.images.image as ArrayCollection;
private function faultHandler( event:FaultEvent ):void
Alert.show( "Fault Response from HTTPService call:\n " );
]]>
</mx:Script>
<mx:TileList id="tilelist"
dataProvider="{arr}">
<mx:itemRenderer>
<mx:Component>
<mx:Image source="images/{data}" />
</mx:Component>
</mx:itemRenderer>
</mx:TileList>
</mx:Application>
Maybe you are looking for
-
Macintosh HD is damaged and can't be repaired
Hi, The other day i decided to purchase and download Mac OS X Lion off from the AppStore for my iMac 21"inch, however after i sucsessfully downloaded the OS it began to Installing, then when it passes 5 minutes of installing the window displays a wor
-
How to update new records in existing Xcelsius DashBoard
Hi GUrus, I have a question about Xcelsius. I was reading some document and it has mentioned that once we have imported any excel file, it gets stored in Xcelsius and does not communicate with the excel file. IN that case when the record changes how
-
Downloading adobe reader osx error message "an internal error occurred"?
Can't seem to use the program, when it ends up on my dock, and I select it, I get the message "an internal error occurred". I don't know how else to test if it's working... Can anyone easily address my problem ? Thank you if so.
-
PS: Working with balloon tips
I have a Powershell function that shows a balloon tip and it works fine, except for two things. First, is there a way to have my script display a message to every logged-in user? Second, according to several blog posts (like this and this), I should
-
Billing plan is not updating project plan revenue
Hi, My client has scenario like he creates projects manually and when he creates any sales order, he assign this sales order to the project though account assignment tab. The plan revenue for the project comes from sales order billing plan. The issue