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] How to update many registers with MODIFY

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[SOLVED] How to update many registers with MODIFY
 Login/Join
 
Member
posted
Hi guys,

I need to update many registers at a time. Searching in the help I think that MODIFY is the way to do that but I don't know how to do it.
I coded an example where I did an update on one single register. But I need to do that in various registers. There is a way to do that?

My code to update one single register:
 -* File teste_modify.fex
-SET &ECHO=ALL;
-DEFAULT &ACAO='NADA';
-DEFAULT &MSG='';
TABLE FILE DIM_SE_TIPOS_SE
PRINT *
ON TABLE HOLD AS REL1 FORMAT HTML
END
-SET &L = IF &ACAO = 'NADA' THEN &ACAO ELSE 'LRUN';
-GOTO &L
-NADA
-HTMLFORM BEGIN
<HTML>
<HEAD>
<SCRIPT>
function executa(acao)
{
MOD.ACAO.value = acao;
MOD.submit();
}
</SCRIPT>
</HEAD>
<BODY BGCOLOR=PINK>
<H1>Exemplo de tela HTML com MODIFY</H1>
<HR>

<FORM NAME=MOD ACTION='/ibi_apps/WFServlet' METHOD="POST">
ID:<INPUT TYPE=TEXT NAME=ID VALUE="">
TE:<INPUT TYPE=TEXT NAME=TE VALUE="">
<INPUT TYPE=HIDDEN NAME="IBIF_ex" VALUE="teste_modify">
<INPUT TYPE=HIDDEN NAME="IBIAPP_app" VALUE="teste_modify">
<INPUT TYPE=BUTTON VALUE="Incluir" ONCLICK="javascript:executa('INS');">
<INPUT TYPE=BUTTON VALUE="Alterar" ONCLICK="javascript:executa('UPD');">
<INPUT TYPE=BUTTON VALUE="Apagar" ONCLICK="javascript:executa('DEL');">
<INPUT TYPE=HIDDEN NAME="ACAO" VALUE="NADA">
<INPUT TYPE=HIDDEN NAME="MSG" VALUE="NADA">
</FORM>
<HR>
!IBI.FIL.REL1;
<HR>
!IBI.AMP.MSG;
</BODY>
</HTML>
-EXIT
-LRUN
MODIFY FILE DIM_SE_TIPOS_SE
FREEFORM ID_SEQ_TIPO_SE TE_TIPO_SE
COMPUTE ACAO/A12 = '&ACAO.EVAL';
PERFORM ACAO
CASE INS
MATCH ID_SEQ_TIPO_SE
ON MATCH REJECT
ON NOMATCH INCLUDE
ENDCASE


CASE UPD
MATCH ID_SEQ_TIPO_SE
  ON MATCH UPDATE TE_TIPO_SE
  ON NOMATCH REJECT
ENDCASE


CASE DEL
MATCH ID_SEQ_TIPO_SE
    ON MATCH DELETE
    ON NOMATCH REJECT
ENDCASE
DATA
&ID,&TE,$
END


-RUN
-GOTO MSG_&ACAO
-MSG_INS
-SET &MSG = IF &INPUT EQ 1 THEN 'OK INCLUIDO ' ELSE 'NAO FOI';
-GOTO FIM
-MSG_UPD
-SET &MSG = IF &CHNGD EQ 1 THEN 'OK ALTERADO' ELSE 'NAO FOI';
-GOTO FIM
-MSG_DEL
-SET &MSG = IF &DELTD EQ 1 THEN 'OK EXCLUIDO' ELSE 'NAO FOI';
-GOTO FIM
-FIM

EX TESTE_MODIFY SET &ACAO='NADA',MSG=&MSG


 

This message has been edited. Last edited by: flavio.menezes,


WebFOCUS 8.0.02 - Windows 7
 
Posts: 12 | Location: Brazil | Registered: July 31, 2013Report This Post
Platinum Member
posted Hide Post
Hi,
What do you mean by registers?
Do you perhaps mean multiple "records" in a database?
Perhaps if you can give a very simple example of your data and what you need to do, then we could give you some examples of code.


WebFOCUS 8.2.06 mostly Windows Server
 
