• 发送数据给sap和接收


    1.确保已经连通sap

    2.发送数据:这是以表的形式发送,而且是批量发送给sap

    3.接收sap返回信息:这个比较特别,碰到时试一试

    package com.yiyezhiqiu.lyh.utils;

    import com.alibaba.fastjson.JSON;
    import com.sap.conn.jco.*;
    import com.yiyezhiqiu.lyh.domain.Job;
    import com.yiyezhiqiu.lyh.service.IWorkTimeService;
    import lombok.extern.slf4j.Slf4j;
    import org.springframework.beans.factory.annotation.Autowired;

    import java.util.ArrayList;
    import java.util.HashMap;
    import java.util.List;
    import java.util.Map;
    @Slf4j

    public class TestSap {

    @Autowired
    IWorkTimeService workTimeService;


    public Map contextLoads(List<Job> jobList) {

    String xmlStr = "";
    Map<String ,Object> maps = null;
    for(Job list:jobList){
    System.out.println("joblist"+list.getID()+"一叶知秋"+jobList.size()+list.getLSTAR());
    }

    JCoDestination destination = null;
    try{
    SapConnection connection = new SapConnection();
    destination = connection.connection();
    }catch(Exception e){
    return maps;
    }


    log.info("JCoDestination: "+destination);
    try {
    if (destination != null) {
    JCoFunction function;
    try{
    function = destination.getRepository().getFunction("ZFMMM_READ_XXXXX");
    }catch(Exception e){
    return maps;
    }

    // function.getImportParameterList().setValue("I_DATA", jobList);
    for(Job list:jobList){
    JCoTable table = function.getTableParameterList().getTable("I_DATA");
    table.appendRow();
    table.setValue("ID",list.getID());
    table.setValue("ARWKS",list.getARWKS());
    table.setValue("VGE01",list.getVGE01());
    table.setValue("TELPO",list.getTELPO());
    table.setValue("PTYPE",list.getPTYPE());
    table.setValue("BUDAT",list.getBUDAT());
    table.setValue("CARDNAME",list.getCARDNAME());
    table.setValue("CARDNO",list.getCARDNO());
    table.setValue("ARBPL",list.getARBPL());
    table.setValue("WRTNR",list.getWRTNR());
    table.setValue("ZZPROJE",list.getZZPROJE());
    table.setValue("WORKP",list.getWORKP());
    table.setValue("AUFNR",list.getAUFNR());
    table.setValue("JOBTYPENAME",list.getJOBTYPENAME());
    table.setValue("JOBTYPE",list.getJOBTYPE());
    table.setValue("LIFNR",list.getLIFNR());
    table.setValue("LINEDNAME",list.getLINEDNAME());
    table.setValue("LINED",list.getLINED());
    table.setValue("ISDDZ",list.getISDDZ());
    table.setValue("IEDDZ",list.getIEDDZ());
    table.setValue("BGTYP",list.getBGTYP());
    table.setValue("VGWRT",list.getVGWRT());
    table.setValue("LSTAR",list.getLSTAR());
    table.setValue("SJPNO",list.getSJPNO());
    table.setValue("USNAM",list.getUSNAM());
    table.setValue("CPUDT",list.getCPUDT());
    table.setValue("AEDAT",list.getAEDAT());
    table.setValue("FLAG",list.getFLAG());
    table.setValue("TEXT",list.getTEXT());
    table.setValue("ZDEL",list.getZDEL());
    table.setValue("CPUDT1",list.getCPUDT1());
    table.setValue("CPUTM1",list.getCPUTM1());
    table.setValue("APUDT1",list.getAPUDT1());
    table.setValue("APUTM1",list.getAPUTM1());
    table.setValue("PHASE",list.getPHASE());
    table.setValue("BATCH",list.getBATCH());
    table.setValue("RUECK",list.getRUECK());
    table.setValue("RMZHL",list.getRMZHL());
    table.setValue("BLART",list.getBLART());
    table.setValue("DSNAM",list.getDSNAM());
    table.setValue("DEDAT",list.getDEDAT());
    table.setValue("BELNR",list.getBELNR());
    table.setValue("F01",list.getF01());
    table.setValue("F02",list.getF02());
    table.setValue("F03",list.getF03());
    table.setValue("F04",list.getF04());
    table.setValue("F05",list.getF05());
    table.setValue("F06",list.getF06());
    table.setValue("F07",list.getF07());
    table.setValue("F08",list.getF08());
    }

    function.execute(destination);

    // JCoParameterList tablePort = function.getTableParameterList();

    //info = tablePort.toXML();
    // System.out.println("info:"+info);

    // XmlParse xmlParse = new XmlParse();
    //xmlStr = xmlParse.getXmlAttribute(info);

    JCoStructure r1 = function.getExportParameterList().getStructure("GS_XXXX");

    String type = "";
    String message = "";
    type = r1.getString("TYPE");
    message = r1.getString("MESSAGE");
    maps = new HashMap<>();
    maps.put("type",type);
    maps.put("message",message);
    return maps;
    }
    }catch (JCoException e){
    e.printStackTrace();
    }

    return maps;

    }
    }
  • 相关阅读:
    如何将SQLServer2005中的数据同步到Oracle中【转】
    八大排序算法总结[转]
    Web报表相关汇集(个人收藏)
    分析:城域网技术PBT交锋TMPLS
    Ubuntu下通过SSH远程登录服务器的方法
    关于VC代码的编写和调试(三)
    Start Starts a separate window to run a specified program or command.
    罗技劲雕鼠标移动速度过慢问题
    Microsoft XML Core Services 4.0 SP2 KB936181老是提示安装(转,不过我也遇到这个问题了)
    四川人逆境中的幽默
  • 原文地址:https://www.cnblogs.com/yiyezhiqiuwuchen/p/12009150.html
Copyright © 2020-2023  润新知