cancel
Showing results for 
Search instead for 
Did you mean: 

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

former_member183402
Participant
0 Kudos

Hi all,

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\............

Below are my sample codes

$oOrder->Lines->Itemcode="A001";
$oOrder->Lines->Quantity=1;
$oOrder->Lines->UnitPrice=200;
$oOrder->Lines->BaseType="1470000113";
$oOrder->Lines->BaseEntry=7;
$RetCode=$oOrder->Lines->Add;


//THE PROBLEMS ARE HERE
$oOrder->Lines->Itemcode=A002;
$oOrder->Lines->Quantity=2;
$oOrder->Lines->UnitPrice=300;
$oOrder->Lines->BaseType="1470000113"; // IF BASE FIELDS ARE COMMENTED THE SECOND LINE WILL BE ADDED IN DATABASE BUT WITHOUT LINK OF BASE DOCUMENT
$oOrder->Lines->BaseEntry=7;// COMMENTED
$RetCode=$oOrder->Lines->Add;
$RetCode=$oOrder->Add;

This means the base doc will be still open where you can edit the second line because the second base fields stored -1 in baseentry

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

Accepted Solutions (1)

Accepted Solutions (1)

Johan_H
Active Contributor
0 Kudos

Hi,

When drawing a document (linking a source document's lines to a target document's lines), you must set four properties:

  1. BaseType, the type of the source document (sales order, goods receipt, etc.)
  2. BaseEntry, the DocEntry of the source document
  3. BaseLine, the LineNum of the line in the source document
  4. TaxCode, the VatGroup of the line in the source document

The Quantity property should only be set if the quantity is less than that of the line in the source document. Don't set any other properties like ItemCode. By drawing the line as described above, all other fields will automatically be copied by the DI API.

If you need to add lines to the target document, that are not in a source document, you must first add the new document, then open it, and only then add the none-linked lines.

Regards,

Johan

former_member183402
Participant
0 Kudos

Thank you so much Johan

former_member183402
Participant
0 Kudos

Hi Johan,

How can I add incoming payment in SAP B1 SDK? I tried to use below fields but I am getting the following error message Notice: Trying to get property of non-object in C:\wamp\www\............

Below is my sample codes (PHP)

$oIncom->CardCode="0000C";
$oIncom->DocDueDate="2018-11-06";
$oIncom->DocDate="2018-11-06";
$oIncom->TaxDate="2018-11-06";
$oIncom->CashSum=100;
$oIncom->CashAcct="569600";


$oIncom->Lines->DocEntry = 82;
$oIncom->Lines->InvType = 13;
$oIncom->Lines->DocLine = 0;
$oIncom->Lines->SumApplied = 100;
$RetCode=$oIncom->Lines->Add;

$RetCode=$oIncom->Add;

I do know if there are missing mandatory fields

Please anyone can help me

former_member183402
Participant

Hi Johan,

I did it

Thank you

Answers (0)