Skip to Content
0
Former Member
Mar 31, 2011 at 12:25 PM

End routine -fields populated with wrong unique key field

30 Views

Hi,

Despite the following end routine has no errors the last elseif ( /BIC/ZOBJETIVO EQ '03' and '04') aren´t doing what they should.

Instead of append the corresponding fields from table l_PZOBJETIVO into KF /BIC/ZMINDESP2 and /BIC/ZPENALIZ2, these fields are populated with the value of the unique key field (/BIC/ZNROINC TYPE /BIC/OIZNROINC -_ty_s_TG_1).

I cannot figure it out why.

data lv_zresal type _ty_s_TG_1-/BIC/ZRESAL.
    data lv_zresmb type _ty_s_TG_1-/BIC/ZRESMB.
    data lv_zdsret type _ty_s_TG_1-/BIC/ZDSRET.
    data: wa_RESULT_PACKAGE type _TY_S_TG_1.
    data: l_PZOBJETIVO type /BIC/PZOBJETIVO.

    Loop at RESULT_PACKAGE into wa_RESULT_PACKAGE.
      lv_zresal = wa_result_package-/BIC/ZRESAL.
      lv_zresmb = wa_result_package-/BIC/ZRESMB.
      lv_zdsret = wa_result_package-/BIC/ZDSRET.

      If lv_zresal NE 0.

        select single *
            into l_PZOBJETIVO
            from /BIC/PZOBJETIVO
             where
            /BIC/ZOBJETIVO EQ '01'.

        wa_RESULT_PACKAGE-/BIC/ZMINDESP = l_PZOBJETIVO-/BIC/ZMINDESP.
        wa_RESULT_PACKAGE-/BIC/ZPENALIZA = l_PZOBJETIVO-/BIC/ZPENALIZA.

      elseif
      lv_zresmb NE 0.

        select single *
      into l_PZOBJETIVO
      from /BIC/PZOBJETIVO
       where
      /BIC/ZOBJETIVO EQ '02'.

        wa_RESULT_PACKAGE-/BIC/ZMINDESP = l_PZOBJETIVO-/BIC/ZMINDESP.
        wa_RESULT_PACKAGE-/BIC/ZPENALIZA = l_PZOBJETIVO-/BIC/ZPENALIZA.

      elseif
      lv_zdsret NE 0
      AND wa_RESULT_PACKAGE-/BIC/ZCRITIC EQ 'Alta'.

        select single *
      into l_PZOBJETIVO
      from /BIC/PZOBJETIVO
       where
      /BIC/ZOBJETIVO EQ '03'.

        wa_RESULT_PACKAGE-/BIC/ZMINDESP2 = l_PZOBJETIVO-/BIC/ZMINDESP.
        wa_RESULT_PACKAGE-/BIC/ZPENALIZ2 = l_PZOBJETIVO-/BIC/ZPENALIZA.


        elseif
      lv_zdsret NE 0
      AND wa_RESULT_PACKAGE-/BIC/ZCRITIC EQ 'Media''Baja'.

        select single *
      into l_PZOBJETIVO
      from /BIC/PZOBJETIVO
       where
      /BIC/ZOBJETIVO EQ '04'.

        wa_RESULT_PACKAGE-/BIC/ZMINDESP2 = l_PZOBJETIVO-/BIC/ZMINDESP.
        wa_RESULT_PACKAGE-/BIC/ZPENALIZ2 = l_PZOBJETIVO-/BIC/ZPENALIZA.

      else.
        clear wa_RESULT_PACKAGE-/BIC/ZMINDESP.
        clear wa_RESULT_PACKAGE-/BIC/ZPENALIZA.
        clear wa_RESULT_PACKAGE-/BIC/ZMINDESP2.
        clear wa_RESULT_PACKAGE-/BIC/ZPENALIZ2.

      endif.

      modify RESULT_PACKAGE from wa_RESULT_PACKAGE.

    Endloop.

Regards,

Diego