package com.ceon.abapeditor.ext;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.dialogs.InputDialog;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.window.Window;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.ui.IFileEditorInput;
import org.eclipse.ui.texteditor.ITextEditor;
import com.ceon.abapeditor.AbapeditorPlugin;
import com.ceon.abapeditor.preferences.PreferenceConstants;
import com.sap.mw.jco.*;
public class communicator {
//private communicateR3 com;
/*
* Retrieve ABAP code based on program name
*/
public String getABAPstring(String programName, int type) {
String newCode = "";
communicateR3 com = new communicateR3();
int resultLogon = setLogon(com, null);
if (resultLogon != 1 )
return "logon" + resultLogon;
/* get ABAP code */
newCode = com.getABAPcode(programName.toUpperCase(), type);
/* set code correct */
String newCode2 = "";
for (int i=0;i<newCode.length(); i++)
{
if ((i % 72) == 0 && i != 0)
newCode2 += '\n';
newCode2 += newCode.charAt(i);
}
newCode = newCode2;
/*if (newCode.equals("fout5!") || newCode.equals("FOUT!")) {
MessageDialog.openError(
shell,
"SAP R/3 Connection Error",
"Retrieve ABAP code from SAP R/3 was executed.");
return "";
}
if (newCode.equals("fout6!")) {
MessageDialog.openError(
shell,
"SAP R/3 Connection Error",
"Logon data is incorrect! Enter logon info in preferences (Window->Preferences->Abap Editor)");
return "";
}*/
return newCode;
}
/*
* Retrieve ABAP code based on program name
*/
public String getABAPstringJCO(String programName, int type ) {
String newCode = "";
Shell shell = new Shell();
//communicateR3 com = new communicateR3();
//int resultLogon = setLogon(com, null);
//if (resultLogon != 1 )
// return "logon" + resultLogon;
/* get ABAP code */
JCO.Client client = null;
try {
// Print the version of the underlying JCO library
//System.out.println("\n\nVersion of the JCO-library:\n" +
// "---------------------------\n" + JCO.getMiddlewareVersion());
/* retrieve logon data. */
String strUser = AbapeditorPlugin.getDefault().getPreferenceStore().getString(PreferenceConstants.P_STRING_USER);
String strPass = AbapeditorPlugin.getDefault().getPreferenceStore().getString(PreferenceConstants.P_STRING_PASSWORD);
String strClient = AbapeditorPlugin.getDefault().getPreferenceStore().getString(PreferenceConstants.P_STRING_CLIENT);
String strHost = AbapeditorPlugin.getDefault().getPreferenceStore().getString(PreferenceConstants.P_STRING_HOST);
String strSystem = AbapeditorPlugin.getDefault().getPreferenceStore().getString(PreferenceConstants.P_STRING_SYSTEM);
String strLang = AbapeditorPlugin.getDefault().getPreferenceStore().getString(PreferenceConstants.P_STRING_LANGUAGE);
if (strUser.equals("") || strClient.equals("") || strHost.equals("")) {
MessageDialog.openError(
shell,
"SAP R/3 Connection Error",
"Logon information not set! Enter logon info in preferences (Window->Preferences->Abap Editor)");
return "";
}
if (strPass.equals("")) {
InputDialog dlg = new InputDialog(
shell,
"Password",
"Waht is you password for user " + strUser + " :",
"",
null); //This is an optional validation class
dlg.open();
if(dlg.getReturnCode()!=Window.OK) //Didn't click on OK!
return "";
strPass = dlg.getValue();
}
// Create a client connection to a dedicated R/3 system
client = JCO.createClient( strClient, // SAP client
strUser, // userid
strPass, // password
strLang, // language
strHost, // host name
strSystem ); // system number
client.setAbapDebug(false);
// Open the connection
client.connect();
IRepository rep = JCO.createRepository("RID", client);
IFunctionTemplate mift = rep.getFunctionTemplate("Z2_ECLIPSEEDITOR");
JCO.Function mcall2 = mift.getFunction();
// Get the attributes of the connection and print them
//JCO.Attributes attributes = client.getAttributes();
//System.out.println("Connection attributes:\n" +
// "----------------------\n" + attributes);
//boolean is_backend_unicode = attributes.getPartnerCodepage().equals("4102") ||
// attributes.getPartnerCodepage().equals("4103");
// Create metadata definition of the input parameter list
//JCO.MetaData input_md = new JCO.MetaData("INPUT");
//input_md.addInfo("REPORTNAME", JCO.TYPE_CHAR, 255, 255 * (is_backend_unicode? 2 : 1 ),
// -1, 0, null, null, 0, null, null);
//input_md.addInfo("FNC", JCO.TYPE_CHAR, 1, 1 * (is_backend_unicode? 2 : 1 ),
// -1, 0, null, null, 0, null, null);
// Create the input parameter list from the metadata object
//JCO.ParameterList input = JCO.createParameterList(input_md);
JCO.ParameterList input = mcall2.getImportParameterList();
// Set the first (and only) input parameter
input.setValue(programName, "REPORTNAME");
if (type == 2)
input.setValue("F", "FNC");
else
input.setValue("G", "FNC");
// Create metadata definition of the output parameter list
/*JCO.MetaData output_md = new JCO.MetaData("OUTPUT");
// Specify the parameters types of the function will be returned
output_md.addInfo("AUTHCHK", JCO.TYPE_CHAR, 255, 255 * (is_backend_unicode? 2 : 1 ),
-1, 0, null, null, 0, null, null);
// Create the output parameter list from the metadata object
JCO.ParameterList output = JCO.createParameterList(output_md);
// Create metadata definition of the tables parameter list
JCO.MetaData tables_md = new JCO.MetaData("TABLES");
// Specify the parameters types of the function will be returned
output_md.addInfo("CODEROWS", JCO.TYPE_TABLE, 255, 255 * (is_backend_unicode? 2 : 1 ),
-1, 0, null, null, 0, null, null);
// Create the output parameter list from the metadata object
JCO.ParameterList tables = JCO.createParameterList(tables_md);*/
// Call the function
client.execute(mcall2);
JCO.Table table1 = mcall2.getTableParameterList().getTable(0);
for (int i = 0;i < table1.getNumRows(); i++)
{
table1.setRow(i);
String line = table1.getString("MESTYPES");
while (line.length() < 72)
line += " ";
newCode += line;
}
// All done
// System.out.println("\n\nCongratulations! It worked.");
}
catch (Exception ex) {
System.out.println("Caught an exception: \n" + ex);
}
finally {
// do not forget to close the client connection
if (client != null) client.disconnect();
}
/* set code correct */
String newCode2 = "";
for (int i=0;i<newCode.length(); i++)
{
if ((i % 72) == 0
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
plugin ABAP Eclipse Editor. 习惯了传统IDE(Vistual Studio,Eclipse)开发,使用SAP的ABAP工作台,极其不习惯呀!试一试这个插件吧,在Eclipse里面建立ABAP项目,编写ABAP程序,语法高亮,带出对象的属性和方法……。
资源推荐
资源详情
资源评论
收起资源包目录
plugin-CEON_ABAP_Eclipse_Editor (134个子文件)
ABAPScanner.class 15KB
ABAPCompletionProcessor.class 12KB
communicator.class 9KB
NewFileWizard.class 8KB
BSPTagScanner.class 7KB
XMLConfiguration.class 7KB
ABAPAnnotationHover.class 7KB
HTML2TextReader.class 7KB
FunctionNewWizard.class 6KB
NewFileWizardPage.class 6KB
NewABAPProjectWizardPage.class 6KB
FunctionNewWizardPage.class 6KB
BSPNewWizardPage.class 6KB
AbapContentOutlinePage$ContentProvider.class 6KB
BSPNewWizard.class 6KB
TableView.class 5KB
ABAPSyntaxRdr.class 5KB
PresentationCheckAction.class 5KB
NewABAPProjectWizard.class 5KB
HTMLTextPresenter.class 5KB
ABAPKeywordHover.class 5KB
abapR3actions.class 5KB
ABAPEditor.class 5KB
PresentationLastestAction.class 5KB
HTMLPrinter.class 4KB
dialogConnect1.class 4KB
XMLConfiguration.class 4KB
abapToR3actions.class 4KB
ABAPActionContributor.class 3KB
NonRuleBasedDamagerRepairer.class 3KB
NonRuleBasedDamagerRepairer.class 3KB
AbapContentOutlinePage.class 3KB
CompositeReconcilingStrategy.class 3KB
ABAPnature.class 3KB
SubstitutionTextReader.class 3KB
LineBreakingReader.class 2KB
PresentationPrintAction.class 2KB
PresentationCheckIntAction.class 2KB
XMLDoubleClickStrategy.class 2KB
XMLDoubleClickStrategy.class 2KB
ABAPWordRule.class 2KB
AbapColorProvider.class 2KB
R3PreferencePage.class 2KB
AbapeditorPlugin.class 2KB
XMLScanner.class 2KB
ABAPElement.class 2KB
AnnotationHover.class 2KB
XMLTagScanner.class 2KB
TableView$2.class 2KB
PresentationSaveAction.class 2KB
NewFileWizard$1.class 1KB
XMLTagScanner.class 1KB
FunctionNewWizard$1.class 1KB
ColorManager.class 1KB
ColorManager.class 1KB
BSPNewWizard$1.class 1KB
MainPreferencePage.class 1KB
XMLPartitionScanner.class 1KB
ABAPCompletionProcessor$Validator.class 1KB
PreferenceInitializer.class 1KB
XMLDocumentProvider.class 1KB
XMLDocumentProvider.class 1KB
TableView$ViewLabelProvider.class 1KB
FunctionNewWizard$2.class 1KB
NewFileWizard$2.class 1KB
BSPNewWizard$2.class 1KB
AbapContentOutlineLabelProvider.class 1KB
XMLPartitionScanner.class 1KB
ABAPKeywordHover$1.class 1KB
ABAPEditorMessages.class 1KB
SingleCharReader.class 1KB
TableView$ViewContentProvider.class 1KB
AbapeditorPlugin.class 1KB
BSPTagRule.class 1KB
NewABAPProjectWizard$1.class 1KB
ABAPEditor$1.class 1KB
PresentationRunAction.class 1KB
TagRule.class 1024B
TagRule.class 1020B
dialogConnect1$1.class 1004B
dialogConnect1$2.class 1004B
PreferenceConstants.class 982B
BSPeditor.class 980B
communicateR3.class 941B
TableView$3.class 920B
TableView$1.class 860B
NewABAPProjectWizardPage$1.class 859B
NewABAPProjectWizardPage$3.class 859B
NewABAPProjectWizardPage$2.class 847B
FunctionNewWizardPage$3.class 841B
FunctionNewWizardPage$1.class 841B
FunctionNewWizardPage$2.class 829B
NewFileWizardPage$1.class 817B
NewFileWizardPage$3.class 817B
BSPNewWizardPage$3.class 811B
BSPNewWizardPage$1.class 811B
NewFileWizardPage$2.class 805B
BSPNewWizardPage$2.class 799B
AbapContentOutlinePage$Segment.class 765B
ABAPReconciler.class 738B
共 134 条
- 1
- 2
bfs198
- 粉丝: 0
- 资源: 20
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
前往页