[SAP ABAP] - Read PO (Purchase Order) Error Message

FUNCTION yofm_read_po_error_log.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  IMPORTING
*"     VALUE(EBELN) LIKE  EKPO-EBELN OPTIONAL
*"     VALUE(ERROR_ONLY) TYPE  CHAR1 DEFAULT 'X'
*"  TABLES
*"      RETURN STRUCTURE  YST_RETURN OPTIONAL
*"----------------------------------------------------------------------

  DATA li_message LIKE STANDARD TABLE OF balm WITH HEADER LINE.
  DATA lv_extnumber LIKE balhdr-extnumber.

  lv_extnumber ebeln.

  CALL FUNCTION 'APPL_LOG_READ_DB'
    EXPORTING
      object           'MMPUR'
      subobject        'BUS2012'
      external_number  lv_extnumber
      transaction_code 'ME23N'
    TABLES
      messages         li_message.
  IF error_only 'X'.
    DELETE li_message WHERE NOT msgty 'E'.
  ENDIF.

  LOOP AT li_message.

    return-type li_message-msgty.

    CALL FUNCTION 'RPY_MESSAGE_COMPOSE'
      EXPORTING
        language                sy-langu
        message_id              li_message-msgid
        message_number          li_message-msgno
        message_var1            li_message-msgv1
        message_var2            li_message-msgv2
        message_var3            li_message-msgv3
        message_var4            li_message-msgv4
      IMPORTING
        message_text            return-message_v1
*    TABLES
*      LONGTEXT                =
      EXCEPTIONS
        message_not_found       1
        OTHERS                  2.

    APPEND return.

  ENDLOOP.

ENDFUNCTION.

YST_RETURN

 
 

Comments