Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Creating Purchase Info Record in SAP using JCO

Former Member
0 Kudos

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

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?

I am using these FMs :

1. ME_INITIALIZE_INFORECORD

2. ME_DIRECT_INPUT_INFORECORD

3. ME_POST_INFORECORD

IFunctionTemplate ft1 = mRepository.getFunctionTemplate("ME_INITIALIZE_INFORECORD");

JCO.Function function1 = ft1.getFunction();

mConnection.execute(function1);

IFunctionTemplate ft = mRepository.getFunctionTemplate("ME_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("ME_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);

Edited by: rs_d123 on Dec 17, 2011 10:46 AM

Edited by: rs_d123 on Dec 17, 2011 10:46 AM

5 REPLIES 5

Former Member
0 Kudos

Hi ,

you already have PIR no , i.e 5300259768 , may be you r missing flow , its like this

PIR have 2 components

1.General Data -->which is at Vendor + Material Level.

2.Purchase Org -->you will extend above created PIR to Purchase Org( + Plant Combination ).....

so check your execution steps one by one ...

regards

Prabhu

0 Kudos

Hi Prabhu,

The PIR number is commented in the code.

Is it required to put PIR number in the parameters? Or it generated it from itself?

Please note that i am new to SAP and ABAP.

Regards,

Rajat

Edited by: rs_d123 on Dec 19, 2011 5:58 AM

0 Kudos

sorry , i didnt noticed it ,anyhow system will generates PIR number if it doesnt exists in SAP for given combination ( as i said earlier) ....and i could find any issue with your codings as well....can you debug that Jco call ?

importparams2.setValue("MYPART0006", "O_MATNR");--> no Need to Pass this param...

headStructure1.setValue("MYPART0006", "MATNR"); -->pass full length value .i.e 18char

headStructure1.setValue("100002","LIFNR"); -->pass full length value .i.e 10char

0 Kudos

If i give 18 char length of the part number then it throws an error:

(104) RFC_ERROR_SYSTEM_FAILURE: The material 00000000MYPART0006 does not exist or is not activated

Edited by: rs_d123 on Dec 19, 2011 8:58 AM

0 Kudos

If i give this much code then it throws an error

Exception in thread "main" com.sap.mw.jco.JCO$Exception: (104) RFC_ERROR_SYSTEM_FAILURE: Enter Purch. group :

I have already set the purchase group in the code: EKGRP as 003. Dont know why its still asking for purchase group.

JCO.Repository mRepository;

mRepository = new JCO.Repository("SAPConnection", mConnection);

System.out.println(" Repository Created ");

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("MYPART0006", "MATNR");

headStructure.setValue("0000100002","LIFNR");

headStructure.setValue("000010000","MATKL");

headStructure.setValue("KGS","MEINS");

headStructure.setValue("1","UMREZ");

headStructure.setValue("1","UMREN");

headStructure.setValue("SG","URZLA");

headStructure.setValue("KGS","LMEIN");

System.out.println("General Data Set");

JCO.Structure purchaseDataStructure = importparams.getStructure("I_EINE");

purchaseDataStructure.setValue("1000","EKORG");

purchaseDataStructure.setValue("1000", "WERKS");

purchaseDataStructure.setValue("003","EKGRP");

purchaseDataStructure.setValue("USD","WAERS");

purchaseDataStructure.setValue("1","APLFZ");

purchaseDataStructure.setValue("1","PEINH");

purchaseDataStructure.setValue("1","BPUMZ");

purchaseDataStructure.setValue("1","BPUMN");

purchaseDataStructure.setValue("1000","EFFPR");

purchaseDataStructure.setValue("0001","BSTAE");

purchaseDataStructure.setValue("1000","NETPR");

purchaseDataStructure.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");

mConnection.execute(function2);

System.out.println("Execution Completed");

Edited by: rs_d123 on Dec 19, 2011 9:04 AM