Adding Sales Order with multiple lines
Hi all,
I have a C# program whereby I am trying to get Sales Orders from one database (source) and create them in another database (destination). I can't get the code to work properly as lRetCode is never equal to 0 but is -5002.
How can I fix it so that it adds the sales orders properly?
Here is the code snippet:
unaddedSOs = sList.Except(dList).ToList(); // contains the header information
// Add the Sales Orders that are missing to destination database
SAPbobsCOM.Documents sboSO = (SAPbobsCOM.Documents)oCompanyDestination.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oOrders); // Destination
// Loop through unadded Sales Orders
foreach (var item in unaddedSOs)
// Set properties of the Sales Order object
sboSO.CardCode = item.cardCode;
sboSO.CardName = item.cardName;
sboSO.DocDate = item.docDate;
sboSO.DocDueDate = item.docDueDate;
// Add Sales Order Document Lines
SAPbobsCOM.Recordset rsLines = oCompanySource.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset); // Source of lines
// Get Sales Orders from source database
rsLines.DoQuery("SELECT ItemCode, Quantity, Price FROM RDR1 WHERE DocEntry = '" + item.docNum + "'");
rsLines.MoveFirst();
if (rsLines.RecordCount > 0)
while (!rsLines.EoF)
sboSO.Lines.ItemCode = rsLines.Fields.Item("ItemCode").Value;
sboSO.Lines.Quantity = rsLines.Fields.Item("Quantity").Value;
sboSO.Lines.Price = rsLines.Fields.Item("Price").Value;
sboSO.Lines.Add();
rsLines.MoveNext();
// Try to add the Sales Order to the database
int lErrCode = 0;
string sErrMsg = "";
int lRetCode = sboSO.Add();
if (lRetCode != 0)
int temp_int = lErrCode;
string temp_string = sErrMsg;
oCompanyDestination.GetLastError(out temp_int, out temp_string);
// Incase adding a Sales Order failed
if (lErrCode != -4006)
// Display error message
MessageBox.Show(lErrCode + " " + sErrMsg);
MessageBox.Show("Done!!!");
Kind Regards,
Kinyanjui.
Hi Kinyanjui,
I think you're always writing to the same line:
int row = 0;
while (!rsLines.EoF)
sboSO.Lines.SetCurrentLine(row);
sboSO.Lines.ItemCode = rsLines.Fields.Item("ItemCode").Value;
sboSO.Lines.Quantity = rsLines.Fields.Item("Quantity").Value;
sboSO.Lines.Price = rsLines.Fields.Item("Price").Value;
sboSO.Lines.Add();
rsLines.MoveNext();
row++;
Best regards,
Pedro Magueija
Similar Messages
-
LSMW program to upload the sales order with multiple line items.
Dear SD and PP Gurus,
I am new to creating LSMW Program.
I want to create a LSMW program to upload the sales order with multiple line items. I have read on SDN that it can be done on two phases. First Create Header Data than line items. IS IT TRUE??, Or
Is there any procedure by which we can load the sales orders with multiple line items in a single run (part).
I want to use Batch process, not a BAPI or IDOC procedure.
I have created a program with
object 0090
Method 0000
Program Name RVINVB10
Program Type D
Source Structure 1 - For Header and Source Structure 2 for Line Items.
Mapped Field INDET (With Fix Value 1), ORDERTYPE, SALESORG, DISTCHANNEL, DIVISION, CUSTOMER, PONUMBER , DELVDATE, PRCGDATE, PMTTERM
INCOT1 INCOT2 with Source Structure - 1 and
Field INDENT (With Fix Value 2), ITEMNO, MATCODE, MATQTY, SUOM, PLANT, BATCH, AMOUNT with Structure-2
than maintained Structure relation ship, field Mapping, Specified Files, Assigned files, Read Data and other process,
At final stage (Start Direct Input program RVINVB10) it is giving a message - Table name not allowed.
Please tell me where I am wrong.
Thanks in advance.
DSCDear SD Gurus n Experts,
I have solved the above problem. But there is another problem appearing regarding the date format. Now system generating a message: Date . . is not valid.
While I am using Date: YYYYMMDD format in flat file, which is SAP's Standard Format.
In SDN Link: LSMW upload Sales Order using VA01/VA02 I have found that there are some date fields which are mandatory to filled. Here I have mapped
VDATU - Requested delivery date, BSTDK - Customer purchase order date, PRSDT - Date for pricing and exchange rate, BSTDK_E - Ship-to party's PO date, FKDAT - Billing Date, KORDT - Delivery Date,
and PRGRS - Date type is Constant = D
Can any one tell me, where is the priblem.
With thanks,
DSC -
Production order from sales order with multiple line item(for one material)
Dear Gurus,
I am working in MTO scenarios. If there is several line item in a sales order for one material, multiple production order( same as no. of sales order line item) is getting created against each of the line item.My requirement is,since the material code is same in each line item and sales order is one, one production order should be generated for all line item. please tell me how to do it.
(Here for one material, multiple line item is required for some specific reason)
Regards
Rajib PathakHi,
This is not possible.
In Std SAP will create one production order for one sales order. The stock is also allocated to thet particular sales order only. Because each and every sales order may vary in any one of the parameters. Considering this, SAP has designed like this.
Regards,
V. Suresh -
Sales order with multiple Schedule lines
Hello,
Could you please help me to create a sales order with multiple line items.
for example, I need to create a sales order with line item 10 with schedule lines more than 3.
Thanks in advance,
Bhaskar.KAs already explained Sh. Line Catg. is determined with Item Catg.of the item + MRP type automatically . As per your assignment in ( SD-sale-sales document-Sh. line-Assign Sh. line Catg.) system automatically propose the Sh. line Catg of your entered item
Now for three Sh line - in VA01 create the order with your item , give quantity -now select the line item, click on the Display item Details ICON extreme left bottom of the screen, than click on Sh. line tab here you maintain as many sh. line as you required.
Actually these Sh lines are nothing but the Requested Delivery Date And Quantity which is ultimately pass on to (Transfer the Requirement) MRP
Hope this'll help you
Ashok
Edited by: Ashok ku. on Aug 17, 2009 11:16 PM -
One order with multiple lines in OM is creating multiple invoices
Application: Oracle 11i (11.5.3)
Modules implemented: GL, OM, AR, AP, PO and CM
Business Requirement:
Our client would like to create Order consisting of multiple lines in Order Management.
The Orders created in OM with multiple lines could be booked, picked, released and transferred
over to Accounts Receivable. On transferring over the Orders from Order Management to Accounts
Receivables using Auto Invoice process the Order should create ONE invoice with multiple lines.
Moreover, for the multiple lines created on an invoice deferred revenue could be applied.
( eg. An order is placed for software and support. The support is to be invoiced all at once but revenue deferred to 1/12
recognized each month as revenue is earned.)
Right now we are getting two invoices. It is putting the deferred revenue item on a seperate invoice. Is this normal
functionality? How can I get both on one invoice.
thanksHello Monique,
Well you can have one invoice generated for an order with multiple lines. This is possible by changing some rules in Account Receivables. Use the grouping rules under setups->autoinvoice in AR. You can club your invoices based on any of the columns of ra_interface_lines_all. Hope this works for you.
Arvind -
Where/ how do I set SNP to create Planned orders with multiple line items?
Hi
Currently our SNP is generating planned orders on a daily basis, it creates a single order with a single line item per location.
Where/ how do set SNP to create planned orders on a daily basis to generate a single order with multiple line items per location, so therefore one planned order with multiple line items for a single location.
Thanx
KeeganHi Keegan,
In SNP (APO) it is not possible to create order with multiple line items.
But you can do some settings so that while planning system can do aggregation and disaggregation.
But your requirment should be set on Aggregation/Dis-aggregation logic.
Please follow the follwing links:
http://help.sap.com/saphelp_scm2007/helpdata/en/2c/c557e9e330cc46b8e440fb3999ca51/content.htm
Aggregation:
http://help.sap.com/saphelp_scm2007/helpdata/en/42/f731d078e73ee4e10000000a1553f6/content.htm
Disaggregation:
http://help.sap.com/saphelp_scm2007/helpdata/en/a6/ebefaf32e22e468355da304cc59387/content.htm
Please be sure that the setting of this logic will be at planning area level.
You can't change aggregation/disaggregation logic further.
Regards,
Santosh -
Sales order with multiple billing doc's
HI Guys
My client has specific requirement related the freight charges .Freight charge is represented with a condition type in my pricing procedure. If a given sales order has multiple shipments (I.E deliveries) then this freight charge is getting calculated partially at item level and passing on to the billing documents accordingly. Customers receive invoices with part of those charges. They will receive other parts with other shipments and invoices until sales order is completed
As per my clients business it would be more logical that Freight charges are invoiced on the first invoice. And not as parts in each billing doc
There are two things which are striking to my mind in terms of solution
1. Since it’s only to do with showing the freight charges on the output sent to the customer. Is there any option to display the complete freight charges on the 1st billing doc’s output type? And restrict to display in the remaining billing doc of a given sales order. Any idea how to achieve it this way
2. Can this be controlled with the help of copy controls between delivery and billing doc at an item category level .i hope there should be some standard routine in place if not what should be my logic in this routine that helps to accomplish this task
3. Create a routine and assign it to the condition type ZMIN…Not sure what logic should I built in here to get the above requirement up and running
Please guide me a way forward on this……………..
Thanks for your support.
Will reward without fail …
MohitHi Madhu,
The billing document cannot be deleted. It can either be cancelled or a credit memo created with reference to it. You can also check in the same VBFA table, if for a billing document any cancellation exists. If yes, then, the delivery cost becomes relevant. Else it does not.
However, there could be a timing issue. Say if there are 3 deliveries and 2 of them are taken for billing at the same time in different sessions. (I am not sure if SAP will allow this because of the locking of VBAK table but still a possibility). Then, when the routine goes back to VBFA with the Sales order number, it does not find any billing document. So there is a chance that the freight charges may appear on both deliveries in full. So, you may want to test a few scenarios like this to make sure the logic is good and accommodates all scenarios.
Hope this helps.
Regards,
Mukund S -
Problem adding sales order with freight since 8.8 pl 20 (and 8.81 pl 0)
Dear All,
Since the upgrade to 8.8 patch 20 I have a problem with adding a sales orders with freight (expensecode 1 does exist!) through the XML import of (the same problem with 8.81 pl 0).
This is the XML:
<BOM>
<BO>
<Documents>
<row>
<DocType>dDocument_Items</DocType>
<DocDate>20110328</DocDate>
<DocDueDate>20110328</DocDueDate>
<CardCode>INT_C_PenS</CardCode>
</row>
</Documents>
<Document_Lines>
<row>
<ItemCode>10000024</ItemCode>
<ItemDescription>Afvalbak CONSTRUCTO 50</ItemDescription>
<Quantity>4.00</Quantity>
<ShipDate>20110328</ShipDate>
<DiscountPercent>20.00</DiscountPercent>
<UnitPrice>528.00</UnitPrice>
<LineStatus>bost_Open</LineStatus>
<LineType>dlt_Regular</LineType>
</row>
</Document_Lines>
<DocumentsAdditionalExpenses>
<row>
<ExpenseCode>1</ExpenseCode>
<LineTotal>64.00</LineTotal>
</row>
</DocumentsAdditionalExpenses>
</BO>
</BOM>
When the DocumentsAdditionalExpeses part is deleted then there is no problem.
The error with the DocumentsAdditionalExpeses is 'Internal error accured'.
Can anyone confirm that this not is working through XML import (DTW works) or is there a solution?
Thanks and best regards,
Wim KleinsmanHi,
Try this one.
<BOM>
<BO>
<Documents>
<row>
<DocType>dDocument_Items</DocType>
<DocDate>20110328</DocDate>
<DocDueDate>20110328</DocDueDate>
<CardCode>INT_C_PenS</CardCode>
</row>
</Documents>
<Document_Lines>
<row>
<ItemCode>10000024</ItemCode>
<ItemDescription>Afvalbak CONSTRUCTO 50</ItemDescription>
<Quantity>4.00</Quantity>
<ShipDate>20110328</ShipDate>
<DiscountPercent>20.00</DiscountPercent>
<UnitPrice>528.00</UnitPrice>
<LineStatus>bost_Open</LineStatus>
<LineType>dlt_Regular</LineType>
<ExpenseCode>1</ExpenseCode>
<LineTotal>64.00</LineTotal>
</row>
</BO>
</BOM>
Regards,
Siva -
Update Sales Order with Text-Line and without regular Lines
Hello Experts,
i have a problem to update a Sales Order with no Item-Lines but with one Text-Lines or one Sub-Total-Lines.
I get only the Error "The specified resource name can not be found in the image file", the %temp% are delete.
i have testet with Methode: #updateDocWithSubDeletion, #Synchronnous Update, #Synchronous Insert with fallback to Update (i was desperate)
my Scenario look like this:
my Payload:
i have allready testet with the part AdminInfo und QueryParams with the same Error.
<Payload id="atom6" Role="X">
<Documents xmlns="">
<row>
<DocNum>227780</DocNum>
<DocType>dDocument_Items</DocType>
<HandWritten>tNO</HandWritten>
<Printed>psNo</Printed>
<DocDate>20150423</DocDate>
<DocDueDate>20150423</DocDueDate>
<CardCode>61052</CardCode>
<CardName>Durchlauf</CardName>
<DocCurrency>EUR</DocCurrency>
<DocRate>1.000000</DocRate>
<DocTotal>0.000000</DocTotal>
<Reference1>227780</Reference1>
<JournalMemo>Kundenaufträge - 61052</JournalMemo>
<PaymentGroupCode>-1</PaymentGroupCode>
<DocTime>0819</DocTime>
<SalesPersonCode>2</SalesPersonCode>
<TransportationCode>-1</TransportationCode>
<Confirmed>tYES</Confirmed>
<SummeryType>dNoSummary</SummeryType>
<ContactPersonCode>0</ContactPersonCode>
<ShowSCN>tNO</ShowSCN>
<Series>5</Series>
<TaxDate>20150423</TaxDate>
<PartialSupply>tYES</PartialSupply>
<DocObjectCode>17</DocObjectCode>
<DiscountPercent>0.000000</DiscountPercent>
<DocTotalFc>0.000000</DocTotalFc>
<RevisionPo>tNO</RevisionPo>
<RequriedDate>20150423</RequriedDate>
<CancelDate>20150523</CancelDate>
<BlockDunning>tNO</BlockDunning>
<Pick>tNO</Pick>
<PaymentMethod/>
<PaymentBlock>tNO</PaymentBlock>
<MaximumCashDiscount>tNO</MaximumCashDiscount>
<WareHouseUpdateType>dwh_CustomerOrders</WareHouseUpdateType>
<Rounding>tNO</Rounding>
<DeferredTax>tNO</DeferredTax>
<NumberOfInstallments>1</NumberOfInstallments>
<ApplyTaxOnFirstInstallment>tNO</ApplyTaxOnFirstInstallment>
<DocumentSubType>bod_None</DocumentSubType>
<Address2/>
<UseShpdGoodsAct>tNO</UseShpdGoodsAct>
<IsPayToBank>tNO</IsPayToBank>
<DownPayment>0.000000</DownPayment>
<ReserveInvoice>tNO</ReserveInvoice>
<LanguageCode>9</LanguageCode>
<SequenceModel>0</SequenceModel>
<UseCorrectionVATGroup>tNO</UseCorrectionVATGroup>
<DownPaymentAmount>0.000000</DownPaymentAmount>
<DownPaymentPercentage>0.000000</DownPaymentPercentage>
<DownPaymentType>dptInvoice</DownPaymentType>
<DownPaymentAmountSC>0.000000</DownPaymentAmountSC>
<DownPaymentAmountFC>0.000000</DownPaymentAmountFC>
<VatPercent>0.000000</VatPercent>
<ServiceGrossProfitPercent>0.000000</ServiceGrossProfitPercent>
<OpeningRemarks/>
<ClosingRemarks/>
<RoundingDiffAmount>0.000000</RoundingDiffAmount>
<ControlAccount>1200</ControlAccount>
<InsuranceOperation347>tNO</InsuranceOperation347>
<ArchiveNonremovableSalesQuotation>tNO</ArchiveNonremovableSalesQuotation>
<ExtraMonth>0</ExtraMonth>
<ExtraDays>30</ExtraDays>
<CashDiscountDateOffset>0</CashDiscountDateOffset>
<StartFrom>pdt_None</StartFrom>
<NTSApproved>tNO</NTSApproved>
<EDocGenerationType>edocNotRelevant</EDocGenerationType>
<DownPaymentStatus>so_Open</DownPaymentStatus>
<GroupHandWritten>tNO</GroupHandWritten>
<CreateOnlineQuotation>tNO</CreateOnlineQuotation>
</row>
</Documents>
<Document_SpecialLines xmlns="">
<row>
<AfterLineNumber>-1</AfterLineNumber>
<LineType>dslt_Subtotal</LineType>
<LineText>Zwischensumme</LineText>
</row>
</Document_SpecialLines>
<Document_Lines xmlns="">
<row>
<ItemCode>108044</ItemCode>
<Quantity>0.01</Quantity>
<FreeText/>
</row>
</Document_Lines>
<TaxExtension xmlns="">
<row>
<NetWeight>0.000000</NetWeight>
<GrossWeight>0.000000</GrossWeight>
<StreetS/>
<BlockS/>
<BuildingS/>
<CityS/>
<ZipCodeS/>
<CountyS/>
<StateS/>
<CountryS/>
<BuildingB/>
</row>
</TaxExtension>
</Payload>
when I insert a new row with an ItemCode , it works
Thanks and Best Regards
RonnyHi,
why don't you create a simple scenario to export B1 Sales Order to XML File?
Maintain the SalesOrder via B1 client UI and check the result in XML as exported to file.
In the Sales Order xml file you can easily see how "AfterLineNumber" needs to be filled in segment "Document_SpecialLines" to achieve what you've entered via B1 client.
Normally the LineNum for B1 Documents starts counting with 0 and if you need to add a subtotal line after a regular item row, the "AfterLineNumber" value should be 0.
Best regards
Bastian -
Hi,
sale order should not be saved if there is no line item.
Sale order should not be saved if there is no quantity or value for a line item.
Can anyone update on this please
RatnaHi,
You can create sales order directly with out any material in standard.
If you enter any material you need to specify quantity.
Regards,
Ravi Duggirala
Edited by: ravi duggirala on May 19, 2009 11:56 AM -
Restrict Adding Sales Order with ProjectCode
Hi Experts,
i try restrict Sales ORder from Adding without ProjectCode (from itemlevel - RDR1.Project). Below is my script on TransactionNotification, but still it doesnt work..please help my with my script...
IF @transaction_type IN ('A', 'U') AND @object_type = '17'
BEGIN
IF EXISTS (SELECT t0.DocNum FROM ORDR t0 inner join RDR1 t1 on t0.docentry
= t1.docentry WHERE t1.Project ='' AND t0.Docentry = @list_of_cols_val_tab_del)
BEGIN
SELECT @Error = 1, @error_message = 'Please enter the field "Project Code" first ! by: IT Dept.'
END
END
Thanks,
jonathanTry with this modification:
IF @transaction_type IN ('A', 'U') AND @object_type = '17'
BEGIN
IF EXISTS (SELECT t0.DocNum FROM ORDR t0 inner join RDR1 t1 on t0.docentry
= t1.docentry WHERE isnull( t1.Project,'') ='' AND t0.Docentry = @list_of_cols_val_tab_del)
BEGIN
SELECT @Error = 1, @error_message = 'Please enter the field "Project Code" first ! by: IT Dept.'
END
END -
Create one internal sales order with two lines
When I try to use internal sales order cycle
I started with create internal purchase requisition with two lines,
Each one will supply from different warehouse
Run Create Internal Orders request
and then switch to Order Management responsibly
Run Order Import request with requisition number in parameter window
All of lines included in internal requisition in same internal sales with different shipping warehouseit's seeded functionality.
What do You expect else?
You then ship to diferent ORGs with different deliveries. Everything is OK.
BR,
Eugene -
Partial delivery of sales order with some line items
Hi all,
Please help me in the issue i want to create delivery against sales order partially for some line items of the sales order . Can any one suggest me the procedure how to do it through programing .
Thanks in advance,Hi,
You have several methods of doing same.
Method 1
Go to VL01N, and given your sales order number.
Without giving the line item, just press Enter
Now inside the delivery, you can delete unwanted line items, and you can adjust quantities under Item overview tab.
After that do picking and PGI.
Method 2
Go to VL10E,
Give your sales order number and execute.
Mark relevant schedule lines only and press execute,
then those line items with marked schedule lines will copied to the delivery document.
Best regards,
Anupa -
Sales order with line items having multiple values in multiple currency
Please suggest solution for creating sales order having line items with multiple values in multiple currencies.
e.g. Line Item A Qty/1 No, value 100INR100$100EUR. Customer wants all three values to display at sales order line item level and create billing in 3 currencies.Hi,
As far as my understanding it may be possible round the solution,
For 1 company code we can able to maintain 3 currancies,
1 currancy is hard currance & other two are dual currancies.
Create sales order with 3 line items having 3 diffrant currancies
Spilt invoice on the basis of currancy
Last pass to this invoices to accounting.
Whole process is
Sales order >>> Delivery >>> Invoice 1, Invoice 2, Invoice 3(Split invoice on basis of Currancy).
Consult with FI Team they will tell you about dual currancy & hard currancy
Kapil -
Scheduling Agreement with multiple line items of different plants
Dear Gurus,
In all plants, delivery of goods is done through multiple plants under one sales order.
The system is given provision to create centralized sales order with multiple delivery plants but it fails at the time of execution.
Hence sales order of same customer has to be prepared three times which leads to lack of control at central office.
scheduling agreement is created and scheduled to deliver through multiple plants. While creating outbound delivery flashes error message as " Delivery split due to different shipping points"
Please help me out.
Regards,
AnbuHi Naveen,
I guess you would like to change the delivery adress in the BBP_DOC_CHANGE_BADI.
Here you can identify the delivery adress (partner function 00000027) line item by the field P_GUID. This P_GUID in the partner table (ET_PARTNER-P_GUID) consists the GUID of the SC line item (ET_ITEM-GUID).
When you know the line item GUID, you can find the SC line item number in the item table (ET_ITEM-NUMBER_INT) and you can see which is the first, second... line item of the SC.
Regards,
Peter
Maybe you are looking for
-
Exchange Active Sync is not working
I have been reading a few dozen of these post that people are having issues with there iphone sync with exchange. I am TOO!. For some i can get into owa and from the iphone safaria. The iphone was able verfy the ssl certificate, but nothing is syncin
-
PHP Form Sending E-mail without inputs in Safari
Hi everyone. I'm having a problem and can't seem to find what the problem is. My form works fine in chrome and firefox but not safari. Below is my code. Please let me know if you can help. HTML Code <form id="form_280313" class="appnitro" method="pos
-
Function keys are not working?
hi all i am using dv-10G(10-1...) can anyone guide me how we can use our desire keys in forms. example For commit form my function keys should be look like this. commit form-----F10 Execute Query...........F11 etc plz help me sarah
-
Hello I would like to install an BI system based on NW7.3 After starting sapinst from..51041560/DATA_UNITS/NW730_IM_HPUX_IA64_ORA I get options.. Application server ABAP Process integration Application server java Standalone engines Additional SAP Sy
-
Hi all, I have this configuration: version 12.2 service nagle no service pad service tcp-keepalives-in service tcp-keepalives-out service timestamps debug datetime service timestamps log datetime msec localtime service password-encryption service int