Skip to Content

BPC error on *FOR cycle when using consecutive scripts

Hi experts!

I'm on BPC 10.1 NW SP4 (SAPK-81004INCPMBPC) and I'm developing a long logic that I segmented in around 10 scripts which are all called in a central script in sequence inside a *FOR cycle, as one month needs to be processed completely before going into the next one. In one of the steps a calculation on Equity accounts is made and for some strange reason I get an "Invalid when/endwhen" error on script log. This calculation takes balance from prior month to apply logic in two parts:

1. IF prior month is december, do something

2. IF prior month is not december, do something else.

The calculation of any of this parts taken independentely works just fine, but whatever part I put on second place gives me the same error.

- On base scenario I have the Priormonth=December first and it gives me an error on Priormonth<>December.

- If I change the order and put Priormonth<>December first it gives me an error on Priormonth=December

The calling logic is the following:

*INCLUDE 00CONSTANTS.LGF
*INCLUDE 00VARIABLES.LGF

*LOOKUP Rates
	*DIM R_ACCOUNT = END
	*DIM R_ENTITY = Global
	*DIM CATEGORY = CATEGORY.RATE_CATEGORY
	*DIM LCMes:INPUTCURRENCY = SOCIEDAD.CURRENCY
	*FOR %CURR% = %RptC%
		*DIM %CURR%Mes:INPUTCURRENCY = UF
	*NEXT
	*FOR %T% = %TIME_SET%
		*DIM LC%T%:TIME = %T%
		*DIM LC%T%:INPUTCURRENCY = SOCIEDAD.CURRENCY
		*FOR %CURR% = %RptC%
			*DIM %CURR%%T%:TIME = %T%
			*DIM %CURR%%T%:INPUTCURRENCY = %CURR%
		*NEXT
	*NEXT
*ENDLOOKUP

*FOR %A% = 1 AND %Y% = %YS%

	*INCLUDE ANG00_CURRCONVLC.LGF

	*FOR %T% = %TIME_SET% AND %TID% = %TIMEID%

		*INCLUDE ANG01_ARRASTREBCE.LGF
		*INCLUDE ANG02_CMPATRIMONIO.LGF
		*INCLUDE ANG03_CMPROPINV.LGF
		*INCLUDE ANG04_DEPRECIACION.LGF
		*INCLUDE ANG05_LINEALES.LGF
		*INCLUDE ANG06_IMPUESTORENTA.LGF
		*INCLUDE ANG07_INTMINORITARIO.LGF
		*INCLUDE ANG08_CMG.LGF
		*INCLUDE ANG09_UTEJERCICIO.LGF

	*NEXT

*NEXT

Just ANG02 and ANG03 have this problem and both works mostly the same way but with different accounts. If I take both of them out, the rest of the script runs flawlessly.

Thank you beforehand! I hope that you guys can help me out in this :)

Best regards,

Joaquín.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

