Do not use on any
shared computer
August 29, 2008 08:03pm pdt
 
[x]
Attachment Details

help to solve the error

Tags: java
Hi,
i my coding it is compling. it showing run time error pls help me to solve.as soon as possible
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211:
212:
213:
214:
215:
216:
217:
218:
219:
220:
221:
222:
223:
224:
225:
226:
227:
228:
229:
230:
231:
232:
233:
234:
235:
236:
237:
238:
239:
240:
241:
242:
243:
244:
245:
246:
247:
248:
249:
250:
251:
252:
253:
254:
255:
256:
257:
258:
259:
260:
261:
262:
263:
264:
265:
266:
267:
268:
269:
270:
271:
272:
273:
274:
275:
276:
277:
278:
279:
280:
281:
282:
283:
284:
285:
286:
287:
288:
289:
290:
291:
292:
293:
294:
295:
296:
297:
298:
299:
300:
301:
302:
303:
304:
305:
306:
307:
308:
309:
310:
311:
312:
313:
314:
315:
316:
317:
318:
319:
320:
321:
322:
323:
324:
325:
326:
327:
328:
329:
330:
331:
332:
333:
334:
335:
336:
337:
338:
339:
340:
341:
342:
343:
344:
345:
346:
347:
348:
349:
350:
351:
352:
353:
354:
355:
356:
357:
358:
359:
360:
361:
362:
363:
364:
365:
366:
package monitor;
 
import java.io.*;
 
public class AirGasInt extends Thread 
{
   /* @Override
    public void run()
    {
        
    }*/
    public static void main(String[] argh_aching_fingers)
	{
 	 directoryReader();
         //AirGasInt t = new AirGasInt();
         //t.start();
	}
 
    private boolean AirGasTillEmpty() 
    {
         this.start();
         return false;
    }
    @Override
    public void run()
{
                try 
                {
                         //while (!(containsFileRegex(getFileList(fileName)))) 
                       Thread.sleep (1000);
                }
               catch(Exception e)
               {}
 
            //  isValidXml("path");//validate the file or watever u want to do .. call the method u want which should be called when the file is put in there
 
        }
	private static void directoryReader() 
        {
		int x = 0;
		int c;
		String filePath = null;
		String filePatho = null;
		while (x == 0) 
                {
			String[] dir = new java.io.File("C:\\AirGasIn\\").list(); // Get list
			java.util.Arrays.sort(dir);// Sort it (Data Structuring chapter))
                    	for (int i = 0; i < dir.length; i++) 
			{
				File f = new File(dir[i]);
				if (true == (f.getName().contains(".xml"))) 
				{
					filePath = "C:\\AirGasIn\\" + f.getName();
					//new STAXIteratorRead(); 
					STAXIteratorRead.staxIteratorRead(filePath);
					new TestConn();
					/* Copying File to Processed Folder */
					File inputFile = new File(filePath);
					filePatho = "C:\\AirGasPr\\" + f.getName();
					File outputFile = new File(filePatho);
					try 
                                        {
						FileReader in = new FileReader(inputFile);
						FileWriter out = new FileWriter(outputFile);
						while ((c = in.read()) != -1)
							out.write(c);
						in.close();
						out.close();
					} 
                                        catch (Exception er) 
                                        {
						System.out.println(er.getMessage());
					}
					inputFile.delete();
					filePath = null;
					filePatho = null;
				}		
			}// Print the list	
		}// while
	}
 
import java.util.*;
import com.sap.mw.jco.IFunctionTemplate;
import com.sap.mw.jco.IRepository;
import com.sap.mw.jco.JCO;
 
class TestConn {
	JCO.Client mConnection;
	String[] SAPInterfaces;
	JCO.Repository SAPRep = null;
	static final String SID = "R3";
	int Partners = 0;
	String PoName = "Test";
	int TempItemNumber = 0;
	JCO.Function function = null;
	JCO.Function commitfunction = null;
	IRepository mRepository;
	static ArrayList xmlTagList = new ArrayList();
	static ArrayList xmlValList = new ArrayList();
	// Arrays to hold item data
	static ArrayList BuyerLineItemNum = new ArrayList();
	static ArrayList PartID = new ArrayList();
	static ArrayList QuantityValue = new ArrayList();
	static ArrayList UOMCoded = new ArrayList();
	static ArrayList OrderIssueDate = new ArrayList();
	static ArrayList UnitPriceValue = new ArrayList();
	String CurrencyCodedTemp = null;
	static ArrayList AgencyCoded = new ArrayList();
 