Posts: 195 | Location: Johannesburg, South Africa | Registered: September 13, 2008Report This Post
Member
posted Hide Post
Exactly!
Sorry for my poor english. =P

I want to update multiple records in a database.
I have a table: column1, column2 and based on the column1 key I want to update the column2 for multiple records in the database.
Talking about interface, it will be a web page showing a report with column1 and column2. So the user can select multiple lines of this reports and change the status of column2.

What do you think? Is the MODIFY the best way to do this?


WebFOCUS 8.0.02 - Windows 7
 
Posts: 12 | Location: Brazil | Registered: July 31, 2013Report This Post
Guru
posted Hide Post
Flavio,

have you considered using MAINTAIN?

Regards
Håkan


WebFOCUS DS 8.0.06/08 DS/AS
WebFOCUS RS 8.0.08 (Linux/IBM i)
WebFOCUS Client 8.0.06 (Linux)
 
Posts: 319 | Location: Stockholm, Sweden | Registered: February 04, 2004Report This Post
Member
posted Hide Post
Håkan,
No, I haven't. I will study MAINTAIN to see how it works. Thanks.


WebFOCUS 8.0.02 - Windows 7
 
Posts: 12 | Location: Brazil | Registered: July 31, 2013Report This Post
Virtuoso
posted Hide Post
You can pass many input records to MODIFY, via either a HOLD file or the DATA statement. But MODIFY loops through the input and processes each record separately, one MATCH at a time. MODIFY comes with FOCUS/WebFOCUS; MAINTAIN requires a separate license.


WebFOCUS 7.7.05
 
Posts: 1213 | Location: Seattle, Washington - USA | Registered: October 22, 2007Report This Post
Platinum Member
posted Hide Post
Hi Flavio,

This is quite a simple example. I haven't used any javascript - just a regular "form" in HTML.
There are many other ways of doing this, but this is possibly just a starting point.

What happens in this example is that if there are multiple records on a screen with the same input field name, an "array" is created.
So, for example, if there are 3 records, I will automatically have amper variables called &COURSECODE1, &COURSECODE2, &COURSECODE3 and &CTITLE1, &CTITLE2 and &CTITLE3.

In my MODIFY DATA statement I then create a loop to read the 3 records.

If there is only 1 record, then the "numbered" amper variable will NOT be created. So I've added a little extra code for that.

See if you can make sense of it!

-*
-DEFAULT &MOD_STEP = 'STEP_HTM' 
-GOTO &MOD_STEP
 
-STEP_HTM
-* Display
DEFINE FILE COURSE
THE_KEY/A80     = '<input type=hidden value="' || COURSECODE || '" name ="COURSECODE">' ;
THE_VALUE/A80 = '<input value="' || CTITLE || '" name ="CTITLE" maxlength=35>' ;
END
-RUN
 
TABLE FILE COURSE
IF COURSECODE EQ 'E$*'
PRINT 
THE_KEY AS ''
COURSECODE
THE_VALUE
BY COURSECODE NOPRINT
ON TABLE SAVE AS THE_FILE FORMAT HTMTABLE
END
-RUN
-SET &MOD_LINES = &LINES ;
 
-HTMLFORM BEGIN
<html><head></head>
<body>
<form  method="post" name="modform" action="/ibi_apps/WFServlet">
<input type=submit value="Update" name="ok">
!IBI.FIL.THE_FILE;
<input type=hidden name="MOD_LINES" value="!IBI.AMP.MOD_LINES;">
<input type=hidden name="MOD_STEP" value="STEP_MOD">
<input type=hidden name="IBIF_ex" value="tj_mod_course">
</form>
</body>
</html>
-HTMLFORM END
-GOTO STEP_BOT
 
-STEP_MOD
-* Update DB
MODIFY FILE COURSE
FREEFORM COURSECODE CTITLE
MATCH COURSECODE
ON NOMATCH REJECT
ON MATCH UPDATE CTITLE
DATA
-SET &CTR=1;
-DEFAULT &COURSECODE1 = 'XX'
-DEFAULT &CTITLE = 'XX'
-SET &COURSECODE1 = IF &MOD_LINES EQ 1 THEN &COURSECODE ELSE &COURSECODE1 ;
-SET &CTITLE = IF &MOD_LINES EQ 1 THEN &CTITLE ELSE &CTITLE1 ; 
-REPEAT MOD_LOOP &MOD_LINES TIMES
&COURSECODE.&CTR ,&CTITLE.&CTR ,$
-SET &CTR = &CTR + 1 ;
-MOD_LOOP
END
-GOTO STEP_BOT
 
