Skip to Content
avatar image
Former Member

Help needed with BAPI_SALESORDER_CREATEFROMDAT1 parameters

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.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • avatar image
    Former Member
    Feb 21, 2008 at 05:38 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Mayuresh,

      When you set the String parameter (OR) followed by two empty space, length will be 4 but check with your BAPI programmer how they are handling in backend?.

      Regards, Suresh KB