Focal Point Banner


As of December 1, 2020, Focal Point is retired and repurposed as a reference repository. We value the wealth of knowledge that's been shared here over the years. You'll continue to have access to this treasure trove of knowledge, for search purposes only.

Join the TIBCO Community
TIBCO Community is a collaborative space for users to share knowledge and support one another in making the best use of TIBCO products and services. There are several TIBCO WebFOCUS resources in the community.

  • From the Home page, select Predict: WebFOCUS to view articles, questions, and trending articles.
  • Select Products from the top navigation bar, scroll, and then select the TIBCO WebFOCUS product page to view product overview, articles, and discussions.
  • Request access to the private WebFOCUS User Group (login required) to network with fellow members.

Former myibi community members should have received an email on 8/3/22 to activate their user accounts to join the community. Check your Spam folder for the email. Please get in touch with us at community@tibco.com for further assistance. Reference the community FAQ to learn more about the community.


Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOLVED] Stack copy in maintain

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[SOLVED] Stack copy in maintain
 Login/Join
 
Guru
posted
Hi,
I have three stacks say stk1,stk2 and stk3 and all has only one column 'name'. I want to copy only those records from stk1 to stk3 which are are not in stk2. e.g, Suppose stk1 have 5 values [say A,B,C,D and E] and stk2 has 3 values [B,D and F]. Now, stk3 should have values A,C and E (which are in stk1 but not in stk2). Please advice.

Thanks in advance.

This message has been edited. Last edited by: <Kathryn Henning>,


WF 8.1.04,Windows 7,
DataBase: Oracle 11g,Output :Excel,PDF,HTML
 
Posts: 281 | Location: India | Registered: April 21, 2007Report This Post
Virtuoso
posted Hide Post
There is not an option to copy a stack dependent upon values in another stack. It has to be a manual process.
Basically step through each stack, sorted on name, within a repeat and copy into stk3 when stk1 has a value less than stk2. Remember to completely run through stk1, and that you will need 3 counters, one for each stack.


Alan.
WF 7.705/8.007
 
Posts: 1451 | Location: Portugal | Registered: February 07, 2007Report This Post
Guru
posted Hide Post
Hi Alan,
Can you please help me with the code.

Thanks for your help.


WF 8.1.04,Windows 7,
DataBase: Oracle 11g,Output :Excel,PDF,HTML
 
Posts: 281 | Location: India | Registered: April 21, 2007Report This Post
Master
posted Hide Post
Here is the code based on your specifics:

COMPUTE I/I2=1;
COMPUTE K/I2=0;
REPEAT STK1.FOCCOUNT
COMPUTE J/I2=1;
COMPUTE FLAG/I1=0;
REPEAT STK2.FOCCOUNT
IF STK1(I).NAME EQ STK2(J).NAME THEN BEGIN
COMPUTE FLAG=1;
GOTO EXITREPEAT
ENDBEGIN
COMPUTE J=J+1;
ENDREPEAT
IF FLAG = 0 THEN BEGIN
COMPUTE K=K+1;
COPY FROM STK1(I) INTO STK3(K);
ENDBEGIN
COMPUTE I=I+1;
ENDREPEAT
 
Posts: 663 | Location: New York | Registered: May 08, 2003Report This Post
Virtuoso
posted Hide Post
Always subtly different...
MAINTAIN

Case Top
Stack1.Name/a12;
Stack2.Name/a12;
Stack3.Name/a12;

  LoadStacks();

  Compare();

EndCase

Case Compare
Declare (i/i4;j/i4;k/i4;);

Stack Sort Stack1 by Name;
Stack Sort Stack2 by Name;

Repeat until Stack1(i).Name eq ' '; i=1;j=1;k=1;
  type "--------------" ;
  type "Stack1 -  " Stack1(i).Name;
  type "Stack2 -  " Stack2(j).Name;

  if STRNCMP(Stack1(i).Name, Stack2(j).Name, 12) eq 0 begin
    i=i+1; j=j+1;
    goto endRepeat;
  endbegin

  if (STRNCMP(Stack1(i).Name, Stack2(j).Name, 12) lt 0) or (Stack2(j).Name eq ' ') begin
    type "into Stack3 -  " Stack1(i).Name; 
    for 1 copy from stack1(i) into Stack3(k);
    k=k+1;i=i+1;
    goto endRepeat;
  endbegin

  if STRNCMP(Stack1(i).Name, Stack2(j).Name, 12) gt 0 begin
    j=j+1;
    goto endRepeat;
  endbegin

endRepeat

  type "--------------" ;

Repeat stack3.foccount k=1;
  type "Stack3 index "  k   " - value is "  Stack3(k).name;
endrepeat k=k+1;

EndCase

Case LoadStacks
Declare (i/i4;alphabet/a26='QWERTYUIOPASDFGHJKLZXCVBNM';);

type "Stack1 values";

Repeat 12 i=1;
  Stack1(i).Name = SUBSTR(alphabet,i*2,1);
  type Stack1(i).Name;
endRepeat i=i+1;

type "Stack2 values";

Repeat 8 i=1;
  Stack2(i).Name = SUBSTR(alphabet,i*3,1);
  type Stack2(i).Name;
endRepeat i=i+1;

EndCase
End


Forgot Stack Sort and final values in stack1!

This message has been edited. Last edited by: Alan B,


Alan.
WF 7.705/8.007
 
Posts: 1451 | Location: Portugal | Registered: February 07, 2007Report This Post
Virtuoso
posted Hide Post
Found the old code I was looking for.
MAINTAIN
module import(mntuws)

