Manejo de mensajes en BADI ME_PROCESS_PO_CUST (Orden de Compra)

En el Método Check de la BADI ME_PROCESS_PO_CUST, podemos realizar chequeos y validaciones. El tema es que si utilizamos la sentencia “MESSAGE” el error aparecerá en la última posición del pedido. Nosotros debemos controlar el error en que posición o si es de cabecera.

Dejo un ejemplo de como sería el caso de mostrar error en una determinada posición o a nivel cabecera

Agregar el Include “MM_MESSAGES_MAC”. Nos servirá para tener las macros disponibles.

INCLUDE MM_MESSAGES_MAC.

DATA: LS_HEADER TYPE MEPOHEADER.
DATA: LT_ITEMS      TYPE  PURCHASE_ORDER_ITEMS,
      LS_ITEMS      TYPE  LINE OF PURCHASE_ORDER_ITEMS,
      LS_ITEM       TYPE  REF TO IF_PURCHASE_ORDER_ITEM_MM,
      LS_MEPOITEM   TYPE  MEPOITEM.

*Cabecera

LS_HEADER = IM_HEADER->GET_DATA( ).

“Si no se cumple la validación

MMPUR_BUSINESS_OBJ_ID LS_HEADER-ID. " ID cabecera
CALL METHOD IM_HEADER->INVALIDATE( ).
MMPUR_MESSAGE_FORCED ‘E’
                                            ‘ZMEN’ ‘000’
                                            ‘texto’
                                            ”
                                            ”
                                            ”.
CH_FAILED = ‘X’.

*Posiciones

LT_ITEMS = IM_HEADER->GET_ITEMS( ).

LOOP AT LT_ITEMS INTO LS_ITEMS.

    LS_ITEM ?= LS_ITEMS-ITEM.
    LS_MEPOITEM = LS_ITEM->GET_DATA( ).

“Si no se cumple la validación"

MMPUR_BUSINESS_OBJ_ID LS_MEPOITEM-ID. " ID del item
CALL METHOD LS_ITEM->INVALIDATE( ).
MMPUR_MESSAGE_FORCED ‘E’
                                            ‘ZGIC’ ‘000’
                                            ‘texto error’
                                            ”
                                            ”
                                            ”.
CH_FAILED = ‘X’. “Evita que permita grabar

ENDLOOP.

Posted in ABAP, BADI, MM. 1 Comment »

One Response to “Manejo de mensajes en BADI ME_PROCESS_PO_CUST (Orden de Compra)”

  1. lose belly fat pills Says:

    If you are going for most excellent contents like me, only pay a visit this
    site all the time because it gives feature contents, thanks


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: