Focal Point
[CLOSED]GOTO labels not recognized

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/8257032196

April 12, 2019, 03:10 PM
Siva1925
[CLOSED]GOTO labels not recognized
Hi
I am trying to implement a logic which seems hard to accomplish.

We have a procedure which creates files in a network location(example: Car sales for each country)
I am doing this using loops.Based on the number of lines i create a file with country in where condition.
After this i have to insert some ID and filename in a DB table(This has to run for each loop)
After this another table has to be updated with complete status.

TABLE FILE CAR
BY COUNTRY
ON TABLE HOLD AS LOOP_CNT
END
-RUN
-TYPE &LINES
-SET &CNTR = &LINES;
-SET &FILENAME
-*************************************************************************************************************
-* LOOP Start
-*************************************************************************************************************
-REPEAT CAR_LOOP &LINES TIMES
-READFILE LOOP_CNT


-*************************************************************************************************************
-* Printing report for TYPE I
-*************************************************************************************************************

FILEDEF SAVEOUT DISK "LOCATION/&COUNTRY"
TABLE FILE CAR
SUM SALES
BY CAR
WHERE COUNTRY EQ '&COUNTRY';
ON TABLE SAVE AS SAVEOUT FORMAT PDF
END
-INCLUDE IBFS:/WFC/Repository/R/zz/Insert_Multifile_Details.fex
-CAR_LOOP 

-GOTO LBL_UPDATE

-LBL_UPDATE
-INCLUDE IBFS:/WFC/Repository/R/zz/Update_Multifile_Summary.fex 
-EXIT


Insert_Multifile_Details.fex
-IF &ERRORCODE EQ 0 THEN GOTO :SUCCESS ELSE GOTO :ERROR

-:SUCCESS


ENGINE SQLORA SET DEFAULT_CONNECTION &CONNECTION
SQL SQLORA
INSERT INTO DETAILS (REQUEST_ID,FILE_PATH) VALUES ('&ID','&FILE_PATH')
END
-RUN





-:ERROR
-SET &FOC_ERR_MSG =  FEXERR(&ERRORCODE,'A72');

SQL SQLORA
INSERT INTO ERROR_LOG(ERROR_NO,ERROR_MSG,OBJECT_TYPE,INPUT_PARAMS,UNIQUE_ID,APP_ERROR,EXECUTED_ON) VALUES ('&FOCERRNUM','&FOC_ERR_MSG','&RPT_NAME',' ','&PPAK_SEQ_ID1',' ','&DATEDMtrYY');
END
-RUN
  


Update_Multifile_Summary.fex
ENGINE SQLORA SET DEFAULT_CONNECTION &CONNECTION
SQL SQLORA
UPDATE SUMMARY SET STATUS ='&STATUS',FILE_COUNT ='&CNTR' WHERE REQUEST_ID = '&ID'
END

-RUN
  


If i use GOTO labels inside the Include FEX and include labels from the main fex it is not recognizing it

My issue is that it goes to error section always.
Is there a way that i can tell webFOCUS to skip a section of code and proceed with the next.

This message has been edited. Last edited by: Siva1925,
April 12, 2019, 03:30 PM
MartinY
Each label exist and recognized within its own fex only to avoid the fact that you try to branch to a label that may exist at several places.

Also &ERRORCODE exist in the main fex not in the sub (included) reason why you condition always branch to :ERROR

Try with the following. Also note the semicolon at the end of the IF statement
-* -------------------------------------------------------------
-* Fex : Main Fex
-* -------------------------------------------------------------
TABLE FILE CAR
BY COUNTRY
ON TABLE HOLD AS LOOP_CNT
END
-RUN
-TYPE &LINES
-SET &CNTR = &LINES;
-SET &FILENAME
-*************************************************************************************************************
-* LOOP Start
-*************************************************************************************************************
-REPEAT CAR_LOOP &LINES TIMES
-READFILE LOOP_CNT

-*************************************************************************************************************
-* Printing report for TYPE I
-*************************************************************************************************************
FILEDEF SAVEOUT DISK "LOCATION/&COUNTRY"
TABLE FILE CAR
SUM SALES
BY CAR
ON TABLE SAVE AS SAVEOUT FORMAT PDF
END
-RUN
-SET &RESULTCD = &ERRORCODE;

-INCLUDE IBFS:/WFC/Repository/R/zz/Insert_Multifile_Details.fex
-CAR_LOOP 

-INCLUDE IBFS:/WFC/Repository/R/zz/Update_Multifile_Summary.fex 
-EXIT

-* ------------------------------------------------------------
-* Fex : IBFS:/WFC/Repository/R/zz/Insert_Multifile_Details.fex
-* ------------------------------------------------------------
-IF &RESULTCD EQ 0 THEN GOTO :SUCCESS ELSE GOTO :ERROR;

-:SUCCESS
ENGINE SQLORA SET DEFAULT_CONNECTION &CONNECTION
SQL SQLORA
INSERT INTO DETAILS (REQUEST_ID,FILE_PATH) VALUES ('&ID','&FILE_PATH')
END
-RUN

-:ERROR
-SET &FOC_ERR_MSG =  FEXERR(&RESULTCD,'A72');

SQL SQLORA
INSERT INTO ERROR_LOG(ERROR_NO,ERROR_MSG,OBJECT_TYPE,INPUT_PARAMS,UNIQUE_ID,APP_ERROR,EXECUTED_ON) VALUES ('&FOCERRNUM','&FOC_ERR_MSG','&RPT_NAME',' ','&PPAK_SEQ_ID1',' ','&DATEDMtrYY');
END
-RUN

-* ------------------------------------------------------------
-* Fex : IBFS:/WFC/Repository/R/zz/Update_Multifile_Summary.fex 
-* ------------------------------------------------------------
ENGINE SQLORA SET DEFAULT_CONNECTION &CONNECTION
SQL SQLORA
UPDATE SUMMARY SET STATUS ='&STATUS',FILE_COUNT ='&CNTR' WHERE REQUEST_ID = '&ID'
END
-RUN



WF versions : Prod 8.2.04M gen 33, Dev 8.2.04M gen 33, OS : Windows, DB : MSSQL, Outputs : HTML, Excel, PDF
In Focus since 2007
April 12, 2019, 04:18 PM
Siva1925
I got this working.
Added a label after SUCCESS block that has nothing.