Declare compare/matchStack;

Describe matchStack = ()
 Case old_and_new takes oldstring/a0, newstring/a0, length/i4 returns outputString/a0;

  if STRNCMP(oldstring, newstring, length) eq 0 and oldstring ne ' ' begin
    outputString='copyOld_old_new';  goto EndCase;
  endbegin

  if (STRNCMP(oldstring, newstring, length) lt 0) or (newstring eq ' ') begin
    outputString='noCopy_old'; goto EndCase;
  endbegin

  if STRNCMP(oldstring, newstring, length) gt 0 begin
    outputString='noCopy_new'; goto EndCase;
  endbegin
 EndCase

 Case old_not_new takes oldstring/a0, newstring/a0, length/i4 returns outputString/a0;

  if STRNCMP(oldstring, newstring, length) eq 0 begin
    outputString='noCopy_old_new'; goto EndCase;
  endbegin

  if (STRNCMP(oldstring, newstring, length) lt 0) or (newstring eq ' ') begin
    outputString='copyOld_old'; goto EndCase;
  endbegin

  if STRNCMP(oldstring, newstring, length) gt 0 begin
    outputString='noCopy_new'; goto EndCase;
  endbegin
 EndCase

 Case old_nor_new takes oldstring/a0, newstring/a0, length/i4 returns outputString/a0;

  if STRNCMP(oldstring, newstring, length) eq 0 begin
    outputString='noCopy_old_new'; goto EndCase;
  endbegin

  if (STRNCMP(oldstring, newstring, length) lt 0) or (newstring eq ' ') begin
    outputString='copyOld_old'; goto EndCase;
  endbegin

  if STRNCMP(oldstring, newstring, length) gt 0 or (oldstring eq ' ') begin
    outputString='copyNew_new'; goto EndCase;
  endbegin

 EndCase

 Case old_or_new takes oldstring/a0, newstring/a0, length/i4 returns outputString/a0;

  if STRNCMP(oldstring, newstring, length) eq 0 begin
    outputString='copyOld_old_new'; goto EndCase;
  endbegin

  if (STRNCMP(oldstring, newstring, length) lt 0) or (newstring eq ' ') begin
    outputString='copyOld_old'; goto EndCase;
  endbegin

  if STRNCMP(oldstring, newstring, length) gt 0 begin
    outputString='copyNew_new'; goto EndCase;
  endbegin
 EndCase

EndDescribe;


Case Top
Stack1.Name/a12;
Stack2.Name/a12;
Stack3.Name/a12;

  LoadStacks();

  Compare();

EndCase

Case Compare
Declare (i/i4;j/i4;k/i4;result/a16;);

Stack Sort Stack1 by Name;
Stack Sort Stack2 by Name;

Repeat until (stack1(i).Name eq ' ' and stack2(j).Name eq ' '); i=1;j=1;k=0;
  type "--------------" ;
  type "Stack1 -  " Stack1(i).Name;
  type "Stack2 -  " Stack2(j).Name;

$$ compare.xxxxxxx arguments are OLDSTACK.FIELD, NEWSTACK.FIELD, LENGTH of FIELD.

  $$result = compare.old_and_new(Stack1(i).Name,Stack2(j).Name,12);  $$ Articles that appear in both the old and the new files.
  result = compare.old_not_new(Stack1(i).Name,Stack2(j).Name,12);  $$ Articles that appear only in the old file and not in the new file.
  $$result = compare.old_or_new(Stack1(i).Name,Stack2(j).Name,12);  $$ Articles that appear in the old and new files, no repeats.
  $$result = compare.old_nor_new(Stack1(i).Name,Stack2(j).Name,12);  $$ Articles that are uniquely in the old or new files, not in both.

  if result contains 'copyOld' then begin 
    k=k+1; for 1 copy from stack1(i) into Stack3(k); 
  endbegin
  else 
  if result contains 'copyNew' then begin 
    k=k+1; for 1 copy from stack2(j) into Stack3(k);
  endbegin

  if result contains '_old' then i=i+1;
  if result contains '_new' then j=j+1;

endRepeat

  type "--------------" ;

Repeat stack3.foccount k=1;
  type "Stack3 index "  k   " - value is "  Stack3(k).name;
endrepeat k=k+1;

EndCase

Case LoadStacks
Declare (i/i4;alphabet/a26='QWERTYUIOPASDFGHJKLZXCVBNM';);

type "Stack1 values";

Repeat 12 i=1;
  Stack1(i).Name = SUBSTR(alphabet,i*2,1);
  type Stack1(i).Name;
endRepeat i=i+1;

type "Stack2 values";

Repeat 8 i=1;
  Stack2(i).Name = SUBSTR(alphabet,i*3,1);
  type Stack2(i).Name;
endRepeat i=i+1;

EndCase
End
This will emulate the basics of MATCH FILE with 'old_and_new', 'old_not_new', old_or_new, old_nor_new.

The Describe class could be separated out into an import module if required so that the code can be reused across multiple maintains.


Alan.
WF 7.705/8.007
 
Posts: 1451 | Location: Portugal | Registered: February 07, 2007Report This Post
Guru
posted Hide Post
Thanks Mark and AlanB for your help.

Best Regards.


WF 8.1.04,Windows 7,
DataBase: Oracle 11g,Output :Excel,PDF,HTML
 
Posts: 281 | Location: India | Registered: April 21, 2007Report This Post
  Powered by Social Strata  

Read-Only Read-Only Topic

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOLVED] Stack copy in maintain

Copyright © 1996-2020 Information Builders