SAP HCM MEDIDAS DINAMICAS

From SapWiki

Medidas Dinámicas

Las medidas dinámicas se crean en la tabla T588Z

Ver Note 386027 - Dynamic actions

Ejemplo 1: en este caso al actualizar ciertos campos del IT0021 se deben crear IT0015. Los nuevos campos se agregaron como tabla con máximo de 12 líneas, cada línea se procesa en este bloque

T001P-MOLGA='39'
PROCESAR(ZHCM_MEDIDAS_DINAMICAS)
RP50D-FLAG1='X'
P0021-ZZFCH_PAGO01<>'00000000'
INS,0015,1159,,(P0021-ZZFCH_PAGO01),(P0021-ZZFCH_PAGO01)
P0015-BETRG=P0021-ZZBET01
P0015-WAERS=P0021-ZZWAERS
P0015-ANZHL=P0021-ZZFASAR01
P0015-ZEINH='025'
P0015-ZUORD=P3226-RUTID

el bloque se repite 12 veces con campos XXXXX01 a XXXXX12

Tabla T588Z

Infotipo Subtipo Nombre campo Caracter funcional Nro secuencia Accion Parte variable de la funcion
0021 06 400 * MI MEDIDA DINAMICA *
0021 06 401 P T001P-MOLGA='39'
0021 06 402 F PROCESAR(ZHCM_MEDIDAS_DINAMICAS)
0021 06 403 P RP50D-FLAG1='X'
0021 06 404 P P0021-ZZFCH_PAGO01<>'00000000'
0021 06 405 I INS,0015,1159,,(P0021-ZZFCH_PAGO01),(P0021-ZZFCH_PAGO01)
0021 06 406 W P0015-BETRG=P0021-ZZBET01
0021 06 407 W P0015-WAERS=P0021-ZZWAERS
0021 06 408 W P0015-ANZHL=P0021-ZZFASAR01
0021 06 409 W P0015-ZEINH='025'
0021 06 410 W P0015-ZUORD=P3226-RUTID
0021 06 420 P T001P-MOLGA='39'
0021 06 421 F PROCESAR(ZHCM_MEDIDAS_DINAMICAS)
0021 06 422 P RP50D-FLAG1='X'
0021 06 423 P P0021-ZZFCH_PAGO02<>'00000000'
0021 06 424 I INS,0015,1159,,(P0021-ZZFCH_PAGO02),(P0021-ZZFCH_PAGO02)
0021 06 425 W P0015-BETRG=P0021-ZZBET02
0021 06 426 W P0015-WAERS=P0021-ZZWAERS
0021 06 427 W P0015-ANZHL=P0021-ZZFASAR02
0021 06 428 W P0015-ZEINH='025'
0021 06 429 W P0015-ZUORD=P3226-RUTID

Programa ZHCM_MEDIDAS_DINAMICAS

REPORT ZHCM_MEDIDAS_DINAMICAS.
TABLES: p0021,
        p3226,
        RP50D.

DATA g_tabix LIKE sy-tabix.
DATA gt_p0015 TYPE TABLE OF p0015.


FORM PROCESAR.

  DATA: ls_p0021 TYPE p0021,
        ls_p3226 TYPE p3226,
        ls_p0015 TYPE p0015.

  ls_p0021 = p0021.
  ls_p3226 = p3226.

  ADD 1 TO  g_tabix.

  RP50D-FLAG1 = space.
  CHECK ls_p3226-RUTID IS NOT INITIAL . "Si carga no tiene RUT no se crea IT0015

  DATA: ZZFCH_PAGO TYPE zq0021-ZZFCH_PAGO,
        ZZBET TYPE zq0021-ZZBET,
        zzfasar TYPE zq0021-zzfasar,
        ZZFLAG0015 TYPE zq0021-ZZFLAG0015.

  DATA: l_subrc TYPE sy-subrc,
        l_message TYPE bapiret2-MESSAGE.

  DO 12 TIMES VARYING ZZFCH_PAGO FROM ls_p0021-ZZFCH_PAGO01 NEXT ls_p0021-ZZFCH_PAGO02
              VARYING ZZBET      FROM ls_p0021-ZZBET01      NEXT ls_p0021-ZZBET02
              VARYING zzfasar    FROM ls_p0021-zzfasar01    NEXT ls_p0021-zzfasar02
              VARYING ZZFLAG0015 FROM ls_p0021-ZZFLAG001501 NEXT ls_p0021-ZZFLAG001502.

    IF sy-INDEX = g_tabix.
      CHECK ZZFCH_PAGO IS NOT INITIAL AND ZZFLAG0015 <> 'X'.
      RP50D-FLAG1 = 'X'.   "ver tabla de medidas dinámicas T588Z con IT0021
    ENDIF.

  ENDDO.
ENDFORM.

form PROCESAR_INIT.
  g_tabix = 0.
