cancel
Showing results for 
Search instead for 
Did you mean: 

SALES DOC NO IS NOT CREATED

Former Member
0 Kudos

I RUN THE SALESORDER_CREATEFROMDAT2

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.getStrItemNo();

String Material = objSalesOrderVO.getStrMaterial();

BigDecimal TargetQty = objSalesOrderVO.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[1]);

iteminx.setMaterial("X");

//iteminx.setTarget_Qty(itemData[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

Replies: 4 Pages: 1

Accepted Solutions (0)

Answers (2)

Answers (2)

kishorg
Advisor
Advisor
0 Kudos

Hi Guru ,

the two main things i noted here are,

1) are you getting any exceptions like data type cast or something like that while execting this?.

then just check, whether the field where u entered values are proper data types or not.(for fields containing DATE.. just check). i think have to type cast it to proper data types before executing the function module.

2). at the time of Import Adaptive RFC model how u created the model .i mean the BAPI for Sales creation and BAPI for commit . are they in the same LUW.

i had faced this type of problem , when i try to create one "create BAPI" and "Commit BAPI " as seperate models .

and i could solve this problem , by creating one model including the create bapi and commit work bapi in one Adaptive RFC model and dont have any change in the code.

Regards

Kishor Gopinathan

Former Member
0 Kudos

hi Bojja,

Checkout the link..,

http://www.henrikfrank.dk/abapexamples/Java/sapjava_createsalesorder.htm

hope it helps..,

regards,

Vinoth