cancel
Showing results for 
Search instead for 
Did you mean: 

BP Addresses line number

tjandra_afandi2
Participant
0 Kudos

Hi, I'm using SAP 9.1

I'm wondering what's the rule for calling SetCurrentLine for BP Addresses? Looks like it's not using CRD1.LineNum field (ie. RowNum property)?

Eg. I have a BP with 4 addresses, and the LineNum is out-of-order, ie. 1, 2, 3, 0 based on this query:

SELECT * FROM CRD1 WHERE CardCode = 'G5K99T'

Test program:

dim oo

set oo = oCompany.GetBusinessObject(obusinesspartners)

oo.GetByKey("G5K99T")

with oo.Addresses

  .SetCurrentLine(0)

  Response.Write .RowNum & "<br>"

  .SetCurrentLine(1)

  Response.Write .RowNum & "<br>"

  .SetCurrentLine(2)

  Response.Write .RowNum & "<br>"

  .SetCurrentLine(3)

  Response.Write .RowNum & "<br>"

end with

The output of this test program is:

1

2

3

0

... which means the RowNum property is from CRD1.LineNum field, but the SetCurrentLine() is just based on the query?

Does this mean the RowNum is not really useful in pointing to the correct line, and also there's no reliable way to call SetCurrentLine() without knowing the row sequence from SQL query?

Accepted Solutions (1)

Accepted Solutions (1)

former_member233854
Active Contributor
0 Kudos

Hi Tjandra,

For documents you have the field VisOrder, I think you can use this one. As for BP I didn't find anything you could use, but you can do something like this below

select ROW_NUMBER() over (order by crd1.cardcode) - 1 as 'RowNum', * from CRD1 where cardcode = 'V70000'

In my understanding the LineNum field is used only as part of the key of the child tables.

tjandra_afandi2
Participant
0 Kudos

Hmm... I don't feel good relying on row number from a query, especially without ORDER BY clause (see here for example: sql server - The order of a SQL Select statement without Order By clause - Stack Overflow)

What I mean is that I'm afraid that row #2 now might become row# 3 later....

Is this the way it works (ie. not using LineNum field) since old versions?

Thanks

former_member233854
Active Contributor
0 Kudos

hmm I got your concern.

I assume it was always like this, I think SAP wouldn't remove any old field, they usually keep them.

The other way you have to do it, but I don't think it is good haha and you might have thought about it.. you can loop through the Lines and check if the LineNum is one you are looking for, then use SetCurrentLine.

edy_simon
Active Contributor
0 Kudos

Hi Tjandra,

One way is to loop the BP Addresses.

The other way is to use query :

SELECT VisOrder FROM (

SELECT ROW_NUMBER() OVER(ORDER BY Address, AdresType) VisOrder, Address  FROM CRD1 WHERE CardCode = 'MyBPCode') WHERE Address = 'TheAddressYouAreLookingFor'

Note that the query has include an ordering by Address and AdresType.

If you do this query right after you call the oBP.GetByKey() you should be okay.

If the record changes in between you call this and oBP.Update(), SAP will not let you go through, there will be a record conflict resolution, ie, the 'Another user modified table' message you might see in the Application.

Unless somebody modify the record by direct SQL statement (Which is illegal in SAP).

Regards

Edy

Answers (1)

Answers (1)

tjandra_afandi2
Participant
0 Kudos

FYI for those who got the same issue/question, hope this helps:

Update oBP.Addresses

http://scn.sap.com/message/9411406