Etiquetas

20120110

ABAP HR: Macro para leer Infotipos de OM

Es increible cuántas veces hice SELECT a las tablas de OM por no investigar un poco. Supongo que existe una macro estándar para leer los Infotipos de OM así como existe para HR, pero mientras no la encuentre, ocuparé esta pequeña macro de ejemplo para leer esos registros.


*&---------------------------------------------------------------------*
*&      Define  RH_READ_INFTY
*&---------------------------------------------------------------------*
DEFINE rh_read_infty.
*&1 otype
*&2 objid
*&3 infty
*&4 innnn
*&5 begda
*&6 endda

  refresh &4.
 
  call function 'RH_READ_INFTY'
   exporting
     plvar                      = '01'
     otype                      = &1
     objid                      = &2
     infty                      = '&3'
     istat                      = '1'
*     SUBTY                      = ' '
     begda                      = &5
     endda                      = &6
    tables
      innnn                      = &4
*     OBJECTS                    =
   exceptions
     all_infty_with_subty       = 1
     nothing_found              = 2
     no_objects                 = 3
     wrong_condition            = 4
     wrong_parameters           = 5
     others                     = 6
            .
  if sy-subrc <> 0.
    message id sy-msgid type sy-msgty number sy-msgno
            with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  endif.
END-OF-DEFINITION.

* proceso de ejemplo
DATA p1001 TYPE TABLE OF p1001 WITH HEADER LINE.

rh_read_infty 'O' <objid> 1001 p1001 sy-datum sy-datum.



* formas de leer el registro
***************************************

*1
read table p1001 with key subty = <subty>.
if sy-subrc = 0.
*  ...
endif.

*2
read table p1001 with key objid = v_sobid1
                          otype = 'O'
                          rsign = 'B'
                          relat = '012'
                          sclas = 'S'.
if sy-subrc = 0.
*  ...
endif.

No hay comentarios:

Publicar un comentario