Advertisement
Guest User

Dettagli_consumo

a guest
Dec 4th, 2014
275
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public subroutine of_scrivi_dettagli_cnsm (ref xxxu021_data_store_base ads_cnsm_fisle, ref xxxu021_data_store_base ads_cnsm_insert, ref xxxu021_data_store_base ads_joint, string as_c_cmp, integer ai_mese, integer ai_anno);/*
  2.     Funzione :
  3.        
  4.         of_scrivi_dettagli_cnsm(ads_cnsm_fisle, ads_cnsm_insert, ai_mese, ai_anno)
  5.        
  6.     Valore di Ritorno :
  7.         Nessuno.
  8.        
  9.     Parametri :
  10.        
  11.         xxxu021_data_store_base     ads_cnsm_fisle      (DS con i dati da salvati nelle chiusure CMP_CNSM_T029 e CNSM_JNT_T192)
  12.         xxxu021_data_store_base     ads_cnsm_insert     (DS con i dati da calcolare CMP_CNSM_CDP_T199)
  13.         xxxu021_data_store_base     ads_joint               (DS con i dati delle Joint PRTNR_CMP_T165)
  14.         Integer                         ai_mese                 (Mese di riferimento) Non utilizzato
  15.         Integer                         ai_anno                 (Anno di riferimento) Non utilizzato
  16.  
  17.     Descrizione :
  18.        
  19.         La funzione si preoccupa di calcolare i dati da inviare per il dettaglio del
  20.         consumato.
  21. */
  22.  
  23. Long        ll_chiusure, ll_riga, ll_find, ll_nuove_righe
  24. Double  l_dbl_add, l_dbl_val
  25. String  ls_c_prdt, ls_c_soc, ls_f100, ls_c_dest, ls_flag_joint, ls_old_filter
  26. String  ls_cnsm_grp, ls_cnsm_tip, ls_find_string
  27. Integer li_mese_succ, li_anno_succ
  28. Date        ld_rif
  29.  
  30. // MK Modifica del 05/09/2007
  31. // Non serve a nulla!
  32. //// Calcolo l'ultimo giorno del mese
  33. //li_mese_succ = ai_mese + 1
  34. //if li_mese_succ = 13 Then
  35. //  li_anno_succ = ai_anno + 1
  36. //  li_mese_succ = 1
  37. //Else
  38. //  li_anno_succ = ai_anno
  39. //End if
  40. // MK Fine modifica del 05/09/2007
  41.  
  42. // Memorizza il filtro corrente per ripristinarlo alla fine
  43. ls_old_filter = ads_joint.Describe("Datawindow.Table.Filter")
  44.  
  45.  
  46. For ll_chiusure = 1 To ads_cnsm_fisle.RowCount()
  47.    
  48.     ls_c_prdt = ads_cnsm_fisle.GetItemString(ll_chiusure, "c_prdt")
  49.     ls_cnsm_grp = ads_cnsm_fisle.GetItemString(ll_chiusure, "c_cnsm_grp")
  50.     ls_cnsm_tip = ads_cnsm_fisle.GetItemString(ll_chiusure, "c_cnsm_tip")
  51.     ls_c_soc = ads_cnsm_fisle.GetItemString(ll_chiusure, "c_soc")
  52.     ls_f100 = ads_cnsm_fisle.GetItemString(ll_chiusure, "f_100")   
  53.     ld_rif = Date(ads_cnsm_fisle.GetItemDateTime(ll_chiusure, "d_rif"))
  54.  
  55.  
  56.     ads_joint.SetFIlter("c_cmp = '" + as_c_cmp + "' and c_prdt = '" + ls_c_prdt + "'")
  57.     ads_joint.Filter()
  58.  
  59.  
  60.     if (ls_c_soc = is_agip) And (ls_f100 = 'S') Then
  61.         // Dato di stoccaggio : da salvare con il 100% agip
  62.         ls_c_soc = ' '
  63.     End if
  64.  
  65.     // Stabilisce il valore di ls_flag_joint
  66.     if ls_c_soc <> ' ' Then
  67.         if ls_f100 = 'S' Then
  68.             // DAto di stoccaggio (non ci sono mai partners) quindi è 100%
  69.             ls_flag_joint = 'T'
  70.         Else
  71.             ll_find = ads_joint.Find("c_soc = '"+ls_c_soc+"'",0,ads_joint.RowCount())
  72.             if ll_find > 0 Then
  73.                 if ads_joint.GetItemString(ll_find,"f_agip") = 'S' Then
  74.                     ls_flag_joint = 'Q' // Dato di Quota per Agip
  75.                 Else
  76.                     ls_flag_joint = ' ' // Dato di Quota per Soc. div. da Agip
  77.                 End if
  78.             Else
  79.                 ls_flag_joint = ' '   // Dato di quota per Soc. div. da Agip
  80.             End if
  81.         End if
  82.     Else
  83.         if ads_joint.RowCOunt() > 0 Then
  84.             ls_flag_joint = 'J' // 100 % con presenza di Joint Ventures
  85.         Else
  86.             ls_flag_joint = 'T' // 100 % senza Joint Ventures
  87.         End if
  88.     End if
  89.  
  90.     ls_find_string = "c_cmp = '" + as_c_cmp + "' And c_prdt = '"+ls_c_prdt+"' And c_soc = '"+ls_c_soc+ &
  91.         "' and c_cnsm_grp = '"+ls_cnsm_grp+"' And c_cnsm_tip = '"+ls_cnsm_tip+ &
  92.         "' and f_100 = '"+ls_f100+"' And d_rif = Date('"+&
  93.         String(ld_rif,'dd/mm/yyyy')+"')"
  94.        
  95.     ll_find = ads_cnsm_insert.Find(ls_find_string,0,ads_cnsm_insert.RowCOunt())
  96.  
  97.     if ll_find = 0  Then
  98.         ll_riga = ads_cnsm_insert.InsertRow(0)
  99.         ll_nuove_righe++
  100.         ads_cnsm_insert.SetItem(ll_riga,"c_cmp",as_c_cmp)
  101.         ads_cnsm_insert.SetItem(ll_riga,"c_cnsm_grp", ls_cnsm_grp)
  102.         ads_cnsm_insert.SetItem(ll_riga,"c_cnsm_tip", ls_cnsm_tip)
  103.         ads_cnsm_insert.SetItem(ll_riga,"c_prdt",ls_c_prdt)
  104.         ads_cnsm_insert.SetItem(ll_riga,"c_soc", ls_c_soc)
  105.         ads_cnsm_insert.SetItem(ll_riga,"d_rif", ld_rif)
  106.         ads_cnsm_insert.SetItem(ll_riga,"f_100", ls_f100)
  107.         ads_cnsm_insert.SetItem(ll_riga,"f_jnt", ls_flag_joint)
  108.     Else
  109.         ll_riga = ll_find
  110.     End if
  111.    
  112.     // Leggo i valori del consumato
  113.     l_dbl_add = ads_cnsm_fisle.GetItemNumber(ll_chiusure,"v_cnsm") 
  114.     l_dbl_val = ads_cnsm_insert.GetItemNumber(ll_riga,"v_cnsm")
  115.     if IsNull(l_dbl_val)  Then
  116.         If Not(IsNull(l_dbl_add)) Then
  117.             // Se il valore già presente è nullo, ma il nuovo no......
  118.             l_dbl_val = 0
  119.         End if
  120.     Else
  121.         if IsNull(l_dbl_add) Then
  122.             // se il vecchio non è nullo, ma il nuovo si......
  123.             l_dbl_add = 0
  124.         End if
  125.     End if 
  126.    
  127.     l_dbl_val += l_dbl_add
  128.    
  129.     ads_cnsm_insert.SetItem(ll_riga,"v_cnsm",l_dbl_val)    
  130. Next
  131.  
  132. // Riapplica il filtro orginale
  133. ads_joint.SetFIlter(ls_old_filter )
  134. ads_joint.Filter()
  135.  
  136. end subroutine
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement