生产订单修改删除组件BDC详解编程语言

 可用函数修改:CO_XT_COMPONENT_CHANGE,一次一个

 FORM prm_change_bom . 
DATA:gw_zstypf TYPE zstypf. 
DATA:lv_rspos TYPE rspos. 
CLEAR:gw_zstypf,lv_rspos. 
LOOP AT gt_zstypf INTO gs_zstypf. 
IF gs_zstypf-rsnum IS NOT INITIAL. 
MOVE-CORRESPONDING gs_zstypf TO gw_zstypf. 
ENDIF. 
ENDLOOP. 
LOOP AT gt_zstypf INTO gs_zstypf WHERE xloek = 'X'."原有组件,需要先删除 
PERFORM prm_delete_bom_line USING gs_zstypf-rspos gs_zstypf-aufnr. 
IF sy-subrc = 0. 
ELSE. 
MESSAGE '删除组件失败,请重新删除!' TYPE 'E'. 
ENDIF. 
ENDLOOP. 
WAIT UP TO 1 SECONDS. 
LOOP AT gt_zstypf INTO gs_zstypf WHERE xloek = 'C' AND rsnum IS NOT INITIAL."修改原有组件 
PERFORM prm_change_bom_line USING gs_zstypf. 
IF sy-subrc = 0. 
ELSE. 
MESSAGE '修改组件失败,请重新修改!' TYPE 'E'. 
ENDIF. 
ENDLOOP. 
WAIT UP TO 1 SECONDS. 
SELECT MAX( rspos ) INTO lv_rspos FROM resb WHERE rsnum = gw_zstypf-rsnum. 
LOOP AT gt_zstypf INTO gs_zstypf WHERE xloek <> 'X' AND rsnum IS INITIAL."新建组件 
gs_zstypf-rspos = lv_rspos + 1. 
gs_zstypf-aufnr = gw_zstypf-aufnr. 
gs_zstypf-posnr = gs_zstypf-rspos * 10. 
lv_rspos = lv_rspos + 1. 
PERFORM prm_add_bom_line USING gs_zstypf. 
IF sy-subrc = 0. 
ELSE. 
MESSAGE '添加组件失败,请重新添加!' TYPE 'E'. 
ENDIF. 
ENDLOOP. 
ENDFORM.                    " PRM_CHANGE_BOM
FORM prm_delete_bom_line  USING    p_posnr p_aufnr. 
DATA:lv_value TYPE bdcdata-fval. 
DATA:lv_fname TYPE bdcdata-fnam. 
REFRESH:messtab,bdcdata. 
CLEAR:lv_value,lv_fname. 
CONCATENATE 'RESBD-POSNR(' p_posnr ')' INTO lv_value. 
CONCATENATE 'RC27X-FLG_SEL(' p_posnr ')' INTO lv_fname. 
PERFORM bdc_dynpro      USING 'SAPLCOKO1' '0110'. 
PERFORM bdc_field       USING 'BDC_CURSOR' 
'CAUFVD-AUFNR'. 
PERFORM bdc_field       USING 'BDC_OKCODE' 
'=KPU2'. 
PERFORM bdc_field       USING 'CAUFVD-AUFNR' 
p_aufnr. 
*                              '100000043'. 
PERFORM bdc_field       USING 'R62CLORD-FLG_OVIEW' 
'X'. 
PERFORM bdc_dynpro      USING 'SAPLCOMK' '0120'. 
PERFORM bdc_field       USING 'BDC_CURSOR' 
lv_value. 
*                              'RESBD-POSNR(02)'. 
PERFORM bdc_field       USING 'BDC_OKCODE' 
'=DEL'. 
PERFORM bdc_field       USING 'FILTER_BOX' 
'NO_FIL'. 
PERFORM bdc_field       USING 'SORT_BOX' 
'ST_STA'. 
PERFORM bdc_field       USING lv_fname"'RC27X-FLG_SEL(02)' 
'X'. 
PERFORM bdc_dynpro      USING 'SAPLCOMK' '0120'. 
PERFORM bdc_field       USING 'BDC_CURSOR' 
'RESBD-MATNR(01)'. 
PERFORM bdc_field       USING 'BDC_OKCODE' 
'=BU'. 
PERFORM bdc_field       USING 'FILTER_BOX' 
'NO_FIL'. 
PERFORM bdc_field       USING 'SORT_BOX' 
'ST_STA'. 
CALL TRANSACTION 'CO02' USING bdcdata 
MODE   'N' 
UPDATE 'S' 
MESSAGES INTO messtab. 
*perform bdc_transaction using 'CO02'. 
ENDFORM.                    " PRM_DELETE_BOM_LINE
FORM prm_change_bom_line  USING    p_gs_zstypf STRUCTURE zstypf. 
DATA:lv_value TYPE bdcdata-fval. 
DATA:lv_dbmn TYPE bdcdata-fval."数量 
DATA:lv_fnam1 TYPE bdcdata-fnam. 
DATA:lv_fnam2 TYPE bdcdata-fnam. 
DATA:lv_fnam3 TYPE bdcdata-fnam. 
REFRESH:messtab,bdcdata. 
CLEAR:lv_value,lv_fnam1,lv_fnam2,lv_fnam3. 
CONCATENATE 'RESBD-MATXT(' p_gs_zstypf-rspos ')' INTO lv_value. 
CONCATENATE 'RC27X-FLG_SEL(' p_gs_zstypf-rspos ')' INTO lv_fnam1. 
CONCATENATE 'RESBD-MATNR(' p_gs_zstypf-rspos ')' INTO lv_fnam2. 
CONCATENATE 'RESBD-MENGE(' p_gs_zstypf-rspos ')' INTO lv_fnam3. 
PERFORM bdc_dynpro      USING 'SAPLCOKO1' '0110'. 
PERFORM bdc_field       USING 'BDC_CURSOR' 
'CAUFVD-AUFNR'. 
PERFORM bdc_field       USING 'BDC_OKCODE' 
'=KPU2'. 
PERFORM bdc_field       USING 'CAUFVD-AUFNR' 
p_gs_zstypf-aufnr. 
PERFORM bdc_field       USING 'R62CLORD-FLG_OVIEW' 
'X'. 
PERFORM bdc_dynpro      USING 'SAPLCOMK' '0120'. 
PERFORM bdc_field       USING 'BDC_CURSOR' 
lv_value. 
PERFORM bdc_field       USING 'BDC_OKCODE' 
'=PICK'. 
PERFORM bdc_field       USING 'FILTER_BOX' 
'NO_FIL'. 
PERFORM bdc_field       USING 'SORT_BOX' 
'ST_STA'. 
PERFORM bdc_field       USING lv_fnam1 
'X'. 
PERFORM bdc_field       USING lv_fnam2 
p_gs_zstypf-matnr. 
MOVE p_gs_zstypf-bdmng TO lv_dbmn. 
CONDENSE lv_dbmn NO-GAPS. 
PERFORM bdc_field       USING lv_fnam3 
lv_dbmn. 
PERFORM bdc_dynpro      USING 'SAPLCOMD' '0110'. 
PERFORM bdc_field       USING 'BDC_OKCODE' 
'=BU'. 
PERFORM bdc_field       USING 'BDC_CURSOR' 
'RESBD-POTX1'. 
PERFORM bdc_field       USING 'RESBD-MATNR' 
p_gs_zstypf-matnr. 
PERFORM bdc_field       USING 'RESBD-POSNR' 
p_gs_zstypf-posnr. 
PERFORM bdc_field       USING 'RESBD-POTX1' 
p_gs_zstypf-potx1. 
PERFORM bdc_field       USING 'RESBD-SANKA' 
'X'. 
PERFORM bdc_dynpro      USING 'SAPLCOMD' '0110'. 
PERFORM bdc_field       USING 'BDC_OKCODE' 
'=BU'. 
PERFORM bdc_field       USING 'RESBD-SANKA' 
'X'. 
CALL TRANSACTION 'CO02' USING bdcdata 
MODE   'N' 
UPDATE 'S' 
MESSAGES INTO messtab. 
ENDFORM.                    " PRM_CHANGE_BOM_LINE
FORM prm_add_bom_line  USING    p_gs_zstypf STRUCTURE zstypf. 
DATA:lv_value TYPE bdcdata-fval. 
DATA:lv_dbmn TYPE bdcdata-fval."数量 
DATA:lv_fnam1 TYPE bdcdata-fnam. 
DATA:lv_fnam2 TYPE bdcdata-fnam. 
DATA:lv_fnam3 TYPE bdcdata-fnam. 
DATA:lv_fnam4 TYPE bdcdata-fnam. 
DATA:lv_fnam5 TYPE bdcdata-fnam. 
DATA:lv_fnam6 TYPE bdcdata-fnam. 
REFRESH:messtab,bdcdata. 
CLEAR:lv_value,lv_fnam1,lv_fnam2,lv_fnam3,lv_fnam4,lv_fnam5,lv_fnam6. 
CONCATENATE 'RESBD-MATXT(' p_gs_zstypf-rspos ')' INTO lv_value. 
CONCATENATE 'RESBD-MATNR(' p_gs_zstypf-rspos ')' INTO lv_fnam1. 
CONCATENATE 'RESBD-MENGE(' p_gs_zstypf-rspos ')' INTO lv_fnam2. 
CONCATENATE 'RESBD-EINHEIT(' p_gs_zstypf-rspos ')' INTO lv_fnam3. 
CONCATENATE 'RESBD-POSTP(' p_gs_zstypf-rspos ')' INTO lv_fnam4. 
CONCATENATE 'RESBD-VORNR(' p_gs_zstypf-rspos ')' INTO lv_fnam5. 
CONCATENATE 'RCOLS-APLFL(' p_gs_zstypf-rspos ')' INTO lv_fnam6. 
PERFORM bdc_dynpro      USING 'SAPLCOKO1' '0110'. 
PERFORM bdc_field       USING 'BDC_CURSOR' 
'CAUFVD-AUFNR'. 
PERFORM bdc_field       USING 'BDC_OKCODE' 
'=KPU2'. 
PERFORM bdc_field       USING 'CAUFVD-AUFNR' 
p_gs_zstypf-aufnr. 
PERFORM bdc_field       USING 'R62CLORD-FLG_OVIEW' 
'X'. 
PERFORM bdc_dynpro      USING 'SAPLCOMK' '0120'. 
PERFORM bdc_field       USING 'BDC_CURSOR' 
lv_value. 
PERFORM bdc_field       USING 'BDC_OKCODE' 
'=PICK'. 
PERFORM bdc_field       USING 'FILTER_BOX' 
'NO_FIL'. 
PERFORM bdc_field       USING 'SORT_BOX' 
'ST_STA'. 
PERFORM bdc_field       USING lv_fnam1 
p_gs_zstypf-matnr. 
MOVE p_gs_zstypf-bdmng TO lv_dbmn. 
CONDENSE lv_dbmn NO-GAPS. 
PERFORM bdc_field       USING lv_fnam2 
lv_dbmn. 
CALL FUNCTION 'CONVERSION_EXIT_CUNIT_OUTPUT' 
EXPORTING 
input          = p_gs_zstypf-meins 
language       = sy-langu 
IMPORTING 
*      LONG_TEXT      = 
output         = p_gs_zstypf-meins 
*      SHORT_TEXT     = 
EXCEPTIONS 
unit_not_found = 1 
OTHERS         = 2. 
PERFORM bdc_field       USING lv_fnam3 
p_gs_zstypf-meins. 
PERFORM bdc_field       USING lv_fnam4 
'L'. 
PERFORM bdc_field       USING lv_fnam5 
p_gs_zstypf-vornr. 
PERFORM bdc_field       USING lv_fnam6 
p_gs_zstypf-plnfl. 
PERFORM bdc_dynpro      USING 'SAPLCOMD' '0110'. 
PERFORM bdc_field       USING 'BDC_OKCODE' 
'=BU'. 
PERFORM bdc_field       USING 'BDC_CURSOR' 
'RESBD-POTX1'. 
PERFORM bdc_field       USING 'RESBD-POTX1' 
p_gs_zstypf-potx1. 
PERFORM bdc_field       USING 'RESBD-SANKA' 
'X'. 
PERFORM bdc_dynpro      USING 'SAPLCOMD' '0110'. 
PERFORM bdc_field       USING 'BDC_OKCODE' 
'=BU'. 
CALL TRANSACTION 'CO02' USING bdcdata 
MODE   'N' 
UPDATE 'S' 
MESSAGES INTO messtab. 
ENDFORM.                    " PRM_ADD_BOM_LINE

原创文章,作者:奋斗,如若转载,请注明出处:https://blog.ytso.com/18714.html

(0)
上一篇 2021年7月19日
下一篇 2021年7月19日

相关推荐

发表回复

登录后才能评论