Advertisement
CDLG_TGR

Gestion des dates et heures id@ to HR to WS

Jan 5th, 2017
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
ABAP 3.18 KB | None | 0 0
  1.     DATA :    lv_date_debut(10) type c,
  2.               lv_heure_char(8) type c,
  3.               lv_heure_debut(5) type c,
  4.               lv_date_fin(10) type c,
  5.               lv_heure_fin(5) type c,
  6.               lv_dates_ab       type string. " Phrase renseignant la période d'absence
  7.  
  8.  
  9. " .................................................... instructions
  10.  
  11.  
  12. * (on veux récupérer notre BOR (ABSENCE) et l'infotype associé
  13. * pour avoir toutes les informatiosn nécessaires)
  14. * Pour cela j'utilise la methode de la classe  zcl_hr_infotype_util
  15.  
  16.     call method _get_p2001_data
  17.       exporting
  18.         io_wu    = io_wu
  19.       receiving
  20.         rs_p2001 = ls_data.
  21.  
  22.  
  23.     " deebug
  24.  
  25. *    data : lv_x type abap_bool.
  26. *
  27. *    while lv_x eq abap_false.
  28. *      continue.
  29. *    endwhile.
  30.     " On récupére les données qu'il nous faut
  31.  
  32.     lv_pernr = ls_data-pernr.
  33.     lv_cat  = ls_data-awart.
  34.     lv_type = ls_data-subty.
  35.     write ls_data-begda to lv_date_debut.
  36.     write ls_data-endda to lv_date_fin.
  37.     write ls_data-beguz to lv_heure_char. " l'heure sur IDA est sans les secondes donc automatique à 00 sur SAP.
  38.     lv_heure_debut = lv_heure_char. " ici on deplace du 8c dans du 5c pour se retrouver avec l'heure sans les secondes !
  39.     write ls_data-enduz to lv_heure_char. " idem avec la date de fin
  40.     lv_heure_fin = lv_heure_char.
  41.  
  42.     " formattage des dates et heures au format conventionnel
  43.     replace all occurrences of '.' in lv_date_debut with '/'.
  44.     replace all occurrences of '.' in lv_date_fin with '/'.
  45.     replace all occurrences of ':' in lv_heure_debut with 'h'.
  46.     replace all occurrences of ':' in lv_heure_fin with 'h'.
  47.  
  48. " ..................................................... instructions
  49.     " On crée la phrase sur la période d'absence qui va bien
  50.     " car les heures sont facultatives
  51.  
  52.     if lv_date_debut eq lv_date_fin.
  53.  
  54.       lv_dates_ab =  `le ` && lv_date_debut && ` `.
  55.  
  56.       if ( ( ls_data-beguz is initial or strlen( ls_data-beguz ) eq 0 ) and ( ls_data-enduz is initial or strlen( ls_data-enduz ) eq 0 ) ).
  57.  
  58.         lv_dates_ab = lv_dates_ab && `toute la journée`.
  59.  
  60.       elseif  ( ls_data-beguz is initial or strlen( ls_data-beguz ) eq 0 ) and  ( ls_data-enduz is not initial and strlen( ls_data-enduz ) ne 0 ).
  61.  
  62.         lv_dates_ab = lv_dates_ab &&  `du début de la journée jusqu'à ` && lv_heure_fin .
  63.  
  64.       elseif  ( ls_data-beguz is not initial and strlen( ls_data-beguz ) ne 0 ) and  ( ls_data-enduz is initial or strlen( ls_data-enduz ) eq 0 ).
  65.  
  66.         lv_dates_ab = lv_dates_ab && `de ` && lv_heure_debut && ` à la fin de la journée`.
  67.       else.
  68.  
  69.         lv_dates_ab = lv_dates_ab && `de ` && lv_heure_debut && ` à ` && lv_heure_fin.
  70.  
  71.       endif.
  72.  
  73.     else.
  74.       lv_dates_ab =  `du ` && lv_date_debut && ` `.
  75.  
  76.       if  ( ls_data-beguz is not initial and strlen( ls_data-beguz ) ne 0 ).
  77.  
  78.         lv_dates_ab = lv_dates_ab && `à ` && lv_heure_debut.
  79.  
  80.       endif.
  81.  
  82.       lv_dates_ab =  lv_dates_ab && ` au ` && lv_date_fin && ` `.
  83.  
  84.       if  ( ls_data-enduz is not initial and strlen( ls_data-enduz ) ne 0 ).
  85.  
  86.         lv_dates_ab = lv_dates_ab && `à ` && lv_heure_debut.
  87.  
  88.       endif.
  89.  
  90.     endif.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement