Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

ERROR MESSGAE CLASS IN BAPI

anilkumar_raina
Participant
0 Likes
965

CAN U TELL ME THE NAME OF ERROR MESSAGE CLASS OF THIS BAPI

BAPI_ACC_GL_POSTING_POST.

REGARDS

3 REPLIES 3
Read only

Former Member
0 Likes
759

There is no error message class as such for this....This will retun the errors after data is posted to SAP to variables. U should use ur defined message class in program and use this message class to output the errors.

Read only

0 Likes
759

hi,

There is no message class for error instead you need to add the error messages in return structure which is of type BAPIRET2.

Here O_RETURN is like BAPIRET2

    PERFORM fill_msg_struct_return
     TABLES o_return
      USING 'F5' 'E' 831 l_text i_doc_header-bus_act '' '' '' c_yes.


FORM FILL_MSG_STRUCT_RETURN
                TABLES  IO_RETURN STRUCTURE BAPIRET2
                 USING  I_MSGID
                        I_MSGTY
                        I_MSGNO
                        I_MSGTXT
                        I_MSGV1
                        I_MSGV2
                        I_MSGV3
                        I_MSGV4
                        I_GET_TXT.
  DATA:
    L_MSGID LIKE SY-MSGID,
    L_MSGNO LIKE SY-MSGNO,
    L_MSGTY LIKE SY-MSGTY,
    L_MSGV1 LIKE SY-MSGV1,
    L_MSGV2 LIKE SY-MSGV2,
    L_MSGV3 LIKE SY-MSGV3,
    L_MSGV4 LIKE SY-MSGV4.

* Start Add constant Line VMARTI HD03250050
CONSTANTS: c_line(4)           TYPE c VALUE 'Line',
           c_ki_msg_cls(2)     TYPE c VALUE 'KI',
           c_ki_msg_cls_wbs(2) TYPE c VALUE 'CJ',
           c_ki_msg_no(3)      TYPE c VALUE '260',
           c_ki_msg_no_wbs(3)  TYPE c VALUE '001',
           c_ki_msg_typ(1)     TYPE c VALUE 'E'.
* End Add constant Line VMARTI HD03250050


  IF I_GET_TXT = C_YES.
    L_MSGID = I_MSGID.
    L_MSGNO = I_MSGNO.
    L_MSGTY = I_MSGTY.
    L_MSGV1 = I_MSGV1.
    L_MSGV2 = I_MSGV2.
    L_MSGV3 = I_MSGV3.
    L_MSGV4 = I_MSGV4.

*   Get message text
    CALL FUNCTION 'FI_MESSAGE_TEXT_GET'
         EXPORTING
              I_LANGU = SY-LANGU
              I_MSGID = L_MSGID
              I_MSGNO = L_MSGNO
              I_MSGTY = L_MSGTY
              I_MSGV1 = L_MSGV1
              I_MSGV2 = L_MSGV2
              I_MSGV3 = L_MSGV3
              I_MSGV4 = L_MSGV4
         IMPORTING
              E_MSGTX = I_MSGTXT.
  ENDIF.
* Start combine error msg w/ line number for blocked cost center VMARTI
* HD03250050
  IF L_MSGID EQ c_ki_msg_cls AND
     L_MSGNO EQ c_ki_msg_no  AND
     L_MSGTY EQ c_ki_msg_typ.
* PALIMA Begin
*     CONCATENATE c_line L_MSGV4 I_MSGTXT INTO I_MSGTXT
*         SEPARATED BY SPACE.

     CONCATENATE c_line L_MSGV4 'Cost Center' I_MSGV2 'is not valid.'
     INTO I_MSGTXT SEPARATED BY SPACE.
* PALIMA End

  ENDIF.
* HD03250050

* Start combine error msg w/ line number for WBS Element PALIMA
* HD03256741  - PALIMA
  IF L_MSGID EQ c_ki_msg_cls_wbs AND
     L_MSGNO EQ c_ki_msg_no_wbs AND
     L_MSGTY EQ c_ki_msg_typ.
     clear I_MSGTXT.
     CONCATENATE c_line L_MSGV4 'WBS Element' I_MSGV2 'is not valid.'
     INTO I_MSGTXT SEPARATED BY SPACE.
  ENDIF.
* HD03256741  - PALIMA

* Clear Header line
  CLEAR IO_RETURN.
* Move data.
  IO_RETURN-ID         = I_MSGID. "Message ID
  IO_RETURN-TYPE       = I_MSGTY. "Message type
  IO_RETURN-NUMBER     = I_MSGNO. "Message number
  IO_RETURN-MESSAGE    = I_MSGTXT."Message number
  IO_RETURN-MESSAGE_V1 = I_MSGV1. "Message variables1
  IO_RETURN-MESSAGE_V2 = I_MSGV2. "Message variables2
  IO_RETURN-MESSAGE_V3 = I_MSGV3. "Message variables3
  IO_RETURN-MESSAGE_V4 = I_MSGV4. "Message variables4
* Save (append) data.
  APPEND IO_RETURN TO IO_RETURN.
ENDFORM.                           " FILL_RETURN

Hope this helps.

Regards,

Richa.

Read only

former_member283648
Participant
0 Likes
759

Hi,

The return structure will have the message class from which the error is raised. That u can reuse by looping at this return parameter table.