Chinaunix首页 | 论坛 | 博客
  • 博客访问: 7184911
  • 博文数量: 655
  • 博客积分: 10264
  • 博客等级: 上将
  • 技术积分: 8278
  • 用 户 组: 普通用户
  • 注册时间: 2007-06-04 17:47
个人简介

ABAP顾问

文章分类

全部博文(655)

文章存档

2017年(2)

2014年(8)

2013年(3)

2012年(2)

2011年(18)

2010年(102)

2009年(137)

2008年(274)

2007年(134)

分类:

2008-08-20 13:48:33

Parameters p_belnr like bkpf-belnr default '0100000236'.
 
*Get last SA type document posted to build document key
CALL FUNCTION 'NUMBER_GET_NEXT'
EXPORTING
NR_RANGE_NR = '01'
OBJECT = 'RF_BELEG'
 
QUANTITY = '1'
SUBOBJECT = '4000' "company code
TOYEAR = '2005'
 
IGNORE_BUFFER = '2005'
IMPORTING
NUMBER = docnum
 
QUANTITY =
RETURNCODE =
EXCEPTIONS
INTERVAL_NOT_FOUND = 1
NUMBER_RANGE_NOT_INTERN = 2
OBJECT_NOT_FOUND = 3
QUANTITY_IS_0 = 4
QUANTITY_IS_NOT_1 = 5
INTERVAL_OVERFLOW = 6
BUFFER_OVERFLOW = 7
OTHERS = 8
.
IF SY-SUBRC 0.
 
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
 
 
 
"Begin to populate docnument header.
*obj_key contains new document no.
CONCATENATE docnum '4000' sy-datlo(4) INTO doc_header-obj_key.
doc_header-obj_type = 'BKPFF'.
*obj_key_r contains document no. needed to reverse
CONCATENATE p_belnr '4000' sy-datlo(4) INTO doc_header-obj_key_r.
 
doc_header-obj_sys = 'A1DMD011'.
*doc_header-OBJ_KEY_R = 'AWREF_REV'.
*doc_header-AC_DOC_NO = '8'.
*doc_header-header_txt = 'TEST BOC BAPI POSTING'.
doc_header-comp_code = '4000'.
doc_header-REASON_REV = '02'.
doc_header-pstng_date = '20050517'.
doc_header-FIS_PERIOD = '05'.
 
 
"All tables filled - now call BAPI.
CALL FUNCTION 'BAPI_ACC_GL_POSTING_REV_POST'
EXPORTING
REVERSAL = doc_header
IMPORTING
OBJ_TYPE = doc_header-obj_type
OBJ_KEY = doc_header-obj_key
OBJ_SYS = doc_header-obj_sys
TABLES
RETURN = return
.
 
LOOP AT return WHERE type = 'E'.
EXIT.
ENDLOOP.
 
IF sy-subrc EQ 0.
WRITE: / 'BAPI call failed - debug and fix!'.
LOOP AT return.
WRITE: / .
WRITE:
return-TYPE,
'|',
return-ID,
'|',
return-NUMBER,
'|',
return-MESSAGE.
ENDLOOP.
ELSE.
LOOP AT return.
WRITE: / .
WRITE:
return-TYPE,
'|',
return-ID,
'|',
return-NUMBER,
'|',
return-MESSAGE.
ENDLOOP.
CLEAR return.
REFRESH return.
 
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
 
EXPORTING
WAIT = 'X'
IMPORTING
return = return.
WRITE: / 'BAPI call worked!!'.
WRITE: / doc_header-obj_key, ' posted'.
 
 
----------------------------------------------------------------
 
另外一个代码:
call function 'OWN_LOGICAL_SYSTEM_GET'
importing
own_logical_system = reversal-obj_sys.

clear reversal[].

select single awtyp awkey awkey into
(reversal-obj_type, reversal-obj_key_r, reversal-obj_key)
from bkpf where belnr = wa_belnr
and bukrs = wa_bukrs
and gjahr = wa_gjahr.

reversal-obj_key(1) = 'R'.
reversal-pstng_date = p_budat.
reversal-fis_period = p_budat+4(2).
reversal-comp_code = wa_bukrs.
reversal-reason_rev = p_stgrd.
reversal-ac_doc_no = wa_belnr.
append reversal.

call function 'BAPI_ACC_DOCUMENT_REV_POST'
exporting
reversal = reversal
bus_act = 'RFBU'
importing
obj_type = obj_type
obj_key = obj_key
obj_sys = obj_sys
tables
return = p_return.
阅读(6257) | 评论(4) | 转发(0) |
给主人留下些什么吧!~~

chinaunix网友2010-04-28 20:36:43

bus_act='RFBU'里的这个RFBU是什么?所有的过账都是用这个吗 例如报销费用的过账

chinaunix网友2009-06-01 20:13:26

OR,Try this: call function 'OWN_LOGICAL_SYSTEM_GET' importing own_logical_system = reversal-obj_sys. clear reversal[]. select single awtyp awkey awkey into (reversal-obj_type, reversal-obj_key_r, reversal-obj_key) from bkpf where belnr = wa_belnr and bukrs = wa_bukrs and gjahr = wa_gjahr. reversal-obj_key(1) = 'R'. reversal-pstng_date = p_budat. reversal-fis_period = p_budat+4(2). reversal-comp_code = wa_bukrs. reversal-reason_rev = p_stgrd. reversal-ac_doc_no = wa_belnr.

chinaunix网友2009-06-01 20:12:41

call function 'OWN_LOGICAL_SYSTEM_GET' importing own_logical_system = doc_header-obj_sys .

chinaunix网友2009-06-01 18:28:17

请教一下: 对于obj_key_r. obj_sys 这两个参数具体应该怎麽赋值呢? 为什麽按照你的代码里的说法设置时,在测试的时候返回的内部return中消息类型总为E.并且显示这两个参数值错误的信息呢?