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] REPEAT in MODIFY

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[solved] REPEAT in MODIFY
 Login/Join
 
Master
posted
Hello

Below sample code I have works successfully as needed to insert 3 records to database.
Can anyone help in simplifying the code to use only 1 MODIFY statement instead of 3 using REPEAT LOOP?

-:REC1
-SET &FLD1 = 'VAL1';
-SET &FLD2 = 'VAL2';
-SET &FLD3 = 'VAL3';
-GOTO :MODIFY1;
 
-:REC2
-SET &FLD1 = 'VAL1';
-SET &FLD2 = 'VAL4';
-SET &FLD3 = 'VAL5';
-GOTO :MODIFY2;
 
-:REC3
-SET &FLD1 = 'VAL1';
-SET &FLD2 = 'VAL6';
-SET &FLD3 = 'VAL7;
-GOTO :MODIFY3;
 
 
-:MODIFY1
MODIFY FILE TABLE_NAME
FREEFORM FLD1 FLD2 FLD3
MATCH FLD1
	ON MATCH   INCLUDE FLD2 FLD3
	ON NOMATCH INCLUDE FLD2 FLD3
DATA
FLD1='&FLD1', FLD2='&FLD2', FLD3='&FLD3', $
END
-RUN
-GOTO :REC2;
 
 
 
-:MODIFY2
MODIFY FILE TABLE_NAME
FREEFORM FLD1 FLD2 FLD3
MATCH FLD1
	ON MATCH   INCLUDE FLD2 FLD3
	ON NOMATCH INCLUDE FLD2 FLD3
DATA
FLD1='&FLD1', FLD2='&FLD2', FLD3='&FLD3', $
END
-RUN
-GOTO :REC3;
 
 
 
 
-:MODIFY3
MODIFY FILE TABLE_NAME
FREEFORM FLD1 FLD2 FLD3
MATCH FLD1
	ON MATCH   INCLUDE FLD2 FLD3
	ON NOMATCH INCLUDE FLD2 FLD3
DATA
FLD1='&FLD1', FLD2='&FLD2', FLD3='&FLD3', $
END
-RUN
-GOTO :END1;
-:END1  



Please suggest.

Thanks.

This message has been edited. Last edited by: Enigma006,


8.1.05
HTML,PDF,EXL2K, Active, All
 
Posts: 484 | Registered: February 03, 2009Report This Post
Expert
posted Hide Post
You should be able to have all three records in the data area.
MODIFY FILE TABLE_NAME
FREEFORM FLD1 FLD2 FLD3
MATCH FLD1
	ON MATCH   INCLUDE FLD2 FLD3
	ON NOMATCH INCLUDE FLD2 FLD3
DATA
FLD1='&FLD1a', FLD2='&FLD2a', FLD3='&FLD3a', $
FLD1='&FLD1b', FLD2='&FLD2b', FLD3='&FLD3b', $
FLD1='&FLD1c', FLD2='&FLD2c', FLD3='&FLD3c', $
END


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

 
Posts: 6347 | Location: 33°49'23.0"S, 151°11'41.0"E | Registered: October 31, 2006Report This Post
Master
posted Hide Post
quote:
Originally posted by Waz:
You should be able to have all three records in the data area.
MODIFY FILE TABLE_NAME
FREEFORM FLD1 FLD2 FLD3
MATCH FLD1
	ON MATCH   INCLUDE FLD2 FLD3
	ON NOMATCH INCLUDE FLD2 FLD3
DATA
FLD1='&FLD1a', FLD2='&FLD2a', FLD3='&FLD3a', $
FLD1='&FLD1b', FLD2='&FLD2b', FLD3='&FLD3b', $
FLD1='&FLD1c', FLD2='&FLD2c', FLD3='&FLD3c', $
END


hello waz, how would I direct the control to MODIFY? Each set of SET statement values will be replaced by next set if I give them continuously. please provide full code.


8.1.05
HTML,PDF,EXL2K, Active, All
 
Posts: 484 | Registered: February 03, 2009Report This Post
Virtuoso
posted Hide Post
quote:
MODIFY FILE TABLE_NAME
FREEFORM FLD1 FLD2 FLD3
MATCH FLD1
ON MATCH INCLUDE FLD2 FLD3
ON NOMATCH INCLUDE FLD2 FLD3
DATA
FLD1='&FLD1', FLD2='&FLD2', FLD3='&FLD3', $
END


Go review the syntax; INCLUDE (as opposed to UPDATE) operates on entire segments, and does not take a list of fields.
Also, ON MATCH INCLUDE is valid syntax, but rarely appropriate.

If FLD1 is the sole key, you probably need

ON MATCH REJECT
ON NOMATCH INCLUDE 


