The problem is connected with two global tables GT_XVEKP and GT_XVEPO
which are not cleared after calling FM. They get cleared when you exit your
program but once you use it this FM they exists and are not cleared.
These tables should be cleared before or after executing this function module.
However, this tables does not exists if the FM has not been executed therefore
I clear them just after calling FM. Clearing these tables "after" ensures that these
tables exists and there is no error with field symbol assigning.
CALL FUNCTION 'HU_PER_DOCUMENT_READ' | ||
EXPORTING | ||
it_objects = it_objects | ||
IMPORTING | ||
it_objects = it_objects | ||
et_highest = et_highest | ||
et_header = et_header | ||
et_item | = et_item | |
et_history = et_history | ||
et_messages = et_messages | ||
EXCEPTIONS | ||
error | = 01 | |
others | = 99. |
* | clear GT_XVEKP and GT_XVEPO so when next time HU_PER_DOCUMENT_READ |
* | executed it will return updated results |
FIELD-SYMBOLS: <fs_gt_xvekp> TYPE ANY. | |
FIELD-SYMBOLS: <fs_gt_xvepo> TYPE ANY. |
ASSIGN ('(SAPLV51P)GT_XVEKP[]') TO <fs_gt_xvekp>. | |
ASSIGN ('(SAPLV51P)GT_XVEPO[]') TO <fs_gt_xvepo>. |
CLEAR <fs_gt_xvekp>. | |
CLEAR <fs_gt_xvepo>. |
Please note, that there is no problem if you use this FM in your code only once.
However - if you use it several times (for example after refreshing ALV) and you
change HUs - the FM will return old values.
This problem is also described very well here but with different solution
http://zevolving.com/2012/12/think-sap-is-bug-free-not-really/
In my opinion this problem applies to FMs in function group V51E
(at least HU_PER_DOCUMENT_READ and HU_GET_HUS)
Keywords: HU_PER_DOCUMENT_READ, HU_GET_HUS, NOT UPDATED VALUES,
ET_ITEM, ET_HEADER, ET_HIGHEST, ET_HISTORY, ET_MESSAGES
Best regards,
Kordian