Skip to Content
author's profile photo Former Member
Former Member

Stock getting double in APO

Hi Guru's

We have implemented a CIF User exit in APO so that If the stock type for particular storage location say A from R/3 is CC(Unrestricted) or CF(Quality Inspection), sum the stock and post into APO with stock type CF only .

But some times when stock in storage location A (in R3) is moved from storage location A to B with the movement type 311,

it is doubling the stock in APO as it shows stock at both the storage location A and B i.e. it is not getting deleted from storage location A.

This is happenning ony in 2% of the cases.

Please let me know if something is missing in this code.

read table it_stock index 1.

v_logsysk = it_stock-logsysk.

loop at it_stock_cus.

clear it_stock.

it_stock-method = 'C'.

it_stock-ext_matnr = it_stock_cus-ext_matnr.

it_stock-ext_locno = it_stock_cus-zzlocno.

move it_stock_cus-zzlocno to v_locno.

call function '/SAPAPO/LOC_LOCID_GET_LOCATION'

exporting

iv_locno = v_locno

importing

ev_loctype = v_loctype

exceptions

location_not_found = 1

others = 2.

if sy-subrc = 0.

it_stock-loctype = v_loctype.

endif.

it_stock-atpcat = 'CS'.

it_stock-logsysk = v_logsysk.

move: '0F' to it_stock-stocktype,

it_stock_cus-zzstock to it_stock-quantity.

it_stock-quantity = it_stock-quantity / 1000.

append it_stock.

endloop.

select *

into table it_zsnp_storageloc

from zsnp_storageloc.

clear v_apo_rfc_destination.

call function 'OWN_LOGICAL_SYSTEM_GET'

importing

own_logical_system = v_apo_rfc_destination

exceptions

own_logical_system_not_defined = 1

others = 2.

if sy-subrc <> 0.

stop.

endif.

loop at it_stock.

v_tabix = sy-tabix.

clear : v_locno,v_loctype.

if it_stock-storageloc = c_storloc and ( it_stock-atpcat = c_atpcat_cc or it_stock-atpcat = c_atpcat_cf ).

if v_batch <> it_stock-batch.

clear v_total.

endif.

  • End of changes- 80082161 CR8000012751-DA1K901673

it_stock_bapi-delta_change_flag = 'C'.

if it_stock-atpcat = c_atpcat_cc.

v_ccstock = it_stock-quantity.

it_stock_bapi-stock_type = c_stocktype.

it_stock_bapi-atpcat = c_atpcat_cf.

endif.

if it_stock-atpcat = c_atpcat_cf.

v_cfstock = it_stock-quantity.

it_stock_bapi-stock_type = c_stocktype.

it_stock_bapi-atpcat = c_atpcat_cf.

endif.

v_total = v_total + v_ccstock + v_cfstock .

it_stock_bapi-quantity = v_total.

it_stock_bapi-storage_location = c_storloc.

v_locno = it_stock-ext_locno.

it_stock_bapi-product = it_stock-ext_matnr.

it_stock_bapi-location = it_stock-ext_locno.

it_stock_bapi-version = it_stock-batch.

v_batch = it_stock-batch.

call function '/SAPAPO/LOC_LOCID_GET_LOCATION'

exporting

iv_locno = v_locno

importing

ev_loctype = v_loctype

exceptions

location_not_found = 1

others = 2.

if sy-subrc = 0.

it_stock_bapi-loctype = v_loctype.

endif.

append it_stock_bapi.

clear : it_stock_bapi.

**---Call BAPI to create stock

call function 'BAPI_STSRVAPS_SAVEMULTI2'

exporting

logical_system = v_apo_rfc_destination

commit_control = c_commit_control

planning_mode_usage = c_planning_mode_usage

planning_version = c_planning_version

tables

stock = it_stock_bapi

return = it_return.

clear it_return.

refresh: it_stock_bapi,it_return.

endif.

clear wa_zsnp_storageloc.

read table it_zsnp_storageloc into wa_zsnp_storageloc

with key storageloc = it_stock-storageloc.

if sy-subrc eq 0.

if it_stock-storageloc <> c_storloc .

delete it_stock index v_tabix .

endif.

if it_stock-storageloc = c_storloc and ( it_stock-atpcat = c_atpcat_cc or it_stock-atpcat = c_atpcat_cf ).

delete it_stock index v_tabix .

endif.

endif.

clear: v_ccstock,v_cfstock,v_tabix.

endloop.

loop at it_stock_cus.

v_tabix = sy-tabix.

read table it_zsnp_storageloc into wa_zsnp_storageloc

with key storageloc = it_stock_cus-storageloc.

if sy-subrc eq 0.

delete it_stock_cus index v_tabix.

endif.

endloop.

.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Posted on Oct 12, 2010 at 02:29 PM

    Hi Mankak,

    We are facing the same problem as yours.

    Did you find any solution for the same? How to get rid of the double counting of Stocks while they r CIFed from R3 to APO?

    Nilay

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.