zoukankan      html  css  js  c++  java
  • 发送数据给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;

    }
    }
  • 相关阅读:
    C# 字符串转换值类型
    C#判断字符串为空
    c#转义字符
    python各种类型的转换
    mysql创建新用户及新用户不能本地登陆的问题
    数据探索的方法
    使用requests爬取猫眼电影TOP100榜单
    Python中的正则表达式教程
    Anaconda多版本Python管理以及TensorFlow版本的选择安装
    Xshell访问虚拟机内Linux
  • 原文地址:https://www.cnblogs.com/yiyezhiqiuwuchen/p/12009150.html
Copyright © 2011-2022 走看看