-STEP_BOT
-EXIT


PS: Your English is MUCH better than my Spanish, Italian, Portuguese etc. ;-)


WebFOCUS 8.2.06 mostly Windows Server
 
Posts: 195 | Location: Johannesburg, South Africa | Registered: September 13, 2008Report This Post
Virtuoso
posted Hide Post
Twanette,

Very nice! Good One

At the risk of being hit upon for plagiarising, I added a bit of functionality: a radio button to be able to choose which records to update (notice that I localized the FOCUS file with a USE command):
  
-SET &ECHO=ALL;
-* File twanette01.fex
-*
-* Display
DEFINE FILE COURSE
THE_KEY/A80     = '<input type=hidden value="' || COURSECODE || '" name ="COURSECODE">' ;
END
-RUN
-*
USE
FOCALPOINT/COURSE.FOC AS COURSE
END
-RUN
TABLE FILE COURSE
IF COURSECODE EQ 'E$*'
PRINT
COMPUTE LL/I3=LAST LL + 1; NOPRINT
COMPUTE ULL/A4='U' | LJUST(3, FPRINT(LL, 'I3', 'A3'), 'A3'); NOPRINT
THE_KEY AS ''
COURSECODE
COMPUTE THE_VALUE/A250 = '<input type="radio" name="' | ULL | '" value="Y">Y ' | 
                         '<input type="radio" name="' | ULL | '" value="N" checked>N ' |
                         '<input value="' || CTITLE || '" name ="CTITLE" size=45 maxlength=45>' ; 
                         AS 'Update the Course Name?'
-*
BY COURSECODE NOPRINT
ON TABLE SAVE AS THE_FILE FORMAT HTMTABLE
END
-RUN
-SET &MOD_LINES = &LINES ;
-*
-HTMLFORM BEGIN
<html><head></head>
<body>
<form  method="post" name="modform" action="/ibi_apps/WFServlet">
<input type=submit value="Update" name="ok">
!IBI.FIL.THE_FILE;
<input type=hidden name="MOD_LINES" value="!IBI.AMP.MOD_LINES;">
<input type=hidden name="IBIF_ex" value="focalpoint/twanette02">
</form>
</body>
</html>
-HTMLFORM END

And for the update:
  
-SET &ECHO=ALL;
-* File twanette02.fex
-DEFAULT &COURSECODE1 = 'XX', &CTITLE1 = 'XX'
-* Update
USE
FOCALPOINT/COURSE.FOC AS COURSE
END
-RUN
MODIFY FILE COURSE
COMPUTE U/A1=;
FREEFORM U COURSECODE CTITLE
MATCH COURSECODE
ON NOMATCH REJECT
ON MATCH IF U EQ 'N' GOTO TOP;
ON MATCH UPDATE CTITLE
DATA
-SET &COURSECODE1 = IF &MOD_LINES EQ 1 THEN &COURSECODE ELSE &COURSECODE1 ;
-SET &CTITLE1 = IF &MOD_LINES EQ 1 THEN &CTITLE ELSE &CTITLE1 ;
-REPEAT #MOD_LOOP FOR &CTR FROM 1 TO &MOD_LINES;
&U.&CTR, &COURSECODE.&CTR ,&CTITLE.&CTR ,$
-#MOD_LOOP
END
? STAT


Daniel
In Focus since 1982
wf 8.202M/Win10/IIS/SSA - WrapApp Front End for WF

 
Posts: 1980 | Location: Tel Aviv, Israel | Registered: March 23, 2006Report This Post
Platinum Member
posted Hide Post
Nice!
Great teamwork ;-)


WebFOCUS 8.2.06 mostly Windows Server
 
Posts: 195 | Location: Johannesburg, South Africa | Registered: September 13, 2008Report This Post
Member
posted Hide Post
Hi guys,
You're awesome! =]

