简体   繁体   English

在 User-Exit 中的测试失败时取消 Post Good Issue 的处理

[英]Cancel Processing of Post Good Issue when test in User-Exit fails

I am currently working on some checks for the SAP transaction vl02n and I want to check batches and if their date of expiration fits some criteria.我目前正在对 SAP 事务vl02n进行一些检查,我想检查批次以及它们的到期日期是否符合某些标准。

For this I am using the user-exit SAVE_DOCUMENT_PREPARE .为此,我使用用户出口SAVE_DOCUMENT_PREPARE If the checks fail there shall be an ALV-grid which contains the faulty positions.如果检查失败,则应有一个包含错误位置的 ALV 网格。 The processing of PGI has to be interrupted.必须中断 PGI 的处理。

My problem is when testing these faulty batches I get an error like this:我的问题是在测试这些有问题的批次时,我收到如下错误:

Risk of posting several mat.documents for one delivery->long text.为一个交付-> 长文本发布多个 mat.document 的风险。

I read an article which said you should use the command ROLLBACK WORK but I am not quite sure if this would work case I think there was no COMMIT until know...我读过一篇文章,说你应该使用命令ROLLBACK WORK但我不太确定这是否可行,我认为在知道之前没有 COMMIT ...

This is what I got so far (ROLLBACK WORK is not tested so far).这是我到目前为止所得到的(到目前为止尚未测试 ROLLBACK WORK)。

[...]

IF lt_faulty_lips IS NOT INITIAL.

" Titel des ALV-Grid abhaengig von der Sprache festlegen
IF sy-langu EQ 'D'.
  lv_grid_title = 'Verfallsdatum folgender Positionen zu klein.'.
ELSE.
  lv_grid_title = 'Expiration date of the following items too small.'.
ENDIF.

" Grid-Title setzen
MESSAGE s001(zamm) INTO lv_grid_title.

" Fehler-Message ausgeben
MESSAGE s000(zamm) DISPLAY LIKE 'E'.

" is this possible?
"ROLLBACK WORK.

" ALV-Grid mit fehlerhaften Positionen ausgeben
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
  EXPORTING
    i_grid_title       = lv_grid_title
    i_callback_program = 'SY-REPID'
    i_structure_name   = 'LIPSVB'
    is_layout          = gs_alv_layout
  TABLES
    t_outtab           = lt_faulty_lips
  EXCEPTIONS
    program_error      = 1
    OTHERS             = 2.
IF sy-subrc <> 0.
  " Implement suitable error handling here
ENDIF.



" nochmals Message-Ausgabe im Hauptbild
MESSAGE e000(zamm) DISPLAY LIKE 'E'.

How could I solve this?我怎么能解决这个问题?

Thanks a lot, every hint is appreciated!非常感谢,每个提示都值得赞赏!

you raise a message with type E. This exits the program and you don't even reach your ALV.你用类型 E 发出一条消息。这会退出程序,你甚至没有到达你的 ALV。 Change the Message to this: MESSAGE s001(zamm) TYPE 'I' DISPLAY LIKE 'E'.将消息更改为:MESSAGE s001(zamm) TYPE 'I' DISPLAY LIKE 'E'。

If this doesn't help, either change the Message to ...DISPLAY LIKE I, after the user confirms, the report should progress.如果这没有帮助,请将 Message 更改为 ...DISPLAY LIKE I,在用户确认后,报告应该继续进行。

regards问候

So like I promised here is my solution:所以就像我在这里承诺的那样是我的解决方案:

we used an already existing imlementation of the Interface IF_EX_LE_SHP_GOODSMOVEMENT .我们使用了接口IF_EX_LE_SHP_GOODSMOVEMENT 的现有实现

In this Interface there is a method called CHANGE_INPUT_HEADER_AND_ITEMS .在这个接口中有一个叫做CHANGE_INPUT_HEADER_AND_ITEMS的方法。

Here we do our checks for the specific criteria.在这里,我们对特定标准进行检查。 After this we fill a declared structure ls_errlog of the type SHP_BADI_ERROR_LOG with the faulty positions.在此之后,我们用错误位置填充类型为SHP_BADI_ERROR_LOG的声明结构ls_errlog Important fields are the following:重要字段如下:

ls_errlog-msgty = 'E'.
ls_errlog-msgid = '<message-class>'.
ls_errlog-msgno = '<message-number'.

Then we append this structure to the table ct_log .然后我们将此结构附加到表ct_log

The result is that if there are positions which don't fit our criteria the PGI will be interrupted and the faulty positions will be shown in an ALV-Grid.结果是,如果存在不符合我们标准的位置,PGI 将被中断,错误位置将显示在 ALV-Grid 中。

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

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