Rabu, 18 Juli 2012

Loading Purchase Request Using Mincom Connector Java .. (Ellipse Part 1)

MSO 230
Integration between java and mincom ellipse v.5 is quite tricky. Although mincom provide middleware to facilitate the integration, but we should know all model used in ellipse screens.
Below is first part on how we can communicate and loading data from java application into ellipse server.
In this example will explain about Purchase Request creation.
1. Firstly we should innitiate connection to ellipse server, get connection and store the session.
this is the class to handle connection :
package com.ellipse.main;
import java.io.IOException;
import java.io.InterruptedIOException;
import com.mincom.mims.tech.mware.cbr.CBRException;
import com.mincom.mims.tech.mware.common.EllipseLoginException;
import com.mincom.mims.tech.mware.common.IMimsSession;
import com.mincom.mims.tech.mware.common.MimsSessionFactory;
import com.mincom.mims.tech.mware.common.MwareException;
public class ConnectionEllipse {
private IMimsSession mySession;
private String buflib = “DOWNLOADED_XML”;
String tp;
String host;
String port;
String userHost;
String passHost;
String userEllipse;
String passEllipse;
/**
* EllipseConnection constructor
*/
public ConnectionEllipse() {
initConnection();
}
private void initConnection(){
try{
this.tp = “Cics”;
this.host = “10.1.1.160:ellprd”;
this.port = “0″;
this.userHost = “guest”;
this.passHost = “guest”;
this.userEllipse = “USER”;
this.passEllipse = “USERPASS”;
}catch (Exception e) {
e.printStackTrace();
}
}
/**
* Set the location of the bfl files (for MSO access)
* @param location
*/
public void setBufferLibraryLocation(String location) {
buflib = location;
}
/**
* Connect to the Ellipse server
* @param TP
* @param hostName
* @param portNumber
* @param hostUsername
* @param hostPassword
* @throws EllipseLoginException
* @throws EllipseConnectionException */
public void connect(String TP, String hostName, int portNumber, String hostUsername, String hostPassword) throws EllipseLoginException {
MimsSessionFactory sessionFactory = MimsSessionFactory.getMimsSessionFactory();
mySession = sessionFactory.getMimsSession(TP,buflib);
//            mySession.setTracing();
try {
mySession.connect(hostName, portNumber, hostUsername, hostPassword);
} catch (InterruptedIOException e) {
throw new EllipseLoginException(e.toString());
} catch (IOException e) {
e.printStackTrace();
throw new EllipseLoginException(e.toString());
} catch (CBRException e) {
throw new EllipseLoginException(e.toString());
}
}
/**
* connect without injecting patameter
* @throws EllipseLoginException */
public void connect() throws EllipseLoginException {
MimsSessionFactory sessionFactory = MimsSessionFactory.getMimsSessionFactory();
mySession = sessionFactory.getMimsSession(this.tp,this.buflib);
//            mySession.setTracing();
try {
System.out.println(this.host+”>>> “+this.passHost);
mySession.connect(this.host,0, this.userHost, this.passHost);
} catch (InterruptedIOException e) {
throw new EllipseLoginException(e.toString());
} catch (IOException e) {
e.printStackTrace();
throw new EllipseLoginException(e.toString());
} catch (CBRException e) {
throw new EllipseLoginException(e.toString());
}
}
/**
* This method attempts to login to the Ellipse server.
* @param mimsUser
* @param mimsPwd
* @param district
* @param position
* @throws EllipseLoginException
* @throws EllipseConnectionException */
//login to mims
public void login(String mimsUser,String mimsPwd,String district,String position) throws EllipseLoginException {
try {
mySession.login(mimsUser,mimsPwd,district,position);
} catch (CBRException e) {
throw new EllipseLoginException(trimQuotes(e.toString()));
} catch (MwareException e) {
throw new EllipseLoginException(trimQuotes(e.toString()));
} catch (com.mincom.mims.tech.mware.common.ServerException e) {
throw new EllipseLoginException(trimQuotes(e.getLocalizedMessage()));
} catch (IOException e) {
throw new EllipseLoginException(trimQuotes(e.toString()));
}
}
/**
* using param from ellipse.properties
* @throws EllipseLoginException */
public void login() throws EllipseLoginException {
try {
mySession.login(this.userEllipse,this.passEllipse,”PTBA”,”");
} catch (CBRException e) {
throw new EllipseLoginException(trimQuotes(e.toString()));
} catch (MwareException e) {
throw new EllipseLoginException(trimQuotes(e.toString()));
} catch (com.mincom.mims.tech.mware.common.ServerException e) {
throw new EllipseLoginException(trimQuotes(e.getLocalizedMessage()));
} catch (IOException e) {
throw new EllipseLoginException(trimQuotes(e.toString()));
}
}
/**
* This method attempts to disconnect from the Ellipse server.
* @throws EllipseLoginException
* @throws EllipseConnectionException */
//disconnect from mims server
public void disconnect() throws EllipseLoginException {
try {
mySession.disconnect();
} catch (IOException e) {
throw new EllipseLoginException(e.toString());
} catch (CBRException e) {
throw new EllipseLoginException(e.toString());
}
}
/**
* Get the current connection to Ellipse
* @return IMimsSession: The current Ellipse session */
public IMimsSession getSession() {
return mySession;
}
/**
* Trim the error message and remove double quotes
* from the ends of the message.
* @param errorMessage String
* @return String
*/
private String trimQuotes(String errorMessage) {
// Start with initial trim
String trimMessage = errorMessage.trim();
// Strip double quotes (“) from error message
if (trimMessage.startsWith(“\”") && trimMessage.endsWith(“\”")) {
trimMessage = trimMessage.substring(1, trimMessage.length()-1);
}
// Trim again on the way out
return trimMessage.trim();
}
}
2. Second step is identify all field screen model on Purchase Request ( MSO 230)
/**
* creating PR
* @param session
*/
public void createPr230(IMimsSession session){
try {
ScreenObject mso = session.executeMSO(“MSO230″);
/** Multi Item PR**/
mso.getFields().item(“OPTION1I”).setValue(“2″);
mso = mso.getCommands().item(“OK”).execute();
/** input requester **/
mso.getFields().item(“REQUEST_BY1I”).setValue(“28025″);
mso.getFields().item(“REQ_BY_DATE1I”).setValue(“18092012″);
mso.getFields().item(“PRIORITY_CODE1I”).setValue(“NORM”);
mso = mso.getCommands().item(“OK”).execute();
/** input item **/
mso.getFields().item(“TYPE1I1″).setValue(“G”);
mso.getFields().item(“QTY_REQD1I1″).setValue(“10″);//quantity
mso.getFields().item(“ACT_GROSS_PR1I1″).setValue(“1000000″);//price
mso.getFields().item(“UOM1I1″).setValue(“AMP”);//UOM
mso.getFields().item(“PART_NO1I1″).setValue(“”);
mso.getFields().item(“ACTION1I1″).setValue(“A”);//input cost center
/** item description **/
mso.getFields().item(“DESC_LINE_11I1″).setValue(“BLA”);
mso.getFields().item(“DESC_LINE_21I1″).setValue(“BLA”);
mso.getFields().item(“DESC_LINE_31I1″).setValue(“BLA”);
mso.getFields().item(“DESC_LINE_41I1″).setValue(“BLA”);
mso = mso.getCommands().item(“OK”).execute();
/** insert cost center **/
mso.getFields().item(“COST_CEN_ACCT1I1″).setValue(“234509876″);
mso = mso.getCommands().item(“OK”).execute();
/** final execution **/
mso = mso.getCommands().item(“OK”).execute();
} catch (Exception e) {
e.printStackTrace();
}
}
Voila, now our Purchase Request Has been created …

 Source : http://kusumah.wordpress.com/

INFO
Anda ingin mencari refrensi dan contoh program lengkap disertai Source Code ? Kami ada. Sekarang Anda bisa mencari Program Penjualan Visual Basic di situs ini : www.skripsi-informatika.com. Koleksi program lengkap di sana, proyek PHP dan MySQL, juga jQuery dan Framework, Visual Basic 6, VB.Net, Delphi 7 dan juga Java NetBeans.

Tidak ada komentar:

Posting Komentar