0% found this document useful (0 votes)
263 views8 pages

Attachment Note 1466740

The document describes creating new function modules to lock business partner accounts locally and remotely in different systems. It includes: 1) Creating a ZUKM_ACCOUNT_LOCK_IN_CHECK module to lock accounts remotely by calling an existing locking function and retrieving related partners. 2) Creating a ZUKM_ACCOUNT_LOCK_LOCAL module to lock accounts locally by calling the remote lock check module, locking the partner and related partners locally, and handling exceptions. 3) Updating a BADI to call the local lock module before performing a credit check outbound.

Uploaded by

thomas william
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
263 views8 pages

Attachment Note 1466740

The document describes creating new function modules to lock business partner accounts locally and remotely in different systems. It includes: 1) Creating a ZUKM_ACCOUNT_LOCK_IN_CHECK module to lock accounts remotely by calling an existing locking function and retrieving related partners. 2) Creating a ZUKM_ACCOUNT_LOCK_LOCAL module to lock accounts locally by calling the remote lock check module, locking the partner and related partners locally, and handling exceptions. 3) Updating a BADI to call the local lock module before performing a credit check outbound.

Uploaded by

thomas william
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 8

Attachment for Note 1466740.

Date: 10.05.2010 Version 1

-----------------------------------------------------------------------------------
----------
Create new function module
ZUKM_ACCOUNT_LOCK_IN_CHECK
Desc: locks account for check and unlocks it after com.update
Mark it as remote-enabled module

Input Param Type Associ.Type Opt Pass Short text


IV_PARTNER TYPE BU_PARTNER x x Business Partner Number
I_GET_LOCK_PARTNER TYPE FLAG x x General Flag
I_SET_FLAG TYPE FLAG x x General Flag
I_DELETE_FLAG TYPE FLAG x x General Flag
I_READ_FLAG TYPE FLAG x x General Flag
IV_SEGMENT TYPE CHAR10 x x Credit segment

Tables
Input Param Type Associ.Type Opt Pass Short text
ET_RETURN LIKE BAPIRET2 x x Return Parameter
T_PARTNER LIKE BUSPARTNER x x BP: partner number

EXCEPTIONS
LOCAL_LOCK locked in local
FSCM_LOCK locked in FSCM

FUNCTION ZUKM_ACCOUNT_LOCK_IN_CHECK.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" VALUE(IV_PARTNER) TYPE BU_PARTNER OPTIONAL
*" VALUE(I_GET_LOCK_PARTNER) TYPE FLAG OPTIONAL
*" VALUE(I_SET_FLAG) TYPE FLAG OPTIONAL
*" VALUE(I_DELETE_FLAG) TYPE FLAG OPTIONAL
*" VALUE(I_READ_FLAG) TYPE FLAG OPTIONAL
*" VALUE(IV_SEGMENT) TYPE CHAR10 OPTIONAL
*" TABLES
*" ET_RETURN STRUCTURE BAPIRET2 OPTIONAL
*" T_PARTNER STRUCTURE BUSPARTNER OPTIONAL
*" EXCEPTIONS
*" LOCAL_LOCK
*" FSCM_LOCK
*"----------------------------------------------------------------------

data: ls_sgm type ukmbp_cms_sgm.


data: lx.
Data: Lt_partner1 type table of Bu_partner,
Lt_partner2 type table of Bu_partner,
Lv_partner type Bu_partner,
lt_return type standard table of bapiret2,
ls_return like line of lt_return,
l_dftval like BUT050-DFTVAL,
l_segment type ukm_credit_sgmnt.

if iv_segment <> space.


l_segment = iv_segment.
else.
l_segment = '0000'.
endif.

if I_GET_LOCK_PARTNER = 'X' or i_read_flag = 'X'.


l_dftval = l_segment.
CALL FUNCTION 'BUB_PARTNER_VIA_RELATIONS_GET'
EXPORTING
I_reltyp = 'UKM001'
I_xrf = space
I_dftval = l_dftval
I_partner1 = Iv_partner
TABLES
T_partner = Lt_partner1.

CALL FUNCTION 'BUB_PARTNER_VIA_RELATIONS_GET'


EXPORTING
I_reltyp = 'UKM001'
I_xrf = space
I_dftval = l_dftval
I_partner2 = Iv_partner
TABLES
T_partner = Lt_partner2.

append lines of lt_partner1 to lt_partner2.


sort lt_partner2.
delete adjacent duplicates from lt_partner2.
T_PARTNER[] = lt_partner2[].
endif.
* lock the debtor

***

* next read Lock umbp_cms_sgm


