Problem when adding buffer to dynamic dataset

Posted by MBeynon on 27-Feb-2013 02:43

Hi,

I have some code which attempts to add a buffer to a dynamic dastaset from another dataset:

DEFINE VARIABLE lvhDataSetHandle AS HANDLE NO-UNDO.

CREATE DATASET lvhDataSetHandle.

        lvhDataSetHandle:EMPTY-DATASET().

        DO lviCount = 1 TO pvDataset:NUM-TOP-BUFFERS:
          MESSAGE "Adding " pvDataset:GET-BUFFER-HANDLE(lviCount):TABLE-HANDLE:name
          VIEW-AS ALERT-BOX.

          lvhDataSetHandle:ADD-BUFFER(pvDataset:GET-BUFFER-HANDLE(lviCount):TABLE-HANDLE).
        END.

The problem is I can't even add one buffer as I get this error:

Buffer <buffer name> may not appear more than once in any dataset. (11860)

This seems strange as the first time through the loop there are no buffers in the datset at all!

pvDataset is a dataset handle containing buffers with no relationships to each other, hence NUM-TOP-BUFFERS.

Thanks,

Mark.

All Replies

Posted by gdb390 on 27-Feb-2013 07:01

Hey Mark,

The solution should be something like this :

DO lviCount = 1 TO dataset ds:NUM-TOP-BUFFERS:

          vhBuffer = dataset ds:get-top-buffer(lvicount).

         
          create buffer vhNewBuffer for table vhBuffer.

          lvhDataSetHandle:add-buffer(vhNewbuffer).

END.

The reason why your code didn't work, is that you were adding the buffer from dataset  to the new dataset.

You have to create a new buffer similar to the one from dataset 1 and than you can add it

HTH

Gerd

Posted by MBeynon on 06-Mar-2013 02:46

Many thanks,

Mark

This thread is closed