четверг, 25 июля 2019 г.

Изменение списка рассылки из ABAP

После долгих боданий с любимой Бивишкой удалось наколхозить ФМ, который в список рассылки подставляет нужное мыло.

Спасибо статье.

И, да, это старый абап.


function zpsb_bw_set_distibution_list.
*"----------------------------------------------------------------------
*"*"Локальный интерфейс:
*"  IMPORTING
*"     REFERENCE(I_OBJNAME) TYPE  SO_OBJ_NAM
*"  TABLES
*"      T_USERSDATA STRUCTURE  SODLIENTI1
*"----------------------------------------------------------------------
  types:
    begin of ty_soucadcp,
        usrtp type so_usr_tp,
        usryr type so_usr_yr,
        usrno type so_usr_no,
      end of ty_soucadcp.

*    BEGIN OF ty_usrno,
*        member_id(20) TYPE c,
*      END OF ty_usrno.

  data:
        wa_soucadcp     type ty_soucadcp,
        lt_usrno        like sodlienti1 occurs 300 with header line,
        search_fol      like soxli occurs 0 with header line,
        ex_region       like soxrg,
        cancel_f,
        folder_id_con   like sofoldati1-object_id,
        object_id       like soodk,
        object_id_con   like sofoldati1-object_id,
        dli_inf         like sodlidati1,
        dli_insert_dat  like sodlichgi1,
        mess            type string.
*"----------------------------------------------------------------------
  select single
      dlitp
      dliyr
      dlino
      foltp
      folyr
      folno
    into (object_id-objtp,
          object_id-objyr,
          object_id-objno,
          search_fol-foltp,
          search_fol-folyr,
          search_fol-folno)
    from soid
   where objnam eq i_objname.

  lt_usrno = t_usersdata.
  sort lt_usrno.

  if search_fol is initial.
    ex_region-finbo    = 'X'.
    ex_region-foutb    = 'X'.
    ex_region-fprv     = 'X'.
    ex_region-fpwb     = 'X'.
    ex_region-fswb     = 'X'.
    ex_region-fresub   = 'X'.

    call function 'SO_WIND_FOLDERS_SELECT'
        exporting
             exclude_regions            = ex_region
             folder_access              = '1'
             full_screen                = ' '
             one_selection              = 'X'
             owner                      = ' '
             region                     = 'Q'
             selection                  = 'X'
*         source_folder_id           = ' '
*         folder_selections          = ' '
*         current_fol_id             = ' '
        importing
             f_cancelled                = cancel_f
*         f_document_selection       =
         tables
             follist                    = search_fol
        exceptions
             component_not_available    = 1
             operation_no_authorization = 2
             owner_not_exist            = 3
             parameter_error            = 4
             x_error                    = 5
             others                     = 6.

    if sy-subrc ne 0.
      clear: search_fol.
    endif.

    case sy-subrc.
      when 1. message e846(so) with 'Component_not_available'.
      when 2. message e846(so) with 'Operation_no_authorization'.
      when 3. message e846(so) with 'Owner_not_exist '.
      when 4. message e846(so) with 'Parameter_error'.
      when 5. message e846(so) with 'X_error'.
      when 6. message e846(so) with 'Unbekannter Fehler'.
      when 0.
        if cancel_f <> ' '.
          clear: search_fol.
        endif.
    endcase.
  endif.

  concatenate search_fol-foltp search_fol-folyr search_fol-folno
         into folder_id_con.

  write:/ text-008 ,/.
  concatenate object_id-objtp object_id-objyr object_id-objno
         into object_id_con.

  call function 'SO_DLI_READ_API1'
      exporting
*         dli_name                   = ' '
          dli_id                     = object_id_con
          shared_dli                 = 'X'
     importing
          dli_data                   = dli_inf
*    TABLES
*         DLI_ENTRIES                =
     exceptions
          dli_not_exist              = 1
          operation_no_authorization = 2
          parameter_error            = 3
          x_error                    = 4
          others                     = 5.

  case sy-subrc.
    when 1. message e846(so) with 'dli_not_exist'.
    when 2. message e846(so) with 'operation_no_authorization'.
    when 3. message e846(so) with 'parameter_error'.
    when 4. message e846(so) with 'x_error'.
    when 5. message e846(so) with 'OTHERS'.
    when 0.
      move-corresponding dli_inf to dli_insert_dat.
      clear dli_inf.
      call function 'SO_DLI_UPDATE_API1'
        exporting
            dli_id                     = object_id_con
            dli_update_data            = dli_insert_dat
*           DLI_NAME                   = ' '
        importing
            dli_info                   = dli_inf
        tables
            dli_entries                = t_usersdata
        exceptions
            dli_not_exist              = 1
            operation_no_authorization = 2
            parameter_error            = 3
            x_error                    = 4
            enqueue_error              = 5
            others                     = 6.
      case sy-subrc.
        when 1. message e846(so) with 'dli_not_exist'.
        when 2. message e846(so) with 'operation_no_authorization'.
        when 3. message e846(so) with 'Parameter_error'.
        when 4. message e846(so) with 'X_error'.
        when 5. message e846(so) with 'Enqueue_error'.
        when 6. message e846(so) with 'Unbekannter Fehler'.
        when 0.
          concatenate mess `Список рассылки ` dli_inf-obj_name ` обновлён` into mess.
          message mess type 'I'.
      endcase.
  endcase.
endfunction.

Комментариев нет:

Отправить комментарий