2008 Jul 25 12:16 PM
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
2008 Sep 09 3:10 PM
2008 Jul 25 12:17 PM
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.
2008 Jul 25 12:50 PM
Thanks for the ideas but chandralekha,
Will put some code to understand ?
2008 Jul 25 12:18 PM
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
2008 Jul 25 12:20 PM
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.
2008 Jul 25 12:57 PM
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
2008 Sep 09 3:10 PM
2010 Jan 12 4:54 PM
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