Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

create table in macro for reload in script

Hello,

I want to know if its possible and why to create a function in script like sql function

i want to create a function like this:

Function AjoutTable(var1, var2, var3...)
  LOAD
    var 1,
    var 2,
    var 3...
  AUTOGENERATE 1
end function

i want tu create a table with variables fields.

have you any idea?

thank you...

8 Replies
Not applicable
Author

I think it is

Sub()

End Sub()

in Qlikview

Sokkorn
Master
Master

Hi,

In QV Module have two Scripting Engine (VBScript and JScript).

You can try it by: Tools ==> Edit Module or Ctrl + M

Let me know if this help you.

Regards,

Sokkorn

Not applicable
Author

Hello!

i know what you sai me Sokkorn but I want help to write the function in bvscript...any idea??

Not applicable
Author

Hello,

My macro don't work, can you help me please.

My macro is :

Sub Table_Heure (I,C,Ce,D,S)
LOAD
I as Indiv_Calcul,
C as Chant_Calcul,
Ce as ChantElm_Calcul,
D as Date_Calcul,
S as Sem_Calcul

AUTOGENERATE 1;
END Sub

And in my script i call her like :

CALL Table_Heure ('$(vIndiv)','$(vChant)','$(vChantElem)','$(vDate)','$(vSem)');

But I have this error message Script error line.

Have you any idea??

My macro is use to load a new table.

kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

   Why dont you use directly load statement to create table, like this.

   Table1:

   load

    $(Var1) as Var1,

   $(Var2) as Var2,

   $(Var3) as Var3

    Autogenerate 1;

   Here you dont require macro.

Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
Not applicable
Author

Thank you for your reponse Kaushik,

I can't create my table in script because to have all my variables, i make 10 cases.

my macro is to avoid copying and pasting.

Have you idea to resolve my problem??

thank

kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

   Even if you write macro you need to reload the script to generate the table.

   What are the 10 cases that you have. Let us know may be we can form it such a way that you dont requie macro.

Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
Not applicable
Author

my script is like this...

it's horrible...is for why i want to use macro...

have you any idea...

for vNumLig = 1 to $(vNbLignHeure)          vIndivPrec       = Text($(vIndiv))         vMmIndiv         = 0         
        
DO WHILE vMmIndiv =0                   vSemPrec = $(vSem)                   vCptHeure = 0
                 
vMmSem = 0                  
                 
DO WHILE vMmSem = 0                            vDebFrange     = '$(vCptHeure)'                            vFinFrange       = NumSum('$(vCptHeure)','$(vDonnee)')
                          
//case 1
                          
IF vFinFrange <= vNbHrContrat THEN                                           IF vRegIndic = Text('HeureJour') THEN
                                            
Nv_Code_Point       = 'HN';
                                            
Nv_Nb_Hr        = '$(vDonnee)';
                                   
ELSEIF vRegIndic = Text('HeureNuit') THEN
                                            
Nv_Code_Point       = 'HNM100';
                                            
Nv_Nb_Hr        = '$(vDonnee)';
                                   
ENDIF
                                   
Tab1 :

                                    LOAD
                                             '$(vIndiv)'                            as Indiv_Calcul,
                                             '$(vChant)'                                    as Chant_Calcul,
                                             '$(vChantElem)'                            as ChantElm_Calcul,
                                             '$(vDate)'                                      as Date_Calcul,
                                             '$(vSem)'                                       as Sem_Calcul,
                                             '$(vIndHis)'                                   as IndHis_Calcul,
                                             '$(vStaHis)'                                   as StaHis_Calcul,      
                                             '$(vSocHis)'                                  as SocHis_Calcul,     
                                             '$(vAnaHis)'                                  as AnaHis_Calcul,
                                             '$(vSoIHis)'                                   as SoIHis_Calcul,
                                             '$(vMoisTrait)'                              as MoisTrait_Calcul,
                                             '$(Nv_Code_Point)'                               as Code_Poin_Calcul,
                                             '$(Nv_Nb_Hr)'                              as NbHeure_Calcul
                                    AUTOGENERATE 1;
                           ENDIF
                          
