Application Development 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: 

how to display error messages in BAPI_PO_CHANGE with PO and item ?

Former Member
0 Kudos
1,070

Hello Friends,

I am calling BAPI_PO_CHANGE to update delivery flag for 50 POs.

Each PO has 4 line items. For ex.

10001 10 5.00 material1 X

10001 20 45.00 material2 X

10001 30 22.00 material15 X u201Cerror

10001 40 45.00 material41 X

10002 10 46.00 material17 X

10002 20 25.00 material3 X u201Cerror

10002 30 75.00 material5 X u201Cerror

10002 40 44.00 material8 X

u2026u2026u2026u2026u2026..

u2026u2026u2026u2026u2026

Now, suppose some line items have error.

I am able to get it from BAPIu2019s RETURN table.

But how can I display that error message with PO and line item?

NOTE : I am calling BAPI_PO_CHANGE for each PO with ITEM internal table.

Please guide me.

Regards

RH

1 ACCEPTED SOLUTION

Former Member
0 Kudos
283

Thanks !!

7 REPLIES 7

Former Member
0 Kudos
283

Hi

IN every BAPI there is a BAPIRETURN structre to hande errors.

Declare this BAPIRETURN in yiour declarations.

Use to this the

FORMAT_MESSAGE FM

pass the BAPIRETURN structure to read the error messages.

Here this BAPIRETURN will only state the error but not the Exact error.

In the SY-SUBRC of this BAPI for each line tiem append the same error record into other internal table this way we can do it.

Thanks & Regards,

Chandralekha.

0 Kudos
283

Thanks for the ideas but chandralekha,

Will put some code to understand ?

former_member223537
Active Contributor
0 Kudos
283

Hi Ronny,

You will have to capture the error line items into an internal table. Keep on appending the internal table inside the loop.

Once all the data is processed, check whether the error internal table is not empty & then loop over it & use write statments to display the entire list of error messages.

Best regards,

Prashant

Former Member
0 Kudos
283

Use FM FORMAT_MESSAGE .. and format your message ..

this shows message with PO and line item

call function 'FORMAT_MESSAGE'

exporting

id = sy-msgid

lang = sy-langu

no = sy-msgno

v1 = sy-msgv1

v2 = sy-msgv2

v3 = sy-msgv3

v4 = sy-msgv4

importing

msg = l_msg

exceptions

not_found = 1

others = 2.

Former Member
0 Kudos
283
  • BAPI Messages

Loop At TB_RETURN Into X_RETURN.

Perform CREATE_LOG Using X_RETURN-ID

X_RETURN-NUMBER

X_RETURN-TYPE

X_RETURN-MESSAGE_V1

X_RETURN-MESSAGE_V2

X_RETURN-MESSAGE_V3

X_RETURN-MESSAGE_V4.

EndLoop.

----


  • Form CREATE_LOG

----


FORM CREATE_LOG USING P_MSGID "Type MSGID

P_MSGNO "Type MSGNO

P_MSGTY "Type MSGTY

P_MSGV1 "Type MSGV1

P_MSGV2 "Type MSGV1

P_MSGV3 "Type MSGV1

P_MSGV4."Type MSGV1.

Data: L_MSG Type String,

L_INDENT(05) Type C Value '-->'.

Clear X_TEXT.

  • Call function to Prepare Message

CALL FUNCTION 'FORMAT_MESSAGE'

EXPORTING

ID = P_MSGID

LANG = Sy-LANGU

NO = P_MSGNO

V1 = P_MSGV1

V2 = P_MSGV2

V3 = P_MSGV3

V4 = P_MSGV4

IMPORTING

MSG = L_MSG

EXCEPTIONS

NOT_FOUND = 1

OTHERS = 2.

Write: / L_MSG.

EndForm

santhosh

Former Member
0 Kudos
284

Thanks !!

0 Kudos
283

The it_change_return fields parameter and row identify the PO_ITEM.

Try this...

&----


*& Form READ_MESSAGES_OP_CHANGE

&----


  • BAPI_PO_CHANGE Return messages

----


FORM read_messages_op_change .

DELETE it_change_return WHERE type = 'W'.

DELETE it_change_return WHERE type = 'I'.

LOOP AT it_change_return ASSIGNING <is_change_return>.

IF <is_change_return>-type = 'E'.

z_error_flg = 'X'.

ENDIF.

v_item = v_item + 1.

it_log_mess-packagenr = v_packagenr.

it_log_mess-object = v_object.

it_log_mess-docnum = v_docnum.

it_log_mess-itemnr = v_item.

it_log_mess-type = <is_change_return>-type.

it_log_mess-id = <is_change_return>-id.

it_log_mess-mnumber = <is_change_return>-number.

IF <is_change_return>-parameter <> 'POITEM'.

it_log_mess-message = text-po1.

REPLACE '&' WITH z_po_number INTO it_log_mess-message.

CONCATENATE it_log_mess-message <is_change_return>-message

INTO it_log_mess-message SEPARATED BY space.

ELSE.

READ TABLE it_change_poitem ASSIGNING <is_change_poitem>

INDEX <is_change_return>-row.

it_log_mess-message = text-pr2.

REPLACE '&' WITH z_po_number INTO it_log_mess-message.

REPLACE '@' WITH <is_change_poitem>-po_item

INTO it_log_mess-message.

CONCATENATE it_log_mess-message <is_change_return>-message

INTO it_log_mess-message SEPARATED BY space.

ENDIF.

it_log_mess-message_v1 = <is_change_return>-message_v1.

it_log_mess-message_v2 = <is_change_return>-message_v2.

it_log_mess-message_v3 = <is_change_return>-message_v3.

it_log_mess-message_v4 = <is_change_return>-message_v4.

APPEND it_log_mess.

ENDLOOP.

ENDFORM. " READ_MESSAGES_OP_CHANGE