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

Errors For BDC: urgent

Former Member
0 Likes
661

Hi Folks,

I am creating new material through BDC,now i wanted to know how to go with error log for the materials which failed during the process.

Could anyone please help me with the code for this?

i)For the error process I am collectign all the errors meanin the material which failed and sending them as an email to the users.

ii)I want all the materials which are created to be displayed in the spool.

could anyone one of you please help in this processign with the code.

4 REPLIES 4
Read only

Former Member
0 Likes
623

Hi

It depends on how you're running your BDC, if you're using CALL TRANSACTION you need only to check sy-subrc.

CALL TRANSACTION 'MM01' USING T_BDC.

IF SY-SUBRC = 0.

WRITE: 'Material:', <.....>, 'is loaded successfully'.

ELSE.

-


> SEND MAIL

ENDIF.

Max

Read only

0 Likes
623

For errors you have to explicitly mention in your call

CALL TRANSACTION - bdc_options

Syntax

... { {[MODE mode] [UPDATE upd]}

| [OPTIONS FROM opt] }

[MESSAGES INTO itab] ... .

Extras:

1. MODE mode

2. UPDATE upd

3. OPTIONS FROM opt

4. MESSAGES INTO itab

Check the following thread to get an idea:

hith

Sunil Achyut

Read only

Former Member
0 Likes
623

1. For Sending mail u can use the following code

FORM send_mail USING p_y16m_rcp_par STRUCTURE y16m_rcp_par.

  • Have a subject for the mail

g_s_document_data-obj_name = text-t02.

g_s_document_data-obj_descr = text-t03.

  • Fill receiver information

g_s_receivers-rec_type = p_y16m_rcp_par-rec_type.

g_s_receivers-rec_id = p_y16m_rcp_par-rec_id.

g_s_receivers-express = 'X'.

APPEND g_s_receivers TO g_t_receivers.

  • Call function to send mail

CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'

EXPORTING

document_data = g_s_document_data

document_type = 'RAW'

  • PUT_IN_OUTBOX = ' '

  • IMPORTING

  • SENT_TO_ALL =

  • NEW_OBJECT_ID =

TABLES

  • OBJECT_HEADER =

object_content = g_t_object_content

  • CONTENTS_HEX =

  • OBJECT_PARA =

  • OBJECT_PARB =

receivers = g_t_receivers

EXCEPTIONS

too_many_receivers = 1

document_not_sent = 2

document_type_not_exist = 3

operation_no_authorization = 4

parameter_error = 5

x_error = 6

enqueue_error = 7

OTHERS = 8

.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

ENDFORM.

2. For sending to Spool use the following code

FORM write_to_spool.

DATA : l_f_list_name LIKE pri_params-plist,

l_f_destination LIKE pri_params-pdest,

l_f_spld LIKE usr01-spld,

l_f_layout LIKE pri_params-paart,

l_f_line_count LIKE pri_params-linct,

l_f_line_size LIKE pri_params-linsz,

l_f_out_parameters LIKE pri_params,

l_f_valid.

l_f_line_size = 255.

l_f_line_count = 65.

l_f_layout = 'X_65_255'.

l_f_list_name = sy-repid.

  • to get defult spool device for the user

SELECT SINGLE spld INTO l_f_spld FROM usr01 WHERE bname = sy-uname.

IF sy-subrc = 0.

MOVE l_f_spld TO l_f_destination.

ENDIF.

CALL FUNCTION 'GET_PRINT_PARAMETERS'

EXPORTING

  • ARCHIVE_ID = C_CHAR_UNKNOWN

  • ARCHIVE_INFO = C_CHAR_UNKNOWN

  • ARCHIVE_MODE = C_CHAR_UNKNOWN

  • ARCHIVE_TEXT = C_CHAR_UNKNOWN

  • AR_OBJECT = C_CHAR_UNKNOWN

  • ARCHIVE_REPORT = C_CHAR_UNKNOWN

  • AUTHORITY = C_CHAR_UNKNOWN

  • COPIES = C_NUM3_UNKNOWN

  • COVER_PAGE = C_CHAR_UNKNOWN

  • DATA_SET = C_CHAR_UNKNOWN

  • DEPARTMENT = C_CHAR_UNKNOWN

