标准的会计凭证bapi BAPI_ACC_DOCUMENT_POST 无法更新票据相关数据想要同时更新票据BSED表相关数据需要按照下列步骤操作
1.增强结构新增票据相关字段
2.在调用程序bapi时export出数据至内存
DATA: lt_bsed TYPE TABLE OF bsed,
ls_bsed TYPE bsed.
DATA: lv_umskz_flag TYPE flag. " 用来判断要创建的会计凭证是否有特别总账标识
IF <ls_data>-umskz = 'W' OR <ls_data>-umskz = 'S'.
CLEAR ls_bsed.
lv_umskz_flag = <ls_data>-umskz.
ls_bsed-buzei = lv_num.
ls_bsed-wname = <ls_data>-wname.
ls_bsed-wbzog = <ls_data>-wbzog.
ls_bsed-wdate = <ls_data>-wdate.
ls_bsed-wbank = <ls_data>-wbank.
APPEND ls_bsed TO lt_bsed.
EXPORT lv_umskz_flag lt_bsed TO MEMORY ID 'ZFIR104'.
ENDIF.
3.创建隐式增强,import 内存中BSED表数据插入BSED表
DATA:lt_bsed TYPE TABLE OF bsed.
DATA:ls_bsed TYPE bsed.
DATA: lv_umskz_flag TYPE flag.
imPORT lv_umskz_flag lt_bsed from MEMORY ID 'ZFIR104'.
IF lv_umskz_flag is not INITIAL AND lt_bsed[] is not INITIAL.
LOOP AT xbseg WHERE umskz = lv_umskz_flag.
READ TABLE lt_bsed into ls_bsed WITH KEY buzei = xbseg-buzei.
IF sy-subrc = 0.
MOVE-CORRESPONDING xbseg TO xbsed.
xbsed-wname = ls_bsed-wname .
xbsed-wbzog = ls_bsed-wbzog .
xbsed-wdate = ls_bsed-wdate .
xbsed-wbank = ls_bsed-wbank .
APPEND xbsed.
ENDIF.
ENDLOOP.
ENDIF.
以上操作同样适用下面情况处理
1.创建会计凭证bapi时报错BSED表相关的问题。
2.创建会计凭证成功了,但是FB08冲销报错说找不到凭证行项目,实际BSEG表可以查到数据,只是BSED表查不到数据的问题,同样可以使用增强写入数据