7 Answers

  • Aug 14, 2017 at 09:24 PM

    Sorry... just noticed that the *.txt wasn't attached. Here is the code for ANG02_CMPATRIMONIO.LGF

    *XDIM_MEMBERSET CATEGORY = %CATS%
    *XDIM_MEMBERSET SEGMENTO = BAS(B_Pza_Chile)
    *XDIM_MEMBERSET CUENTAS = BAS(Patrimonio)
    *XDIM_MEMBERSET F_AUDITTRAIL = BAS(TotaldeGestión)
    *XDIM_MEMBERSET RPTCURRENCY = LC
    
    *XDIM_MEMBERSET TIME = TMVL(-1, %T%)
    
    // ********************************
    // January Calculation
    
    *WHEN TIME.BASE_PERIOD
    *IS 012
    
    	*WHEN CATEGORY
    	*IS TIME.PRIOR_CAT // Property that points to correct CATEGORY to look at
    
    		*WHEN SEGMENTO
    		*IS 8001
    
    			*WHEN CUENTAS
    			*IS BCE_0420
    
    				*REC(FACTOR = C_IPC, TIME = %T%, F_AUDITTRAIL = CMNormaMes, CATEGORY = %CATEGORY_SET%, CEBE = NA)
    				*REC(FACTOR = -C_IPC, TIME = %T%, F_AUDITTRAIL = CMNormaMes, CATEGORY = %CATEGORY_SET%, CEBE = 8000900, CUENTAS = 8700001)
    
    			*ELSE
    
    				*REC(FACTOR = C_IPC, TIME = %T%, F_AUDITTRAIL = CMNormaMes, CATEGORY = %CATEGORY_SET%, CEBE = NA, CUENTAS = BCE_0450)
    				*REC(FACTOR = -C_IPC, TIME = %T%, F_AUDITTRAIL = CMNormaMes, CATEGORY = %CATEGORY_SET%, CEBE = 8000900, CUENTAS = 8700001, )
    
    			*ENDWHEN // CUENTAS
    
    		*FOR %SEG% = %SEGS%
    
    		*IS %SEG%
    
    			*WHEN CUENTAS
    			*IS BCE_0420
    
    				*REC(FACTOR = C_IPC, TIME = %T%, F_AUDITTRAIL = CMNormaMes, CATEGORY = %CATEGORY_SET%, CEBE = NA)
    				*REC(FACTOR = -C_IPC, TIME = %T%, F_AUDITTRAIL = CMNormaMes, CATEGORY = %CATEGORY_SET%, CEBE = %SEG%601, CUENTAS = 8700001)
    
    			*ELSE
    
    				*REC(FACTOR = C_IPC, TIME = %T%, F_AUDITTRAIL = CMNormaMes, CATEGORY = %CATEGORY_SET%, CEBE = NA, CUENTAS = BCE_0450)
    				*REC(FACTOR = -C_IPC, TIME = %T%, F_AUDITTRAIL = CMNormaMes, CATEGORY = %CATEGORY_SET%, CEBE = %SEG%601, CUENTAS = 8700001)
    
    			*ENDWHEN // CUENTAS
    
    		*NEXT
    
    		*ENDWHEN // SEGMENTO
    
    	*ENDWHEN // CATEGORY
    
    *ENDWHEN // TIME
    
    // ********************************
    // Calculation for the rest of the year
    
    *XDIM_MEMBERSET F_AUDITTRAIL = BAS(TotalIFRS), AjustedeGestión
    *XDIM_MEMBERSET CATEGORY = %CATEGORY_SET%
    *XDIM_MEMBERSET TIME = TMVL(-1, %T%)
    
    *WHEN TIME.BASE_PERIOD
    *IS <> 012
    
    	*WHEN SEGMENTO
    	*IS 8001
    
    		*WHEN CUENTAS
    		*IS BCE_0420
    
    			*REC(FACTOR = C_IPC, TIME = %T%, F_AUDITTRAIL = CMNormaMes, CEBE = NA)
    			*REC(FACTOR = -C_IPC, TIME = %T%, F_AUDITTRAIL = CMNormaMes, CEBE = 8000900, CUENTAS = 8700001)
    
    		*IS <> BCE_0420, BCE_0480
    
    			*REC(FACTOR = C_IPC, TIME = %T%, F_AUDITTRAIL = CMNormaMes, CEBE = NA, CUENTAS = BCE_0450)
    			*REC(FACTOR = -C_IPC, TIME = %T%, F_AUDITTRAIL = CMNormaMes, CEBE = 8000900, CUENTAS = 8700001)
    
    		*ENDWHEN // CUENTAS
    
    	*FOR %SEG% = %SEGS%
    
    	*IS %SEG%
    
    		*WHEN CUENTAS
    		*IS BCE_0420
    
    			*REC(FACTOR = C_IPC, TIME = %T%, F_AUDITTRAIL = CMNormaMes, CEBE = NA)
    			*REC(FACTOR = -C_IPC, TIME = %T%, F_AUDITTRAIL = CMNormaMes, CEBE = %SEG%601, CUENTAS = 8700001)
    
    		*IS <> BCE_0420, BCE_0480
    
    			*REC(FACTOR = C_IPC, TIME = %T%, F_AUDITTRAIL = CMNormaMes, CEBE = NA, CUENTAS = BCE_0450)
    			*REC(FACTOR = -C_IPC, TIME = %T%, F_AUDITTRAIL = CMNormaMes, CEBE = %SEG%601, CUENTAS = 8700001)
    
    		*ENDWHEN // CUENTAS
    
    	*NEXT
    
    	*ENDWHEN // SEGMENTO
    
    *ENDWHEN // TIME
    

    Code for:

    00CONSTANTS.LGF

    *FUNCTION C_IMPUESTO = ([CEBE].[NA],[F_AUDITTRAIL].[Input],[INTERCO].[I_NA],[RPTCURRENCY].[NA],[TIME].[%T%],[CUENTAS].[Z01_IMPUESTO])
    *FUNCTION C_IPC      = ([CEBE].[NA],[F_AUDITTRAIL].[Input],[INTERCO].[I_NA],[RPTCURRENCY].[NA],[TIME].[%T%],[CUENTAS].[Z05_IPC])
    *FUNCTION C_IMPMINIQ = ([CEBE].[NA],[F_AUDITTRAIL].[Input],[INTERCO].[I_NA],[RPTCURRENCY].[NA],[CUENTAS].[Z02_INT_MINOR_IQUIQUE])
    *FUNCTION C_IMPMINND = ([CEBE].[NA],[F_AUDITTRAIL].[Input],[INTERCO].[I_NA],[RPTCURRENCY].[NA],[CUENTAS].[Z03_INT_MINOR_CONS_ND])
    

    00VARIABLES.LGF

    *SELECT(%YS%, YEAR, TIME, ID = %TIME_SET%)
    *SELECT(%TIMEID%, TIMEID, TIME, ID = %TIME_SET%)
    *SELECT(%SEGS%, ID, SEGMENTO, CALC = N AND ID <> 8001)
    *SELECT(%CATS%, ID, CATEGORY, CALC = N)
    *SELECT(%RptC%, ID, RPTCURRENCY, REPORTING = Y)
    

    Thank you again.

    Best regards,

    Joaquín.

    Add comment
    10|10000 characters needed characters exceeded

  • Aug 15, 2017 at 08:27 PM

    Upgrade to some recent SP and test.

    Add comment
    10|10000 characters needed characters exceeded

    • Hi Vadim.

      Our IT Staff told me that there is an SP upgrade planned by the end of september as we are migrating to HEC. Is there any other possible solution that could be implemented? As I need this piece of code in production on the first week of september.

      Thanks again!

      Best regards,

      Joaquín.

  • Aug 18, 2017 at 02:49 PM

    Hi again.

    Sorry for the bump, but any other idea?

    Best regards,

    Joaquín.

    Add comment
    10|10000 characters needed characters exceeded

  • Aug 18, 2017 at 08:38 PM

    Continuing testing I've narrowed the problem to a single *FOR cycle in the second part of the logic (*FOR %SEG% = %SEGS%...). If I remove the *FOR loop and hardcode it, the error is gone.

    I've raised an incident with SAP, but any help would be great!

    Best regards,

    Joaquín.

    Add comment
    10|10000 characters needed characters exceeded

    • I've read a lot of your replys recomending to remove it, but I added it at the end of every script in this logic to force reset of scope and start clear in each step.

      Now i've removed it and same result: Invalid when/endwhen.

      Best regards,

      Joaquín.

  • Aug 23, 2017 at 12:59 PM

    Use different loop variables in 2 loops:

    *FOR %SEG% = %SEGS%
    	*IS %SEG%
    ...
    *FOR %SEG1% = %SEGS%
    	*IS %SEG1%
    ...
    
    Add comment
    10|10000 characters needed characters exceeded

    • Vadim

      LGX:
      
      -------------------------------------------------------------------------------------------------------------------------------------
      LOG:
      
      FILE:\ROOT\WEBFOLDERS\xxx \ADMINAPP\xxx\TEST.LGF
      USER:JPRICE
      APPSET:xxx
      APPLICATION:xxx
      
      UJK_VALIDATION_EXCEPTION:Line 3: Unknown or unimplemented keyword "*FOR %SEG1% = 1001,1101,1102,1109,1201,1202,1209,1"<br>
  • Aug 23, 2017 at 01:39 PM

    In my system the script:

    *SELECT(%SEGS%, ID, FUNCTIONAL_AREA, CALC = N AND ID <> FA_NONE)
    *XDIM_MEMBERSET FUNCTIONAL_AREA=%SEGS%
    
    *FOR %T% = 2017.01,2017.02 //Provide some fixed members
    
    *XDIM_MEMBERSET TIME = TMVL(-1, %T%)
    
    *FOR %SEG% = %SEGS%
    *XDIM_MEMBERSET FUNCTIONAL_AREA=%SEG%
    *NEXT
    
    *FOR %SEG1% = %SEGS%
    *XDIM_MEMBERSET FUNCTIONAL_AREA=%SEG1%
    *NEXT
    
    *NEXT

    Generates the following lgx after Execute simulate:

    LGX:
    
    *XDIM_MEMBERSET FUNCTIONAL_AREA=FA_0001,FA_600000,FA_610001,FA_610002,FA_610003,FA_610100,FA_610200,FA_610210,FA_610300,FA_610400,FA_640000,FA_66000T,FA_69000T,FA_700000,FA_72000T,FA_73000T,FA_74000T,FA_75000T,FA_75100T,FA_76000T,FA_77000T,FA_78000T,FA_999998,FA_999999,FA_PL00-WAW,FA_PL00-WRO
    *XDIM_MEMBERSET TIME = 2016.12
    *XDIM_MEMBERSET FUNCTIONAL_AREA=FA_0001
    *XDIM_MEMBERSET FUNCTIONAL_AREA=FA_600000
    *XDIM_MEMBERSET FUNCTIONAL_AREA=FA_610001
    *XDIM_MEMBERSET FUNCTIONAL_AREA=FA_610002
    *XDIM_MEMBERSET FUNCTIONAL_AREA=FA_610003
    *XDIM_MEMBERSET FUNCTIONAL_AREA=FA_610100
    *XDIM_MEMBERSET FUNCTIONAL_AREA=FA_610200
    *XDIM_MEMBERSET FUNCTIONAL_AREA=FA_610210
    *XDIM_MEMBERSET FUNCTIONAL_AREA=FA_610300
    *XDIM_MEMBERSET FUNCTIONAL_AREA=FA_610400
    *XDIM_MEMBERSET FUNCTIONAL_AREA=FA_640000
    *XDIM_MEMBERSET FUNCTIONAL_AREA=FA_66000T
    *XDIM_MEMBERSET FUNCTIONAL_AREA=FA_69000T
    *XDIM_MEMBERSET FUNCTIONAL_AREA=FA_700000
    *XDIM_MEMBERSET FUNCTIONAL_AREA=FA_72000T
    *XDIM_MEMBERSET FUNCTIONAL_AREA=FA_73000T
    *XDIM_MEMBERSET FUNCTIONAL_AREA=FA_74000T
    *XDIM_MEMBERSET FUNCTIONAL_AREA=FA_75000T
    *XDIM_MEMBERSET FUNCTIONAL_AREA=FA_75100T
    *XDIM_MEMBERSET FUNCTIONAL_AREA=FA_76000T
    *XDIM_MEMBERSET FUNCTIONAL_AREA=FA_77000T
    *XDIM_MEMBERSET FUNCTIONAL_AREA=FA_78000T
    *XDIM_MEMBERSET FUNCTIONAL_AREA=FA_999998
    *XDIM_MEMBERSET FUNCTIONAL_AREA=FA_999999
    *XDIM_MEMBERSET FUNCTIONAL_AREA=FA_PL00-WAW
    *XDIM_MEMBERSET FUNCTIONAL_AREA=FA_PL00-WRO
    *XDIM_MEMBERSET FUNCTIONAL_AREA=FA_0001
    *XDIM_MEMBERSET FUNCTIONAL_AREA=FA_600000
    *XDIM_MEMBERSET FUNCTIONAL_AREA=FA_610001
    *XDIM_MEMBERSET FUNCTIONAL_AREA=FA_610002
    *XDIM_MEMBERSET FUNCTIONAL_AREA=FA_610003
    *XDIM_MEMBERSET FUNCTIONAL_AREA=FA_610100
    *XDIM_MEMBERSET FUNCTIONAL_AREA=FA_610200
    *XDIM_MEMBERSET FUNCTIONAL_AREA=FA_610210
    *XDIM_MEMBERSET FUNCTIONAL_AREA=FA_610300
    *XDIM_MEMBERSET FUNCTIONAL_AREA=FA_610400
    *XDIM_MEMBERSET FUNCTIONAL_AREA=FA_640000
    *XDIM_MEMBERSET FUNCTIONAL_AREA=FA_66000T
    *XDIM_MEMBERSET FUNCTIONAL_AREA=FA_69000T
    *XDIM_MEMBERSET FUNCTIONAL_AREA=FA_700000
    *XDIM_MEMBERSET FUNCTIONAL_AREA=FA_72000T
    *XDIM_MEMBERSET FUNCTIONAL_AREA=FA_73000T
    *XDIM_MEMBERSET FUNCTIONAL_AREA=FA_74000T
    *XDIM_MEMBERSET FUNCTIONAL_AREA=FA_75000T
    *XDIM_MEMBERSET FUNCTIONAL_AREA=FA_75100T
    *XDIM_MEMBERSET FUNCTIONAL_AREA=FA_76000T
    *XDIM_MEMBERSET FUNCTIONAL_AREA=FA_77000T
    *XDIM_MEMBERSET FUNCTIONAL_AREA=FA_78000T
    *XDIM_MEMBERSET FUNCTIONAL_AREA=FA_999998
    *XDIM_MEMBERSET FUNCTIONAL_AREA=FA_999999
    *XDIM_MEMBERSET FUNCTIONAL_AREA=FA_PL00-WAW
    *XDIM_MEMBERSET FUNCTIONAL_AREA=FA_PL00-WRO
    *XDIM_MEMBERSET TIME = 2017.01
    *XDIM_MEMBERSET FUNCTIONAL_AREA=FA_0001
    *XDIM_MEMBERSET FUNCTIONAL_AREA=FA_600000
    *XDIM_MEMBERSET FUNCTIONAL_AREA=FA_610001
    *XDIM_MEMBERSET FUNCTIONAL_AREA=FA_610002
    *XDIM_MEMBERSET FUNCTIONAL_AREA=FA_610003
    *XDIM_MEMBERSET FUNCTIONAL_AREA=FA_610100
    *XDIM_MEMBERSET FUNCTIONAL_AREA=FA_610200
    *XDIM_MEMBERSET FUNCTIONAL_AREA=FA_610210
    *XDIM_MEMBERSET FUNCTIONAL_AREA=FA_610300
    *XDIM_MEMBERSET FUNCTIONAL_AREA=FA_610400
    *XDIM_MEMBERSET FUNCTIONAL_AREA=FA_640000
    *XDIM_MEMBERSET FUNCTIONAL_AREA=FA_66000T
    *XDIM_MEMBERSET FUNCTIONAL_AREA=FA_69000T
    *XDIM_MEMBERSET FUNCTIONAL_AREA=FA_700000
    *XDIM_MEMBERSET FUNCTIONAL_AREA=FA_72000T
    *XDIM_MEMBERSET FUNCTIONAL_AREA=FA_73000T
    *XDIM_MEMBERSET FUNCTIONAL_AREA=FA_74000T
    *XDIM_MEMBERSET FUNCTIONAL_AREA=FA_75000T
    *XDIM_MEMBERSET FUNCTIONAL_AREA=FA_75100T
    *XDIM_MEMBERSET FUNCTIONAL_AREA=FA_76000T
    *XDIM_MEMBERSET FUNCTIONAL_AREA=FA_77000T
    *XDIM_MEMBERSET FUNCTIONAL_AREA=FA_78000T
    *XDIM_MEMBERSET FUNCTIONAL_AREA=FA_999998
    *XDIM_MEMBERSET FUNCTIONAL_AREA=FA_999999
    *XDIM_MEMBERSET FUNCTIONAL_AREA=FA_PL00-WAW
    *XDIM_MEMBERSET FUNCTIONAL_AREA=FA_PL00-WRO
    *XDIM_MEMBERSET FUNCTIONAL_AREA=FA_0001
    *XDIM_MEMBERSET FUNCTIONAL_AREA=FA_600000
    *XDIM_MEMBERSET FUNCTIONAL_AREA=FA_610001
    *XDIM_MEMBERSET FUNCTIONAL_AREA=FA_610002
    *XDIM_MEMBERSET FUNCTIONAL_AREA=FA_610003
    *XDIM_MEMBERSET FUNCTIONAL_AREA=FA_610100
    *XDIM_MEMBERSET FUNCTIONAL_AREA=FA_610200
    *XDIM_MEMBERSET FUNCTIONAL_AREA=FA_610210
    *XDIM_MEMBERSET FUNCTIONAL_AREA=FA_610300
    *XDIM_MEMBERSET FUNCTIONAL_AREA=FA_610400
    *XDIM_MEMBERSET FUNCTIONAL_AREA=FA_640000
    *XDIM_MEMBERSET FUNCTIONAL_AREA=FA_66000T
    *XDIM_MEMBERSET FUNCTIONAL_AREA=FA_69000T
    *XDIM_MEMBERSET FUNCTIONAL_AREA=FA_700000
    *XDIM_MEMBERSET FUNCTIONAL_AREA=FA_72000T
    *XDIM_MEMBERSET FUNCTIONAL_AREA=FA_73000T
    *XDIM_MEMBERSET FUNCTIONAL_AREA=FA_74000T
    *XDIM_MEMBERSET FUNCTIONAL_AREA=FA_75000T
    *XDIM_MEMBERSET FUNCTIONAL_AREA=FA_75100T
    *XDIM_MEMBERSET FUNCTIONAL_AREA=FA_76000T
    *XDIM_MEMBERSET FUNCTIONAL_AREA=FA_77000T
    *XDIM_MEMBERSET FUNCTIONAL_AREA=FA_78000T
    *XDIM_MEMBERSET FUNCTIONAL_AREA=FA_999998
    *XDIM_MEMBERSET FUNCTIONAL_AREA=FA_999999
    *XDIM_MEMBERSET FUNCTIONAL_AREA=FA_PL00-WAW
    *XDIM_MEMBERSET FUNCTIONAL_AREA=FA_PL00-WRO
    
    -------------------------------------------------------------------------------------------------------------------------------------
    LOG:
    

    You can see that all loops are working fine!

    Add comment
    10|10000 characters needed characters exceeded

    • I've just tried with only one ID on the SELECT statement and results in the same error.

      LGX:
      
      -------------------------------------------------------------------------------------------------------------------------------------
      LOG:
      
      FILE:\ROOT\WEBFOLDERS\xxx \ADMINAPP\xxx\TEST.LGF
      USER:JPRICE
      APPSET:xxx
      APPLICATION:xxx
      
      UJK_VALIDATION_EXCEPTION:Line 4: Unknown or unimplemented keyword "*FOR %SEG1% = 1001"
      
  • Aug 23, 2017 at 05:17 PM

    "I've just tried with only one ID on the SELECT statement and results in the same error." - then only SP upgrade! I see no notes directly related to this issue...

    Add comment
    10|10000 characters needed characters exceeded