if i_read_flag = 'X'.
perform read_fscm_lock using iv_partner
changing sy-subrc.
if sy-subrc = 0.
Message E000(ukm_bp) with 'Partner ' iv_partner 'item error'
raising FSCM_lock.
endif.
* check whether the related BPs are in lock
Loop at Lt_partner2 into Lv_partner.
perform read_fscm_lock using lv_partner
changing sy-subrc.
If sy-subrc = 0.
Message e000(Ukm_bp) with 'Rel Partner ' Lv_partner 'item error'
raising Fscm_lock.
endif.
Endloop.
endif.

* use item_error as persistent 'lock'


if I_SET_FLAG = 'X'.
SELECT SINGLE for update * FROM ukmbp_cms_sgm
INTO ls_sgm
where partner = iv_partner
and credit_sgmnt = l_segment.
*
if sy-subrc = 0.
if ls_sgm-item_error = space.
update ukmbp_cms_sgm
set item_error = 'X'
where partner = iv_partner
and credit_sgmnt = l_segment.
else.
* message E000(ukm_bp) with 'Partner ' iv_partner 'Commitment in queue'.
endif.

endif.

endif.

if I_DELETE_FLAG = 'X'.
SELECT SINGLE for update * FROM ukmbp_cms_sgm
INTO ls_sgm
where partner = iv_partner
and credit_sgmnt = l_segment.
*
if sy-subrc = 0.
if ls_sgm-item_error = 'W'.
update ukmbp_cms_sgm
set item_error = space
where partner = iv_partner
and credit_sgmnt = l_segment.
endif.
endif.
endif.

ENDFUNCTION.

form lock using i_partner type bu_partner


changing c_subrc like sy-subrc.

CALL FUNCTION 'ENQUEUE_EUKMCOMM'


EXPORTING
mode_ukm_enqcomm = 'E'
* client = sy-mandt
partner_low = i_partner
partner_high = i_partner
_scope = '1'
_wait = ' '
_collect = ' '
EXCEPTIONS
foreign_lock = 1
system_failure = 2
OTHERS = 3.
c_subrc = sy-subrc.
endform.
* note: the read is done without any segments
form read_fscm_lock using i_partner type bu_partner
changing c_subrc like sy-subrc..
data: L_error type UKM_ITEM_ERROR.
select item_error from ukmbp_cms_sgm into L_error
where
partner = i_partner
and item_error = 'X'.
endselect.
c_subrc = sy-subrc.
endform.

-----------------------------------------------------------------------------------
------------

-----------------------------------------------------------------------------------
------------
Create new function module
ZUKM_ACCOUNT_LOCK_LOCAL Desc: locks locally

Input Param Type Associ.Type Opt Pass default Short text


IV_PARTNER TYPE BU_PARTNER Business Partner Number
IV_DEST TYPE RFCDEST X 'NONE' destination of
FSCM

tables
T_PARTNER LIKE BUSPARTNER x related partners

exceptions
LOCAL_LOCK locked in local

FUNCTION ZUKM_ACCOUNT_LOCK_LOCAL.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" REFERENCE(IV_PARTNER) TYPE BU_PARTNER
*" REFERENCE(IV_DEST) TYPE RFCDEST DEFAULT 'NONE'
*" REFERENCE(IV_SEGMENT) TYPE CHAR10 OPTIONAL
*" TABLES
*" T_PARTNER STRUCTURE BUSPARTNER OPTIONAL
*" EXCEPTIONS
*" LOCAL_LOCK
*"----------------------------------------------------------------------

statics: s_partner_locked type bu_partner,


s_segment_locked type char10,
st_partner_locked type table of Bu_partner.

data: Lt_partner type table of Bu_partner.


data: Lv_partner type Bu_partner.
data: l_err.
* find related partners
lv_partner = iv_partner.
if s_partner_locked = lv_partner and s_segment_locked = iv_segment.
exit. "is already locked
else.
perform unlock_local using s_partner_locked changing sy-subrc.
clear s_partner_locked.
Loop at st_partner_locked into Lv_partner.
perform unlock_local using lv_partner changing sy-subrc.
endloop.
refresh st_partner_locked.
endif.

lv_partner = iv_partner.
CALL FUNCTION 'ZUKM_ACCOUNT_LOCK_IN_CHECK'
destination iv_dest
EXPORTING
IV_PARTNER = lv_partner
iv_segment = iv_segment
I_GET_LOCK_PARTNER = 'X'
TABLES
T_PARTNER = lt_partner
EXCEPTIONS
OTHERS = 0.

* lock partner
perform lock_local using iv_partner changing sy-subrc.
IF SY-SUBRC = 0.
Loop at lt_partner into Lv_partner.
perform lock_local using lv_partner changing sy-subrc.
If sy-subrc <> 0.
l_err = 'X'. exit.
Endif.
Endloop.
else.
l_err = 'X'.
endif.

ifl_err = 'X'.
perform unlock_local using iv_partner changing sy-subrc.
Loop at lt_partner into Lv_partner.
perform unlock_local using lv_partner changing sy-subrc.
endloop.
clear s_partner_locked.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4
raising local_lock.
else.
* lock was successfull, do not retry it
s_partner_locked = lv_partner.
s_segment_locked = iv_segment.
st_partner_locked[] = lt_partner[].
ENDIF.

