简体   繁体   English

对于自定义表,通过转换出口转换 MATNR 失败

[英]Converting MATNR via conversion exit fails for custom table

I'm trying to select the latest date of a material movement from MSEG, but the material needs to be in stock and that is sourced from a bespoke table which uses unconverted Material names.我正在尝试从 MSEG 中选择材料移动的最新日期,但材料需要有库存,并且来自使用未转换材料名称的定制表。

I've tried using the CALL FUNCTION 'CONVERSION_EXIT_MATN1_OUTPUT' (and INPUT ) but I'm not sure how to properly utilize it in a select statement.我试过使用CALL FUNCTION 'CONVERSION_EXIT_MATN1_OUTPUT' (和INPUT ),但我不确定如何在选择语句中正确使用它。

IF MSEG-BWART = '101'.

  CALL FUNCTION 'CONVERSION_EXIT_MATN1_OUTPUT'
    EXPORTING
      INPUT  = ZBJSTOCK-ZMAT10
    IMPORTING
      OUTPUT = WA2-MATNR.

  SELECT MAX( BUDAT_MKPF )
  FROM MSEG
  INTO GRDT
  WHERE MATNR = WA2-MATNR.

ENDIF.

Currently, WA2-MATNR seems to come out as blank and therefore is not pulling the data from MSEG.目前, WA2-MATNR似乎是空白的,因此没有从 MSEG 中提取数据。

You shouldn't use conversion exit here.你不应该在这里使用转换出口。 Material number in SAP tables lays in internal (INPUT) format and you are converting it into readable format (OUTPUT) in order to query table. SAP 表中的物料编号采用内部 (INPUT) 格式,您将其转换为可读格式 (OUTPUT) 以查询表。 It is obvious you will not find anything.很明显你不会找到任何东西。

Sample:样本:

MATNR internal format (for OUT exits) MATNR 内部格式(用于 OUT 出口)

000000000000025567 000000000000025567

MATNR external format (for IN exits) MATNR 外部格式(用于 IN 出口)

25567 25567

Conversions cases:转换案例:

000000000000025567 -> CONVERSION_EXIT_MATN1_OUTPUT -> 25567 ✔️ 000000000000025567 -> CONVERSION_EXIT_MATN1_OUTPUT -> 25567 ✔️

25567 -> CONVERSION_EXIT_MATN1_OUTPUT -> 25567 ❌ nothing changes 25567 -> CONVERSION_EXIT_MATN1_OUTPUT -> 25567 ❌ 没有任何变化

25567 -> CONVERSION_EXIT_MATN1_INPUT -> 000000000000025567 ✔️ 25567 -> CONVERSION_EXIT_MATN1_INPUT -> 000000000000025567 ✔️

000000000000025567 -> CONVERSION_EXIT_MATN1_INPUT -> 000000000000025567 ❌ nng changes 000000000000025567 -> CONVERSION_EXIT_MATN1_INPUT -> 000000000000025567 ❌ nng 变化

Most likely, your bespoke table contains faulty material number so exit doesn't return anything.最有可能的是,您的定制表包含错误的材料编号,因此退出不会返回任何内容。 Or material number in format that exit doesn't expect, eg 19 characters instead of 18 and so on.或退出不期望格式的材料编号,例如 19 个字符而不是 18 个等等。

PS聚苯乙烯

Just for you info, you can use templates for conversion.仅供您参考,您可以使用模板进行转换。 It is the same as calling conversion FMs与调用转换FM相同

SELECT SINGLE matnr FROM mara INTO @DATA(l_matnr) WHERE EXISTS ( SELECT * FROM mseg WHERE matnr = mara~matnr ).

l_matnr = | { l_matnr ALPHA = OUT } |. <<-- templating

SELECT SINGLE matnr, budat_mkpf
  FROM mseg
  INTO @DATA(l_mkpf)
  WHERE matnr = @l_matnr.

In the above sample SELECT will not return anything, but if you comment out the template line it will.在上面的示例中 SELECT 不会返回任何内容,但是如果您注释掉模板行,它会返回。

Unless you've added code into the user exits in that function, it's not going to do what you want.除非您在该函数的用户出口中添加了代码,否则它不会执行您想要的操作。 The standard purpose of that function is to format the material number for display on the screen.该函数的标准用途是格式化材料编号以显示在屏幕上。

The quickest way to do what you want is to select from your custom table to do the lookup.执行所需操作的最快方法是从自定义表中进行选择以进行查找。

That said, there is a user exit in that function where you can code the select to do the lookup.也就是说,该函数中有一个用户出口,您可以在其中编写选择代码以进行查找。 The extra benefit of doing that is that your users will be able to type in the legacy material number and the system will switch it with the new one.这样做的额外好处是您的用户将能够输入旧物料编号,系统会将其切换为新编号。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM