cancel
Showing results for 
Search instead for 
Did you mean: 

BAPI_SALESORDER_CREATEFROMDAT2 using JCo

Former Member
0 Kudos

Hi,

I am trying to execute <b>BAPI_SALESORDER_CREATEFROMDAT2</b> using <b>JCo</b>.

I created a JSP Dynpage with the following is the code

JCO.Client client = JCO.createClient("100", "Username", "password", "EN", "hostname", "00");
client.connect();
JCO.Repository repository = new JCO.Repository("REPOSITORY", client);
JCO.Function function = repository.getFunctionTemplate("BAPI_SALESORDER_CREATEFROMDAT2").getFunction();
			
JCO.Structure orderHeaderIn = function.getImportParameterList().getStructure("ORDER_HEADER_IN");
orderHeaderIn.setValue(salesOrg,"SALES_ORG");
orderHeaderIn.setValue(distChannel,"DISTR_CHAN");
orderHeaderIn.setValue(division,"DIVISION");
orderHeaderIn.setValue(salesDocType,"DOC_TYPE");
			
JCO.Table orderPartners = function.getTableParameterList().getTable("ORDER_PARTNERS");
orderPartners.appendRow();
orderPartners.setValue(partnerRole,"PARTN_ROLE");
orderPartners.setValue(partnerNumber,"PARTN_NUMB");
			
JCO.Table orderItemsIn = function.getTableParameterList().getTable("ORDER_ITEMS_IN");
orderItemsIn.appendRow();
orderItemsIn.setValue(material,"MATERIAL");
client.execute(function);

Created a iView and when I try to execute nothing happens in the back end?

Any clue of what I am doing wrong?

Thank you,

Vamsi

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

hi Vamsi,

The only thing you need to check is the connection.

check the paramters that you are passing in createClient(),

client = JCO.createClient(Client,userid,passoword,Lang,Server,SysNum);

Just make sure that the server is correct.

Regards,

Richa

Answers (7)

Answers (7)

Former Member
0 Kudos

Hi~

in my option,it miss the item quantity of material.

wish help.

sapsky....

Former Member
0 Kudos

Hai Vamsi...

If you have solved this problem can you please help me out as i am new to Jco and i am getting the same problem

Former Member
0 Kudos

Did this get solved?

Stephen

Former Member
0 Kudos

Did you check that the server that you are running the SAP Netweaver on can actually get to the server that your Enterprise system runs on. There are no firewalls between the two? Make sure that if you are not using IP that the DNS is setup correctly.

Former Member
0 Kudos

I found out that the connection to the back end is failing, following is the exception I am getting:

error occured com.sap.mw.jco.JCO$Exception: (102) RFC_ERROR_COMMUNICATION: Connect to SAP gateway failed Connect_PM TYPE=A ASHOST= SYSNR=00 GWHOST= GWSERV=sapgw00 PCS=1 LOCATION CPIC (TCP/IP) on local host with Unicode ERROR partner not reached (host , service sapgw00) TIME Thu Oct 20 13:10:24 2005 RELEASE 640 COMPONENT NI (network interface) VERSION 37 RC -10 MODULE nixxi_r.cpp LINE 8672 DETAIL NiPConnect2 SYSTEM CALL SiPeekPendConn ERRNO 10060 ERRNO TEXT WSAETIMEDOUT: Connection timed out COUNTER 1

Former Member
0 Kudos

Here is my connection statement and variables that i just. Maybe this will help:

client = JCO.createClient(SAPConnect.SAPClient, request.getParameter("user"),request.getParameter("pass"),SAPConnect.SAPLang,SAPConnect.SAPServer,SAPConnect.SAPSysNum);

SAPClient = 100

SAPLang = EN

SAPServer = sapserver.corporate.paccoast.com

SAPSysNum = 00

former_member182294
Active Contributor
0 Kudos

Hi Vamsi,

Make sure that the host name your passing is mapped in the host file of your WAS server.

Regards

Abhilash

SRudra
Contributor
0 Kudos

Hi all,

Were you people able to solve the problem. If not, one more suggstion : -

When you pass the values, try to padd up the value with zeros , say if it is 100 put 0000000100, the same for other numeric values. Let the forum know the curresnt staus for the problem.

