FUNCTION ZVIM_BUYER_ROLE.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" REFERENCE(PRODUCTCODE) LIKE /PTGWFI/W_ROLE-ZPDCD
*" REFERENCE(RESPONSIBLEPARTY) LIKE /PTGWFI/W_ROLE-ZRSP
*" REFERENCE(OBJTYPE) LIKE SWOTBASDAT-OBJTYPE
*" REFERENCE(OBJKEY) LIKE SWOTOBJID-OBJKEY
*" TABLES
*" ACTOR_TAB STRUCTURE SWHACTOR
*" EXCEPTIONS
*" NOBODY_FOUND
*"----------------------------------------------------------------------
TYPES: BEGIN OF ltyp_bukrs,
sign(1) TYPE c,
option(2) TYPE c,
low TYPE bukrs,
high TYPE bukrs,
END OF ltyp_bukrs.
DATA : BEGIN OF rseg_key,
belnr LIKE bkpf-belnr,
gjahr LIKE bkpf-gjahr,
buzei LIKE rseg-buzei,
END OF rseg_key,
ls_rseg TYPE rseg,
lv_reswk TYPE reswk,
lr_bukrs TYPE STANDARD TABLE OF ltyp_bukrs,
ls_bukrs TYPE ltyp_bukrs,
lt_const TYPE STANDARD TABLE OF /ptgwfi/z_const,
ls_const TYPE /ptgwfi/z_const,
lv_call_old_fm TYPE flag,
lv_zpcd TYPE /ptgwfi/w_role-zpdcd VALUE 'LIX',
lv_zrsp TYPE /ptgwfi/w_role-zrsp VALUE 'HB_BUYER3',
lv_objtyp TYPE swotobjid-objtype,
lv_objkey TYPE swotobjid-objkey,
* lt_user TYPE TABLE OF swhactor,
lv_docid TYPE /opt/docid.
REFRESH : actor_tab. CLEAR : actor_tab.
CLEAR : rseg_key.
rseg_key = objkey.
SELECT *
FROM /ptgwfi/z_const
INTO TABLE lt_const
WHERE zpdcd = '005'
AND zconst = 'R7_COMPANY_CODES'.
IF sy-subrc = 0 AND lt_const[] IS NOT INITIAL.
LOOP AT lt_const INTO ls_const.
DO.
SPLIT ls_const-zvalue AT ';' INTO ls_bukrs-low ls_const-zvalue.
IF ls_bukrs-low IS NOT INITIAL.
ls_bukrs-sign = 'I'.
ls_bukrs-option = 'EQ'.
APPEND ls_bukrs TO lr_bukrs.
CLEAR ls_bukrs.
ELSE.
EXIT.
ENDIF.
ENDDO.
CLEAR ls_const.
ENDLOOP.
ELSE.
lv_call_old_fm = abap_true.
ENDIF.
IF lv_call_old_fm = abap_false.
SELECT SINGLE *
FROM rseg
INTO ls_rseg
WHERE belnr = rseg_key-belnr
AND gjahr = rseg_key-gjahr.
IF sy-subrc = 0 AND ls_rseg-bukrs IN lr_bukrs.
IF objtype = '/OPT/B2081' OR objtype = '/OPT/LIV'.
SELECT SINGLE reswk
FROM ekko
INTO lv_reswk
WHERE ebeln = ls_rseg-ebeln.
IF sy-subrc = 0 AND lv_reswk IS NOT INITIAL.
SELECT SINGLE docid FROM /opt/vim_1head INTO lv_docid WHERE belnr =
ls_rseg-belnr AND gjahr = ls_rseg-gjahr.
IF sy-subrc = 0.
UPDATE /opt/vim_1head SET zz_ship_plant = lv_reswk WHERE docid =
lv_docid.
COMMIT WORK.
lv_objkey = lv_docid.
CALL FUNCTION 'ZVIM_RETRIEVE_USERS'
EXPORTING
zpdcd = lv_zpcd
zrsp = lv_zrsp
* OBJTYPE = lv_objtyp
objkey = lv_objkey
TABLES
userlist = actor_tab
EXCEPTIONS
role_not_resolved = 1
OTHERS = 2.
ENDIF.
ENDIF.
ENDIF.
ELSE.
lv_call_old_fm = abap_true.
ENDIF.
ENDIF.
IF lv_call_old_fm = abap_true.
CALL FUNCTION 'ZRTP_VIM_BUYER_ROLE'
EXPORTING
productcode = productcode
responsibleparty = responsibleparty
objtype = objtype
objkey = objkey
TABLES
actor_tab = actor_tab
EXCEPTIONS
nobody_found = 1
OTHERS = 2.
IF sy-subrc <> 0 AND actor_tab[] IS INITIAL.
RAISE nobody_found.
ENDIF.
ENDIF.
ENDFUNCTION.
ticket 12719