Based on your answers I could do what I wanted! Thank you so much! Here's the step by step:

1- I created a HOLD with the records that will appear on the page.
2- I created the HTMLFORM where I put this HOLD and the form that receive the values to be changed.
3- Then I created a HOLD that receives these values as parameters
4- Then I made the MODIFY passing this HOLD from last step on the DATA

My code is a little bit longer because I put the result in a jQuery Datatable, as discussed in this post http://forums.informationbuild...077005036#3077005036

 -SET &ECHO=ALL;

SET BYDISPLAY=ON
SET HOLDLIST=PRINTONLY
SET HOLDFORMAT=ALPHA
SET CENT-ZERO=ON

-DEFAULT &ACAO='NENHUMA';
-DEFAULT &MSG='';
-DEFAULT &NOME_TABELA = '_FOC_NULL';

TABLE FILE AT_DW_TRATAMENTO_REGISTROS_MAPEAMENTO
PRINT
COMPUTE ROWCOUNT/P15 = ROWCOUNT + 1; NOPRINT
COMPUTE COMMA/A1 = IF ROWCOUNT EQ 1 THEN '' ELSE ',';
COMPUTE JS_ARRAY_VALUES/A1000 =
'["' ||
     FPRINT(AT_DW_TRATAMENTO_REGISTROS_MAPEAMENTO.AT_TRATAMENTOS_REGISTROS.ID_SEQ_TRATAMENTO_REGISTRO, 'P16', 'A16') || '","' ||
	 AT_DW_TRATAMENTO_REGISTROS_MAPEAMENTO.AT_TRATAMENTOS_REGISTROS.TE_SITUACAO_REGISTRO || '","' ||
	 AT_DW_TRATAMENTO_REGISTROS_MAPEAMENTO.AT_TRATAMENTOS_REGISTROS.SEVERIDADE || '","' ||
     AT_DW_TRATAMENTO_REGISTROS_MAPEAMENTO.AT_TRATAMENTOS_REGISTROS.TE_ERRO || '","' ||
     HCNVRT(AT_DW_TRATAMENTO_REGISTROS_MAPEAMENTO.AT_TRATAMENTOS_REGISTROS.DT_EXTRACAO_TRANS, '(HDMYYS)', 20, 'A20') || '","' ||
     AT_DW_TRATAMENTO_REGISTROS_MAPEAMENTO.AT_DW_TRATAMENTO_REGISTROS_MAPEAMENTO.TE_TABELA_NAME || '","' ||
     AT_DW_TRATAMENTO_REGISTROS_MAPEAMENTO.AT_TRATAMENTOS_REGISTROS.NM_VL_COL_1 || '","' ||
     AT_DW_TRATAMENTO_REGISTROS_MAPEAMENTO.AT_TRATAMENTOS_REGISTROS.NM_VL_COL_30 || '"]';
WHERE AT_DW_TRATAMENTO_REGISTROS_MAPEAMENTO.AT_TRATAMENTOS_REGISTROS.TE_TABELA EQ '&NOME_TABELA'
AND AT_DW_TRATAMENTO_REGISTROS_MAPEAMENTO.AT_TRATAMENTOS_REGISTROS.CS_SITUACAO_REGISTRO EQ 0;
ON TABLE HOLD AS REL
ON TABLE NOTOTAL
END

-SET &DEFINE_ACAO = IF &ACAO = 'NENHUMA' THEN &ACAO ELSE 'ATUALIZA';

-GOTO &DEFINE_ACAO

-NENHUMA

