简体   繁体   中英

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.

For this I am using the user-exit SAVE_DOCUMENT_PREPARE . If the checks fail there shall be an ALV-grid which contains the faulty positions. The processing of PGI has to be interrupted.

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.

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...

This is what I got so far (ROLLBACK WORK is not tested so far).

[...]

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. Change the Message to this: 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.

regards

So like I promised here is my solution:

we used an already existing imlementation of the Interface IF_EX_LE_SHP_GOODSMOVEMENT .

In this Interface there is a method called 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. 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 .

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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