本文主要是介绍SAP ABAP MIGO交货单gohead-LFSNR字段增强,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
需求:根据采购订单供应商信息,自动填充交货单字段。
效果:
经过DEBUG及翻译资料。并无合适的增强用来做增强。所以可以采用隐士增强的方式来实现功能。
se38:LMIGOHG2 找到 METHOD pai. 。
创建增强实施:
*$*$-Start: (1)---------------------------------------------------------------------------------$*$*
ENHANCEMENT 1 ZEP_LMIGOHG2. "active version
*自动生成交货单号 。
*103收货订单类型:ZNB1\ZNB2\ZNB3\ZNB4\ZNB5\ZNB6\ZNB9\ZNBF\ZNBX\ZNBY
*101收货订单类型:ZNB7\ZNB8
*号码规则:供应商+系统的六位年月日+两位流水(根据供应商送货次数来)
*两位流水:如果此供应商一次送了三张采购订单,则是三位流水,三次送货也是三位流水。DATA:LS_EKKO TYPE EKKO.DATA:LV_XBLNR TYPE MKPF-XBLNR .DATA:LV_STR TYPE CHAR02 .DATA:LV_STRS TYPE CHAR02 .DATA:LV_NUM TYPE N LENGTH 2 .DATA:LV_BSART TYPE EKKO-BSART .DATA:LV_LIFNR TYPE EKKO-LIFNR.BREAK ZWANGGF.if gohead-LFSNR is INITIAL and sy-tcode eq 'MIGO'.IF GODYNPRO-ACTION EQ 'A01' AND godynpro-REFDOC EQ 'R01' AND godynpro-PO_NUMBER IS NOT INITIAL .
*自动生成交货单号 。
*103收货订单类型:ZNB1\ZNB2\ZNB3\ZNB4\ZNB5\ZNB6\ZNB9\ZNBF\ZNBX\ZNBY
*101收货订单类型:ZNB7\ZNB8
*号码规则:供应商+系统的六位年月日+两位流水(根据供应商送货次数来)
*两位流水:如果此供应商一次送了三张采购订单,则是三位流水,三次送货也是三位流水。CLEAR LV_BSART .SELECT SINGLE * INTO LS_EKKO FROM EKKOWHERE EBELN = godynpro-PO_NUMBER.LV_BSART = LS_EKKO-BSART .FIND LV_BSART IN 'ZNB1\ZNB2\ZNB3\ZNB4\ZNB5\ZNB6\ZNB9\ZNBF\ZNBX\ZNBY\ZNB7\ZNB8' .IF SY-SUBRC = 0 .
*查询已经流水的记录。CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'EXPORTINGINPUT = LS_EKKO-LIFNRIMPORTINGOUTPUT = LV_LIFNR.CONCATENATE LV_LIFNR SY-DATUM+2(6) '*' INTO LV_XBLNR .SELECTMKPF~MBLNR,MKPF~XBLNRINTO TABLE @DATA(LT_HIS)FROM MKPF INNER JOIN MSEG ON MSEG~MBLNR EQ MKPF~MBLNR AND MSEG~MJAHR EQ MKPF~MJAHRWHEREMKPF~CPUDT EQ @SY-DATUMAND MKPF~VGART EQ 'WE'AND MSEG~LIFNR EQ @LS_EKKO-LIFNR .
*获取系统中的记录数据。DELETE LT_HIS WHERE XBLNR NP LV_XBLNR .SORT LT_HIS BY XBLNR DESCENDING .LOOP AT LT_HIS INTO DATA(LS_HIS) .LV_STR = LS_HIS-XBLNR+13(2) .CALL FUNCTION 'CATS_NUMERIC_INPUT_CHECK'EXPORTINGINPUT = LV_STR
* INTERNAL = 'X'IMPORTINGOUTPUT = LV_STRSEXCEPTIONSNO_NUMERIC = 1
* OTHERS = 2.IF SY-SUBRC <> 0.CONTINUE .ELSE .LV_NUM = LV_STR .EXIT .ENDIF.ENDLOOP .IF LV_NUM IS INITIAL .LV_NUM = 01 .ELSE .LV_NUM = LV_NUM + 1 .ENDIF .CONCATENATE LV_LIFNR SY-DATUM+2(6) LV_NUM INTO gohead-LFSNR .ENDIF .ENDIF .endif .
ENDENHANCEMENT.
如果通过MIGO_DIALOG函数跳转,需要设置 I_REF_DOC_NO参数即可。
这篇关于SAP ABAP MIGO交货单gohead-LFSNR字段增强的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!