-HTMLFORM BEGIN
<HTML>
	<HEAD>
		<meta http-equiv="X-UA-Compatible" content="IE=edge" />
		<link rel="stylesheet" type="text/css" href="http://code.jquery.com/ui/1.10.3/themes/ui-darkness/jquery-ui.css">
		<link rel="stylesheet" type="text/css" href="/approot/cnisgestao_suporte/jquery.datatables_themeroller.css">
		<link rel="stylesheet" type="text/css" href="/approot/cnisgestao_suporte/bgcnis_suporte.css">

		<script src="/approot/cnisgestao_suporte/jquery-1.10.2.min.js"></script>
		<script src="/approot/cnisgestao_suporte/jquery.datatables.min.js"></script>

		<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>

		<script type="text/javascript" charset="utf-8">
		/* Data set - can contain whatever information you want */
		var aDataSet = [

		!IBI.FIL.REL;

		];
		</script>
	</HEAD>
	<BODY id="dt_example">
		<H1 class="titulo-cnis">Erros e rejeitados por tabela</H1>

		<div id="info" class="info !IBI.AMP.LVL;">
			!IBI.AMP.MSG;
		</div>

		<div id="resultado-relatorio">

		</div>
		<br />
		<FORM NAME="form_modify" ACTION='/ibi_apps/WFServlet' METHOD="POST">
			<div id="ids-selecionados">IDs:<textarea ID="ID" NAME="ID" VALUE="" rows="1" cols="50"></textarea></div>
			<label for="TE">Tratamento: </label>
			<select id="TE" name="TE">
			  <option value="0">Não Tratado</option>
			  <option value="1">Tratado</option>
			  <option value="2">Rejeitado</option>
			</select>
			<INPUT TYPE=HIDDEN NAME="IBIF_ex" VALUE="at_tratamentos_registros_datatable">
			<INPUT TYPE=HIDDEN NAME="IBIAPP_app" VALUE="cnisgestao_suporte">
			<INPUT TYPE=BUTTON VALUE="Atualizar" ONCLICK="javascript:executa('UPD');">
			<INPUT TYPE=HIDDEN NAME="ACAO" VALUE="NENHUMA">
			<INPUT TYPE=HIDDEN NAME="MSG" VALUE="NENHUMA">
		</FORM>

		<SCRIPT>
			function executa(acao) {

				var numRegistros = jQuery("#ID").text().split(',').length - 1;

				if (confirm("Tem certeza que deseja atualizar " + numRegistros + " registros para a situação " + jQuery( "#TE option:selected" ).text() + "?")) {

					var str = jQuery("#ID").text().trim();

					if(str.charAt( str.length-1 ) == ",") {
					  jQuery("#ID").html(jQuery("#ID").text().trim().slice(0,-1));
					}

					form_modify.ACAO.value = acao;
					form_modify.submit();
				}
			}
		</SCRIPT>
		<script src="/approot/cnisgestao_suporte/bgcnis_suporte.js"></script>
	</BODY>
</HTML>
-EXIT

-ATUALIZA
TABLE FILE AT_TRATAMENTOS_REGISTROS
ON TABLE SET HOLDLIST PRINTONLY
PRINT ID_SEQ_TRATAMENTO_REGISTRO CS_SITUACAO_REGISTRO NOPRINT
COMPUTE CS_SITUACAO_REGISTRO/P2 = EDIT('&TE');
WHERE ID_SEQ_TRATAMENTO_REGISTRO IN (&ID)
ON TABLE HOLD FORMAT ALPHA AS HOLD_REGS
END

-RUN

MODIFY FILE AT_TRATAMENTOS_REGISTROS
FIXFORM ID_SEQ_TRATAMENTO_REGISTRO CS_SITUACAO_REGISTRO
COMPUTE ACAO/A12 = '&ACAO.EVAL';
PERFORM ACAO

CASE UPD
MATCH ID_SEQ_TRATAMENTO_REGISTRO
  ON MATCH UPDATE CS_SITUACAO_REGISTRO
  ON NOMATCH REJECT
ENDCASE

DATA ON HOLD_REGS
END

-SET &MSG = IF &CHNGD NE 0 THEN 'Atualizado com sucesso' ELSE 'Falha ao atualizar  o(s) registro(s)';
-SET &LVL = IF &CHNGD NE 0 THEN 'success' ELSE 'warning';

EX AT_TRATAMENTOS_REGISTROS_DATATABLE SET &ACAO='NENHUMA',MSG=&MSG, LVL=&LVL
 


Now I will refactor the code and it's done! =]
Thank you all, guys!


WebFOCUS 8.0.02 - Windows 7
 
Posts: 12 | Location: Brazil | Registered: July 31, 2013Report 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] How to update many registers with MODIFY

Copyright © 1996-2020 Information Builders