PS CJ37/CJ38 增加和返回预算


一、预算补充CJ37/预算返回CJ38

二、补充预算CJ37,点击保存

预算返回CJ38,点击保存

三、代码示例

预算补充代码

    SELECT
      pspnr,
      posid,
      objnr
    FROM prps
    INTO TABLE @DATA(lt_prps)
    FOR ALL ENTRIES IN @lt_ysbc
    WHERE posid = @lt_ysbc-posid. //WBS

    IF lt_prps IS NOT INITIAL.
      SORT lt_prps BY posid.
      "参数 I_BUDGET_ACTIVITY 是业务交易,支持以下这些业务交易。
      "原始预算
      "– KBUD 预算修改(TCODE:CJ30/CJ32)
      "– KBN0 预算补充(TCODE:CJ37)
      "– KBR0 预算返回(TCODE:CJ38)
      "
      "总体规划
      "– KSTP 总收入(TCODE:CJ40)
      "– KSTR(仅项目 TCODE:CJ42)
      LOOP AT lt_ysbc INTO ls_ysbc.
        READ TABLE lt_prps INTO DATA(ls_prps) WITH KEY posid = ls_ysbc-posid BINARY SEARCH.
        IF sy-subrc EQ 0.
          CLEAR:ls_bpak.
          ls_bpak-e_objnr = ls_prps-objnr.
          ls_bpak-twaer    = 'CNY'.
          ls_bpak-wert    = ls_ysbc-wtges.
          "ls_bpak-e_ges   = 'X'.
          "ls_bpak-e_versn = '001'.
          "ls_bpak-e_wrttp  = '01'.
          APPEND ls_bpak TO lt_bpak.
        ENDIF.

        CLEAR:ls_ysbc.
      ENDLOOP.

      CALL FUNCTION 'KBPP_EXTERN_UPDATE_CO'
        EXPORTING
          i_budget_activity      = 'KBN0'
          i_budget_activ_sup_ret = ' '
          i_delta_amounts        = 'X'
          i_rollup_data          = 'X'
          i_check_plan_data      = 'X'
          i_commit_all           = 'Y'
        IMPORTING
          e_errors_found         = lv_oax
        TABLES
          it_bpak                = lt_bpak
          it_return              = lt_return
        EXCEPTIONS
          no_update              = 1
          OTHERS                 = 2.

      IF lv_oax IS INITIAL.
        e_return-type = 'S'.
        e_return-message = '预算维护成功'.
        CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
      ELSE.
        e_return-type = 'E'.
        e_return-message = '预算维护失败'.
        CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
      ENDIF.

    ELSE.
      e_return-type = 'E'.
      e_return-message = '未维护对应的WBS'.
      RETURN.
    ENDIF.

预算返回代码

CALL FUNCTION 'KBPP_EXTERN_UPDATE_CO'
        EXPORTING
          i_budget_activity      = 'KBR0'
          i_budget_activ_sup_ret = ' '
          i_delta_amounts        = 'X'
          i_rollup_data          = 'X'
          i_check_plan_data      = 'X'
          i_commit_all           = 'Y'
        IMPORTING
          e_errors_found         = lv_oax
        TABLES
          it_bpak                = lt_bpak
          it_return              = lt_return
        EXCEPTIONS
          no_update              = 1
          OTHERS                 = 2.

      IF lv_oax IS INITIAL.
        e_return-type = 'S'.
        e_return-message = '预算减少成功'.
        CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
      ELSE.
        e_return-type = 'E'.
        e_return-message = '预算减少失败'.
        CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
      ENDIF.