cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Example to call AVAILABILITY_CHECK to retrieve information from GATP

amit_singh20
Explorer
0 Kudos
756

Dear Experts,

I have the following requirement.

I need to change order qty and update order rejection in case the ordered qty is not maintained.All this has to be done before save as user would like to see the result of final qty immediately on screen. I am able to achieve this in ECC in the exit USEREXIT_MOVE_FIELD_VBAP

where I call AVAILABILITY_CHECK and it gives me the desired result of availability and based on that I influence the XVBAP and XVBEP structures.

So far all good, but when GATP is activated. I need to know the confirmed qty from GATP as well. So, I need your help to know the parameter changes required to achieve this.

ls_atpca-force_r3 = lc_x.( This has to be removed for sure ). But, what are teh additional parameters taht we need to pass.

As an alternative, I tried to write my code in USEREXIT_CHECK_VBAP to influence order qty as I can read the results of GATP from stack and it is called at the end but in this change to XVBAP is not working as I think, it is too late and change to VBAP is working but prohibiting me to change the order qty further. Also, in this solution the drawback is I need to write an additional logic in USEREXIT_MOVE_FIELD_VBAP to reduce the values confirmed in previous line item as the current call to AVAILABILITY_CHECK is not considering APO details and it does not seem to be a very good solution.

* prepare structures for ATP check:
ls_atpca-anwdg = '3'.
ls_atpca-anwdg2 = '5'.
ls_atpca-azerg = '1'.

MOVE-CORRESPONDING ps_vbap TO ls_atpcs.
ls_atpcs-prreg = 'A'.
ls_atpcs-chmod = '041'.
ls_atpcs-delkz = 'VC'.
ls_atpcs-bdter = p_bdter.
ls_atpcs-trtyp = 'V'.
ls_atpcs-idxatp = '1'.
ls_atpcs-chkflg = 'X'.
ls_atpca-force_r3 = lc_x.
SORT pt_mcha_batch BY vfdat charg.

* do a check for all selected batches:
LOOP AT pt_mcha_batch ASSIGNING <mcha>.
ls_atpcs-xline = sy-tabix.
ls_atpcs-charg = <mcha>-charg.
APPEND ls_atpcs TO lt_atpcsx.
ENDLOOP.

* do check:
CALL FUNCTION 'AVAILABILITY_CHECK'
TABLES
p_atpcsx = lt_atpcsx
CHANGING
p_atpca = ls_atpca
* P_ATPCB =
* P_ATPCC =
EXCEPTIONS
error = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE 'I' NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.

Accepted Solutions (0)

Answers (0)