cancel
Showing results for 
Search instead for 
Did you mean: 

creating purchase order from code

Former Member
0 Kudos

I am importing an excel file and then for each row,trying to create purchase order through coding by using document object. I am successful in creating Order Headers but how can i create Lines if the excel sheet is having Same order but different Item codes????

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hello,

Please refer to the post you have posted.

Thanks,

Nick He

Former Member
0 Kudos

Suppose there are more than 1 lines, then how can I insert it into purchase order?? Should I use some loop ...

Former Member
0 Kudos

Hi Ashish,

If you want to add more than one line item in the same PO Header , use PO.Lines.Add before the next item.

PO.CardCode="V0001"

PO.Lines.ItemCode="ITEM001"

PO.Lines.Quantity =10

PO.Lines.Add()

PO.Lines.ItemCode ="ITEM0002"

PO.Lines.Quantity =20

'// You can ad many no of line item here using PO.Lines.Add()

IRET =PO.Add()

Regards

BBN

Former Member
0 Kudos

I was trying to import excel file in purchase order by following way:-

I read each row and for each row, call function for creating order. This is my sample code---

(var30 is previous excel value of order no. & var1 is current value)

public sub createorder()

odocs = GOD_Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oPurchaseOrders)

If irow = 2 Then

odocs.CardCode = "200173"

odocs.Lines.ItemCode = var16

odocs.Lines.Add()

Else

If var1 = var30 Then

odocs.CardCode = "200173"

odocs.Lines.ItemCode = "3231015"

odocs.Lines.Add()

Else

lRetCode = odocs.Add()

odocs.CardCode = "200173"

odocs.Lines.ItemCode = var16

odocs.Lines.Add()

End If

End If

lRetCode = odocs.Add()

Dim x As String

GOD_Company.GetNewObjectCode(x)

If lRetCode <> 0 Then

GOD_Company.GetLastError(lErrCode, sErrMsg)

MsgBox(sErrMsg)

Else

MsgBox("Order Created with no " & x & ".")

End If

var30 = var1

This code is giving error as "Item No. is missing(OPOR.ObjType)", But Item no. is not present in Purchase Order. Please check whether Code is proper or i need to make any changes???????/

Former Member
0 Kudos

Hi Ashish,

Every time you call Documents_Lines.Add(), the system creates a new line for you to fill in.

You must set the values for itemcode etc. on each line you create, including the last. Otherwise you will get an error message.

You should call lines.Add() before you are about to add a new line, not after (except for the first line, as the line has already been added for you).

Henry

Answers (0)