cancel
Showing results for 
Search instead for 
Did you mean: 

Unsetting SetCurrentLine in DI API for B1

Former Member
0 Kudos

I am writing a method in which users input data into a PHP form and the data gets sent into SAP. The one hangup I have is working with SetCurrentLine, specifically when a user attempts to update a BP Address and also add a new BP Address. First I have to check to see if the Address already exists, so I do a For loop as such:

for ($i=0; $i<$oBP->Addresses->Count; $i++) {

$oBP->Addresses->SetCurrentLine($i);

     if ($oBP->Addresses->AddressName == $billname && $oBP->Addresses->AddressType == 1) {

     //code here

     }

}

However, if I then wish to add a new address as such:

$oBP->Addresses->AddressType = 0;

  $oBP->Addresses->AddressName = 'test';

  $oBP->Addresses->add();

it still has SetCurrentLine set from the for loop and thus just overwrites the address at the last LineNum. Is there a way to UnsetCurrentLine i.e. tell the DI API that I want to input a new address as opposed to working on the current LineNum? I'm not sure how to work around this issue.

Accepted Solutions (0)

Answers (1)

Answers (1)

edy_simon
Active Contributor
0 Kudos

Hi Ian,

As with most of the DI API object :

  1. By default, a new object has already a new line for you to enter data.
  2. The Line Add() methods adds a new empty line for you to enter. (Not add the line you have just entered the data into the object)

Example.

When you initialize a new BP object, :

  1. An empty line in the address is available for you to enter the address. (You do not need to call the Add() method)
  2. If you need to enter a 2nd new address, before entering the new address, you call the Add() method first. This will give you a second empty line in the address object.

In such view, for your answer,


$oBP->Addresses->add();

$oBP->Addresses->AddressType = 0;

$oBP->Addresses->AddressName = 'test';

Regards

Edy