Record.COPY with Temporary variable

FishermanFisherman Member Posts: 456

I have a function that is calling Codeunit 99000770 (Where-Used Management) in order to find out which assemblies a particular component is used in. I've added a new fuction to Where-Used Management to externalize the results to my function. That new function looks like this:
CopyWhereUsed(VAR WhereUsedListCopy : TEMPORARY Record "Where-Used Line") Count : Integer


WhereUsedList is the existing global, temporary record variable pointing to Where-Used Line. In my calling function, I trap the result as
AssyCount := WhereUsedMgt.CopyWhereUsed(tmpWhereUsed)
IF (AssyCount > 0) THEN

When I ran it through the debugger, count was returning 0 for a component I knew to be in multiple assemblies, so I went back to Where-Used Management and inserted
MESSAGE('Where Used Count %1', WhereUsedList.COUNT());

And found that there were, in fact, 1185 records in the WhereUsedList record variable.

Any ideas here? I feel like I'm missing something basic, but after looking through posts here and online, nothing's really ringing a bell. This is 5.0 SP1.


  • Options
    FishermanFisherman Member Posts: 456
    Stupid me... forgot to loop the temporary records and insert.

    Problem solved.
  • Options
    kapamaroukapamarou Member Posts: 1,152
    Well, if you are using 2009R2 and both tables are temporary you could try using
    Record.COPY(FromRecord [, ShareTable])
    Type: Boolean
    Specifies whether the function creates a copy of the record or creates a reference to a temporary record.
    If FromRecord and Record are both temporary and ShareTable is true, then the COPY function does not create a new copy of the record. Instead, the COPY function causes Record to reference the same table as FromRecord.
    The default value is false. If you specify false, all records are copied to Record from FromRecord.
  • Options
    FishermanFisherman Member Posts: 456
    I've been wondering about that. We're not in 2009 yet, but will be migrating soon.
  • Options
    jglathejglathe Member Posts: 639

    this replaces the array of temporary record structure/workaround. Nice feature, this.

    with best regards

Sign In or Register to comment.