cancel
Showing results for 
Search instead for 
Did you mean: 

copy expenses from base document

martin_heigl
Participant
0 Kudos

i want to copy a "purcase order po" to "goods receipt po"

(...)

odocument.lines.baseentry=5

odocument.lines.baseline=0

odocument.lines.basetype=22

this is working

and i need the freight from the base-document (not from the lines)

(example only one line in the base document)

odocument.expenses.basedocentry=5

odocument.expenses.basedoctype=22

odocument.expenses.basedocline=0

but this is not working

please help

regards

M.Heigl

Accepted Solutions (1)

Accepted Solutions (1)

edy_simon
Active Contributor
0 Kudos

Hi M,

Are you sure your base document header has the expenses ?

the odocument.expenses.BaseDocLine should refer to the POR3 table LineNum field.

Which B1 version are you on ?

I am able to do it in 881. PL 9.

Regards

Edy

martin_heigl
Participant
0 Kudos

Hi Edy,

i use  8.82.064 PL:03

Yes, the base-document has expenses

and all Data in the Database are correct

if i insert this three lines in my existing source code

odocument.expenses.basedocentry=58

odocument.expenses.basedoctype=22

odocument.expenses.basedocline=0

Answer: No matching recorts found (ODBC -2028)

i check the Profiler and search for "por3"

all other tables are correct, but no select on por3

(sorry, is german. Answer: "por3 not found")

I created the GRPo without the 3 lines: all ok - but without Freight

I created the GRPo with SAP: all ok with Freight

regards

Nussi
Active Contributor
0 Kudos

Hi,

just some suggestions:

did you use Documents.Expenses.SetCurrentLine(0)

and has ExpenseCode and Name of .Expenses a Value than?

because these two fields are Mandatory...

just an idea...

lg David

edy_simon
Active Contributor
0 Kudos

Hi Martin,

I ran a quick test on 882 PL5 using below code (VBA script)

It is working fine.

Below code will add the PO and after successfull addition, add the GRPO

     Set oPO = oComp.GetBusinessObject(oPurchaseOrders

    oPO.CardCode = "V10000"

    oPO.DocDate = Now

    oPO.DocDueDate = Now

   

    oPO.Lines.ItemCode = "A00002"

    oPO.Lines.Quantity = 1

   

    oPO.Expenses.ExpenseCode = 1

    oPO.Expenses.LineTotal = 10

   

    lErr = oPO.Add

   

    If lErr = 0 Then

          iDocEntry   = oComp.GetNewObjectKey

          Set oGR = oComp.GetBusinessObject(20)    'GoodReceipt PO

         oGR.CardCode = "V10000"

         oGR.DocDate = Now

         oGR.DocDueDate = Now

   

         oGR.Lines.BaseEntry = iDocEntry

         oGR.Lines.BaseLine = 0

         oGR.Lines.BaseType = 22

   

         oGR.Expenses.BaseDocEntry = iDocEntry

         oGR.Expenses.BaseDocLine = 0

         oGR.Expenses.BaseDocType = 22

   

         lErr = oGR.Add

   

         If lErr <> 0 Then MsgBox (.GetLastErrorDescription) Else MsgBox ("Success")

    Else

         MsgBox (oComp.GetLastErrorDescription)

    End If

    oComp.Disconnect

Regards

Edy

martin_heigl
Participant
0 Kudos

Hello,

the error is in 882 PL3. Now i work with 882 PL 7 and the Script is working

thanks for your help

regards

Answers (0)