ENDFUNCTION.

form lock_local using i_partner type bu_partner


changing c_subrc like sy-subrc.

data: lv_kunnr like kna1-kunnr.


lv_kunnr = i_partner.
check not lv_kunnr is initial.
CALL FUNCTION 'ENQUEUE_EXKNA1'
EXPORTING
* MODE_KNA1 = 'E'
* MANDT = SY-MANDT
KUNNR = lv_kunnr
* X_KUNNR = ' '
_SCOPE = '2' "
* _WAIT = ' '
* _COLLECT = ' '
EXCEPTIONS
FOREIGN_LOCK = 1
SYSTEM_FAILURE = 2
OTHERS = 3.

c_subrc = sy-subrc.
endform.

form unlock_local using i_partner type bu_partner


changing c_subrc like sy-subrc.

data: lv_kunnr like kna1-kunnr.


lv_kunnr = i_partner.
check not lv_kunnr is initial.
CALL FUNCTION 'DEQUEUE_EXKNA1'
EXPORTING
* MODE_KNA1 = 'E'
* MANDT = SY-MANDT
KUNNR = lv_kunnr
* X_KUNNR = ' '
_SCOPE = '2'
* _WAIT = ' '
* _COLLECT = ' '
EXCEPTIONS
OTHERS = 3.

c_subrc = sy-subrc.
endform.

-----------------------------------------------------------------------------------
-----------

Badi UKM_FILL
IF_EX_UKM_FILL~CREDIT_CHECK_CONVERT_OUTBOUND
...

data: lv_partner type bu_partner,


lv_segment type char10.

data: dest type rfcdest value 'NONE'. "<<<replace this with your FSCM system RFC
destination
data: subrc type sysubrc, lx.

dATA: lt_return type standard table of bapiret2.


lv_partner = cs_query-debtor_party-internal_id-value.
lv_segment = cs_query-CREDIT_SEGMENT_INTERNAL_ID.
* implementation for note
* lock all bps local
CALL FUNCTION 'ZUKM_ACCOUNT_LOCK_LOCAL'
EXPORTING
IV_PARTNER = lv_partner
IV_segment = lv_segment
IV_DEST = dest
EXCEPTIONS
LOCAL_LOCK = 1
FSCM_LOCK = 2
OTHERS = 3.
* check on fscm side
IF SY-SUBRC = 0.
CALL FUNCTION 'ZUKM_ACCOUNT_LOCK_IN_CHECK'
destination dest
EXPORTING
IV_PARTNER = lv_partner
IV_segment = lv_segment
I_read_flag = 'X'
EXCEPTIONS
LOCAL_LOCK = 1
FSCM_LOCK = 2
OTHERS = 3.
endif.
subrc = sy-subrc.
IF subrc <> 0.
if sy-batch <> space.
Message E600(FR) with 'Partner ' lv_partner 'is locked' into lx.
* invalidate query to force an error
clear cs_query-debtor_party-internal_id-value.
else.
case subrc.
when 1. Message E600(FR) with 'Partner ' lv_partner 'is locked'.
when 2. Message E600(FR) with 'Partner ' lv_partner 'item error or still
in queue'.
when others. Message E600(FR) with 'other error'.
endcase.
endif.
ENDIF.
...

-----------------------------------------------------------------------------------
-------------

Badi UKM_FILL
IF_EX_UKM_FILL~FILL_FIELDS.

include the following lines in you implementation

....
LOOP AT is_notification INTO ls_in.
ls_data = ls_data_clear.

ls_data-debtor_party-internal_id-value = ls_in-partner.
IF ls_data-debtor_party-internal_id-value IS INITIAL.
ls_data-debtor_party-internal_id-value = ls_in-kunnr.
ENDIF.

****************** check for note 1466740 ****<<<begin of insertion


* set the lock flag in FSCM
data: lv_partner type bu_partner.
if lv_partner <> ls_data-debtor_party-internal_id-value.
lv_partner = ls_data-debtor_party-internal_id-value.
CALL FUNCTION 'ZUKM_ACCOUNT_LOCK_IN_CHECK'
IN BACKGROUND TASK
destination 'NONE' "<<<replace this with your FSCM system RFC
destination
EXPORTING
IV_PARTNER = lv_partner
IV_segment = ls_in-credit_sgmnt
I_SET_FLAG = 'X'
EXCEPTIONS
OTHERS = 0.
endif.
******************* check for note 1466740 ****<<<end of insertion
....
CALL FUNCTION 'LCR_GET_OWN_BUSINESS_SYSTEM'
IMPORTING
bs_key_name = l_business.

-----------------------------------------------------------------------------------
-------------

You might also like