cancel
Showing results for 
Search instead for 
Did you mean: 

How to use variables in Script logic

arkaitz_orozko
Explorer
0 Kudos

Hi,

We are developing a new script, where we have a package with a variable “VERSION_SET”. In this case, the user select a copy destination version, for example “V015″. Once the user select this versión we need to create a new condition where if VERSION_SET == "V015" It is neccesary to save data, but if VERSION_SET <> "V015" it is not neccesary to save data: See an example below:

// MOD. 07/07/2016 --> BAS(F_FIL)

*XDIM_MEMBERSET FLUJOCONTABLE = BAS(TOT), F999, BAS(F_FIL)

*XDIM_MEMBERSET CUENTA = BAS(BALANCE), BAS(RESULTADO_DOM)

*XDIM_MEMBERSET MONEDA = LC

*XDIM_MEMBERSET GRUPO = NG *XDIM_MEMBERSET TIPODATO = BI, AP1, AP2, Aj_HTemporal

*XDIM_MEMBERSET VERSION = %VERSION_SET%, V001

*XDIM_MEMBERSET PERIODO = %PERIODO_SET%

*XDIM_MEMBERSET SOCIEDAD = %SOCIEDAD_SET%

*SELECT(%VERS%, VERSION_DEST, VERSION, ID=%VERSION_SET%) //*************************** // COPIA CUENTAS DE BALANCE: //************************** *WHEN CUENTA

*IS BAS(BALANCE)

*IS <> 1291000

*WHEN FLUJOCONTABLE

*IS = F100, F901A

*WHEN VERSION

*IS V001

*WHEN SOCIEDAD.IS_EP

*IS 015

*REC(EXPRESSION=%VERSION_SET%=='V015' ? %VALUE%: 0, TIPODATO = BI, VERSION = V015) //THIS SENTENCE IS NOT WORKING, SOMEONE KNOW HOW TO IMPLEMENT THIS REQUIREMENT

*ENDWHEN //SOCIEDAD//

*ENDWHEN //VERSION//

*ENDWHEN //FLUJOCONTABLE//

*ENDWHEN //CUENTA//

*COMMIT

Accepted Solutions (0)

Answers (9)

Answers (9)

arkaitz_orozko
Explorer
0 Kudos

Thank you Vadim, it is working fine!!!!

former_member186338
Active Contributor
0 Kudos

Then please accept the correct answer!

former_member186338
Active Contributor
0 Kudos

Something like here:

*SELECT(%IFV015%,ID,VERSION,ID=%VERSION_SET% AND ID<=V015 AND ID>=V015) //%C% will be empty if not V015

*XDIM_MEMBERSET FLUJOCONTABLE = BAS(TOT), F999, BAS(F_FIL)
*XDIM_MEMBERSET CUENTA = BAS(BALANCE), BAS(RESULTADO_DOM)
*XDIM_MEMBERSET MONEDA = LC
*XDIM_MEMBERSET GRUPO = NG 
*XDIM_MEMBERSET TIPODATO = BI, AP1, AP2, Aj_HTemporal
*XDIM_MEMBERSET VERSION = V001 //don't scope %VERSION_SET%!
*XDIM_MEMBERSET PERIODO = %PERIODO_SET%
*XDIM_MEMBERSET SOCIEDAD = %SOCIEDAD_SET%

*WHEN CUENTA
*IS <> 1291000
  *WHEN FLUJOCONTABLE
  *IS <> F100, F901A //not clear = or <>
    *WHEN SOCIEDAD
    *IS 015
      *FOR %T%=%IFV015% //if not V015 - not executed!
        *REC(EXPRESSION=%VALUE%, TIPODATO = BI, VERSION = %VERSION_SET%)
      *NEXT
    *ELSE
      *REC(EXPRESSION=%VALUE%, TIPODATO = BI, VERSION = %VERSION_SET%)
    *ENDWHEN //SOCIEDAD//
  *ENDWHEN //FLUJOCONTABLE//
*ENDWHEN //CUENTA//

The key thing is in this line:

*SELECT(%IFV015%,ID,VERSION,ID=%VERSION_SET% AND ID<=V015 AND ID>=V015)

