cancel
Showing results for 
Search instead for 
Did you mean: 

Help needed with BAPI_SALESORDER_CREATEFROMDAT1 parameters

Former Member
0 Kudos

Dear all,

I am trying to execute BAPI_SALESORDER_CREATEFROMDAT1 from Java.

I am passing all mandatory parameters.

I am setting the DOC_TYPE as "OR".

However in the Return structure I get the message

Sales document type OR is not defined.

This works fine from the ECC system.

The DOC_TYPE field has 4 characters.

So I have tried passing "OR ". (OR followed by 2 spaces.)

But the string passed is getting trimmed and te reult is the same return message.

Can anyone please help me in this matter.

Thanks and regards,

Mayuresh.

Accepted Solutions (0)

Answers (5)

Answers (5)

Former Member
0 Kudos

Hello Sameer,

Thanks a lot.

I checked with VOV8. "OR" is listed there and not blocked.

But I noticed a wierd thing.

Passing "TA" as DOC_TYPE works from Java.

"TA" is not listed there.

Moreover, all entries are in ascending order but the entry for "OR".

It is at the same position where "TA" should be in the list.

Also, I see I can modify this list by adding new entries and deleting entries.

Do you recommend doing that or will it stop other function modules from functioning properly?

Thanks and regards,

Mayuresh

Edited by: Mayuresh Kanvinde on Feb 28, 2008 6:12 PM

Former Member
0 Kudos

Hi Mayuresh,

Maybe you can add it only to test - I hope you do it on the test system :). But I am not sure if a simple addition there would work.

Some kind of entries also need to be made in the table TVAK for the new document type if I remember right...I am not sure which entries exactly.

Maybe you can ask one the in-house SAP people at your place if it is possible?

And one more thing I forgot to mention before - use the BAPI_SALESORDER_CREATEFROMDAT2 instead of 1. I also had problems working with the _CREATEFROMDAT1.

Bye,

Sameer

Former Member
0 Kudos

Hi,

Thanks everyone.

But the problem still persists.

"'OR'" did not work.

As for AU, it doesn't matter since TA is working. and ZTCS and be used for standard order.

I was just wondering why OR is not working.

Thanks and regards,

Mayuresh

Former Member
0 Kudos

Hi,

you can check if the "OR" type is free to be used as a document type in the transaction VOV8. If it's not in the list, you can't use it.

Bye,

Sameer

Former Member
0 Kudos

Hi Mathieu,

Thanks for replying. I was waiting for someomne to help me with a solution.

I have checked in the SAP system.

The sales order is getting created there when the doc_tyoe is OR.

However, it does not work from Java.

I get the message "Sales Document Type OR is not defined".

But it works with doc_type "ZTCS" or "TA".

Also i figured that for Partn_Role, passing "SP" for the value from Java does not work, I had to specify "AG".

I am of the opinion that the SAP system is not properly configured.

What do yo think?

Thanks and regards,

Mayuresh

Former Member
0 Kudos

Hi,

I think that the error don't come from your SAP system.

Maybe the String value OR is interpreted like a SQL expression.

Try to put the value between quotes ( ' )

try with this : String docType = "'OR'";

Best regards,

Mathieu

PS : reward points if answer helpful.

Former Member
0 Kudos

Hi,

Trying giving the type as "AU" instead of "OR".

Sameer

Former Member
0 Kudos

Hi,

Have you try the function BAPI_SALESORDER_CREATEFROMDAT1 in the SAP system with the transaction code SE37!

Which message do you get ?

Best regards,

Mathieu

Former Member
0 Kudos

Dear All,

This is my code.


import com.sap.mw.jco.*;
import java.io.StringWriter;
public class Test {

	public static void main(String[] args) {
		
			String result = "";
		
			try {
				JCO.Client mConnection;
				JCO.Repository mRepository;
				JCO.Function mFunction;		   
				JCO.Table mTable; 

				mConnection =
								JCO.createClient( "100" , "user" , "password" , "en" , "host-ip" , "10" ); 
					   
							mConnection.connect();		   
							mRepository = new JCO.Repository("myRep", mConnection);
							mFunction = mRepository.getFunctionTemplate( "BAPI_SALESORDER_CREATEFROMDAT1").getFunction();
							
							
							JCO.Structure mStructure = mFunction.getImportParameterList().getStructure("ORDER_HEADER_IN");
							
							String doc = "OR  ";
							System.out.println(doc);
							System.out.println(doc.length());
							mStructure.setValue(doc,"DOC_TYPE");
							
							System.out.println(doc);
							System.out.println(doc.length());
							
							mStructure.setValue("1000","SALES_ORG");
							mStructure.setValue("10","DISTR_CHAN");
							mStructure.setValue("01","DIVISION");
							
							mTable = mFunction.getTableParameterList().getTable("ORDER_PARTNERS");
							mTable.appendRow();
							mTable.setValue("SP","PARTN_ROLE");
							mTable.setValue("AMIT","PARTN_NUMB");
															
							mTable = mFunction.getTableParameterList().getTable("ORDER_ITEMS_IN");
							mTable.appendRow();
							mTable.setValue("58","MATERIAL");
							mTable.setValue("6","REQ_QTY");
								
							
							mConnection.execute(mFunction);
							
							//mFunction = mRepository.getFunctionTemplate("BAPI_TRANSACTION_COMMIT").getFunction();
							//mConnection.execute(mFunction);
							
							mStructure = mFunction.getExportParameterList().getStructure( "RETURN" );
							
							StringWriter writer = new StringWriter();
							mStructure.writeXML(writer);
							result = writer.getBuffer().toString();		   		   
							
							mConnection.disconnect();		 		   
			}
			catch (Exception ex) {
				ex.printStackTrace();
				result = ex.getMessage();
			}

			System.out.println(result);

	}
}

I hope now someone will be able to help.

Thanks and regards,

Mayuresh