Workspace source report

Posted by cverbiest on 22-Dec-2015 08:46

I created a quick report temp-table to show workspace sources.

The report builds a temp-table showing the source workspaces for products/pmods.

Quick =

  • I did not have time to find out which sdo I could use for this so it reads directly from the rtb database.
  • I did not create an actual report either, opening the resulting xml in Excel works fine for me.
  • No nice UI, just run from procedure editor

I have no immediate plans of extending this but it would be nice if

  • this would collect it's data using an api instead of direct db access
  • we could round-trip, update the temp-table and write the result back

/*
assume nothing works, and you may be pleasantly surprised; and when it breaks, you get to keep both pieces. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ def var lwspace-id as char init "Test". def var tpmodsource-hnd as handle no-undo. def var tpmodsource-bufhnd as handle no-undo. update lwspace-id. run CreateTemptable. run FillTempTable. tpmodsource-hnd:write-json("file", subst("&1/&2_wspacepmod.json", session:temp-directory, lwspace-id), yes). tpmodsource-hnd:write-xml("file", subst("&1/&2_wspacepmod.xml", session:temp-directory, lwspace-id), yes). finally: delete object tpmodsource-hnd. end finally. /******************************/ procedure FillTempTable: for each rtb_wssrc where rtb_wssrc.wspace-id = lwspace-id no-lock: run FindOrCreatewspacePmod(rtb_wssrc.wspace-id, rtb_wssrc.product-id, ""). tpmodsource-bufhnd:buffer-field(subst("from-&1", rtb_wssrc.src-wspace-id)):buffer-value = src-status. tpmodsource-bufhnd:buffer-release(). for each rtb_wspmod where rtb_wspmod.wspace-id = rtb_wssrc.wspace-id and rtb_wspmod.src-wspace-id = rtb_wssrc.src-wspace-id no-lock: run FindOrCreatewspacePmod(rtb_wspmod.wspace-id, rtb_wspmod.product-id, rtb_wspmod.pmod). tpmodsource-bufhnd:buffer-field(subst("from-&1", rtb_wssrc.src-wspace-id)):buffer-value = rtb_wspmod.src-status. tpmodsource-bufhnd:buffer-release(). end. end. end procedure. /* FillTempTable */ /******************************/ procedure FindOrCreatewspacePmod: def input param iwspace-id as char no-undo. def input param iproduct-id as char no-undo. def input param ipmod as char no-undo. tpmodsource-bufhnd:find-unique(subst("where wspace-pmod.wspace-id = '&1' and wspace-pmod.product-id = '&2' and wspace-pmod.pmod = '&3'", iwspace-id, iproduct-id, ipmod)) no-error. if not tpmodsource-bufhnd:available then do: tpmodsource-bufhnd:buffer-create(). tpmodsource-bufhnd::wspace-id = iwspace-id. tpmodsource-bufhnd::product-id = iproduct-id. tpmodsource-bufhnd::pmod = ipmod. end. end procedure. /* FindOrCreate */ /******************************/ procedure CreateTemptable: create temp-table tpmodsource-hnd. tpmodsource-hnd:add-new-field("wspace-id", "char" , 0). tpmodsource-hnd:add-new-field("product-id", "char" , 0). tpmodsource-hnd:add-new-field("pmod", "char" , 0). for each rtb_wssrc where rtb_wssrc.wspace-id = lwspace-id break by src-wspace-id: if first-of(src-wspace-id) then tpmodsource-hnd:ADD-NEW-FIELD ( subst("from-&1", rtb_wssrc.src-wspace-id) , "char" , 0). disp rtb_wssrc. end. tpmodsource-hnd:ADD-NEW-INDEX("wspace-pmod", TRUE, TRUE). tpmodsource-hnd:ADD-INDEX-FIELD("wspace-pmod", "wspace-id"). tpmodsource-hnd:ADD-INDEX-FIELD("wspace-pmod", "product-id"). tpmodsource-hnd:ADD-INDEX-FIELD("wspace-pmod", "pmod"). tpmodsource-hnd:TEMP-TABLE-PREPARE("wspace-pmod" ). tpmodsource-bufhnd = tpmodsource-hnd:default-buffer-handle. end procedure. /* CreateTemptable */

All Replies

Posted by Jeff Ledbetter on 22-Dec-2015 09:16

Hi Carl.

That information is available in the proxy layer (which returns temp-tables). Most everything is available in the proxy layer actually. :)

I'll try and put together a sample later today.

Posted by asthomas on 07-Jan-2016 09:37

Carl,

If there are methods for the proxy calls you need in RtbProxyHelper.cls, then you should be able to work things out from there.

This thread is closed