	public TestConn() {
		// TODO Auto-generated constructor stub
		try {
			// p17
			// mConnection = JCO.createClient("100", "VINCENVD", "p17*deep",
			// "EN",
			// "159.151.100.61", "10");
			// t16
			// mConnection = JCO.createClient("100", "VINCENVD", "deept16*",
			// "EN",
			// "159.151.29.41", "10");
			// q16- ok
			// mConnection = JCO.createClient("210", "VINCENVD", "qualq16*",
			// "EN",
			// "159.151.100.61", "00");
			// d16- ok
			mConnection = JCO.createClient("300", "VINCENVD", "d16^deep", "EN",
					"159.151.29.41", "00");
			mConnection.connect();
			mRepository = new JCO.Repository("<repository>", mConnection);
			function = this.createFunction("BAPI_SALESORDER_CREATEFROMDAT2");
			if (function == null) {
				throw new JCO.Exception(200, "FUNCTION",
						"FUNCTION NOT FOUND IN SAP ");
			}
 
			// Assigning the values to the header
			JCO.Structure order_header_in = function.getImportParameterList()
					.getStructure("ORDER_HEADER_IN");
			// Setting the default values
 
			order_header_in.setValue("ZOR", "DOC_TYPE");
			order_header_in.setValue("4004", "SALES_ORG");
			order_header_in.setValue("00", "DISTR_CHAN");
			order_header_in.setValue("00", "DIVISION");
			order_header_in.setValue("B01", "SALES_GRP");
			order_header_in.setValue("NCPD", "SALES_OFF");
			// Assigning the values to the header inx
			JCO.Structure order_header_inx = function.getImportParameterList()
					.getStructure("ORDER_HEADER_INX");
			// Setting the default values
			order_header_inx.setValue("I", "UPDATEFLAG");
			order_header_inx.setValue("X", "DOC_TYPE");
			order_header_inx.setValue("X", "SALES_ORG");
			order_header_inx.setValue("X", "DISTR_CHAN");
			order_header_inx.setValue("X", "DIVISION");
			order_header_inx.setValue("X", "SALES_GRP");
			order_header_inx.setValue("X", "SALES_OFF");
			order_header_inx.setValue("X", "REQ_DATE_H");
			order_header_inx.setValue("X", "PURCH_DATE");
			order_header_inx.setValue("X", "PURCH_NO_C");
			// clearing agency coded and currency
			AgencyCoded.clear();
			CurrencyCodedTemp = null;
			PoName = null;
			for (int k = 0; k < xmlTagList.size(); k++) {
				if (xmlTagList.get(k) != null) {
 
					// Count no.of partners.
					if (xmlTagList.get(k) == "AgencyCoded") {
						Partners++;
						// To set the Agency Coded
						AgencyCoded.add(xmlValList.get(k + 1));
					}
					// To set the PURCH_NO_C
					if (xmlTagList.get(k) == "BuyerOrderNumber") {
						order_header_in.setValue((xmlValList.get(k + 1)),
								"PURCH_NO_C");
						PoName = (xmlValList.get(k + 1).toString());
					}
					// To set the REQ_DATE_H and PURCH_DATE
					if (xmlTagList.get(k) == "OrderIssueDate") {
						order_header_in.setValue((xmlValList.get(k + 1)
								.toString().subSequence(0, 8)), "REQ_DATE_H");
						order_header_in.setValue((xmlValList.get(k + 1)
								.toString().subSequence(0, 8)), "PURCH_DATE");
					}
					// To set the CURRENCY
					if (xmlTagList.get(k) == "CurrencyCoded") {
						CurrencyCodedTemp = (xmlValList.get(k + 1).toString());
					}
 
				}// if
			}// for taglist
			// Cleaning data for Item lines
			BuyerLineItemNum.clear();
			PartID.clear();
			QuantityValue.clear();
			UOMCoded.clear();
			UnitPriceValue.clear();
			for (int k = 0; k < xmlTagList.size(); k++) {
 
				if (xmlTagList.get(k) != null) {
 
					// To set the ITM_NUMBER
					if (xmlTagList.get(k) == "BuyerLineItemNum") {
						BuyerLineItemNum.add(xmlValList.get(k + 1));
					}
					// To set the MATERIAL
					if (xmlTagList.get(k) == "PartID") {
						PartID.add(xmlValList.get(k + 1));
					}
					// To set the TARGET_QTY
					if (xmlTagList.get(k) == "QuantityValue") {
						QuantityValue.add(xmlValList.get(k + 1));
					}
					 //To set the TARGET_QU
					if (xmlTagList.get(k) == "UOMCoded") {
						UOMCoded.add(xmlValList.get(k + 1));
					}
					// To set the COND_VALUE
					if (xmlTagList.get(k) == "UnitPriceValue") {
						UnitPriceValue.add(xmlValList.get(k + 1));
					}
 
				}// if
			}// for taglist
			// Assigning the order items in
			JCO.Table order_items_in = function.getTableParameterList()
					.getTable("ORDER_ITEMS_IN");
			JCO.Table order_items_inx = function.getTableParameterList()
					.getTable("ORDER_ITEMS_INX");
			JCO.Table order_schedules_in = function.getTableParameterList()
					.getTable("ORDER_SCHEDULES_IN");
			JCO.Table order_schedules_inx = function.getTableParameterList()
					.getTable("ORDER_SCHEDULES_INX");
			JCO.Table order_conditions_in = function.getTableParameterList()
					.getTable("ORDER_CONDITIONS_IN");
			for (int i = 0; i < BuyerLineItemNum.size(); i++) {
				// Append row to item tables
				order_items_in.appendRow();
				order_items_inx.appendRow();
				order_schedules_in.appendRow();
				order_schedules_inx.appendRow();
				order_conditions_in.appendRow();
				TempItemNumber = (i + 1) * 10;
				// constants
				order_items_in.setValue("TAN", "ITEM_CATEG");
				order_items_inx.setValue("X", "ITEM_CATEG");
				order_items_inx.setValue("I", "UPDATEFLAG");
				order_schedules_inx.setValue("I", "UPDATEFLAG");
				order_conditions_in.setValue("ZNP0", "COND_TYPE");
				order_conditions_in.setValue(CurrencyCodedTemp, "CURRENCY");
 
				// To set the ITM_NUMBER
				order_items_in.setValue(TempItemNumber, "ITM_NUMBER");
				order_items_inx.setValue(TempItemNumber, "ITM_NUMBER");
				order_schedules_in.setValue(TempItemNumber, "ITM_NUMBER");
				order_schedules_inx.setValue(TempItemNumber, "ITM_NUMBER");
				order_conditions_in.setValue(TempItemNumber, "ITM_NUMBER");
 
				// To set the MATERIAL
				order_items_in.setValue((PartID.get(i)), "MATERIAL");
				order_items_inx.setValue("X", "MATERIAL");
 
				// To set the TARGET_QTY
				order_items_in.setValue(QuantityValue.get(i), "TARGET_QTY");
				order_items_inx.setValue("X", "TARGET_QTY");
				order_schedules_in.setValue(QuantityValue.get(i), "REQ_QTY");
				order_schedules_inx.setValue("X", "REQ_QTY");
 
				// To set the COND_VALUE
				order_conditions_in.setValue(UnitPriceValue.get(i),
						"COND_VALUE");
 
			}// for itemnumbers
 
			JCO.Table order_partners = function.getTableParameterList()
					.getTable("ORDER_PARTNERS");
			// Assign the partners- [first- buyer(SP-AG)], [second- shipto(
			// SH-WE)]
			// [third- ?
			for (int i = 0; i < Partners; i++) {
				order_partners.appendRow();
				if (i == 0)
					order_partners.setValue("AG", "PARTN_ROLE");
				if (i == 1)
					order_partners.setValue("WE", "PARTN_ROLE");
				order_partners.setValue(AgencyCoded.get(i), "PARTN_NUMB");
			}// for partners
 
			// ---------------------------------------------------------
			// Execute function
			// ---------------------------------------------------------
			try {
				mConnection.execute(function);
			} catch (Exception mException) {
				mException.printStackTrace();
 
			}
			// ---------------------------------------------------------
			// commit function
			// ---------------------------------------------------------
			commitfunction = this.createFunction("BAPI_TRANSACTION_COMMIT");
			if (commitfunction == null) {
				throw new JCO.Exception(200, "FUNCTION",
						"FUNCTION NOT FOUND IN SAP ");
			}
			try {
				mConnection.execute(commitfunction);
			} catch (Exception mException) {
				mException.printStackTrace();
 
			}
 
			// Display the return
			JCO.Table functionreturn = function.getTableParameterList()
					.getTable("RETURN");
			functionreturn.writeXML("C:\\AirGasOut\\" + PoName + ".xml");
			// start TEST
			order_items_in.writeXML("C:\\AirGasTest\\order_items_in.xml");
			order_items_inx.writeXML("C:\\AirGasTest\\order_items_inx.xml");
			order_partners.writeXML("C:\\AirGasTest\\order_partners.xml");
			order_schedules_in
					.writeXML("C:\\AirGasTest\\order_schedules_in.xml");
			order_schedules_inx
					.writeXML("C:\\AirGasTest\\order_schedules_inx.xml");
			order_conditions_in
					.writeXML("C:\\order_conditions_in.xml");
 
			// end test
			mConnection.disconnect();
		}// try
		catch (Exception er) {
			System.out.println(er.getMessage());
		}
	}// Main
 
