在SAP中创建采购信息记录 [英] Creating Purchase Info Record in SAP

查看:133
本文介绍了在SAP中创建采购信息记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用以下JCo代码在SAP中创建购买信息记录(ME11):

I am trying to create a Purchase Info Record (ME11) in SAP using the below JCo code:

它的执行没有失败并且没有引发错误,但是我无法在SAP中获得新创建的信息记录.在ME13中说未找到信息记录.我能知道我在想什么吗?

It executes without fail and throws no error, but i am not able to get the newly created info record in SAP. In ME13 it says info record not found. Can i know what am i missing?

IFunctionTemplate ft1 = mRepository.getFunctionTemplate("ZME_INITIALIZE_INFORECORD");
    JCO.Function function1 = ft1.getFunction();
    mConnection.execute(function1);

    IFunctionTemplate ft = mRepository.getFunctionTemplate("ZME_DIRECT_INPUT_INFORECORD");
    JCO.Function function = ft.getFunction();
    JCO.ParameterList importparams =function.getImportParameterList();

    //  Setting HeadData Structure Information
    JCO.Structure headStructure = importparams.getStructure("I_EINA");
    //headStructure.setValue("105","MANDT");
    //headStructure.setValue("5300259768", "INFNR");
    headStructure.setValue("MYPART0006", "MATNR");      
    //headStructure.setValue("MYPART0006", "IDNLF");
    headStructure.setValue("100002","LIFNR");
    headStructure.setValue("10000","MATKL");
    headStructure.setValue("KGS","MEINS");
    headStructure.setValue("1","UMREZ");
    headStructure.setValue("1","UMREN");
    headStructure.setValue("SG","URZLA");
    headStructure.setValue("KGS","LMEIN");
    //headStructure.setValue("0000005300259768","URZZT");

    JCO.Structure headStructure1 = importparams.getStructure("O_EINA");
    //headStructure1.setValue("105","MANDT");
    //headStructure1.setValue("5300259768", "INFNR");
    headStructure1.setValue("MYPART0006", "MATNR");     
    //headStructure1.setValue("MYPART0006", "IDNLF");
    headStructure1.setValue("100002","LIFNR");
    headStructure1.setValue("10000","MATKL");
    headStructure1.setValue("KGS","MEINS");
    headStructure1.setValue("1","UMREZ");
    headStructure1.setValue("1","UMREN");
    headStructure1.setValue("SG","URZLA");
    headStructure1.setValue("KGS","LMEIN");

    //headStructure1.setValue("0000005300259768","URZZT");
    System.out.println("General Data Set");

    JCO.Structure purchaseDataStructure = importparams.getStructure("I_EINE");
    //purchaseDataStructure.setValue("105","MANDT");
    //purchaseDataStructure.setValue("5300259768", "INFNR");
    purchaseDataStructure.setValue("1000","EKORG");
    purchaseDataStructure.setValue("1000", "WERKS");
    purchaseDataStructure.setValue("003","EKGRP");
    purchaseDataStructure.setValue("USD","WAERS");
    purchaseDataStructure.setValue("3","APLFZ");
    purchaseDataStructure.setValue("1","PEINH");
    purchaseDataStructure.setValue("1","BPUMZ");
    purchaseDataStructure.setValue("1","BPUMN");
    purchaseDataStructure.setValue("1000","EFFPR");     
    purchaseDataStructure.setValue("0001","BSTAE");     
    purchaseDataStructure.setValue("100000","NETPR");
    purchaseDataStructure.setValue("X","KZABS");

    JCO.Structure purchaseDataStructure1 = importparams.getStructure("O_EINE");
    //purchaseDataStructure1.setValue("105","MANDT");
    //purchaseDataStructure1.setValue("5300259768", "INFNR");
    purchaseDataStructure1.setValue("1000","EKORG");
    purchaseDataStructure1.setValue("1000", "WERKS");
    purchaseDataStructure1.setValue("003","EKGRP");
    purchaseDataStructure1.setValue("USD","WAERS");
    purchaseDataStructure1.setValue("3","APLFZ");
    purchaseDataStructure1.setValue("1","PEINH");
    purchaseDataStructure1.setValue("1","BPUMZ");
    purchaseDataStructure1.setValue("1","BPUMN");
    purchaseDataStructure1.setValue("1000","EFFPR");        
    purchaseDataStructure1.setValue("0001","BSTAE");        
    purchaseDataStructure1.setValue("100000","NETPR");
    purchaseDataStructure1.setValue("X","KZABS");

    mConnection.execute(function);

    IFunctionTemplate ft2 = mRepository.getFunctionTemplate("ZME_POST_INFORECORD");
    JCO.Function function2 = ft2.getFunction();

    JCO.ParameterList importparams2 =function2.getImportParameterList();
    importparams2.setValue("MYPART0006", "I_MATNR");
    importparams2.setValue("MYPART0006", "O_MATNR");
    mConnection.execute(function2);

推荐答案

我可能是错的,但是我认为您正在获取要填充的结构的副本. 您是否可以在执行函数之前通过添加一组"setValue"来对此进行测试 即:

I could be wrong, but i think you're getting a copy of the structure that you fill. could you test this by adding a set of "setValue" just before the execution of the function ie :

importparams.setValue("I_EINA", headStructure);
importparams.setValue("O_EINA", headStructure1);
importparams.setValue("I_EINE", purchaseDataStructure);
importparams.setValue("O_EINE", purchaseDataStructure1);
mConnection.execute(function);

否则,可能是在函数中添加一个外部断点(执行Java函数将触发ABAP中的调试会话),

otherwise, a possibility is to add an external break-point into your function (the execution of the java function will trigger a debugging session in ABAP),

  • 并检查ABAP中的值以及执行情况
  • 您说该函数不会引发任何错误,但是我看不到任何错误 检查您的代码.您的函数应在ABAP端返回一个指示成功或错误的结构或表(例如,键入BAPIRETURN1).仅当存在ABAP转储或参数无效时,JCO才会自行触发错误.
  • and check what the values are in ABAP, and the execution
  • you say the function does not throws any error, but i don't see any error checking in your code. your function should return a struct or table indicating success or errors in the ABAP side (type BAPIRETURN1 for exemple). JCO will trigger an error by itself only if there is an ABAP dump or invalid parameters.

致谢

这篇关于在SAP中创建采购信息记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