原文链接:https://blog.csdn.net/qq_45063256/article/details/128464411
增强点:程序LCTMSF3Z
在MIGO中点击批次右边的分类时,自动将该批次的批次特性值带出来。
现在打开程序LCTMSF3Z
该程序就只有一个FORM,首先切换到编辑模式,并点击菜单栏的增强
然后在ENDFORM处鼠标右键->增强操作->显示隐式增强
完成后会出现虚线,在虚线中点击鼠标右键->增强操作->创建实施
创建好之后双击创建的实施名字,就可以写代码了
具体实现代码如下:
可以关注一下该增强点程序的MI[] WS[]内表的值,批次特性值都存在WS[]中,而直接修改WS[]内表的值的话就会被重制为被修改前的状态,因为MI会影响WS。
因此下方代码主要是对MI[]进行修改,从而影响WS[]中批次特性值
ENHANCEMENT 3 Z_MM_MIGO_PCTX. "active versionIF MI[] IS NOT INITIAL AND WS[] IS NOT INITIAL AND SY-UCOMM <> 'ENDE'.DATA: INSTANCE LIKE DDB_C02-INSTANCE VALUE 1,VALUE LIKE CAWN-ATWRT,INTERNAL_VALUE LIKE CAWN-ATWRT,IMP_REDUN LIKE TCLAO-REDUN VALUE 'X'.
"这里的代码就是引用程序SAPLMIGO中GOHEAD工作区的值
"只需要引用批次特性值所需要的就可以了ASSIGN ('(SAPLMIGO)GOHEAD-BUDAT') TO FIELD-SYMBOL(<LFS_BUDAT>).IF SY-SUBRC <> 0. EXIT. ENDIF.ASSIGN ('(SAPLMIGO)GOITEM-EBELN') TO FIELD-SYMBOL(<LFS_EBELN>).IF SY-SUBRC <> 0. EXIT. ENDIF.ASSIGN ('(SAPLMIGO)GOITEM-EBELP') TO FIELD-SYMBOL(<LFS_EBELP>).IF SY-SUBRC <> 0. EXIT. ENDIF.ASSIGN ('(SAPLMIGO)GOITEM-MENGE') TO FIELD-SYMBOL(<LFS_MENGE>).IF SY-SUBRC <> 0. EXIT. ENDIF.ASSIGN ('(SAPLMIGO)GOITEM-LSMNG') TO FIELD-SYMBOL(<LFS_LSMNG>).IF SY-SUBRC <> 0. EXIT. ENDIF.LOOP AT MI INTO DATA(LS_MI) .CASE LS_MI-ATNAM.WHEN 'Z_MSEG_MENGE'."批次特性名VALUE = <LFS_MENGE>.WHEN 'Z_MSEG_LSMNG'.VALUE = <LFS_LSMNG>.WHEN 'Z_MKPF_BUDAT'.VALUE = <LFS_BUDAT>.WHEN 'Z_EKPO_EBELN'.VALUE = <LFS_EBELN>.WHEN 'Z_EKPO_EBELP'.VALUE = <LFS_EBELP>.WHEN OTHERS.CONTINUE.ENDCASE.CALL FUNCTION 'CUDB_GET_CURRENT_VAL'EXPORTINGATINN = LS_MI-ATINNINSTANCE = INSTANCEEXCEPTIONSINTERNAL_ERROR = 1NO_VALUE_FOUND = 2OTHERS = 3.IF SY-SUBRC <> 0.CALL FUNCTION 'CTMS_DDBI_SET_VALUE_OCHAR'EXPORTINGCHARACTERISTIC = LS_MI-ATINNVALUE = VALUEINTERNAL_VALUE = INTERNAL_VALUEIMP_REDUN = IMP_REDUNEXCEPTIONSVALUE_NOT_FOUND = 1OTHERS = 2.ENDIF.ENDLOOP.ENDIF.ENDENHANCEMENT.