destination = l_f_destination

  • EXPIRATION = C_NUM1_UNKNOWN

immediately = 'X'

  • IN_ARCHIVE_PARAMETERS = ' '

  • IN_PARAMETERS = ' '

layout = l_f_layout

line_count = l_f_line_count

line_size = l_f_line_size

list_name = l_f_list_name

  • LIST_TEXT = C_CHAR_UNKNOWN

  • MODE = ' '

  • NEW_LIST_ID = C_CHAR_UNKNOWN

  • NO_DIALOG = C_FALSE

  • RECEIVER = C_CHAR_UNKNOWN

  • RELEASE = C_CHAR_UNKNOWN

  • REPORT = C_CHAR_UNKNOWN

  • SAP_COVER_PAGE = C_CHAR_UNKNOWN

  • HOST_COVER_PAGE = C_CHAR_UNKNOWN

  • PRIORITY = C_NUM1_UNKNOWN

  • SAP_OBJECT = C_CHAR_UNKNOWN

  • TYPE = C_CHAR_UNKNOWN

  • USER = SY-UNAME

IMPORTING

  • OUT_ARCHIVE_PARAMETERS =

out_parameters = l_f_out_parameters

valid = l_f_valid

EXCEPTIONS

archive_info_not_found = 1

invalid_print_params = 2

invalid_archive_params = 3

OTHERS = 4

.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

IF l_f_valid NE space.

NEW-PAGE PRINT ON PARAMETERS l_f_out_parameters.

WRITE : /5 'Material No.',

25 'Message Type',

40 'Message Issued'.

ULINE.

LOOP AT g_t_message_table WHERE type = 'E'.

WRITE : / g_t_message_table-matnr UNDER 'Material No.',

g_t_message_table-type UNDER 'Message Type',

g_t_message_table-message UNDER 'Message Issued'.

ENDLOOP.

NEW-PAGE PRINT OFF.

ENDIF.

ENDFORM. " WRITE_TO_SPOOL

Hope this helps.

Regards

Read only

Bema
Active Participant
0 Likes
623

hi ,

If you are using CALL TRANSACTION method

CALL TRANSACTION tcode USING bdcdata

MODE ctumode

UPDATE cupdate

MESSAGES INTO messtab.

l_subrc = sy-subrc.

SELECT SINGLE * FROM t100 WHERE sprsl = messtab-msgspra

AND arbgb = messtab-msgid

AND msgnr = messtab-msgnr.

IF sy-subrc = 0.

l_mstring = t100-text.

IF messtab-msgtyp = 'E'.

IF l_mstring CS '&1'.

REPLACE '&1' WITH messtab-msgv1 INTO l_mstring.

REPLACE '&2' WITH messtab-msgv2 INTO l_mstring.

REPLACE '&3' WITH messtab-msgv3 INTO l_mstring.

REPLACE '&4' WITH messtab-msgv4 INTO l_mstring.

ELSEIF l_mstring CS '&'.

REPLACE '&' WITH messtab-msgv1 INTO l_mstring.

REPLACE '&' WITH messtab-msgv2 INTO l_mstring.

REPLACE '&' WITH messtab-msgv3 INTO l_mstring.

REPLACE '&' WITH messtab-msgv4 INTO l_mstring.

ENDIF.

CONDENSE l_mstring.

WRITE: /4 l_mstring(250).

******Send mail.

ELSEIF messtab-msgtyp = 'S'.

  • cnt_success = cnt_success + 1.

IF l_mstring CS '&1'.

REPLACE '&1' WITH messtab-msgv1 INTO l_mstring.

REPLACE '&2' WITH messtab-msgv2 INTO l_mstring.

REPLACE '&3' WITH messtab-msgv3 INTO l_mstring.

REPLACE '&4' WITH messtab-msgv4 INTO l_mstring.

ELSEIF l_mstring CS '&'.

REPLACE '&' WITH messtab-msgv1 INTO l_mstring.

REPLACE '&' WITH messtab-msgv2 INTO l_mstring.

REPLACE '&' WITH messtab-msgv3 INTO l_mstring.

REPLACE '&' WITH messtab-msgv4 INTO l_mstring.

ENDIF.

CONDENSE l_mstring.

write l_mstring.

endif.

endif.