ENDFORM.

Ejemplo 2: Al ejecutar una Contratación o Recontratación (trn. PA40) se deben generar IT0008 y IT0014, esto se realiza después de crear el IT0007 de la medida

Tabla T588Z

Infotipo Subtipo Nombre campo Caracter funcional Nro secuencia Accion Parte variable de la funcion
0007 06 100 *ASIGNACIONES
0007 06 101 P T001P-MOLGA='39'
0007 06 102 F INIT(ZHCM_MEDIDAS_DINAMICAS)
0007 06 103 F ASIGNACIONES(ZHCM_MEDIDAS_DINAMICAS)
0007 06 104 P RP50D-FLAG1='X'
0007 06 105 I INS,0008,0,,(P0000-BEGDA),(P0000-ENDDA)/D
0007 06 106 W P0008-TRFAR=RP50D-ZZFIELD01
0007 06 107 W P0008-TRFGB=RP50D-ZZFIELD02
0007 06 108 W P0008-TRFGR=RP50D-ZZFIELD03
0007 06 109 W P0008-TRFST=RP50D-ZZFIELD04
0007 06 110 W P0008-LGA01=RP50D-ZZFIELD05
0007 06 111 W P0008-BET01=RP50D-ZZFIELD06
0007 06 112 W P0008-SPRPS=RP50D-ZZFIELD07
0007 06 113 F ASIGNACIONES(ZHCM_MEDIDAS_DINAMICAS)
0007 06 114 P RP50D-FLAG1='X'
0007 06 115 I INS,0014,(RP50D-ZZFIELD01),,(P0000-BEGDA),(P0000-ENDDA)
0007 06 116 W P0014-LGART=RP50D-ZZFIELD01
0007 06 117 W P0014-BETRG=RP50D-ZZFIELD02
0007 06 118 W P0014-WAERS=RP50D-ZZFIELD03
0007 06 119 W P0014-ANZHL=RP50D-ZZFIELD04
0007 06 120 P T001P-MOLGA='39'
0007 06 121 F ASIGNACIONES(ZHCM_MEDIDAS_DINAMICAS)
0007 06 122 P RP50D-FLAG1='X'
0007 06 123 I INS,0014,(RP50D-ZZFIELD01),,(P0000-BEGDA),(P0000-ENDDA)
0007 06 124 W P0014-LGART=RP50D-ZZFIELD01
0007 06 125 W P0014-BETRG=RP50D-ZZFIELD02
0007 06 126 W P0014-WAERS=RP50D-ZZFIELD03
0007 06 127 W P0014-ANZHL=RP50D-ZZFIELD04
0007 06 128 P T001P-MOLGA='39'
0007 06 129 F ASIGNACIONES(ZHCM_MEDIDAS_DINAMICAS)
0007 06 130 P RP50D-FLAG1='X'
0007 06 131 I INS,0014,(RP50D-ZZFIELD01),,(P0000-BEGDA),(P0000-ENDDA)
0007 06 132 W P0014-LGART=RP50D-ZZFIELD01
0007 06 133 W P0014-BETRG=RP50D-ZZFIELD02
0007 06 134 W P0014-WAERS=RP50D-ZZFIELD03
0007 06 135 W P0014-ANZHL=RP50D-ZZFIELD04
0007 06 136 P T001P-MOLGA='39'
0007 06 137 F ASIGNACIONES(ZHCM_MEDIDAS_DINAMICAS)
0007 06 138 P RP50D-FLAG1='X'
0007 06 139 I INS,0014,(RP50D-ZZFIELD01),,(P0000-BEGDA),(P0000-ENDDA)
0007 06 140 W P0014-LGART=RP50D-ZZFIELD01
0007 06 141 W P0014-BETRG=RP50D-ZZFIELD02
0007 06 142 W P0014-WAERS=RP50D-ZZFIELD03
0007 06 143 W P0014-ANZHL=RP50D-ZZFIELD04

Programa ZHCM_MEDIDAS_DINAMICAS

REPORT  zhcm_medidas_dinamicas.
TYPE-POOLS zhr01.

CONSTANTS: c_enviado(1) TYPE c VALUE '1',
           c_pendiente(1) TYPE c VALUE '2'.

TABLES: p0000,
        p0001,
        p0002,
        p0007,
        p0105,
        pspar,
        rp50d,
        t001p.

TYPES: BEGIN OF ty_lgart,
       infty TYPE infty,
       lgart TYPE lgart,
       betrg TYPE betrg,
       waers TYPE waers,
END OF ty_lgart.

DATA gt_lgart TYPE TABLE OF ty_lgart.
DATA wa_lgart LIKE LINE OF gt_lgart.
DATA wa_asignac TYPE zhr_asignac_rbk2.

DATA g_tabix TYPE sy-tabix.

