2005 Apr 15 3:32 PM
Hi,
i´ve got the following code:
CLEAR: i_messages, i_bdcdata.
REFRESH: i_messages, i_bdcdata.
Execute transaction XXXX
LOOP AT i_lf1pro.
perform bdc_dynpro using '' ''.
......
call transaction 'XK02' using i_bdcdata
mode c_n
update c_s
messages into i_messages.
ENDLOOP.
Afterwards i want to display an identifying field of i_lf1pro with it´s corresponding message in an ALV.
The problem is that i´m not able to link this field to structure i_messages.
i´ve tried to replace i_messages with structure i_err where:
DATA: BEGIN OF i_err OCCURS 0,
DATA: newfield TYPE ...
INCLUDE STRUCTURE BDCMSGCOLL.
DATA: END OF i_mess.
LOOP AT i_lf1pro.
perform bdc_dynpro using '' ''.
......
MOVE i_lf1pro-newfield TO i_err-newfield.
call transaction 'XXXX' using i_bdcdata
mode c_n
update c_s
messages into i_err.
ENDLOOP.
but it doesn´t work.
How can i do it?
Best regards.
2005 Apr 15 3:58 PM
Hi Casadillo,
I think I know why it does not work.
1. When you place the CALL TRANSACTION statement inside the loop, the messages that were collected in the internal table i_messages will get overwritten by the new messages.
2. Also, adding the new field is a good approach, but the new field is not getting populated into the internal table at all.
Try out something like this.
DATA I_MESSAGES TYPE BDCMSGCOLL OCCURS 0 WITH HEADER LINE.
DATA: BEGIN OF I_ERROR_TABLE OCCURS 0,
DATA: NEWFIELD TYPE <XYZ>.
INCLUDE STRUCTURE BDCMSGCOLL.
DATA: END OF IERROR_TABLE.
LOOP AT I_LF1PRO.
PERFORM BDC_DYNPRO USING '' ''.
......
MOVE I_LF1PRO-NEWFIELD TO I_ERROR_TABLE-NEWFIELD.
CALL TRANSACTION 'XXXX' USING I_BDCDATA
MODE C_N
UPDATE C_S
MESSAGES INTO I_MESSAGES[].
LOOP AT I_MESSAGES.
MOVE-CORRESPONDING I_MESSAGES TO I_ERROR_TABLE.
APPEND I_ERROR_TABLE.
ENDLOOP.
ENDLOOP.
Regards,
Anand Mandalika.
2005 Apr 15 3:58 PM
Hi Casadillo,
I think I know why it does not work.
1. When you place the CALL TRANSACTION statement inside the loop, the messages that were collected in the internal table i_messages will get overwritten by the new messages.
2. Also, adding the new field is a good approach, but the new field is not getting populated into the internal table at all.
Try out something like this.
DATA I_MESSAGES TYPE BDCMSGCOLL OCCURS 0 WITH HEADER LINE.
DATA: BEGIN OF I_ERROR_TABLE OCCURS 0,
DATA: NEWFIELD TYPE <XYZ>.
INCLUDE STRUCTURE BDCMSGCOLL.
DATA: END OF IERROR_TABLE.
LOOP AT I_LF1PRO.
PERFORM BDC_DYNPRO USING '' ''.
......
MOVE I_LF1PRO-NEWFIELD TO I_ERROR_TABLE-NEWFIELD.
CALL TRANSACTION 'XXXX' USING I_BDCDATA
MODE C_N
UPDATE C_S
MESSAGES INTO I_MESSAGES[].
LOOP AT I_MESSAGES.
MOVE-CORRESPONDING I_MESSAGES TO I_ERROR_TABLE.
APPEND I_ERROR_TABLE.
ENDLOOP.
ENDLOOP.
Regards,
Anand Mandalika.
2005 Apr 15 5:43 PM
Hi all,
added to Anand answer, you can get the message text using FM MESSAGE_GET_TEXT and if you want to show only one message for call transacction (remember that call transaction get you back all the messages of the transacction in MESSAGES, warnings, informations...) you can ask for the ok message, and if it not exist, look for the message with type E (Error) and only put in table I_ERROR_TABLE one message, ok or error.
I hope it is useful,
Regards,
PabloX