	public JCO.Function createFunction(String name) throws Exception {
		try {
			IFunctionTemplate ft = mRepository.getFunctionTemplate(name
					.toUpperCase());
			if (ft == null)
				return null;
			return ft.getFunction();
		} catch (Exception ex) {
			throw new JCO.Exception(200, "FUNCTION",
					"Problem retrieving JCO.Function object.");
		}// Exception
	}// create.Function
 
	public static void listGotFromSTAXIteratorRead(List xmlTagAndXmlValList) {
		STAXIteratorReadVO iteratorReadVO = null;
		String xmlTag = null;
		String xmlValue = null;
		for (int i = 0; i < xmlTagAndXmlValList.size(); i++) {
			iteratorReadVO = (STAXIteratorReadVO) xmlTagAndXmlValList.get(i);
			xmlTag = iteratorReadVO.getXmlTag();
			xmlValue = iteratorReadVO.getXmlValue();
			xmlTagList.add(i, xmlTag);
			xmlValList.add(i, xmlValue);
		}
	}
 
}// Class Testconn
 
      }
Start your free trial to view this solution
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

Question Stats
Zone: Programming
Question Asked By: ranbijay11
Solution Provided By: shaz_
Participating Experts: 2
Solution Grade: C
Views: 0
Translate:
Loading Advertisement...
 
[+][-]Author Comment by ranbijay11
Author Comment by ranbijay11:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Expert Comment by karanw
Expert Comment by karanw:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Expert Comment by shaz_
Expert Comment by shaz_:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Expert Comment by shaz_
Expert Comment by shaz_:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Author Comment by ranbijay11
Author Comment by ranbijay11:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Expert Comment by shaz_
Expert Comment by shaz_:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Author Comment by ranbijay11
Author Comment by ranbijay11:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Expert Comment by shaz_
Expert Comment by shaz_:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Author Comment by ranbijay11
Author Comment by ranbijay11:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Expert Comment by karanw
Expert Comment by karanw:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Expert Comment by shaz_
Expert Comment by shaz_:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Author Comment by ranbijay11
Author Comment by ranbijay11:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Accepted Solution by shaz_
Accepted Solution by shaz_:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Loading Advertisement...
20080723-EE-VQP-34 / EE_QW_2_20070628