Is it possible to change the payment block via a BAPI, FM or code?
Asked
Active
Viewed 5,263 times
2 Answers
5
Use BAdi INVOICE_UPDATE
for changing this, method CHANGE_BEFORE_UPDATE
.
Implementation sample is here.
For changing payment block via BAPI use BAPI_ACC_PYMNTBLK_UPDATE_POST
, here is how to call:
DATA: it_return TYPE STANDARD TABLE OF bapiret2,
wa_return LIKE LINE OF it_return .
DATA ld_referenceinv TYPE bapiacpmblk.
MOVE it_bkfp-awkey TO ld_referenceinv-obj_key.
MOVE it_bkfp-awtyp TO ld_referenceinv-obj_type.
MOVE it_bkfp-awsys TO ld_referenceinv-obj_sys.
MOVE it_bkfp-bukrs TO ld_referenceinv-comp_code.
CALL FUNCTION 'BAPI_ACC_PYMNTBLK_UPDATE_POST'
EXPORTING
referenceinv = ld_referenceinv
TABLES
return = it_return .
IF sy-subrc = 0.
" Everything OK
ENDIF.

Suncatcher
- 10,355
- 10
- 52
- 90
-
I can't call this from an RFC, I presume? – Eric S Sep 05 '18 at 19:17
-
Thank you for your answer. The status first says 'Invoice verification'. When I run your example, it changes to 'Free for payment'. That's one of two I'm looking for. How can I pick any of the other options? – Eric S Sep 07 '18 at 11:22
-
`That's one of two I'm looking for. How can I pick any of the other options` what do you mean by other options? You cannot set other status values than `Free for payment`? – Suncatcher May 01 '20 at 17:49
4
I've always used FI_DOCUMENT_CHANGE
. Check out this example.
Hope it helps.
" VARIABLES
DATA: LT_ACCCHG TYPE TABLE OF ACCCHG.
DATA: LS_ACCCHG TYPE ACCCHG.
DATA: LV_AWTYP TYPE AWTYP.
DATA: LV_AWSYS TYPE AWSYS.
DATA: LV_AWREF TYPE AWREF.
DATA: LV_AWORG TYPE AWORG.
DATA: LV_LIFNR TYPE LIFNR.
" Fill variables here
" Can be found in tables BKPF AND BSIK
" SET VALUES FOR NEW PAYMENT BLOCK
" P = Payment request, A = Blocked for payment
" Check T008 for more Payment Block values
LS_ACCCHG-FDNAME = 'ZLSPR'. "Payment Block
LS_ACCCHG-NEWVAL = 'P'.
APPEND LS_ACCCHG TO LT_ACCCHG.
" CHANGE PAYMENT BLOCK
CALL FUNCTION 'FI_DOCUMENT_CHANGE'
EXPORTING
I_AWTYP = LV_AWTYP
I_AWREF = LV_AWREF
I_AWORG = LV_AWORG
I_AWSYS = LV_AWSYS
I_LIFNR = LV_LIFNR
TABLES
T_ACCCHG = LT_ACCCHG.

Matthijs Mennens
- 1,125
- 9
- 33