we can't use *SELECT(%IFV015%,ID,VERSION,ID=%VERSION_SET% AND ID=V015) because if you have 2 "=" for the same property OR will be used instead of AND.

arkaitz_orozko
Explorer
0 Kudos

Hi Vadim,

I attach a document with an example:

There 2 slice:

Thank you.

former_member186338
Active Contributor
0 Kudos

Ok, now it's more or less clear (using data sample, script code is useless!)

arkaitz_orozko
Explorer
0 Kudos

Hi Vadim,

For this particular requrement.it should be possible only save data if user select VERSION_SET="V015" and SOCIEDAD_SET="015".

IF SOCIEDAD_SET="015" AND VERSION_SET="V015"

REC new records in "V015" and "015"

ELSEIF SOCIEDAD_SET = "015" AND VERSION_SET<>"V015"

NOTHING

ELSEIF SOCIEDAD_SET<> "015" and VERSION_SET="V015" or VERSION_SET<>"V015")

REC new records in VERSION_SET.

ENDIF

ENDIF

ENDIF.

Something like this.

Thanks

,

Hi Vadim,

The question is that if the user select SOCIEDAD_SET= "015" and VERSION_SET="V015" we generate new records in V015 but, if the user select SOCIEDAD_SET="015" and VERSION_SET= "V100" no generate records.

Otherways, if the user select SOCIEDAD_SET<> "015" and VERSION_SET="V015" we generate new records in V015 but, if the user select SOCIEDAD_SET<>"015" and VERSION_SET= "V100" generate new records.

Thank you

former_member186338
Active Contributor
0 Kudos

The logic you describe has very little relation to the script you provided in the original message!

That's why I always ask to explain the calculation logic instead of some incorrect script.

Now start from the very beginning:

1. Read https://blogs.sap.com/2014/01/31/how-to-ask-questions-about-script-logic-issues

2. Provide calculation logic for each combination of input parameters (not like "REC new records in "V015" and "015"")

Is it clear?

P.S. Please avoid mistakes like SOCIEDAD_SET="015" From your code I can see that you are checking the property

SOCIEDAD.IS_EP, not SOCIEDAD ID!

former_member186338
Active Contributor
0 Kudos

"The user can run the package with all VERSIONS but only can copy If she select V015"

Why the user will need to run this package with any version other then V015?

Why you can't remove version selection at all and name the package like calculation for V015????

And the user will run this package only when he need to calculate with V015!

arkaitz_orozko
Explorer
0 Kudos

Hi Vadim,

The user can run the package with all VERSIONS but only can copy If she select V015

Thnak you

arkaitz_orozko
Explorer
0 Kudos

Hi Vadim,

The question is that i can not ask for VERSION_SET value in the script

For example:

Data origin is in V001 VERSION then if SOCIEDAD is 015 or 008 or 010 for example ,we need to check if %VERSION_SET% (this variable is in the package prompt and user can select V015, V100,....). If the user select V105 we need to copy to this V015 VERSION, but if the user select other, for example, V100, V101,.. We do not need to copy data y this VERSION_SET selected.

Thank you.

arkaitz_orozko
Explorer
0 Kudos

Hi Vadim,

Sorry if it is not clear. If the user select Version Destination -->VERSION_SET ="V015" and SOCIEDAD = "015" then, it should be save data in "V015" and if VERSION_SET<> "V015" we do not need to save data.

*REC(EXPRESSION=%VERSION_SET%=='V015' ? %VALUE%: 0, TIPODATO = BI, VERSION = V015)

Thnaks you

former_member186338
Active Contributor
0 Kudos

Still not clear!

What is the reason to ask user to select VERSION at all if the script has to run only for selection V015????

What is the logic?????

former_member186338
Active Contributor
0 Kudos

Requirements are not clear...

Do you want to do nothing if the user select anything other then V015?

What's the reason to ask user?

Please explain the logic of the script like here: https://blogs.sap.com/2014/01/31/how-to-ask-questions-about-script-logic-issues/

former_member186338
Active Contributor
0 Kudos

Do you understand my questions?