*----------------------------------------------------------------------*
* 程序名称: ZJISCOPS_REXEC_001
* 程序标题: 自定义创建项目
* 项目名称: 西部重工项目
* 程序类型: Report
* 创建人 : 苏井祥
* 创建日期: 2014/6/2
* 模块 : PS
* 事务码 : ZPSR001
* 请求号 :
* 功能描述: 利用BDC自定义或使用模板创建项目
* 相关文档:
*----------------------------------------------------------------------*
* 修改记录:
* 作者 日期 请求号 修改原因描述
*----------- -------- -----------------------------------------------*
*
*----------------------------------------------------------------------*
REPORT zjiscops_rexec_001.
*----------------------------------------------------------------------*
* INCLUDE *
*----------------------------------------------------------------------*
*----------------------------------------------------------------------*
* tables;
*----------------------------------------------------------------------*
TYPE-POOLS vrm.
*&------------------------------------------------------------
*& Global data declarations.
*&------------------------------------------------------------
TYPES: BEGIN OF ty_sdata,
pspid TYPE proj-pspid,"项目编码
profl TYPE proj-profl,"项目参数文件
END OF ty_sdata.
*&------------------------------------------------------------
*& Globlal work area and internal table declarations.
*&------------------------------------------------------------
DATA: gs_sdata TYPE ty_sdata,
gt_sdata TYPE TABLE OF ty_sdata.
DATA: gwa_bdcdata TYPE bdcdata,
gt_bdcdata TYPE TABLE OF bdcdata.
DATA: gwa_messtab TYPE bdcmsgcoll,
gt_messtab TYPE TABLE OF bdcmsgcoll.
DATA: g_message TYPE balmsgtxtp.
DATA: gwa_return TYPE bapiret2,
gt_return TYPE TABLE OF bapiret2.
DATA: g_flag_fdyj TYPE c," FD YJ 项目类型选择标记
g_flag_yf TYPE c." YF
DATA: g_obj TYPE char30. "转换的对象
DATA: g_obj_out TYPE proj-pspid. "外部的项目ID
DATA: g_profidproj TYPE tcj41-profidproj."项目参数文件
*&------------------------------------------------------------
*& ALV data declarations.
*&------------------------------------------------------------
*&------------------------------------------------------------
*& Constant.
*&------------------------------------------------------------
*&------------------------------------------------------------
*& Selection-screen.
*&------------------------------------------------------------
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
SELECTION-SCREEN BEGIN OF LINE .
SELECTION-SCREEN COMMENT 1(10) text-004."年度
PARAMETERS p_year TYPE mkpf-mjahr DEFAULT sy-datum+0(4) OBLIGATORY.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE .
SELECTION-SCREEN COMMENT 1(10) text-002."公司代码
PARAMETERS p_bukrs TYPE ekko-bukrs OBLIGATORY DEFAULT ‘7340‘.
SELECTION-SCREEN COMMENT 30(10) text-003."工厂
PARAMETERS p_werks TYPE marc-werks OBLIGATORY DEFAULT ‘7340‘.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE .
SELECTION-SCREEN COMMENT 1(10) text-014."项目描述
PARAMETERS p_post1 TYPE proj-post1 OBLIGATORY .
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE .
SELECTION-SCREEN COMMENT 1(10) text-008."项目负责人
PARAMETERS p_vernr TYPE proj-vernr OBLIGATORY .
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE .
SELECTION-SCREEN COMMENT 1(10) text-012. "开始日期
PARAMETERS: p_plfaz TYPE proj-plfaz .
SELECTION-SCREEN COMMENT 30(10) text-013."完成日期
PARAMETERS: p_plsez TYPE proj-plsez .
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE .
SELECTION-SCREEN COMMENT 1(10) text-005. "项目类
PARAMETERS: zlist TYPE spfli-connid AS LISTBOX VISIBLE LENGTH 10
USER-COMMAND zfl OBLIGATORY.
SELECTION-SCREEN COMMENT 30(10) text-006."项目类明细
PARAMETERS: zlist2 TYPE spfli-connid AS LISTBOX VISIBLE LENGTH 10
OBLIGATORY.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE .
SELECTION-SCREEN COMMENT 1(10) text-007."标准项目定义
PARAMETERS p_pspnr TYPE proj-pspid MATCHCODE OBJECT prss.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE .
SELECTION-SCREEN COMMENT 1(10) text-009 ."销售组织
PARAMETERS p_vkorg TYPE proj-vkorg .
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE .
SELECTION-SCREEN COMMENT 1(10) text-010."分销渠道
PARAMETERS p_vtweg TYPE proj-vtweg .
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE .
SELECTION-SCREEN COMMENT 1(10) text-011."产品组
PARAMETERS p_spart TYPE proj-spart .
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK b1.
*&------------------------------------------------------------
*& Initialization.
*&------------------------------------------------------------
INITIALIZATION.
CLEAR: gt_return,gt_messtab,gt_bdcdata,
gwa_return,gwa_messtab,gwa_bdcdata.
*&------------------------------------------------------------
*& At selection-screen.
*&------------------------------------------------------------
AT SELECTION-SCREEN OUTPUT.
PERFORM frm_selectlist_pbo CHANGING zlist."二级下拉菜单关联
PERFORM frm_modify_screen."研发类型不显示销售区域
*&------------------------------------------------------------
*& Start-of-selection.
*&------------------------------------------------------------
START-OF-SELECTION.
PERFORM frm_check_data."检查销售区域数据
PERFORM frm_process_data."处理逻辑
IF p_pspnr IS INITIAL.
PERFORM frm_fill_bdcdata."填充BDC数据
PERFORM frm_call_transaction."调用事务
ELSE.
* PERFORM frm_delete_wbs."删除原有元素
PERFORM frm_create_project."基于模版创建项目
ENDIF.
PERFORM frm_show_message.
*&------------------------------------------------------------
*& End-of-selection.
*&------------------------------------------------------------
END-OF-SELECTION.
*&---------------------------------------------------------------------*
*& Form FRM_PROCESS_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM frm_process_data .
DATA: lds_proj TYPE proj,
ldt_proj TYPE TABLE OF proj.
DATA: ldf_condtion TYPE string.
DATA: ldf_c3(3) TYPE c.
CASE zlist.
WHEN ‘0001‘.
gs_sdata-pspid+0(2) = ‘FD‘."风电
g_profidproj = ‘XZ00001‘.
WHEN ‘0002‘.
gs_sdata-pspid+0(2) = ‘YJ‘."冶金
g_profidproj = ‘XZ00001‘.
WHEN ‘0003‘.
gs_sdata-pspid+0(2) = ‘YF‘."研发
g_profidproj = ‘XZ00002‘.
WHEN OTHERS.
ENDCASE.
gs_sdata-pspid+2(4) = p_year."年度
IF zlist = ‘0001‘.
CASE zlist2.
WHEN ‘0001‘."FD
gs_sdata-pspid+6(2) = ‘TJ‘."集团
WHEN ‘0002‘."YJ
gs_sdata-pspid+6(2) = ‘QT‘."其他
WHEN OTHERS.
ENDCASE.
ELSEIF zlist = ‘0002‘.
CASE zlist2.
WHEN ‘0001‘."FD
gs_sdata-pspid+6(2) = ‘JT‘.
WHEN ‘0002‘."YJ
gs_sdata-pspid+6(2) = ‘WB‘.
WHEN OTHERS.
ENDCASE.
ELSEIF zlist = ‘0003‘.
CASE zlist2.
WHEN ‘0001‘."FD
gs_sdata-pspid+6(2) = ‘FD‘.
WHEN ‘0002‘."YJ
gs_sdata-pspid+6(2) = ‘YJ‘.
WHEN ‘0003‘."YJ
gs_sdata-pspid+6(2) = ‘MH‘.
WHEN ‘0004‘."YJ
gs_sdata-pspid+6(2) = ‘SY‘.
WHEN OTHERS.
ENDCASE.
ENDIF.
" 动态SQL 以及 拼字符串处理
ldf_condtion = gs_sdata.
CONCATENATE ldf_condtion ‘%‘ INTO ldf_condtion.
CONCATENATE ‘PSPID‘ ‘ LIKE‘ ‘ ‘‘‘ldf_condtion‘‘‘‘ INTO
ldf_condtion .
SELECT * INTO TABLE ldt_proj FROM proj
WHERE (ldf_condtion).
SORT ldt_proj BY pspid DESCENDING.
CLEAR lds_proj.
READ TABLE ldt_proj INTO lds_proj INDEX 1.
IF sy-subrc = 0.
ldf_c3 = lds_proj-pspid+8(3) + 1.
ELSE.
ldf_c3 = 1.
ENDIF.
CALL FUNCTION ‘CONVERSION_EXIT_ALPHA_INPUT‘
EXPORTING
input = ldf_c3
IMPORTING
output = ldf_c3.
gs_sdata-pspid+8(3) = ldf_c3. "最终编号
ENDFORM. " FRM_PROCESS_DATA
*&---------------------------------------------------------------------*
*& Form FRM_FILL_BDCDATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM frm_fill_bdcdata .
DATA: lds_tcj41 TYPE tcj41,
ldt_tcj41 TYPE TABLE OF tcj41,
lds_projs TYPE projs,
ldt_projs TYPE TABLE OF projs,
lds_prpss TYPE prpss,
ldt_prpss TYPE TABLE OF prpss.
DATA: ldf_lines TYPE i.
SELECT * INTO TABLE ldt_tcj41 FROM tcj41.
IF g_flag_yf = ‘X‘.
p_vkorg = ‘‘."销售组织
p_vtweg = ‘‘."分销渠道
p_spart = ‘‘."产品组
ENDIF.
"是否启用标准模板
IF p_pspnr = ‘‘.
IF g_flag_fdyj = ‘X‘.
*****************自定义销售***********************************
CLEAR lds_tcj41.
*READ TABLE ldt_tcj41 INTO lds_tcj41 WITH KEY profidproj = ‘XZ00001‘.
READ TABLE ldt_tcj41 INTO lds_tcj41 WITH KEY profidproj =
g_profidproj.
g_obj = lds_tcj41-scope.
PERFORM frm_conver_unit USING lds_tcj41-zteht."单位转换
PERFORM frm_conver_obj USING g_obj."对象类转换
PERFORM bdc_dynpro USING ‘SAPLCJWB‘ ‘0100‘.
PERFORM bdc_field USING ‘BDC_CURSOR‘ ‘*PROJ-PSPID‘.
PERFORM bdc_field USING ‘BDC_OKCODE‘ ‘=MDTB‘.
PERFORM bdc_field USING ‘*PROJ-PSPID‘ gs_sdata-pspid.
PERFORM bdc_field USING ‘RCWBS-PROFL‘ ‘XZ00001‘."参数文件
PERFORM bdc_field USING ‘RCWKP-VORSPSP‘ ‘‘.
PERFORM bdc_dynpro USING ‘SAPLCJWB‘ ‘0998‘.
PERFORM bdc_field USING ‘BDC_OKCODE‘ ‘=PCNT‘.
PERFORM bdc_field USING ‘PROJ-PSPID‘ gs_sdata-pspid.
PERFORM bdc_field USING ‘PROJ-POST1‘ p_post1."项目描述
PERFORM bdc_field USING ‘BDC_CURSOR‘ ‘PROJ-PLSEZ‘.
PERFORM bdc_field USING ‘PROJ-VERNR‘ p_vernr. "负责人
PERFORM bdc_field USING ‘PROJ-VKOKR‘ ‘XBZG‘."此项目的控制范围
PERFORM bdc_field USING ‘PROJ-VBUKR‘ p_bukrs."项目公司代码
PERFORM bdc_field USING ‘PROJ-WERKS‘ p_werks."工厂
IF p_plfaz IS INITIAL.
PERFORM bdc_field USING ‘PROJ-PLFAZ‘ ‘‘."开始日期
ELSE.
PERFORM bdc_field USING ‘PROJ-PLFAZ‘ p_plfaz."开始日期
ENDIF.
IF p_plsez IS INITIAL.
PERFORM bdc_field USING ‘PROJ-PLSEZ‘ ‘‘."结束日期
ELSE.
PERFORM bdc_field USING ‘PROJ-PLSEZ‘ p_plsez."结束日期
ENDIF.
PERFORM bdc_field USING ‘PROJ-KALID‘ lds_tcj41-kalid.
"工厂日历码
PERFORM bdc_field USING ‘PROJ-ZTEHT‘ lds_tcj41-zteht.
"在时间计划中的时间单位
PERFORM bdc_field USING ‘PROJ-PWHIE‘ lds_tcj41-waers.
"WBS货币(项目定义)
PERFORM bdc_dynpro USING ‘SAPLCJWB‘ ‘0998‘.
PERFORM bdc_field USING ‘BDC_OKCODE‘ ‘=LETB‘.
PERFORM bdc_field USING ‘PROJ-PSPID‘ gs_sdata-pspid.
PERFORM bdc_field USING ‘PROJ-POST1‘ p_post1.
PERFORM bdc_field USING ‘PROJ-BPROF‘ lds_tcj41-bprof.
"预算参数文件
PERFORM bdc_field USING ‘PROJ-VPROF‘ lds_tcj41-vprof.
"网络参数文件
PERFORM bdc_field USING ‘PROJ-PPROF‘ lds_tcj41-pprof.
"计划参数文件
PERFORM bdc_field USING ‘PROJ-SCPRF‘ lds_tcj41-scprf.
"WBS 计划概要
PERFORM bdc_field USING ‘PROJ-ABGSL‘ lds_tcj41-abgsl.
"RA 码
PERFORM bdc_field USING ‘PROJ-VGPLF‘ lds_tcj41-vgplf.
"计划方法/基本
PERFORM bdc_field USING ‘PROJ-EWPLF‘ lds_tcj41-ewplf.
"计划方法/预测
PERFORM bdc_field USING ‘PROJ-SCOPE‘ g_obj."对象类
PERFORM bdc_field USING ‘PROJ-PLINT‘ lds_tcj41-plint.
"综合计划
PERFORM bdc_field USING ‘PROJ_BEST_BWRT‘ lds_tcj41-besta
.
"项目存货
PERFORM bdc_field USING ‘PROJ-VKORG‘ p_vkorg."销售组织
PERFORM bdc_field USING ‘PROJ-VTWEG‘ p_vtweg."分销渠道
PERFORM bdc_field USING ‘PROJ-SPART‘ p_spart."产品组
PERFORM bdc_dynpro USING ‘SAPLCJWB‘ ‘0901‘.
PERFORM bdc_field USING ‘BDC_OKCODE‘ ‘=BU‘.
PERFORM bdc_field USING ‘PROJ-POST1‘ gs_sdata-pspid."
PERFORM bdc_field USING ‘PROJ-POST1‘ p_post1.
PERFORM bdc_field USING ‘BDC_CURSOR‘ ‘PRPS-POST1(01)‘.
PERFORM bdc_field USING ‘RCWBS-IDENT(01)‘ gs_sdata-pspid.
"WBS元素
PERFORM bdc_field USING ‘PRPS-POST1(01)‘ p_post1."WBS描述
ENDIF.
*************************** END *******************************
******************自定义研发************************
IF g_flag_yf = ‘X‘.
CLEAR lds_tcj41.
*READ TABLE ldt_tcj41 INTO lds_tcj41 WITH KEY profidproj = ‘XZ00002‘.
READ TABLE ldt_tcj41 INTO lds_tcj41 WITH KEY profidproj =
g_profidproj.
PERFORM frm_conver_unit USING lds_tcj41-zteht."单位转换
PERFORM bdc_dynpro USING ‘SAPLCJWB‘ ‘0100‘.
PERFORM bdc_field USING ‘BDC_CURSOR‘ ‘*PROJ-PSPID‘.
PERFORM bdc_field USING ‘BDC_OKCODE‘ ‘=MDTB‘.
PERFORM bdc_field USING ‘*PROJ-PSPID‘ gs_sdata-pspid.
PERFORM bdc_field USING ‘RCWBS-PROFL‘ ‘XZ00002‘."参数文件
PERFORM bdc_field USING ‘RCWKP-VORSPSP‘ ‘‘.
PERFORM bdc_dynpro USING ‘SAPLCJWB‘ ‘0998‘.
PERFORM bdc_field USING ‘BDC_OKCODE‘ ‘=LETB‘.
PERFORM bdc_field USING ‘PROJ-PSPID‘ gs_sdata-pspid.
PERFORM bdc_field USING ‘PROJ-POST1‘ p_post1."
PERFORM bdc_field USING ‘BDC_CURSOR‘ ‘PROJ-PLSEZ‘.
PERFORM bdc_field USING ‘PROJ-VERNR‘ p_vernr."
PERFORM bdc_field USING ‘PROJ-VKOKR‘ ‘XBZG‘."
PERFORM bdc_field USING ‘PROJ-VBUKR‘ p_bukrs."
PERFORM bdc_field USING ‘PROJ-WERKS‘ p_werks."
IF p_plfaz IS INITIAL.
PERFORM bdc_field USING ‘PROJ-PLFAZ‘ ‘‘."开始日期
ELSE.
PERFORM bdc_field USING ‘PROJ-PLFAZ‘ p_plfaz."开始日期
ENDIF.
IF p_plsez IS INITIAL.
PERFORM bdc_field USING ‘PROJ-PLSEZ‘ ‘‘."结束日期
ELSE.
PERFORM bdc_field USING ‘PROJ-PLSEZ‘ p_plsez."结束日期
ENDIF.
PERFORM bdc_field USING ‘PROJ-KALID‘ lds_tcj41-kalid.
"工厂日历码
PERFORM bdc_field USING ‘PROJ-ZTEHT‘ lds_tcj41-zteht.
"在时间计划中的时间单位
PERFORM bdc_field USING ‘PROJ-PWHIE‘ lds_tcj41-waers.
"WBS货币(项目定义)
PERFORM bdc_dynpro USING ‘SAPLCJWB‘ ‘0901‘.
PERFORM bdc_field USING ‘BDC_OKCODE‘ ‘=BU‘.
PERFORM bdc_field USING ‘PROJ-POST1‘ p_post1."
PERFORM bdc_field USING ‘BDC_CURSOR‘ ‘PRPS-POST1(01)‘.
PERFORM bdc_field USING ‘RCWBS-IDENT(01)‘ gs_sdata-pspid.
"WBS元素
PERFORM bdc_field USING ‘PRPS-POST1(01)‘ p_post1."WBS描述
ENDIF.
*************** end ********************
ENDIF.
ENDFORM.
" FRM_FILL_BDCDATA
*&---------------------------------------------------------------------*
*& Form FRM_CALL_TRANSACTION
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM frm_call_transaction .
CALL TRANSACTION ‘CJ01‘ USING gt_bdcdata MODE ‘N‘ MESSAGES INTO
gt_messtab.
WAIT UP TO 1 SECONDS.
LOOP AT gt_messtab INTO gwa_messtab WHERE msgtyp = ‘E‘
OR msgtyp = ‘A‘ OR msgtyp = ‘S‘.
PERFORM get_message USING gwa_messtab
CHANGING g_message .
gwa_return-type = gwa_messtab-msgtyp.
gwa_return-message = g_message.
APPEND gwa_return TO gt_return.
CLEAR gwa_return.
CLEAR g_message.
ENDLOOP.
ENDFORM.
" FRM_CALL_TRANSACTION
*-------------------------------------------------------------------*
* Start new screen
*
*-------------------------------------------------------------------*
FORM bdc_dynpro USING program dynpro.
CLEAR gwa_bdcdata.
gwa_bdcdata-program = program.
gwa_bdcdata-dynpro = dynpro.
gwa_bdcdata-dynbegin =
‘X‘.
APPEND gwa_bdcdata TO gt_bdcdata.
ENDFORM.
"bdc_dynpro
*-------------------------------------------------------------------*
* Insert field
*
*-------------------------------------------------------------------*
FORM bdc_field USING fnam fval.
CLEAR gwa_bdcdata.
gwa_bdcdata-fnam = fnam.
gwa_bdcdata-fval = fval.
APPEND gwa_bdcdata TO gt_bdcdata.
ENDFORM.
"bdc_field
*&---------------------------------------------------------------------*
*& Form GET_MESSAGE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_WA_BDC_MESSAGE text
* <--P_WA_MESSAGE_MSG_TXT text
*----------------------------------------------------------------------*
FORM get_message USING lw_message TYPE bdcmsgcoll
CHANGING g_message TYPE balmsgtxtp.
CLEAR g_message.
CALL FUNCTION ‘MESSAGE_TEXT_BUILD‘
EXPORTING
msgid = lw_message-msgid
msgnr = lw_message-msgnr
msgv1 = lw_message-msgv1
msgv2 = lw_message-msgv2
msgv3 = lw_message-msgv3
msgv4 = lw_message-msgv4
IMPORTING
message_text_output = g_message.
ENDFORM.
" GET_MESSAGE
*&---------------------------------------------------------------------*
*& Form frm_selectlist_pbo
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->ZLIST text
*----------------------------------------------------------------------*
FORM frm_selectlist_pbo CHANGING zlist.
* data itab_list type vrm_values.
DATA: ldt_list
TYPE TABLE OF vrm_value,
lds_list
TYPE vrm_value.
DATA: ldt_list2
TYPE TABLE OF vrm_value,
lds_list2
TYPE vrm_value.
FREE ldt_list.
lds_list-key =
‘01‘.
lds_list-text =
‘风电‘.
APPEND lds_list TO ldt_list.
lds_list-key =
‘02‘.
lds_list-text =
‘冶金‘.
APPEND lds_list TO ldt_list.
lds_list-key =
‘03‘.
lds_list-text =
‘研发‘.
APPEND lds_list TO ldt_list.
CALL FUNCTION ‘VRM_SET_VALUES‘
EXPORTING
id = ‘ZLIST‘ "屏幕中的下拉菜单的NAME,下拉菜单选择LISTBOX
values = ldt_list.
IF zlist = ‘‘.
READ TABLE ldt_list INTO lds_list INDEX 1.
zlist = lds_list-key.
ENDIF.
FREE ldt_list2.
IF zlist = ‘01‘ .
FREE ldt_list2.
lds_list2-key =
‘01‘.
lds_list2-text =
‘塔架‘.
APPEND lds_list2 TO ldt_list2.
lds_list2-key =
‘02‘.
lds_list2-text =
‘其他‘.
APPEND lds_list2 TO ldt_list2.
ELSEIF zlist = ‘02‘ .
FREE ldt_list2.
lds_list2-key =
‘01‘.
lds_list2-text =
‘集团‘.
APPEND lds_list2 TO ldt_list2.
lds_list2-key =
‘02‘.
lds_list2-text =
‘外部‘.
APPEND lds_list2 TO ldt_list2.
ELSEIF zlist = ‘03‘ .
FREE ldt_list2.
lds_list2-key =
‘01‘.
lds_list2-text =
‘风电‘.
APPEND lds_list2 TO ldt_list2.
lds_list2-key =
‘02‘.
lds_list2-text =
‘冶金‘.
APPEND lds_list2 TO ldt_list2.
lds_list2-key =
‘03‘.
lds_list2-text =
‘煤化‘.
APPEND lds_list2 TO ldt_list2.
lds_list2-key =
‘04‘.
lds_list2-text =
‘石油‘.
APPEND lds_list2 TO ldt_list2.
ENDIF.
CALL FUNCTION ‘VRM_SET_VALUES‘
EXPORTING
id = ‘ZLIST2‘ "屏幕中的下拉菜单的NAME,下拉菜单选择LISTBOX
values = ldt_list2.
READ TABLE ldt_list2 INTO lds_list2 INDEX 1.
zlist2 = lds_list2-key.
ENDFORM.
"frm_selectlist_pbo
*&---------------------------------------------------------------------*
*& Form FRM_MODIFY_SCREEN
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM frm_modify_screen.
IF zlist = ‘0003‘ .
LOOP AT SCREEN.
CASE screen-name.
WHEN ‘P_VKORG‘.
screen-active =
0.
MODIFY SCREEN.
WHEN ‘P_VTWEG‘.
screen-active =
0.
MODIFY SCREEN.
WHEN ‘P_SPART‘.
screen-active =
0.
MODIFY SCREEN.
WHEN ‘%C009036_1000‘.
screen-active =
0.
MODIFY SCREEN.
WHEN ‘%C010040_1000‘.
screen-active =
0.
MODIFY SCREEN.
WHEN ‘%C011044_1000‘.
screen-active =
0.
MODIFY SCREEN.
WHEN OTHERS.
ENDCASE.
ENDLOOP.
ENDIF.
ENDFORM.
" FRM_MODIFY_SCREEN
*&---------------------------------------------------------------------*
*& Form FRM_SHOW_MESSAGE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM frm_show_message .
LOOP AT gt_return INTO gwa_return.
WRITE: / gwa_return-type, gwa_return-message.
ENDLOOP.
ENDFORM.
" FRM_SHOW_MESSAGE
*&---------------------------------------------------------------------*
*& Form FRM_CHECK_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM frm_check_data .
IF zlist = ‘0001‘ OR zlist = ‘0002‘ .
g_flag_fdyj =
‘X‘.
ELSEIF zlist = ‘0003‘.
g_flag_yf =
‘X‘.
ENDIF.
IF g_flag_fdyj = ‘X‘.
IF p_vkorg = ‘‘ OR p_vtweg = ‘‘ OR p_spart = ‘‘.
MESSAGE ‘请填写完整销售区域数据‘ TYPE ‘E‘.
ENDIF.
ENDIF.
ENDFORM.
" FRM_CHECK_DATA
*&---------------------------------------------------------------------*
*& Form FRM_CONVER_UNIT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_P_PSPNR text
*----------------------------------------------------------------------*
FORM frm_conver_unit USING p_unit.
CALL FUNCTION ‘CONVERSION_EXIT_CUNIT_OUTPUT‘
EXPORTING
input = p_unit
IMPORTING
output = p_unit
EXCEPTIONS
unit_not_found =
1
OTHERS = 2.
ENDFORM.
" FRM_CONVER_UNIT
*&---------------------------------------------------------------------*
*& Form FRM_UNIT_INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_LDF_PSPID text
*----------------------------------------------------------------------*
FORM frm_pspnr_input USING p_pspnr.
CALL FUNCTION ‘CONVERSION_EXIT_KONPS_INPUT‘
EXPORTING
input = p_pspnr
IMPORTING
output = p_pspnr.
ENDFORM.
" FRM_UNIT_INPUT
*&---------------------------------------------------------------------*
*& Form FRM_CONVER_OBJ
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_LDS_TCJ41_SCOPE text
*----------------------------------------------------------------------*
FORM frm_conver_obj USING p_scope.
CALL FUNCTION ‘CONVERSION_EXIT_SCOPE_OUTPUT‘
EXPORTING
input = p_scope
IMPORTING
output = p_scope.
ENDFORM.
" FRM_CONVER_OBJ
*&---------------------------------------------------------------------*
*& Form FRM_DELETE_WBS
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM frm_delete_wbs .
* DATA:it_ret2 LIKE bapiret2 OCCURS 0 WITH HEADER LINE.
*DATA: it_delete_wbs_element LIKE TABLE OF bapi_wbs_list WITH HEADER
*LINE.
*
*
* DATA: str(20) TYPE c.
* DATA: gt_prps TYPE TABLE OF prps,
* gwa_prps TYPE prps.
*
* CALL FUNCTION ‘CONVERSION_EXIT_KONPD_INPUT‘
* EXPORTING
* input = gs_sdata-pspid
* IMPORTING
* output = gs_sdata-pspid.
*
*
* SELECT * INTO TABLE gt_prps FROM prps
* WHERE psphi = gs_sdata-pspid.
*
* LOOP AT gt_prps INTO gwa_prps.
* CALL FUNCTION ‘CONVERSION_EXIT_ABPSP_OUTPUT‘
* EXPORTING
* input = gwa_prps-pspnr
* IMPORTING
* output = str.
*
* it_delete_wbs_element-wbs_element = str.
* APPEND it_delete_wbs_element.
* ENDLOOP.
*
*
* CALL FUNCTION ‘CONVERSION_EXIT_KONPD_OUTPUT‘
* EXPORTING
* input = gs_sdata-pspid
* IMPORTING
* output = gs_sdata-pspid.
*
* CALL FUNCTION ‘BAPI_PS_INITIALIZATION‘.
*
* CALL FUNCTION ‘BAPI_BUS2054_DELETE_MULTI‘
* EXPORTING
* i_project_definition = gs_sdata-pspid
* TABLES
* it_delete_wbs_element = it_delete_wbs_element
* et_return = it_ret2.
*
* CALL FUNCTION ‘BAPI_PS_PRECOMMIT‘
* TABLES
* et_return = it_ret2.
*
* CALL FUNCTION ‘BAPI_TRANSACTION_COMMIT‘
* EXPORTING
* wait = ‘X‘.
ENDFORM.
" FRM_DELETE_WBS
*&---------------------------------------------------------------------*
*& Form FRM_CREATE_PROJECT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM frm_create_project .
DATA: i_pro_def_new
TYPE STANDARD TABLE OF bapi_bus2001_new WITH
HEADER LINE.
DATA: gt_prhis
TYPE TABLE OF prhis,
gwa_prhis
TYPE prhis.
DATA: gt_prpss
TYPE TABLE OF prpss,
gwa_prpss
TYPE prpss.
DATA: it_wbs
LIKE bapi_bus2054_new OCCURS 0 WITH HEADER LINE ,
it_ret2
LIKE bapiret2 OCCURS 0 WITH HEADER LINE.
DATA: it_wbs_update
LIKE bapi_bus2054_chg OCCURS 0 WITH HEADER LINE,
it_update
LIKE bapi_bus2054_upd OCCURS 0 WITH HEADER LINE.
DATA: str(30)
TYPE c,
str_up(30)
TYPE c,
str_left(30)
TYPE c.
PERFORM frm_pspnr_input USING p_pspnr."项目ID转换
SELECT * INTO TABLE gt_prhis FROM prhis
WHERE psphi = p_pspnr.
SELECT * INTO TABLE gt_prpss FROM prpss
WHERE psphi = p_pspnr.
i_pro_def_new-project_definition = gs_sdata-pspid.
i_pro_def_new-description = p_post1.
i_pro_def_new-project_profile = g_profidproj.
APPEND i_pro_def_new.
CALL FUNCTION ‘BAPI_PS_INITIALIZATION‘.
CALL FUNCTION ‘BAPI_BUS2001_CREATE‘
EXPORTING
i_project_definition = i_pro_def_new
TABLES
et_return = it_ret2[].
APPEND LINES OF it_ret2[] TO gt_return.
CLEAR:it_wbs[].
LOOP AT gt_prhis INTO gwa_prhis .
CLEAR gwa_prpss.
READ TABLE gt_prpss INTO gwa_prpss WITH KEY pspnr = gwa_prhis-posnr.
IF sy-subrc = 0.
CALL FUNCTION ‘CONVERSION_EXIT_KONPT_OUTPUT‘
EXPORTING
input = gwa_prhis-posnr
IMPORTING
output = str.
CALL FUNCTION ‘CONVERSION_EXIT_KONPT_OUTPUT‘
EXPORTING
input = gwa_prhis-up
IMPORTING
output = str_up.
CALL FUNCTION ‘CONVERSION_EXIT_KONPT_OUTPUT‘
EXPORTING
input = gwa_prhis-left
IMPORTING
output = str_left.
str+0(11) = gs_sdata-pspid.
IF str_up IS NOT INITIAL.
str_up+0(11) = gs_sdata-pspid.
ENDIF.
IF str_left IS NOT INITIAL.
str_left+0(11) = gs_sdata-pspid.
ENDIF.
it_wbs-wbs_element = str.
it_wbs-wbs_left = str_left.
it_wbs-wbs_up = str_up.
IF str = gs_sdata-pspid.
it_wbs-description = p_post1.
ELSE.
it_wbs-description = gwa_prpss-post1.
ENDIF.
APPEND it_wbs.
ENDIF.
ENDLOOP.
CALL FUNCTION ‘BAPI_BUS2054_CREATE_MULTI‘
EXPORTING
i_project_definition = gs_sdata-pspid
TABLES
it_wbs_element = it_wbs[]
et_return = it_ret2[].
APPEND LINES OF it_ret2[] TO gt_return.
CLEAR:it_wbs_update,it_update.
LOOP AT gt_prhis INTO gwa_prhis .
CLEAR gwa_prpss.
READ TABLE gt_prpss INTO gwa_prpss WITH KEY pspnr = gwa_prhis-posnr.
IF sy-subrc = 0.
CALL FUNCTION ‘CONVERSION_EXIT_KONPT_OUTPUT‘
EXPORTING
input = gwa_prhis-posnr
IMPORTING
output = str.
str+0(11) = gs_sdata-pspid.
it_wbs_update-wbs_element = str.
it_wbs_update-wbs_planning_element = gwa_prpss-plakz.
"计划
it_wbs_update-wbs_account_assignment_element = gwa_prpss-belkz.
"科目
it_wbs_update-wbs_billing_element = gwa_prpss-fakkz.
"开票
it_wbs_update-statistical = gwa_prpss-xstat.
"统计WBS
it_wbs_update-planintegrated = gwa_prpss-plint.
"综合计划
APPEND it_wbs_update.
it_update-wbs_element = str.
it_update-wbs_planning_element =
‘X‘."计划
it_update-wbs_account_assignment_element =
‘X‘."科目
it_update-wbs_billing_element =
‘X‘."开票
it_update-statistical =
‘X‘.
it_update-planintegrated =
‘X‘.
APPEND it_update.
ENDIF.
ENDLOOP.
CALL FUNCTION ‘BAPI_BUS2054_CHANGE_MULTI‘
EXPORTING
i_project_definition = gs_sdata-pspid
TABLES
it_wbs_element = it_wbs_update[]
it_update_wbs_element = it_update[]
et_return = it_ret2[].
APPEND LINES OF it_ret2[] TO gt_return.
CALL FUNCTION ‘BAPI_PS_PRECOMMIT‘
TABLES
et_return = it_ret2.
APPEND LINES OF it_ret2[] TO gt_return.
READ TABLE it_ret2 WITH KEY type = ‘E‘.
IF sy-subrc <> 0.
CALL FUNCTION ‘BAPI_TRANSACTION_COMMIT‘.
ELSE.
CALL FUNCTION ‘BAPI_TRANSACTION_ROLLBACK‘.
ENDIF.
ENDFORM.
" FRM_CREATE_PROJECT
PS 项目创建