请问如何使用SAP 外向交货单过账BAPI:BAPI_OUTB_DELIVERY_CONFIRM_DEC,越详细越好,谢谢! 5

使用过程中输入参数后,无法正常过账且无错误提示,非常感谢!... 使用过程中输入参数后,无法正常过账且无错误提示,非常感谢! 展开
 我来答
IT管理小憩
2013-08-02
知道答主
回答量:19
采纳率:0%
帮助的人:12.2万
展开全部
这是05年写过的,基于R4.6,你看一下吧,难得我今天上baidu知道并且有心情。。。。。

REPORT zsdi003 .

TABLES: likp,lips,ekpo,t001l .
DATA: header_data LIKE bapiobdlvhdrcon,
header_control LIKE bapiobdlvhdrctrlcon,
delivery LIKE bapiobdlvhdrcon-deliv_numb,
bapidlvcontrol LIKE bapidlvcontrol.
DATA: datum(8),uzeit(6),timestamp(15),flag,
rate(7) TYPE p DECIMALS 3, ll_wadat LIKE likp-wadat.
DATA: return LIKE bapiret2 OCCURS 0 WITH HEADER LINE.
DATA: item_data LIKE bapiobdlvitemcon OCCURS 0 WITH HEADER LINE,
item_control LIKE bapiobdlvitemctrlcon OCCURS 0 WITH HEADER LINE,
header_deadlines LIKE bapidlvdeadln OCCURS 0 WITH HEADER LINE.

DATA: wa_import LIKE zsd_vtimport,
itab_import LIKE STANDARD TABLE OF zsd_vtimport WITH DEFAULT KEY.
DATA tstamp TYPE timestamp.
DATA: info LIKE soli OCCURS 0 WITH HEADER LINE,
mailtitle LIKE sood1-objdes,
nx TYPE i, nnx(5) TYPE n.
DATA: l_posnr LIKE lips-posnr, l_ebelp LIKE ekpo-ebelp.

START-OF-SELECTION.

SELECT * INTO TABLE itab_import FROM zsd_vtimport WHERE state IN ('','0','X','E','P').

IF itab_import[] IS INITIAL.
EXIT.
ENDIF.

SORT itab_import BY line_no(10) line_no+10(6).

LOOP AT itab_import INTO wa_import.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = wa_import-line_no+10(6)
IMPORTING
output = l_posnr.

SELECT SINGLE * FROM lips WHERE vbeln = wa_import-line_no(10)." AND posnr = l_posnr.

IF sy-subrc <> 0.
wa_import-state = '0'.
wa_import-message = text-001.
CONCATENATE sy-datum sy-uzeit INTO wa_import-importeddate.
MODIFY itab_import FROM wa_import.
CLEAR: wa_import,item_data,ekpo,lips.
CONTINUE.
* ELSEIF lips-lgort IS INITIAL.
* MESSAGE '更新库存地点' TYPE 'S'.
* UPDATE lips SET lgort = wa_import-lgort
* WHERE vbeln = wa_import-vbeln AND
* posnr = l_posnr.
* COMMIT WORK.
* CALL FUNCTION 'ENQUE_SLEEP'
* EXPORTING
* seconds = 1.
ENDIF.
CLEAR lips.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = wa_import-line_no+10(6)
IMPORTING
output = l_posnr.

item_data-fact_unit_nom = ekpo-umrez.
item_data-fact_unit_denom = ekpo-umren.
CLEAR: ekpo,lips.
item_data-dlv_qty_imunit = wa_import-dquan. "lfimg.
item_data-deliv_numb = wa_import-line_no(10). "vbeln.
item_data-deliv_item = l_posnr. "wa_import-posnr.
item_data-batch = wa_import-charg.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = wa_import-matnr
IMPORTING
output = item_data-material.
APPEND item_data.

*----------------------------------------

SELECT SINGLE wadat INTO ll_wadat FROM likp WHERE vbeln = wa_import-line_no(10).
datum = ll_wadat.
uzeit = sy-uzeit.
CONCATENATE datum uzeit INTO timestamp.
header_deadlines-deliv_numb = wa_import-line_no(10).
header_deadlines-timetype = 'WSHDRWADAT'. "Goods issue date (planned)
header_deadlines-timezone = ''.
header_deadlines-timestamp_utc = timestamp.
APPEND header_deadlines.
CLEAR: datum,uzeit,timestamp,ll_wadat.

*----------------------------------------

datum = wa_import-ddate.
uzeit = sy-uzeit.
CONCATENATE datum uzeit INTO timestamp.
header_deadlines-deliv_numb = wa_import-line_no(10).
header_deadlines-timetype = 'WSHDRWADTI'. "Goods issue date (actual)
header_deadlines-timestamp_utc = timestamp.
header_deadlines-timezone = ''.
APPEND header_deadlines.

item_control-deliv_numb = wa_import-line_no(10).
item_control-deliv_item = l_posnr. "wa_import-posnr.
item_control-chg_delqty = 'X'.
APPEND item_control.

bapidlvcontrol-upd_ind = 'X'.
header_data-deliv_numb = wa_import-line_no(10).
header_control-deliv_numb = wa_import-line_no(10).
header_control-post_gi_flg = 'X'.
header_control-gdsi_date_flg = 'X'.
header_control-simulate = 'X'.

AT END OF line_no(10).
flag = 'X'.
ENDAT.

IF flag = 'X'.
CLEAR flag.

CALL FUNCTION 'BAPI_OUTB_DELIVERY_CONFIRM_DEC'
EXPORTING
header_data = header_data
header_control = header_control
delivery = wa_import-line_no(10)
techn_control = bapidlvcontrol
TABLES
header_deadlines = header_deadlines[]
item_data = item_data[]
item_control = item_control[]
return = return.

IF sy-subrc = 0.
COMMIT WORK .
ENDIF.
IF return[] IS NOT INITIAL.
CLEAR wa_import-message.
* LOOP AT return.
READ TABLE return INDEX 1.
SELECT SINGLE text INTO return-message FROM t100
WHERE arbgb = return-id AND
msgnr = return-number AND
sprsl = '1'.
CONCATENATE wa_import-message ',' return-message
',' return-message_v1 ',' return-message_v2
',' return-message_v3 ',' return-message_v4
INTO wa_import-message.
* CLEAR return.
CONDENSE wa_import-message NO-GAPS.
* ENDLOOP.
CLEAR return.
wa_import-state = 'E'.
CONCATENATE sy-datum sy-uzeit INTO wa_import-importeddate.
MODIFY itab_import FROM wa_import
TRANSPORTING state message importeddate
WHERE line_no = wa_import-line_no.
ELSE.
* 成功发货过账
wa_import-state = 'P'.

CONCATENATE sy-datum sy-uzeit INTO wa_import-importeddate.

SELECT SINGLE vbeln INTO wa_import-message FROM vbfa
WHERE vbelv = wa_import-line_no(10) AND
vbtyp_n = 'R'.
IF sy-subrc = 0.
CONCATENATE 'TF在途库存凭证号码' wa_import-message
INTO wa_import-message.
ENDIF.

MODIFY itab_import FROM wa_import
TRANSPORTING state message importeddate
WHERE line_no = wa_import-line_no.
ENDIF.

CLEAR: header_data,header_control,bapidlvcontrol.
REFRESH:header_deadlines,item_data,item_control,return.
ENDIF.
CLEAR: wa_import,item_data.
ENDLOOP.

MODIFY zsd_vtimport FROM TABLE itab_import.
COMMIT WORK.
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
lynsky00
2013-07-25
知道答主
回答量:3
采纳率:0%
帮助的人:3547
展开全部
你用的是SAP的哪个产品?R3、A1还是B1?
追问
R3
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 1条折叠回答
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式