Cheers

Former Member
0 Kudos

Hi Vamsi

Check Whether you are passing all the mandatory fields. One more thing is there is one more structure ORDER_HEADER_INX and a table ORDER_ITEMS_INX which have to be assigned. Hope this helps.

Regards

Vasundhara.

Former Member
0 Kudos

Hi Vasundhara,

Yes, I am passing all the mandatory fields .

<b>Mandatory Fields:</b>

<b>ORDER_HEADER_IN :</b>

DOC_TYPE Sales document type

SALES_ORG Sales organization

DISTR_CHAN Distribution channel

DIVISION Division

<b>ORDER_PARTNERS..:</b>

PARTN_ROLE Partner role, SP sold-to party

PARTN_NUMB Customer number

<b>ORDER_ITEMS_IN..:</b>

MATERIAL Material number

I dont think <b>structure ORDER_HEADER_INX and table ORDER_ITEMS_INX</b> need to be assigned. I mean they are not mandatory so I dont think they need to be assigned. But I will try.

Thank you,

Vamsi

Former Member
0 Kudos

Hi Vamsi,

Have you checked executing your FM in SAP R/3 with same data?

If it is working properly then debug your code.

I guess i are getting problem in connecting to sap system.

Regards,

Bhavik

Former Member
0 Kudos

Hi Bhavik,

It cant be the problem connecting to R/3 system because I am execting BAPI_SALESORDER_GETLIST and I am getting the data.

I tried executing the FM and it is workign fine.

I think I am doing some thing wrong some where in the following code, but cant figure out what.

The following code might be correct also, since <b>ORDER_HEADER_IN</b> is a structure I got it using JCo and assigned values, and the remaining (<b>ORDER_PARTNERS and ORDER_ITEMS_IN</b>) are tables, I am getting them and assigning the values, so the following code (I think) is correct.

JCO.Structure orderHeaderIn = function.getImportParameterList().getStructure("ORDER_HEADER_IN");
			
orderHeaderIn.setValue(salesOrg,"SALES_ORG");
orderHeaderIn.setValue(distChannel,"DISTR_CHAN");
orderHeaderIn.setValue(division,"DIVISION");
orderHeaderIn.setValue(salesDocType,"DOC_TYPE");
			
JCO.Table orderPartners = function.getTableParameterList().getTable("ORDER_PARTNERS");
orderPartners.appendRow();
orderPartners.firstRow();
orderPartners.setValue(partnerRole,"PARTN_ROLE");
orderPartners.setValue(partnerNumber,"PARTN_NUMB");
			
JCO.Table orderItemsIn = function.getTableParameterList().getTable("ORDER_ITEMS_IN");
orderItemsIn.appendRow();
orderItemsIn.firstRow();
orderItemsIn.setValue(material,"MATERIAL");

sid-desh
Advisor
Advisor
0 Kudos

Hi Vamsi,

I hope you have executed a commit after a call to BAPI. Maybe its just that all the data that you are sending may be correct. Its just that you may not be commiting after the BAPI call and hence the documnet is not visible in SAP.

if possible try creating a wrapper around the BAPI module and in that wrapper also issue a commit and then call it using JCO.

Hope this helps.

Regards

Sidharth

Former Member
0 Kudos

Hi Sidharth,

I am trying to execute the BAPI using JCo and as per the documentation I read all I have to do is to execute the function, which I did.

Can you please eloberate on "creating a wrapper around BAPI module"

Thanks,

Vamsi

Former Member
0 Kudos

try adding this after you first bapi call.

JCO.Function BAPI_TRANSACTION_COMMIT = new JCO.Function(mRepository.getFunctionTemplate("BAPI_TRANSACTION_COMMIT"));//

client.execute(BAPI_TRANSACTION_COMMIT);

sid-desh
Advisor
Advisor
0 Kudos

Hi Vamsi,

What i meant by a wrapper module was that create a Z RFC function module which has an interface similar to BAPI and also calls BAPI_TRANSACTION_COMMIT after the call to the actual BAPI. You can then call this Z RFC FM.

Or you can call the actual BAPI using JCO and then also follow it up with a call to BAPI_TRANSACTION_COMMIT as has been explained by Nathan.

Regards

Sidharth