*&---------------------------------------------------------------------*
*&      Form  asignaciones
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM asignaciones.
  DATA ls_t511 TYPE t511.

  rp50d-flag1 = space.

  IF t001p-molga <> '39'.
    RETURN.
  ENDIF.

  IF sy-tcode <> 'PA40' AND sy-tcode <> 'ZHR_PA40'.
    RETURN.
  ENDIF.

* contratacion - recontratacion
  CHECK p0000-massn = 'U1' OR p0000-massn = 'U3'.

  IF gt_lgart[] IS INITIAL.
    SELECT  SINGLE * INTO wa_asignac FROM  zhr_asignac_rbk2
           WHERE  werks  = p0001-werks
           AND    persk  = p0001-persk
           AND    stell  = p0001-stell
           AND    wostd  = p0007-wostd
           AND    endda >= p0001-begda
          AND begda <= p0001-endda.
    IF sy-subrc = 0.
      wa_lgart-waers  = wa_asignac-waers.
      wa_lgart-infty = '0008'.
      wa_lgart-lgart = wa_asignac-lgartsueldobase.
      wa_lgart-betrg = wa_asignac-sueldobase.
      APPEND wa_lgart TO gt_lgart.

      wa_lgart-infty = '0014'.
      wa_lgart-lgart = wa_asignac-lgartmoviliza.
      wa_lgart-betrg = wa_asignac-asigmovilizacion.
      APPEND wa_lgart TO gt_lgart.

      wa_lgart-infty = '0014'.
      wa_lgart-lgart = wa_asignac-lgartcolacion.
      wa_lgart-betrg = wa_asignac-asigcolacion.
      APPEND wa_lgart TO gt_lgart.

      wa_lgart-infty = '0014'.
      wa_lgart-lgart = wa_asignac-lgartmovadic.
      wa_lgart-betrg = wa_asignac-movadicional.
      APPEND wa_lgart TO gt_lgart.

      wa_lgart-infty = '0014'.
      wa_lgart-lgart = wa_asignac-lgartcoladic.
      wa_lgart-betrg = wa_asignac-coladicional.
      APPEND wa_lgart TO gt_lgart.
    ELSE.
      CLEAR wa_lgart.
      DO 5 TIMES.
        IF sy-index = 1.
          wa_lgart-infty = '0008'.
        ELSE.
          wa_lgart-infty = '0014'.
        ENDIF.
        APPEND wa_lgart TO gt_lgart.
      ENDDO.
    ENDIF.
  ENDIF.

  ADD 1 TO g_tabix.

  READ TABLE gt_lgart INTO wa_lgart INDEX g_tabix.
  IF sy-subrc = 0.
    IF wa_lgart-lgart IS INITIAL.
      rp50d-flag1 = space.
      RETURN.
    ELSE.
      CASE wa_lgart-infty.
*--------------------------------------------------------------------*
        WHEN '0008'.
*--------------------------------------------------------------------*
          CASE p0001-persk.
            WHEN 'C9'. "alumnos en práctica
              rp50d-zzfield01 = 'SC'.
            WHEN OTHERS.
              rp50d-zzfield01 = 'CP'.
          ENDCASE.

          rp50d-zzfield02 = 'NO'.
          rp50d-zzfield03 = 'SUPERM'.
          rp50d-zzfield04 = '01'.

          rp50d-zzfield05 = wa_lgart-lgart.
          MOVE wa_lgart-betrg TO rp50d-zzfield06.
          CONDENSE rp50d-zzfield06.
          rp50d-flag1 = 'X'.

          CASE p0000-massn.
            WHEN 'U1'.
              rp50d-zzfield07 = 'X'.
            WHEN 'U3'.
              rp50d-zzfield07 = space.
          ENDCASE.

*--------------------------------------------------------------------*
        WHEN '0014'.
*--------------------------------------------------------------------*
          SELECT SINGLE * INTO ls_t511 FROM t511 WHERE molga = '39' AND
                                                      lgart = wa_lgart-lgart.
          rp50d-zzfield01 = wa_lgart-lgart.
          MOVE wa_lgart-betrg TO rp50d-zzfield02.
          CONDENSE rp50d-zzfield02.
          rp50d-zzfield03 = wa_lgart-waers.

* verificar si hay que ingresar cantidad
          IF ls_t511-anmax IS NOT INITIAL.
            rp50d-zzfield04 = '100'.                        "=> 1,00
          ELSE.
            rp50d-zzfield04 = space.
          ENDIF.
          rp50d-flag1 = 'X'.
      ENDCASE.
    ENDIF.
  ELSE.
    rp50d-flag1 = space.
    RETURN.
  ENDIF.

ENDFORM.                    "asignaciones_0014

*&---------------------------------------------------------------------*
*&      Form  INIT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM init.
  g_tabix = 0.
  CLEAR gt_lgart[].
ENDFORM.                    "INIT