quarta-feira, 27 de novembro de 2013

Gerar Situação de Afastamento Funcionário Aviso Prévio 7 dias ( HCM210 )



Def Var cdn_empresa_ini     As  Int     Format ">>9"        Initial 0   Label "Empresa de".
Def Var cdn_empresa_fim     As  Int     Format ">>9"        Initial 999 Label "At‚".
Def Var cdn_estab_ini       As  Int     Format ">>9"        Initial 0   Label "Estab.  de".
Def Var cdn_estab_fim       As  Int     Format ">>9"        Initial 999 Label "At‚".
Def Var dat_avprev_ini      As  Date    Format "99/99/9999"             Label "Av.Prev.de".
Def Var dat_avprev_fim      As  Date    Format "99/99/9999"             Label "At‚".
Def Var cdn_sit_afast       As  Int     Format ">9"         Initial 52  Label "Situa‡Æo".

Assign dat_avprev_ini   =   Date (Month(Today),01,Year(Today)).
If Lookup (string (Month(Today),"99"),"01,03,05,07,08,10,12") > 0
Then Assign dat_avprev_fim   =   Date (Month(Today),31,Year(Today)).
Else If Lookup (string (Month(Today),"99"),"04,06,09,11") > 0
Then Assign dat_avprev_fim   =   Date (Month(Today),30,Year(Today)).
Else Assign dat_avprev_fim   =   Date (Month(Today),28,Year(Today)).

Update cdn_empresa_ini      cdn_empresa_fim  
       cdn_estab_ini        cdn_estab_fim
       dat_avprev_ini       dat_avprev_fim
       cdn_sit_afast
    With Frame f_selec 2 Column 1 Down.
Find sit_afast
    Where sit_afast.cdn_sit_afast_func  =   cdn_sit_afast
    No-error.
If Avail sit_afast
Then Disp sit_afast.des_sit_afast_func With Frame f_selec.
Else Do:
    Disp "Situa‡Æo nÆo Cadastrada" @ sit_afast.des_sit_afast_func With Frame f_selec.
    Pause 10.
    Undo, Retry.
End.

Def Var v_cont As Int.
Def Var v_data As Date.

For Each habilit_rescis
    Where habilit_rescis.cdn_empresa            >=  cdn_empresa_ini
    And   habilit_rescis.cdn_empresa            <=  cdn_empresa_fim
    And   habilit_rescis.cdn_estab              >=  cdn_estab_ini
    And   habilit_rescis.cdn_estab              <=  cdn_estab_fim
    And   habilit_rescis.dat_inic_aviso_previo  >=  dat_avprev_ini
    And   habilit_rescis.dat_inic_aviso_previo  <=  dat_avprev_fim
    And   habilit_rescis.dat_term_aviso_previo  >=  dat_avprev_ini
    And   habilit_rescis.dat_term_aviso_previo  <=  dat_avprev_fim
    And   habilit_rescis.idi_tip_aviso_previo   =   2
    And   habilit_rescis.idi_reduc_jorn_trab    =   3
    :

    Disp
        habilit_rescis.cdn_empresa
        habilit_rescis.cdn_estab
        habilit_rescis.cdn_funcionario
        /*habilit_rescis.idi_tip_aviso_previo
        habilit_rescis.idi_reduc_jorn_trab */
        habilit_rescis.dat_inic_aviso_previo
        habilit_rescis.dat_term_aviso_previo
        .

    Do v_cont = 1 To 7:
        Assign v_data = (habilit_rescis.dat_term_aviso_previo - 7) + v_cont.
        Find sit_afast_func
            Where sit_afast_func.cdn_empresa        =   habilit_rescis.cdn_empresa  
            And   sit_afast_func.cdn_estab          =   habilit_rescis.cdn_estab    
            And   sit_afast_func.cdn_funcionario    =   habilit_rescis.cdn_funcionario
            And   sit_afast_func.dat_inic_sit_afast =   v_data
            And   sit_afast_func.cdn_sit_afast_func =   cdn_sit_afast
            No-lock No-error.
        If Not Avail sit_afast_func
        Then Do:
            CREATE sit_afast_func.
            ASSIGN sit_afast_func.cdn_empresa               =   habilit_rescis.cdn_empresa  
                   sit_afast_func.cdn_estab                 =   habilit_rescis.cdn_estab    
                   sit_afast_func.cdn_funcionario           =   habilit_rescis.cdn_funcionario
                   sit_afast_func.cdn_sit_afast_func        =   cdn_sit_afast
                   sit_afast_func.dat_inic_sit_afast        =   v_data
                   sit_afast_func.dat_term_sit_afast        =   v_data
                   sit_afast_func.dat_inic_proces_sit_afast =   v_data
                   sit_afast_func.dat_term_proces_sit_afast =   v_data
                   sit_afast_func.idi_sit_afast_func        =   1
                   sit_afast_func.qti_dias_sit_func         =   1
                    .
        End.
       
    End.

End.

Nenhum comentário:

Postar um comentário