Skip to Content

I got a (at least I thought) simple task to update a package instruction via BAPI.

So I started first with retrieving the data via BAPI_HU_PI_READ.

Then (first for testing purpose) I used this data to call the update BAPI_HU_PI_CHANGE.

And surprise it worked – not as I expected.

Normal packaging items (e.g. simple quantity change) worked fine. But we have as well some text items within our packaging instructions which I would not like to change.

Unfortunately calling the BAPI_HU_PI_CHANGE will delete the content of these text items – nevertheless how are you calling the BAPI.

Believe it or not SAP at least provided note 2250415.

Thus makes it impossible to change the package instruction via BAPI as you will get an error message that text items are not supported.

So there comes BAdI PL_PACK_INSTR_BADI where you can suppress the deletion of the text item.

Therefore i implemented method PACK_INSTR_BEFORE_SAVE:

DATA lt_packpo_del TYPE pi_t_packpo.
FIELD-SYMBOLS <ls_packpo> TYPE packpo.
FIELD-SYMBOLS <ls_cmvhupo> TYPE cmvhupo.

*     First check if it is called via BAPI
ASSIGN (‘(SAPLVHUPO)CMVHUPO’) TO <ls_cmvhupo>.
IF sysubrc = 0.
IF <ls_cmvhupo>nodia <> ‘X’.
RETURN.
ENDIF.
ELSE.
RETURN.
ENDIF.
IF packpo_del IS INITIAL.
RETURN.
ENDIF.
*    !BAPI deletes content oft text items
*    to suppress deletion remove insert und deletion entries
*    before database update happens
LOOP AT packpo_ins ASSIGNING <ls_packpo> WHERE paitemtype = c_postyp_text.
DELETE packpo_ins WHERE packitemid = <ls_packpo>packitemid.
ENDLOOP.

SELECT * FROM packpo INTO TABLE lt_packpo_del FOR ALL ENTRIES IN packpo_del
WHERE packitemid = packpo_delpackitemid
AND paitemtype = c_postyp_text.

LOOP AT lt_packpo_del ASSIGNING <ls_packpo>.
DELETE packpo_del WHERE packitemid = <ls_packpo>packitemid.
ENDLOOP.

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply