viernes, 26 de abril de 2013

Infopaquete ABAP ejemplos


**********30 dias hacia atras**************************************+
program conversion_routine.
* Type pools used by conversion program
type-pools: rsarc, rsarr, rssm.
tables: rssdlrange.
* Global code used by conversion rules
*$*$ begin of global - insert your declaration only below this line  *-*
* TABLES: ...
* DATA:   ...
*$*$ end of global - insert your declaration only before this line   *-*
* -------------------------------------------------------------------
*     InfoObject      = Z_BUDAT
*     Fieldname       = BUDAT
*     data type       = DATS
*     length          = 000008
*     convexit        =
* -------------------------------------------------------------------
form compute_BUDAT
  tables l_t_range structure rssdlrange
  changing p_subrc like sy-subrc.
*       Insert source code to current selection field
*$*$ begin of routine - insert your code only below this line        *-*
data: l_idx like sy-tabix, l_budat_low like sy-datum.

  read table l_t_range with key fieldname = 'BUDAT'.
  l_idx = sy-tabix.

* Se calcula la fecha de dos día hacia atras
*  clear l_budat_low.
  l_budat_low = sy-datum.
  l_budat_low = (  l_budat_low - 29 ).

* Se pone la fecha de dos días hacia atras como límite inferior del
* rango de fechas, el límite superior la fecha que venía y el
* signo de igual se pasa a between.
*  clear l_t_range-high.
  l_t_range-high   = sy-datum.
  l_t_range-low    = l_budat_low.
  l_t_range-option = 'BT'.
  l_t_range-sign   = 'I'.
  modify l_t_range index l_idx.

  p_subrc = 0.

*$*$ end of routine - insert your code only before this line         *-*
endform.

*****************************************************************+
*********ultimo dia del mes******************************************
data: l_idx like sy-tabix.
read table l_t_range with key
     fieldname = 'STIDA'.
l_idx = sy-tabix.
*....
data: u_fecha like sy-datum.
* Se calcula la fecha
  u_fecha = sy-datum.
* Ultimo dia do mes
      CALL FUNCTION 'SLS_MISC_GET_LAST_DAY_OF_MONTH'
        EXPORTING
          DAY_IN            = u_fecha
        IMPORTING
          LAST_DAY_OF_MONTH = u_fecha
        EXCEPTIONS
          DAY_IN_NOT_VALID  = 1
          OTHERS            = 2.
* rango de fechas
  l_t_range-high   = u_fecha.
  l_t_range-low    = u_fecha.
  l_t_range-option = 'BT'.
  l_t_range-sign   = 'I'.
  modify l_t_range index l_idx.

No hay comentarios: