Sales Order uplaod from JAVA to SAP R/3
Hi all,
My cousin is working on uploading Sales Order Document
from java server to R/3.
for that he is having a code from JCO jar.
the below is the file from which one can upload his SO details from JAVA to R/3.
But in this program he is just able to upload one Item detail for one Sales document.
but requirement is to upload 'n' item details for one Sales document.
Here is the Java code.
@author pega
TODO To change the template for this generated type comment go to
Window - Preferences - Java - Code Style - Code Templates
Created on Jun 24, 2004
To change the template for this generated file go to
Window>Preferences>Java>Code Generation>Code and Comments
package com.sap.satyam.salesorder;
import java.sql.Timestamp;
import java.util.Calendar;
import com.sap.mw.jco.IFunctionTemplate;
import com.sap.mw.jco.IRepository;
import com.sap.mw.jco.JCO;
public class SalesOrder {
static final String SID = "R3";
static final String errorID = "E";
IRepository repository;
//String orderNumber = orderCreation("M-01","3000","0002",3,"ST");
int counter;
public SalesOrder()
try {
// Add a connection pool to the specified system
JCO.addClientPool(SID, // Alias for this pool
10, // Max. number of connections
"800", // SAP client
"develop", // userid
"bslabap", // password
"EN", // language
"172.18.33.20", // host name
"00");
// Create a new repository
repository = JCO.createRepository("MYRepository", SID);
catch (JCO.Exception ex) {
System.out.println("Caught an exception: \n" + ex);
// Retrieves and sales order Create
public void createSalesOrder(String PO_NO, String MAT,String RQTY,String CUSTMAT, String SOLD_NAME, String SOLD_STREET,String SOLD_COUNTRY, String SOLD_POST_CODE,String SHIP_NAME, String SHIP_STREET,String SHIP_COUNTRY, String SHIP_POST_CODE)
try {
// Get a function template from the repository
IFunctionTemplate ftemplate = repository.getFunctionTemplate("BAPI_SALESORDER_CREATEFROMDAT1");
JCO.MetaData so_metadata = new JCO.MetaData("BAPI_SALESORDER_CREATEFROMDAT1");
// Create a function from the template
JCO.Function function = new JCO.Function(ftemplate);
// Get a client from the pool
JCO.Client client = JCO.getClient(SID);
// Fill in input parameters
// Header
JCO.ParameterList input = function.getImportParameterList();
JCO.ParameterList tables = function.getTableParameterList();
JCO.Structure input_header = input.getStructure("ORDER_HEADER_IN");
// Item details
JCO.Table table_item = tables.getTable("ORDER_ITEMS_IN");
//JCO.Structure input_item = table_item.getStructure("ORDER_ITEMS_IN");
// Partner details
JCO.Table table_partner = tables.getTable("ORDER_PARTNERS");
// Populate the header details
input_header.setValue("ZAD5","DOC_TYPE"); // Document Type
input_header.setValue("3000","SALES_ORG"); // Sales Organization
input_header.setValue("10","DISTR_CHAN"); // Distribution Channel
input_header.setValue("00","DIVISION"); // Distribution Channel
input_header.setValue("20041212","REQ_DATE_H");// can be changed in yyyymmdd (Requested date)
input_header.setValue(PO_NO,"PURCH_NO_C");// can be changed ( Customer PO Number )
//Populate the item detalis
table_item.appendRow();
table_item.setRow(1);
table_item.setValue("000010","ITM_NUMBER");
table_item.setValue("AA01","PO_ITM_NO");// can be changed
table_item.setValue("IAD-SC3000","MATERIAL");
table_item.setValue(CUSTMAT,"CUST_MAT");// can be changed
table_item.setValue("20041212","REQ_DATE");// can be changed in yyyymmdd
table_item.setValue(RQTY,"REQ_QTY");// can be changed Qty * 1000
table_item.appendRow();
table_item.setRow(2);
table_item.setValue("000020","ITM_NUMBER");
table_item.setValue("AA01","PO_ITM_NO");// can be changed
table_item.setValue("IAD-SC3000","MATERIAL");
table_item.setValue(CUSTMAT,"CUST_MAT");// can be changed
table_item.setValue("20041212","REQ_DATE");// can be changed in yyyymmdd
table_item.setValue(RQTY,"REQ_QTY");// can be changed Qty * 1000
//Populate the Partner details
// Sold to Party
table_partner.appendRow();
table_partner.setRow(1);
table_partner.setValue("AG","PARTN_ROLE");
//table_partner.setValue("0000002007","PARTN_NUMB");
table_partner.setValue("0000100067","PARTN_NUMB");
table_partner.setValue(SOLD_NAME,"NAME"); // can be changed
table_partner.setValue(SOLD_STREET,"STREET"); // can be changed
table_partner.setValue(SOLD_COUNTRY,"COUNTRY");
table_partner.setValue(SOLD_POST_CODE,"POSTL_CODE"); // can be changed
// Ship to party
table_partner.appendRow();
table_partner.setRow(2);
table_partner.setValue("WE","PARTN_ROLE");
table_partner.setValue("0000100067","PARTN_NUMB");
table_partner.setValue(SHIP_NAME,"NAME");// can be changed
table_partner.setValue(SHIP_STREET,"STREET"); // can be changed
table_partner.setValue(SHIP_COUNTRY,"COUNTRY");
table_partner.setValue(SHIP_POST_CODE,"POSTL_CODE");// can be changed
// Call the remote system
client.execute(function);
// Print return message
JCO.Structure ret = function.getExportParameterList().getStructure("RETURN");
System.out.println("BAPI_SALES_ORDER_GETLIST RETURN: " + ret.getString("MESSAGE"));
// Get table containing the orders
//JCO.Table sales_orders = function.getTableParameterList().getTable("SALES_ORDERS");
JCO.Field sales_order = function.getExportParameterList().getField("SALESDOCUMENT");
// Print results
String so = sales_order.getString();
String message = ret.getString("MESSAGE");
String message_type = ret.getString("TYPE");
if (message_type.equalsIgnoreCase("E")) {
System.out.println("Error in Sales Order Creation:" + message);
else{
System.out.println("Sales Order " + so + " Created Succesfully");
// Release the client into the pool
JCO.releaseClient(client);
catch (Exception ex) {
System.out.println("Caught an exception: \n" + ex);
// Retrieves and sales order Create
public void listSalesOrders()
try {
// Get a function template from the repository
IFunctionTemplate ftemplate = repository.getFunctionTemplate("BAPI_SALESORDER_GETLIST");
// Create a function from the template
JCO.Function function = new JCO.Function(ftemplate);
// Get a client from the pool
JCO.Client client = JCO.getClient(SID);
// Fill in input parameters
JCO.ParameterList input = function.getImportParameterList();
//input.setValue("0000002007", "CUSTOMER_NUMBER" );
input.setValue( "3000", "SALES_ORGANIZATION");
//input.setValue( "0", "TRANSACTION_GROUP" );
//input.setValue("PO_NUMBER_JAVA01","PURCHASE_ORDER_NUMBER");
// Call the remote system
client.execute(function);
// Print return message
JCO.Structure ret = function.getExportParameterList().getStructure("RETURN");
System.out.println("BAPI_SALES_ORDER_GETLIST RETURN: " + ret.getString("MESSAGE"));
// Get table containing the orders
JCO.Table sales_orders = function.getTableParameterList().getTable("SALES_ORDERS");
// Print results
if (sales_orders.getNumRows() > 0) {
// Loop over all rows
do {
counter++;
System.out.println("--" + counter + "--
// Loop over all columns in the current row
for (JCO.FieldIterator e = sales_orders.fields(); e.hasMoreElements(); ) {
JCO.Field field = e.nextField();
System.out.println(field.getName() + ":\t" + field.getString());
}//for
} while(sales_orders.nextRow());
else {
System.out.println("No results found");
}//if
// Release the client into the pool
JCO.releaseClient(client);
catch (Exception ex) {
System.out.println("Caught an exception: \n" + ex);
public static void main(String[] argv) {
SalesOrder so = new SalesOrder();
so.createSalesOrder("PO_NUMBER_JAVA02", "","0000000020000","121-223-2332-1231", "SOFTWARE SYSTEME GMBH-WE", "STREET-SH","US", "53125","SOFTWARE SYSTEME GMBH-WE", "STREET-SH","US", "53125");
//so.listSalesOrders();
>>>>Please if any of SDN users can help in resolving this issue. It will be very helpful to my cousin.
Before:
//Populate the item detalis
table_item.appendRow();
table_item.setRow(1);
table_item.setValue("000010","ITM_NUMBER");
table_item.setValue("AA01","PO_ITM_NO");// can be changed
table_item.setValue("IAD-SC3000","MATERIAL");
table_item.setValue(CUSTMAT,"CUST_MAT");// can be changed
table_item.setValue("20041212","REQ_DATE");// can be changed in yyyymmdd
table_item.setValue(RQTY,"REQ_QTY");// can be changed Qty * 1000
table_item.appendRow();
table_item.setRow(2);
table_item.setValue("000020","ITM_NUMBER");
table_item.setValue("AA01","PO_ITM_NO");// can be changed
table_item.setValue("IAD-SC3000","MATERIAL");
table_item.setValue(CUSTMAT,"CUST_MAT");// can be changed
table_item.setValue("20041212","REQ_DATE");// can be changed in yyyymmdd
table_item.setValue(RQTY,"REQ_QTY");// can be changed Qty * 1000
Try to add:
//Populate the item detalis
table_item.appendRow();
table_item.setRow(2);
table_item.setValue("000020","ITM_NUMBER");
table_item.setValue("AA01","PO_ITM_NO");// can be changed
table_item.setValue("IAD-SC3000","MATERIAL");
table_item.setValue(CUSTMAT,"CUST_MAT");// can be changed
table_item.setValue("20041212","REQ_DATE");// can be changed in yyyymmdd
table_item.setValue(RQTY,"REQ_QTY");// can be changed Qty * 1000
table_item.appendRow();
table_item.setRow(2);
table_item.setValue("000020","ITM_NUMBER");
table_item.setValue("AA01","PO_ITM_NO");// can be changed
table_item.setValue("IAD-SC3000","MATERIAL");
table_item.setValue(CUSTMAT,"CUST_MAT");// can be changed
table_item.setValue("20041212","REQ_DATE");// can be changed in yyyymmdd
table_item.setValue(RQTY,"REQ_QTY");// can be changed Qty * 1000
Regards.
Similar Messages
-
Upload Sales order item from excel to SAP in VA01 thru frontend
Hi,
I am a front end user.
SAP version 710.
we enter sales order thru frontend in VA01 in SAP. The data is stored in excel.
Currently the following is performed.
Open VA01. In transaction entry screen ,
Copy from Excel & Paste In SAP the following
SAPID of the Customer
PO No.
PO Date
Then copy and paste the line items from excel block by block i.e. depending on no. of line items seen in SAP per screen, copy that many lines from excel and Paste in SAP.
Then select next block and
SAVE the order.
In excel there are many orders of different customers.
I know litte bit of VBA.
Can this be automated somehow.
Pl. help.
ThanksHi Suhas,
to automate the work in the SAP, it requires e.g. SAP GUI Scripting.
1. Please check whether your client is allowed to SAP GUI Scripting. (ALT / F12 -> Options -> Scripting -> Enable Scripting)
2. There should be only an indicator for Enable Scripting.
3.The other two indicators by Notify When ... should be inactive.
4.You would then be able to record a SAP GUI script. (ALT / F12 -> Script Recording and Playback... -> red dot)
5.Please record all that to what you have to do it manually for first record in Excel.
6.Stop recording (record and playback -> yellow dot)
7.Please then present the results here in the forum for your script.
8.Present us also your Excel sheet with some rows.
Unfortunately I have no access to the VA01 transaction. But you can already read a lot in advance on the following link.:
Re: Transferring data from Excel to SAP
Regards,
ScriptMan -
Sales Order iDoc from SAP SCM 7.0
Hi Experts
I have two question fro you guys.
1. Can we generate VMI sales order idoc from SAP SCM 7.0? I know is can generate xml message. If we can generate idoc for VMI sales order from SAP SCM , please give me some direction or path to explore.
2. Can I use idoc to to create to VMI sales order in ECC skiping CIF. But the changes in ECC to these order should use the CIF to update the VMI orders in SAP SCM.
Please share your experience on this.Hi,
Did you set up this scenario? I want something similar, but I want an ERP order to be created. Do you know if that is possible? Do you have som tips?
regards Camilla -
Workflow fo returned sales order modified from updating the billing block t
please tell me how to find returned sales order modified from updating the billing block to delivery block and how to create blocks here.i want to know updating means what is happening here.
Thread locked.
Beginner questions are very welcome, but your question makes it obvious that you didn't even bother looking at the help or searching on SDN.
Please read the [Rules of Engagement|https://wiki.sdn.sap.com/wiki/display/HOME/RulesofEngagement] on how to post a good question and make a little effort yourself before expecting people to give up their time to help you. -
How to send sales orders through XI to non sap system
Hello Experts,
i need to send Sales order details from ECC to non sap system.
anybody can help me to proceed with this in detailed way.
i know how to send idoc through xi between sap systems.
But i need between sap to non sap system.
Thanks & Regards,
Lakshmi..Hi !!
Check this weblog on how to enable SSL:
/people/gregor.wolf3/blog/2005/10/11/setup-https-ssl-for-the-sneak-preview-sap-netweaver-04-abap-edition-on-windows
refer this realtive thread which shows the .NETnet integration with XI
Re: .NET Client Integration with SAP XI
https://www.sdn.sap.com/irj/sdn/weblogs?blog=/pub/wlg/2131 [original link is broken] [original link is broken] [original link is broken]
for idoc related settings in r/3 refer the below link...
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/73527b2c-0501-0010-5398-c4ac372c9692
IDoc to File scenario
/people/prateek.shah/blog/2005/06/08/introduction-to-idoc-xi-file-scenario-and-complete-walk-through-for-starters
check this out ..
http://help.sap.com/printdocu/core/Print46c/en/data/pdf/CABFAALEQS/CABFAALEQS.pdf
http://www.thespot4sap.com/Articles/SAP_ALE_Introduction.asp
Also go thru this Blogs
ALE Configuration for Pushing IDOC's from SAP to XI by Swaroopa Vishwanath
Configuration Steps for Posting IDOC's by Ravikumar Allampalam.
IDOC - File scenario
/people/prateek.shah/blog/2005/06/08/introduction-to-idoc-xi-file-scenario-and-complete-walk-through-for-starters
configuring IDOCS
/people/sravya.talanki2/blog/2006/12/27/aspirant-to-learn-sap-xiyou-won-the-jackpot-if-you-read-this-part-iii
IDOC scenarios
https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/cdded790-0201-0010-6db8-beb9bb2b2660
Idoc related setting
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/73527b2c-0501-0010-5398-c4ac372c9692
refer this thread also
Integration between sap and non-sap
/people/prateek.shah/blog/2005/06/08/introduction-to-idoc-xi-file-scenario-and-complete-walk-through-for-starters
https://www.sdn.sap.com/irj/sdn/weblogs?blog=/pub/wlg/5651.. [original link is broken] [original link is broken] [original link is broken]
also referthe concept of SSO
To undersand SSO scenarios gothro the links in my reply in the following thread:
SSO scenarios and configuring steps
Check the following link to know the procedure for user mapping:
Procedure to follow for user mapping.
The following link gives you more idea on User Mapping:
More Info on User Mapping
Pls reward if useful -
Reduce Sales Order element from MRP using MIGO (Movement Types)
Hi Folks,
I was wondering if its possible to remove the Sales Order element from MRP through a movement type using transaction MIGO.
Basically we don't want to use a delivery document to do this.
Thanks in advance for your help.
Regards,
Gilberto Lito remove the Sales Order element from MRP through a movement type
Sorry I am not sure whether I understood your requirement correctly. You need to reduce the inventory by doing MIGO instead throgh PGI which means, the movement type will also differ. Better if you can brief about your requirement, a suitable suggestion can be given.
Incidentally, this is not the right forum to post. You can post in the following forum
[Forum: ERP - Sales and Distribution (SD) General |SAP ERP Sales and Distribution (SAP SD);
thanks
G. Lakshmipathi -
Syntax for commiet for sales order creation from VB
syntax for commit for sales order creation from VB.
i have created sales order from vb using "sap bapi control" object, i am getting message too that sales order created of this number
BUT it will not reflect in particular table or tcode?
what should i do to commiet that sales order creation from vb while using sap bapi control.
i have tried sap function call too,
now how to commiet or is there any other way?
regards,
dushyant.Hi,
Check this link, explains step by step.
http://abaplovers.blogspot.com/2008/02/bap-sales-order-create.html
Thanks,
Krishna -
New Workflow for returned sales order modified from updating the billin
now i am creating Created Workflow for returned sales order modified from updating the billing block to the delivery block.tell me how to do this.ca n use here the control approval process.
Thread locked.
Beginner questions are very welcome, but your question makes it obvious that you didn't even bother looking at the help or searching on SDN.
Please read the [Rules of Engagement|https://wiki.sdn.sap.com/wiki/display/HOME/RulesofEngagement] on how to post a good question and make a little effort yourself before expecting people to give up their time to help you. -
Which table I can get sales order no from delivery numbar.
Hi,
I want sales order no from delivery no. right now I am using table VBFA where I am passing VBELN and POSNN and geting sales order no. but performance of select query is very poor bcouse I am not passing first two key fields in the select query.
Is there any other tablefrom where we can get sales order no. from delivery no. so that performance of report can be improved.
Thanks,hi,
sales doc header ( table VBAK ) copy to Delivery header table( LIKP)
sales doc item table ( VBAP) copy to Delivery item table( LIPS)
you can see this in copy control VTLA ,
now u want slaes doc no. from dilv doc. no.
so go to t-code se11.....
fill table LIKP u will get VBELN field for deliv doc no, & TERNR field for sales doc. no.
so if u want to call sales doc no from dilv doc no.. u can use table LIKP in ur report.
i hope it will help u. -
Hi All, We are in to Release 11.5.10.2.There is a specific requirement to Prevent users from creating Manual Sales Orders in Oracle and yet users should be able to book the Sales Orders Imported from CRM system into Orcale.Please advise.
Thanks for your advise.
However, I missed to mention that we have two set of users One is for Finished Goods and another for Spares.
Only Spares users need to be prevented from creating Direct/Manual Sales Orders in Oracle.
As you suggested, if this will be done at Form level, that may Disallow FG users also to create Manula Sales Orders which should not be the case.
Further, I tried to test one scenario through Processing Constraints but it did not work.
Application
OM
Validation Type
Entity
Temp
Short Name
TBL
Validation Semantics
Created By
Equal To
User(Myself)
Processing Cosntraint
Application
OM
Entity
Order Header
Constraint
Operation
User Action
Create
Not Allowed
Conditions
Group
Scope
Validation Entity
Record Set
Validation Template
101
Any
Order Header
Order
Above Created
Please advise. -
Hi Frinds..
I am Creating Program Sales Order Uplaod Progrm using BAPI BAPI_SALESORDER_CREATEFROMDAT2.
All header and Po data uploaded Properly . But Item Leal data not updated.. Please let me know any Conditions need to pass to update item data.
CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'
EXPORTING
salesdocumentin = v_extr
order_header_in = l_vbak
order_header_inx = l_vbakx
behave_when_error = 'P'
IMPORTING
salesdocument = v_vbeln
TABLES
return = return
order_items_in = l_vbap
order_items_inx = l_vbapx
order_partners = l_vbpa
order_schedules_in = l_shline
order_schedules_inx = l_shlinex .
I can pass like that.hi Prabu,
It is not uploading for company code 1100 .. -
Problem creating a sales order for configurable material in SAP ECC
I have a Variant Configurable material named X.
The structure of this VC material is
Material X has charatcertics CHARCTERISTIC1 and CHARCTERISTIC2.
CHARCTERISTIC1 has values VALUE1
CHARCTERISTIC2 has values VALUE2
I created a sales order manually from VA01 using configurable material and read the values of all configuration tables to be filled from BAPISDORDER_GETDETAILEDLIST. With the help of this data i got an idea how to fill the tables of BAPI BAPI_SALESORDER_CREATEFROMDAT2. But still i am able to create a sales order but the configuration data that i give is not getting populated in the sales order.
Where am i missing. please some body suggest. I am unable to debug and searched the forums
for this information but dint find solution for my problem. some body please tell me where am i missing?
Any help would be highly appreciated
Edited by: jessica sam on Jan 12, 2009 2:59 PMEven after maintaining the item category MTAC(Mills Make to order config at mat level), the configurable material is not getting replaced in the sales order (va02). It is just showing material variant exists for the configurable material.
The setting in item category for configuration is.
Config. Strategy 01(Sales Order Strategy (TAC, TAM))
Mat. Variant Action 4 (Replace configurable material (Append and change))
ATP material variant 2 (Do not substitute if not completely available)
Structure scope D (Configuration, poss. with BOM explosion)
I have maintained the stock for material variant as well to take care of ATP material varinat setting shown above.
Please suggest if missing something. -
Stop sales order replication from CRM to R/3
Hi friends,
How can we stop the sales order Replication from CRM to R/3? Pls Guide me.
Thanking u in advance.Hi Madhu,
You can do by making distribution lock set in further statuses of the CRM sales order.
It will stop replication of CRM sales order to ECC.
Regards,
Madhu -
No new item in sales order refernced from quotation
Dear All,
I am creating sales order which is referenced from Quotation.
I should not able to add item directly in sales order other than item which i got from quotation. i have checked copy control of QT to OR but could not find
how can i do this?
please helpHi friend ,
In order that you should not be able to enter any item in the sales order apart from reference to the quotation .
1. Goto VOV8 .
2. Select your sales order type , enter into it , in General Control , Select Reference Mandatory press F4 select " With Reference to Quotation".
This will solve ur problem .
Reward if it helps .
Regards,
Aditya. -
How to get master sales order number from delivery number
Hi All,
I need logic for getting master sales order number from available Delivery number.
Note: There can be many SO's in diffrent levels.
Finally i need to pick up master sales order no.
Thanks in advance.
Thanks,
Deep.Hi,
I have a outbound delivery[VL03N] 'X' in my system .
Then for getting sales order no i am writing below code:
SELECT single vbelv vbeln
from vbfa
INTO (vbelv, vbeln)
where vbeln EQ p_vbeln AND
vbtyp_n EQ 'J'.
Then vbelv i need to pick up master sales order no.
SELECT vbelv vbeln
from vbfa
INTO TABLE i_so
where vbeln EQ l_vbelv AND
vbtyp_n EQ 'C'.
If i write code as above it is giving four sales orders which one of them is master sales order no!
Thanks,
Deep.
Maybe you are looking for
-
How do I create a dependant drop down in a web form?
I am trying to add a web form to a web page that includes a dependant drop down menu. For example, I'd like there to be a drop down menu called "Interested Class" with three fields: "Tribe Fit", "Tribe Life" and "Tribe Core". When a user selects one
-
I USED TO be able to make phone calls using continuity on my MacBook Pro (Retina, 15-inch, Mid 2014) with Yosemite (10.10) via my iPhone 6 Plus on iOS 8.1 without any problems. Once I updated Yosemite to 10.10.1, my iPhone's springboard would contin
-
Let's see, where do I begin? I was a Verizon customer for 25 days, before returning everything to the Verizon store I bought it from. I found I really didn't have Verizon reception in my area, and I barely used the equipment. Now, somehow, I have a b
-
I, as others on here, am experiencing a problem with Flash completely freezing my computer. I lose mouse and keyboard control when viewing flash video (such as youtube) or playing flash games (armour games). It is a bit intermittent, but probably f
-
No print-relevant changes to document & exist
Hi Iam changing the MENGE ( QTY) in Scheduling agreement and when iam doing change message output the error No print-relevant changes to document xxxxxxx exist, where as for other fields the change message output is working. Can you please help me o