or maybe

ON MATCH UPDATE FLD2 FLD3
ON NOMATCH INCLUDE  


- Jack Gross
WF through 8.1.05
 
Posts: 1925 | Location: NYC | In FOCUS since 1983 | Registered: January 11, 2005Report This Post
Master
posted Hide Post
quote:
Originally posted by j.gross:
quote:
MODIFY FILE TABLE_NAME
FREEFORM FLD1 FLD2 FLD3
MATCH FLD1
ON MATCH INCLUDE FLD2 FLD3
ON NOMATCH INCLUDE FLD2 FLD3
DATA
FLD1='&FLD1', FLD2='&FLD2', FLD3='&FLD3', $
END


Go review the syntax; INCLUDE (as opposed to UPDATE) operates on entire segments, and does not take a list of fields.
Also, ON MATCH INCLUDE is valid syntax, but rarely appropriate.

If FLD1 is the sole key, you probably need

ON MATCH REJECT
ON NOMATCH INCLUDE 


or maybe

ON MATCH UPDATE FLD2 FLD3
ON NOMATCH INCLUDE  


This is sample code and my main issue is looping the code and not REJECT or UPDATE records.


8.1.05
HTML,PDF,EXL2K, Active, All
 
Posts: 484 | Registered: February 03, 2009Report This Post
Master
posted Hide Post
quote:
Originally posted by Waz:
You should be able to have all three records in the data area.
MODIFY FILE TABLE_NAME
FREEFORM FLD1 FLD2 FLD3
MATCH FLD1
	ON MATCH   INCLUDE FLD2 FLD3
	ON NOMATCH INCLUDE FLD2 FLD3
DATA
FLD1='&FLD1a', FLD2='&FLD2a', FLD3='&FLD3a', $
FLD1='&FLD1b', FLD2='&FLD2b', FLD3='&FLD3b', $
FLD1='&FLD1c', FLD2='&FLD2c', FLD3='&FLD3c', $
END


waz, I got it to work. thank you..


8.1.05
HTML,PDF,EXL2K, Active, All
 
Posts: 484 | Registered: February 03, 2009Report This Post
Virtuoso
posted Hide Post
quote:
This is sample code and my main issue is looping the code and not REJECT or UPDATE records.


Then either stack the transactions under DATA, as WAZ indicated,

or you can house the MODIFY in a separate fex (with parameters &FLD1, &FLD2, &FLD3) and EX that once per set of values:

EX my_modify_fex FLD1=aaa,FLD2=bbb,FLD3=ccc
EX my_modify_fex FLD1=ddd,FLD2=eee,FLD3=fff
EX my_modify_fex FLD1=ggg,FLD2=hhh,FLD3=iii

Depends on how you are coming by the transaction sets.


- Jack Gross
WF through 8.1.05
 
Posts: 1925 | Location: NYC | In FOCUS since 1983 | Registered: January 11, 2005Report This Post
Master
posted Hide Post
Enigma - You've marked it Solved, so this is just a comment.

When you put the incoming data after the DATA command at the bottom of a simple MODIFY the "looping" you refer to is implied and doesn't need to be explicitly coded. Control branches from before the END statement back up to the first line after the MODIFY FILE command. When the last data line is processed the END statement is invoked and control passes out of the MODIFY.

As Jack says, when the data is outside the MODIFY there are number of approaches - and the one he suggests here (with parameters after the FEX name) is news to me, even though I've been writing MODIFYs for 30 years ...


WebFOCUS 7.7.05 Windows, Linux, DB2, IBM Lotus Notes, Firebird, Lotus Symphony/OpenOffice. Outputs PDF, Excel 2007 (for OpenOffice integration), WP
 
Posts: 674 | Location: Guelph, Ontario, Canada ... In Focus since 1985 | Registered: September 28, 2010Report This Post
Virtuoso
posted Hide Post
To spell it out:
-* first.fex
EX SECOND 'aaa','bbb','ccc'
EX SECOND 'ddd','eee','fff'
EX SECOND 'ggg','hhh','iii'

-* second.fex
MODIFY FILE TABLE_NAME
FREEFORM FLD1 FLD2 FLD3
MATCH FLD1
	ON MATCH REJECT 
	ON NOMATCH INCLUDE 
DATA
FLD1='&1', FLD2='&2', FLD3='&3', $
END 


Not that I recommend it -- why force parsing of the MODIFY three times? -- but it answers the original question: How to avoid coding three identical MODIFY procedures.


- Jack Gross
WF through 8.1.05
 
Posts: 1925 | Location: NYC | In FOCUS since 1983 | Registered: January 11, 2005Report 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] REPEAT in MODIFY

Copyright © 1996-2020 Information Builders