cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with BAPIs

Former Member
0 Kudos

i want create SALEORDER IN SAP

send to me code ...please..

Guru

Accepted Solutions (0)

Answers (1)

Answers (1)

kishorg
Advisor
Advisor
0 Kudos

HI Guru,

You can find out the bapis , by running transaction -bapi (Bapi Explorer).

Here u get a list of standard BAPI's given by SAP.

(Standard BAPIs for sales creation are there.)

u can select appropriate bapi from here.. Associated with each bapi documentation is there . from this u will get a clear picture of import params ,export params and tables.

Regards

Kishor Gopinathan

Former Member
0 Kudos

i know the bapi name bapi_createfromdat2 in sales order

i wrote the code and i created salesorder in my local network sap system.But while i am trying to create salesorder in the another net work ,it is not giving sdDoc number.

Former Member
0 Kudos

Check your sddoc number format and how its returned, wht is the type of that

check the path

Former Member
0 Kudos

i wrote the code as giveb below

please check the code and tell me if any modification.

String DocType = "TA";

String xUploadFlag = "I";

String xDocType = "X";

String xSalesOrg = "X";

String xDisChan = "X";

String xDivision = "X";

String xPurchNo = "X";

String PartnerRole = "AG";

try {

jcoclient =

JCO.createClient(

strSapClient,

strSapUser,

strSapPassWord,

strSapLang,

strSapHost,

strSapSysNo);

jcoclient.connect();

}

catch (RuntimeException e1) {

errorCode = "J222";

objClsSuper.setErrorCode(errorCode);

return objClsSuper;

}

catch (Exception e1) {

errorCode = "J112";

objClsSuper.setErrorCode(errorCode);

return objClsSuper;

}

Bapi_Salesorder_Createfromdat2_Output output = null;

MySalesOrder_PortType mysalesorder = new MySalesOrder_PortType();

Bapi_Salesorder_Createfromdat2_Input input=null;

MyCommit_PortType mycommit = new MyCommit_PortType();

try{

input =

new Bapi_Salesorder_Createfromdat2_Input();

Bapisdhd1Type headerin = new Bapisdhd1Type();

headerin.setDoc_Date(CrtDate);

headerin.setReq_Date_H(ReqDate);

headerin.setDoc_Type(DocType);

headerin.setSales_Org(SalesOrg);

headerin.setDistr_Chan(DisChan);

headerin.setDivision(Division);

headerin.setPurch_No_C(PurchNo);

input.setOrder_Header_In(headerin);

Bapisdhd1XType headerinx = new Bapisdhd1XType();

headerinx.setUpdateflag(xUploadFlag);

headerinx.setDoc_Type(xDocType);

headerinx.setSales_Org(xSalesOrg);

headerinx.setDistr_Chan(xDisChan);

headerinx.setDivision(xDivision);

headerinx.setPurch_No_C(xPurchNo);

input.setOrder_Header_Inx(headerinx);

BapisditmType_List itemsinlist = new BapisditmType_List();

BapisditmxType_List iteminxlist = new BapisditmxType_List();

for (int i = 0; i < objSalesOrderVO.length; i++) {

String itemno = objSalesOrderVO<i>.getStrItemNo();

String Material = objSalesOrderVO<i>.getStrMaterial();

BigDecimal TargetQty = objSalesOrderVO<i>.getTargetQty();

BapisditmType itemsin = new BapisditmType();

BapisditmxType iteminx = new BapisditmxType();

itemsin.setItm_Number(itemno);

itemsin.setMaterial(Material);

itemsin.setTarget_Qty(TargetQty);

//BapisditmType_List itemsinlist = new BapisditmType_List();

itemsinlist.addBapisditmType(itemsin);

iteminx.setItm_Number(itemno);

//iteminx.setMaterial(itemData<i>[1]);

iteminx.setMaterial("X");

//iteminx.setTarget_Qty(itemData<i>[2]);

iteminx.setTarget_Qty("X");

iteminx.setUpdateflag("X");

//BapisditmxType_List iteminxlist = new BapisditmxType_List();

iteminxlist.addBapisditmxType(iteminx);

}

input.setOrder_Items_In(itemsinlist);

input.setOrder_Items_Inx(iteminxlist);

BapiparnrType partner = new BapiparnrType();

partner.setPartn_Role(PartnerRole);

partner.setPartn_Numb(PartnerNo);

BapiparnrType_List partnrlist = new BapiparnrType_List();

partnrlist.addBapiparnrType(partner);

input.setOrder_Partners(partnrlist);

mysalesorder = new MySalesOrder_PortType();

mysalesorder.messageSpecifier.setJcoClient(jcoclient);

mycommit = new MyCommit_PortType();

mycommit.messageSpecifier.setJcoClient(jcoclient);

//Bapi_Salesorder_Createfromdat2_Output output = null;

}catch(Exception e){

objClsSuper.setErrorCode(e.toString());

return objClsSuper;

}

try {

output = mysalesorder.bapi_Salesorder_Createfromdat2(input);

} catch (SystemFaultException e) {

// TODO Auto-generated catch block

errorCode += "J113";

objClsSuper.setErrorCode(errorCode);

e.printStackTrace();

return objClsSuper;

} catch (ApplicationFaultException e) {

// TODO Auto-generated catch block

errorCode += "J114";

objClsSuper.setErrorCode(errorCode);

e.printStackTrace();

return objClsSuper;

}

String docno = output.getSalesdocument();

objClsSuper.setDocNumber(docno);

Bapi_Transaction_Commit_Input commitinput =

new Bapi_Transaction_Commit_Input();

commitinput.setWait(docno);

Bapi_Transaction_Commit_Output outcommit = null;

try {

outcommit = mycommit.bapi_Transaction_Commit(commitinput);

} catch (SystemFaultException e1) {

// TODO Auto-generated catch block

errorCode += "J113";

objClsSuper.setErrorCode(errorCode);

e1.printStackTrace();

return objClsSuper;

} catch (ApplicationFaultException e1) {

// TODO Auto-generated catch block

errorCode += "J114";

objClsSuper.setErrorCode(errorCode);

e1.printStackTrace();

return objClsSuper;

}

jcoclient.disconnect();

errorCode = "J000";

objClsSuper.setErrorCode(errorCode);

return objClsSuper;

i am wating for ur response

Thanqqqqqqqqqqqq

Guru