How can I add document which has base document with 2 lines in SDK, SAP B1? - sapb1

I have a problem of base document,
I tried to add document which has base document with 1 line or row in php it works fine,
But if base document has more than 1 row it does not work, if I try to add the second row, I get error message Notice: Trying to get property of non-object in C:\wamp\www............
$oOrder->Lines->Itemcode="A001";
$oOrder->Lines->Quantity=1;
$oOrder->Lines->UnitPrice=200;
$oOrder->Lines->BaseType="1470000113";
$oOrder->Lines->BaseEntry=7;
$RetCode=$oOrder->Lines->Add;
$oOrder->Lines->Itemcode=A002;
$oOrder->Lines->Quantity=2;
$oOrder->Lines->UnitPrice=300;
$oOrder->Lines->BaseType="1470000113";
$oOrder->Lines->BaseEntry=7;
$RetCode=$oOrder->Lines->Add;
$RetCode=$oOrder->Add;
As it seems the second row does not allow BaseEntry and BaseType fields
How can I add document which has base document with 2 lines in SDK?
Please anyone can help me

It misses the $oOrder->Lines->SetCurrentLIne after the first Add.
Lines is a collection of Line and adding a row in it doesn't change the index.

You don't need the second $RetCode=$oOrder->Lines->Add; just before the Add of the order.
When you create a new order object, you get a blank 'Lines' object ready to be populated, so you only need one Lines->Add for a two line order. The extra one you have at the end is making a three line order with the last line being unpopulated.

Related

Searching through a file and seperate data in a file with a separator value in vb.net

Hello I want some help with a code to search through the text file and to separate the text from a separator value followed by a rogue(stopping) value.
Each line of text in the text file is: for example with sample data:
DAC11010|This is a Desk and a chair|$100;.
In the above example has the | sign as a seperator value and ;sign as a rogue(stopping) value. The separator value separate the text DAC11010 , This is a Desk and a chair , $100 the rogue(stopping) value means that it it is the EOLN(end of line) and ready to check the next line.
The separated text goes to 3 ListBoxes and the data added one after the other. The DAC11010 goes to the lstItemCode , This is a desk and chair goes to the lstDescription , $100 goes to the lstPrice.
I would like if someone would volunteer to help me program the code in vb.net. I hope I made myself clear.
Thank you [shannon].
If you haven't already done so, please turn on Option Strict. This is a 2 part process. First for the current project - In Solution Explorer double click My Project. Choose Compile on the left. In the Option Strict drop-down select ON. Second for future projects - Go to the Tools Menu -> Options -> Projects and Solutions -> VB Defaults. In the Option Strict drop-down select ON. This will save you from bugs at runtime.
I will not write the code for you. That is not the purpose of Stack Overflow. We help with specific problems you are having with your code. You don't appear to have any code.
I will explain one way your goal might be accomplished.
Declare 3 New List(Of String) variables to hold the data for the three list boxes. We will be looping through the text files lines but we don't want to update the user interface until after the loop so we will collect the data in memory.
You will need to import System.IO to use methods of the File class. You can use File.ReadAllLines to get an array of strings; each member of the array will contain one line from the text file.
Next, you will want to loop through the lines splitting each line into 3 sections. Use the For Each...Next type of loop. You can use the String.Split method passing in your "|"c parameter. The c tells the compiler that this is a Char not a string because .Split is expecting a Char Now you can use the .Add method to add the sections to the appropriate list.
After the loop, you can assign the 3 list to the .DataSource property of the appropriate ListBox.
Now write the code and if you have any problems ask a new question showing the specific code where you are having the problem.

Get bookmark index using system.Information()

I'm using below line to get a selected drop down from an endoresment.
ActiveDocument.FormFields(ActiveDocument.Range.Bookmarks(Selection.Information(30)).Name).Dropdown.Value
But I'm unable to get the correct bookmark index through Selection.Information(30) hence getting incorrect bookmark name.
Can any one please help me here.
The more "conventional" way to get the name of the currently active/selected bookmark name is:
Selection.Bookmarks(1).Name
Since this appears to be a form field, it's also possible to get the name via that collection:
Selection.Range.FormFields(1).Name
In a comment the request is for the bookmark index, although the request in the Question is for the bookmark name... In any case, to get the bookmark index get the count of all bookmarks from the start of the document to the end of the selection. (Note that this gets the index of the last previous bookmark, which is not necessary in the selection):
bkmIndex = ActiveDocument.Range(0, Selection.Range.End).Bookmarks.Count
Debug.Print ActiveDocument.Bookmarks(bkmIndex).Name
Please note that Information(30) is an old Word Basic value (I had to look it up in 1995 literature) that has no official equivalent in the VBA object model. It still works for reasons of backwards compatibility, but in such cases there are no guarantees that it will continue to work.

How to add line numbers to a file in Pentaho Data Integration (Kettle)?

I have a file names.txt with this data:
NAME;AGE;
alberto;22
andrea;51
ana;16
and I want to add a new column N with the line number of the row:
N;NAME;AGE;
1;alberto;22
2;andrea;51
3;ana;16
I've been looking and what I found was something related with Add sequence. I tried but I don't know how.
Thank you very much.
The Add Sequence step will get the job done, but you don't even need that. Both the CSV file input and Text file input steps can add a row number to the input rows. For the 'CSV file input' step it's called 'The row number field name (optional)'.
For Text file input, check the 'Rownum in output?' box on the Content tab and fill in the 'Rownum fieldname' text box.
I'm really baffled why you couldn't figure out the Add sequence step. It should work with no changes at all. Just drop it in and connect the output of the csv file to it and the sequence should appear as a field name called 'valuename'. I would change that personally, but still, it should work.

Remove first line from Word Document process it and put a new line at the beginning of the document

I am developing an application wherein I need to delete the first line of several word documents, merge them, merge their tables into one and place it at the top, remove all the individual tables which are merged, and then giving the merged table a name.
I am through with almost everything except removing the first line of the individual word documents (which will be merged into one) and Putting name string to the newly generated table in the new document on top of the table. The newly generated table will be placed at the top of the new document (which is result of merging of all other documents).
Can someone suggest a way to do it. If possible, deletion of first two lines will help more.
Removing first line could mean removing first paragraph or just first line as you could see it. They are not the same therefore I provide both solution below
'Remark: for ActiveDocument
'removing first paragraph
ActiveDocument.Paragraphs(1).Range.Delete
'removing first line
ActiveDocument.Range(0, 0).Select
Selection.MoveEnd wdLine
Selection.Delete

An item with the same key has already been added - csvreader.fieldcount

I'm trying to create an import program from CSV.
My code is
csv = New CsvReader(New StreamReader("CSVFileLocation"), True)
Dim fieldCount As Integer = csv.FieldCount
The error message "An item with the same key has already been added." on the second line.
If I changed "HasReaders" to "False", there's no such error. But, I'm not able to get the Headers.
Could somebody help me on this, please?
FYI: I'm using Visual Studio 2010 version.
Regards,
Richard
Check that your CSV file may have duplicate column names, or multiple empty cells, in the header row?
If that's the case, try to loop through your csv object, and try rename the headers in code before calling the property FieldCount.
My guess is that the CsvReader class is going through the first row adding strings to a dictionary, and the header row has two cells with the same value (so two identically named fields). Take a look at your data and see if this is the case. Alternately, if you have access to the source code for CsvReader, you could have it handle this case by naming the second field something slightly different (e.g., by appending a "1" onto the end of its name).