////case 2...                           IF vFinFrange <= vNbHrContrat  and Var1>var2THEN                                            IF vRegIndic = Text('HeureJour') THEN
                                            
Nv_Code_Point       = 'HN';
                                            
Nv_Nb_Hr        = '$(vDonnee)';
                                   
ELSEIF vRegIndic = Text('HeureNuit') THEN
                                            
Nv_Code_Point       = 'HNM100';
                                            
Nv_Nb_Hr        = '$(vDonnee)';
                                   
ENDIF
                                   
Tab1 :

                                    LOAD
                                             '$(vIndiv)'                            as Indiv_Calcul,
                                             '$(vChant)'                                    as Chant_Calcul,
                                             '$(vChantElem)'                            as ChantElm_Calcul,
                                             '$(vDate)'                                      as Date_Calcul,
                                             '$(vSem)'                                       as Sem_Calcul,
                                             '$(vIndHis)'                                   as IndHis_Calcul,
                                             '$(vStaHis)'                                   as StaHis_Calcul,      
                                             '$(vSocHis)'                                  as SocHis_Calcul,     
                                             '$(vAnaHis)'                                  as AnaHis_Calcul,
                                             '$(vSoIHis)'                                   as SoIHis_Calcul,
                                             '$(vMoisTrait)'                              as MoisTrait_Calcul,
                                             '$(Nv_Code_Point)'                               as Code_Poin_Calcul,
                                             '$(Nv_Nb_Hr)'                              as NbHeure_Calcul
                                    AUTOGENERATE 1;

ENDIF

////case 3 à 10...

                           vCptHeure = '$(vFinFrange)'
                          
vNumLig  = Num($(vNumLig))+1
                          
IF vNumLig < vNbLignHeure THEN
                                   
vIndiv                = Text(Peek('Indiv',$(vNumLig),'HeurePaie_Temp2'))
                                   
vChant              = Text(Peek('Co_Aff',$(vNumLig),'HeurePaie_Temp2'))
                                   
vChantElem     = Text(Peek('Co_Cha_Elem',$(vNumLig),'HeurePaie_Temp2'))
                                   
vDate                = Date(Peek('DatGlob',$(vNumLig),'HeurePaie_Temp2'))
                                   
vSem                 = Num(Peek('Semaine_Calcul',$(vNumLig),'HeurePaie_Temp2'))
                                   
vIndHis             = Text(Peek('Indiv_Histo',$(vNumLig),'HeurePaie_Temp2'))
                                   
vStaHis             = Text(Peek('Stat_Histo',$(vNumLig),'HeurePaie_Temp2'))
                                   
vSocHis             = Text(Peek('Soc_Histo',$(vNumLig),'HeurePaie_Temp2'))
                                   
vAnaHis            = Text(Peek('Co_Analy_Histo',$(vNumLig),'HeurePaie_Temp2'))
                                   
vSoIHis             = Text(Peek('Soc_Int_Histo',$(vNumLig),'HeurePaie_Temp2'))
                                   
vDonnee = Peek('DonnCalcul',$(vNumLig),'HeurePaie_Temp2')
                                   
vRegIndic        = Text(Peek('Regp',$(vNumLig),'HeurePaie_Temp2'))
                                   
vNbHrContrat = Num(Peek('H_Contr',$(vNumLig),'HeurePaie_Temp2'))
                                   
vMoisTrait       = Text(Peek('Mois_Traitem',$(vNumLig),'HeurePaie_Temp2'))
                          
ENDIF
                          
                          
IF vSem = vSemPrec and vIndiv = vIndivPrec THEN

                                    vMmSem = 0;
                          
ELSE
                                   
vMmSem = 1;
                          
ENDIF
                 
LOOP                   IF vIndiv = vIndivPrec THEN                            vMmIndiv = 0;
                 
ELSE
                          
vMmIndiv = 1;
                 
ENDIF
        
LOOP          vNumLig  = $(vNumLig) -1;NEXT vNumLig