PS CJ34预算转借
一、CJ34,输入发出预算和接收预算的WBS
二、调用BAPI
SELECT pspnr, posid, objnr FROM prps INTO TABLE @DATA(lt_prps) FOR ALL ENTRIES IN @lt_yszj WHERE posid = @lt_yszj-outwbs OR posid = @lt_yszj-inwbs. IF lt_prps IS NOT INITIAL. SORT lt_prps BY posid. LOOP AT lt_yszj INTO ls_yszj. CLEAR:ls_bpak. READ TABLE lt_prps INTO DATA(ls_prps) WITH KEY posid = ls_yszj-outwbs BINARY SEARCH. IF sy-subrc EQ 0. ls_bpak-s_objnr = ls_prps-objnr."借出 ENDIF. READ TABLE lt_prps INTO ls_prps WITH KEY posid = ls_yszj-inwbs BINARY SEARCH. IF sy-subrc EQ 0. ls_bpak-e_objnr = ls_prps-objnr."借入 ENDIF. "ls_bpak-s_vorga = 'KBUS'. "ls_bpak-e_vorga = 'KBUE'. ls_bpak-bldat = ls_yszj-bldat."凭证日期 ls_bpak-s_ges = 'X'."总价值 ls_bpak-e_ges = 'X'."总价值 ls_bpak-s_profil = '800001'."预算参数文件 ls_bpak-e_profil = '800001'. ls_bpak-wert = ls_yszj-wtges. ls_bpak-twaer = 'CNY'. APPEND ls_bpak TO lt_bpak. CLEAR:ls_yszj. ENDLOOP. CALL FUNCTION 'KBPP_EXTERN_UPDATE' EXPORTING * IMP_CARRY_OVER = ' ' * IMP_CHECK = ' ' imp_commit = 'X' imp_fcode = ' ' * IMP_SUPRESS_AVA_CHECK = ' ' imp_tcode = 'CJ34' * IMP_UNAME = ' ' TABLES imp_bpak = lt_bpak * imp_bpak_per = lt_bpak_per return = lt_return. CLEAR:lv_message. LOOP AT lt_return INTO ls_return WHERE type CA 'EAX'. lv_message = lv_message && ls_return-message. CLEAR:ls_return. ENDLOOP. IF lv_message IS INITIAL. e_return-type = 'S'. e_return-message = '预算转借成功'. * CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'. ELSE. e_return-type = 'E'. e_return-message = '预算转借失败:' && lv_message. * CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'. ENDIF. ELSE. e_return-type = 'E'. e_return-message = '未维护对应的WBS'. RETURN. ENDIF.