Транзакция ZCHANGE_KODPROF изменение кода профессии

Транзакция ZCHANGE_KODPROF изменение кода профессии

В таблице ZPROF:

ZKPROF_OLD Код профессии старый
ZKPROF_NEW Код профессии новый

При первом запуске копирует в эти поля из ZKPROF.

Изменяет поле  ZKPROF в PLPO и ZPROF

 

*&---------------------------------------------------------------------*
*& Report  ZCHANGE_KODPROF_LOPATKO
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

report  zchange_kodprof_lopatko.
tables: zprof.
data: it_zprof type table of zprof,
      it_plpo type table of plpo.
field-symbols: <fs_zprof> like line of it_zprof,
               <fs_plpo> like line of it_plpo.
select-options: zkprof for zprof-zkprof,
                so_old for zprof-zkprof_old,
                so_new for zprof-zkprof_new.
parameters: p_old as checkbox.
*            p_test as checkbox default 'X'.
update zprof set zkprof_old = zprof~zkprof where zkprof_old = ''.
update zprof set zkprof_new = zprof~zkprof where zkprof_new = ''.
select * from zprof into corresponding fields of table it_zprof where zkprof in zkprof and zkprof_old in so_old and zkprof_new in so_new.
loop at it_zprof assigning <fs_zprof>.
  if p_old = ''.
    delete from zprof where zkprof = <fs_zprof>-zkprof.
    commit work and wait.
    <fs_zprof>-zkprof = <fs_zprof>-zkprof_new.
    insert zprof from <fs_zprof>.
    commit work and wait.
    update plpo set zkprof = <fs_zprof>-zkprof_new where ( zkprof = <fs_zprof>-zkprof_new ) or ( zkprof = <fs_zprof>-zkprof_old ).
    if sy-subrc = 0.
      select * from plpo appending table it_plpo where ( zkprof = <fs_zprof>-zkprof_new ) or ( zkprof = <fs_zprof>-zkprof_old ).
    endif.
  else.
    delete from zprof where zkprof = <fs_zprof>-zkprof.
    commit work and wait.
    <fs_zprof>-zkprof = <fs_zprof>-zkprof_old.
    insert zprof from <fs_zprof>.
    commit work and wait.
    update plpo set zkprof = <fs_zprof>-zkprof_old where ( zkprof = <fs_zprof>-zkprof_new ) or ( zkprof = <fs_zprof>-zkprof_old ).
    if sy-subrc = 0.
      select * from plpo appending table it_plpo where ( zkprof = <fs_zprof>-zkprof_new ) or ( zkprof = <fs_zprof>-zkprof_old ).
    endif.
  endif.
  commit work and wait.
endloop.
include zchange_kodprof_uotput.

Добавить комментарий