销售订单审批状态启用后,前端显示界面如下图
销售订单审批状态读取:STATUS_READ
销售订单审批状态修改:I_CHANGE_STATUS
销售订单审批状态读取
代码样例如下:
DATA: lv_objnr TYPE vbak-objnr,lv_objnr_t TYPE jsto-objnr,lv_obtyp TYPE jsto-obtyp,lv_stsma TYPE jsto-stsma,lv_stonr TYPE tj30-stonr,lt_status TYPE TABLE OF jstat,ls_status TYPE jstat.
SELECT SINGLE objnr INTO lv_objnrFROM vbakWHERE vbeln = i_vbeln.IF lv_objnr IS NOT INITIAL.lv_objnr_t = lv_objnr.CALL FUNCTION 'STATUS_READ'EXPORTING
* CLIENT = SY-MANDTobjnr = lv_objnr_t
* ONLY_ACTIVE = ' 'IMPORTINGobtyp = lv_obtypstsma = lv_stsmastonr = lv_stonrTABLESstatus = lt_statusEXCEPTIONSobject_not_found = 1OTHERS = 2.IF sy-subrc <> 0.
* Implement suitable error handling hereENDIF.READ TABLE lt_status INTO ls_status WITH KEY stat = lv_estat2inact = ''.IF sy-subrc = 0.ENDIF.
ENDIF.
销售订单审批状态修改
具体代码样例如下:
FUNCTION zjkdms003.
*"----------------------------------------------------------------------
*"*"本地接口:
*" IMPORTING
*" VALUE(I_VBELN) TYPE VBELN_VA OPTIONAL
*" VALUE(I_ESTAT) TYPE J_ESTAT OPTIONAL
*" VALUE(I_APPROVER) TYPE TEXT30 OPTIONAL
*" VALUE(I_NAME) TYPE TEXT30 OPTIONAL
*" EXPORTING
*" VALUE(E_MSG) TYPE BAPIRET2
*"----------------------------------------------------------------------DATA: lv_objnr TYPE vbak-objnr,lv_objnr_t TYPE jsto-objnr,lv_obtyp TYPE jsto-obtyp,lv_stsma TYPE jsto-stsma,lv_stonr TYPE tj30-stonr,lt_status TYPE TABLE OF jstat,ls_status TYPE jstat,lt_tj30 TYPE TABLE OF tj30,ls_tj30 TYPE tj30,lv_estat1 TYPE tj30-estat,lv_estat2 TYPE tj30-estat,lv_estat3 TYPE tj30-estat,ieinfo TYPE einfo,lt_003 TYPE TABLE OF ztjkdms003,ls_003 TYPE ztjkdms003.CLEAR: lv_objnr,lv_objnr_t,lv_obtyp,lv_stsma,lv_stonr,lt_status,ls_status,lt_tj30,ls_tj30,lv_estat1,lv_estat2,lv_estat3,ieinfo,lt_003,ls_003.CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'EXPORTINGinput = i_vbelnIMPORTINGoutput = i_vbeln.SELECT SINGLE objnr INTO lv_objnrFROM vbakWHERE vbeln = i_vbeln.IF lv_objnr IS NOT INITIAL.lv_objnr_t = lv_objnr.CALL FUNCTION 'STATUS_READ'EXPORTING
* CLIENT = SY-MANDTobjnr = lv_objnr_t
* ONLY_ACTIVE = ' 'IMPORTINGobtyp = lv_obtypstsma = lv_stsmastonr = lv_stonrTABLESstatus = lt_statusEXCEPTIONSobject_not_found = 1OTHERS = 2.IF sy-subrc <> 0.
* Implement suitable error handling hereENDIF.IF lt_status IS NOT INITIAL.SELECT * INTO TABLE lt_tj30FROM tj30WHERE stsma = lv_stsma.SORT lt_tj30 BY estat.CLEAR: ls_tj30.READ TABLE lt_tj30 INTO ls_tj30 INDEX 1.IF sy-subrc = 0.lv_estat1 = ls_tj30-estat.ENDIF.CLEAR: ls_tj30.READ TABLE lt_tj30 INTO ls_tj30 INDEX 2.IF sy-subrc = 0.lv_estat2 = ls_tj30-estat.ENDIF.CLEAR: ls_tj30.READ TABLE lt_tj30 INTO ls_tj30 INDEX 3.IF sy-subrc = 0.lv_estat3 = ls_tj30-estat.ENDIF.IF i_estat = lv_estat1.READ TABLE lt_status INTO ls_status WITH KEY stat = lv_estat2inact = ''.IF sy-subrc = 0.CALL FUNCTION 'I_CHANGE_STATUS'EXPORTINGobjnr = lv_objnr_testat_inactive = lv_estat2estat_active = lv_estat1stsma = lv_stsmaEXCEPTIONScannot_update = 1OTHERS = 2.ENDIF.READ TABLE lt_status INTO ls_status WITH KEY stat = lv_estat3inact = ''.IF sy-subrc = 0.CALL FUNCTION 'I_CHANGE_STATUS'EXPORTINGobjnr = lv_objnr_testat_inactive = lv_estat3estat_active = lv_estat1stsma = lv_stsmaEXCEPTIONScannot_update = 1OTHERS = 2.ENDIF.IF sy-subrc <> 0.
* Implement suitable error handling hereENDIF.IF sy-msgty = 'E' OR sy-msgty = 'A'.e_msg-type = sy-msgty.e_msg-id = sy-msgid.e_msg-number = sy-msgno.ieinfo-msgid = sy-msgid.ieinfo-msgty = sy-msgty.ieinfo-msgno = sy-msgno.CALL FUNCTION 'MESSAGE_GET_TEXT'EXPORTINGieinfo = ieinfoilangu = '1'IMPORTINGetext = e_msg-messageEXCEPTIONSno_t100_found = 1OTHERS = 2.IF sy-subrc <> 0.
* Implement suitable error handling hereENDIF.ELSE.e_msg-type = 'S'.e_msg-message = '审批成功'.ENDIF.ENDIF.IF i_estat = lv_estat2.READ TABLE lt_status INTO ls_status WITH KEY stat = lv_estat1inact = ''.IF sy-subrc = 0.CALL FUNCTION 'I_CHANGE_STATUS'EXPORTINGobjnr = lv_objnr_testat_inactive = lv_estat1estat_active = lv_estat2stsma = lv_stsmaEXCEPTIONScannot_update = 1OTHERS = 2.ENDIF.READ TABLE lt_status INTO ls_status WITH KEY stat = lv_estat3inact = ''.IF sy-subrc = 0.CALL FUNCTION 'I_CHANGE_STATUS'EXPORTINGobjnr = lv_objnr_testat_inactive = lv_estat3estat_active = lv_estat2stsma = lv_stsmaEXCEPTIONScannot_update = 1OTHERS = 2.ENDIF.IF sy-subrc <> 0.
* Implement suitable error handling hereENDIF.IF sy-msgty = 'E' OR sy-msgty = 'A'.e_msg-type = sy-msgty.e_msg-id = sy-msgid.e_msg-number = sy-msgno.ieinfo-msgid = sy-msgid.ieinfo-msgty = sy-msgty.ieinfo-msgno = sy-msgno.CALL FUNCTION 'MESSAGE_GET_TEXT'EXPORTINGieinfo = ieinfoilangu = '1'IMPORTINGetext = e_msg-messageEXCEPTIONSno_t100_found = 1OTHERS = 2.IF sy-subrc <> 0.
* Implement suitable error handling hereENDIF.ELSE.e_msg-type = 'S'.e_msg-message = '审批成功'.ENDIF.ENDIF.IF i_estat = lv_estat3.IF lv_estat3 IS NOT INITIAL.READ TABLE lt_status INTO ls_status WITH KEY stat = lv_estat2inact = ''.IF sy-subrc = 0.CALL FUNCTION 'I_CHANGE_STATUS'EXPORTINGobjnr = lv_objnr_testat_inactive = lv_estat2estat_active = lv_estat3stsma = lv_stsmaEXCEPTIONScannot_update = 1OTHERS = 2.ENDIF.READ TABLE lt_status INTO ls_status WITH KEY stat = lv_estat1inact = ''.IF sy-subrc = 0.CALL FUNCTION 'I_CHANGE_STATUS'EXPORTINGobjnr = lv_objnr_testat_inactive = lv_estat1estat_active = lv_estat3stsma = lv_stsmaEXCEPTIONScannot_update = 1OTHERS = 2.ENDIF.IF sy-subrc <> 0.
* Implement suitable error handling hereENDIF.IF sy-msgty = 'E' OR sy-msgty = 'A'.e_msg-type = sy-msgty.e_msg-id = sy-msgid.e_msg-number = sy-msgno.ieinfo-msgid = sy-msgid.ieinfo-msgty = sy-msgty.ieinfo-msgno = sy-msgno.CALL FUNCTION 'MESSAGE_GET_TEXT'EXPORTINGieinfo = ieinfoilangu = '1'IMPORTINGetext = e_msg-messageEXCEPTIONSno_t100_found = 1OTHERS = 2.IF sy-subrc <> 0.
* Implement suitable error handling hereENDIF.ELSE.e_msg-type = 'S'.e_msg-message = '审批成功'.ENDIF.ENDIF.ENDIF.IF i_estat IS INITIAL.e_msg-type = 'E'.e_msg-message = '请指定审批节点'.ENDIF.ENDIF.ENDIF.IF e_msg-type = 'S'. "当状态更新成功后,记录当前审批人信息ls_003-vbeln = i_vbeln.ls_003-estat = i_estat.ls_003-approver = i_approver.ls_003-name = i_name.ls_003-erdat = sy-datum.ls_003-erzet = sy-uzeit.COLLECT ls_003 INTO lt_003.CLEAR: ls_003.IF lt_003 IS NOT INITIAL.MODIFY ztjkdms003 FROM TABLE lt_003.IF sy-subrc = 0.COMMIT WORK AND WAIT.ELSE.ROLLBACK WORK.ENDIF.ENDIF.ENDIF.ENDFUNCTION.
销售订单审批状态更新日志表
表:JCDS