您的位置:首页 > 其它

采购订单审批BAPI ---BAPI_PO_RELEASE

2013-04-28 10:00 387 查看
REPORT z_release_po.

DATA gc_frggr LIKE ekko-frggr. "Release Group

DATA gc_frgsx LIKE ekko-frgsx. "Release Strategy

DATA gc_frgke LIKE ekko-frgke. "Release Status.

DATA ret_code LIKE sy-subrc.

DATA msg(255) TYPE c.

DATA: gt_t16fs LIKE t16fs OCCURS 0 WITH HEADER LINE.

DATA: gc_new_status LIKE bapimmpara-rel_status.

DATA: gc_indicator_new LIKE bapimmpara-po_rel_ind.

DATA: gt_log LIKE bapiret2 OCCURS 0 WITH HEADER LINE.

DATA: gc_no_commit LIKE bapimmpara-selection.

DATA: et_log LIKE bapiret2 OCCURS 0 WITH HEADER LINE.

DATA:BEGIN OF it_po_rel_code OCCURS 0,

rel_code TYPE frgco,

END OF it_po_rel_code.

SELECTION-SCREEN BEGIN OF BLOCK block WITH FRAME TITLE title.

PARAMETERS:po_num LIKE ekko-ebeln,"采购订单号

rel_code TYPE frgco."审批代码

SELECTION-SCREEN END OF BLOCK block.

SELECT SINGLE ekko~frgke INTO gc_frgke FROM ekko WHERE ekko~ebeln = po_num.

IF gc_frgke = '1'.

ret_code = -1.

CONCATENATE: po_num '已经通过审核' INTO msg.

* EXIT.

ELSE.

SELECT SINGLE ekko~frggr ekko~frgsx INTO (gc_frggr,gc_frgsx) FROM ekko WHERE ekko~ebeln = po_num.

IF ( gc_frggr IS NOT INITIAL ) AND ( gc_frgsx IS NOT INITIAL ).

REFRESH gt_t16fs.

CLEAR gt_t16fs.

SELECT * INTO CORRESPONDING FIELDS OF TABLE gt_t16fs FROM t16fs WHERE t16fs~frggr = gc_frggr AND t16fs~frgsx = gc_frgsx.

ELSE.

ret_code = -1.

msg ='未找到对应审批策略,请检查输入'.

EXIT.

ENDIF.

IF rel_code IS NOT INITIAL.

CLEAR gc_new_status.

CLEAR gc_indicator_new.

CALL FUNCTION 'BAPI_PO_RELEASE'

EXPORTING

purchaseorder = po_num

po_rel_code = rel_code

use_exceptions = 'X'

* no_commit =

IMPORTING

rel_status_new = gc_new_status

rel_indicator_new = gc_indicator_new

* ret_code =

TABLES

return = gt_log.

.

IF sy-subrc = 0.

et_log-type = 'S'.

CONCATENATE: '采购订单通过审核码' rel_code '的审核成功!' '返回采购订单审批状态为:' gc_new_status ' 审批标识为:'

gc_indicator_new INTO et_log-message.

APPEND et_log.

IF NOT gt_log[] IS INITIAL.

et_log-type = gt_log-type.

et_log-message = gt_log-message.

APPEND et_log.

ENDIF.

ENDIF.

ELSE.

ret_code = -1.

msg = '未找到对应审批策略,请检查输入'.

EXIT.

ENDIF.

IF et_log[] IS NOT INITIAL.

READ TABLE et_log WITH KEY type = 'E'.

IF sy-subrc = 0.

msg = 'po审核存在错误,请查看错误日志'.

ret_code = -1.

EXIT.

ELSE.

msg = 'PO已审核成功,请查看日志'.

ret_code = 0.

ENDIF.

ENDIF.

ENDIF.

WRITE:msg.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: