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

Regarding BDC

Former Member
0 Likes
1,017

Hi friends

To capture errors in BDC call transaction i used BDCMSGCOLL .But i am not able to get errors even if i give wrong record in input file(presentaion server file) and when recording it is showing error wrong material number(for ex.) after when i exit that recording and return to program but it doesn't show what errors occured in output.

what type of errrors may be captured during processing in real time

I am in confusion plz help me

thanks & Regards

sandhya

7 REPLIES 7
Read only

Former Member
0 Likes
962

All the messages will be captured in bdcmsgcoll..

After call transaction, do not check for sy-subrc.. instead

loop at bdcmsgcoll .

if bdcmsgcoll-msgtyp = 'E' or bdcmsgcoll-msgtyp = 'W'

Function module.. FORMAT_MESSAGE.. and get the message text and print it on the screen...

endif.

endloop.

But remember not at all the error messages will have the msgtyp E or A or W.. Some of them can be I or S..

Read only

Former Member
0 Likes
962

Hi sandhya,

1. Suppose you have 5 records in file,

and the error comes only on the 1st and 2nd records.

2. then after the full bdc is done,

the BDCMSGCOLL will contain

errors (IF ANY) for the 5th record only.

3. In your case if 5th record is ok,

then it will be blank.

4. This happens bcos CALL TRANSACTION is called in a

loop 5 times.

5. U will have to , after each call transaction,

use anothr table just like bdcmsgcoll,

and append it to this new table.

regards,

amit m.

Read only

0 Likes
962

hi

Thanks

But I used Format_message too

I want to know what type of errors we get in real time when doing BDC

Thanks

Sandhya

Read only

0 Likes
962

Hi again,

1. what type of errors we get in real time when doing BDC

We get only those errors(if any)

which the transaction will issue

while doing data entry.

2. There are no separate set of errors

which will specially occur when doing bdc !

regards,

amit m.

Read only

Former Member
0 Likes
962

Hi sandya,

i think BDCMSGCOLL will capture the errors in the recorded fields. if you give wrong file name and if it exist in the presentation server then it will be captured and the the data that will be placed in the material field. the datas placed might be wrong that why it will be giving the error.

and did you use format_message function module to convert the messages to text.

i think in that you will get type of error.

Read only

Former Member
0 Likes
962

Hi,

I think u should save Error Message each time after Call Transaction, like:


  CALL TRANSACTION TCODE USING BDCDATA
                   MODE   CTUMODE
                   UPDATE CUPDATE
                   MESSAGES INTO MESSTAB.

  IF MESSTAB[] IS NOT INITIAL.
      READ TABLE MESSTAB INDEX 1.
      MOVE-CORRESPONDING MESSTAB TO ITAB_ERR.
      COLLECT ITAB_ERR.  
  ENDIF.

Regards,

Read only

Former Member
0 Likes
962

Hi sandhya,

The following code may helps your requirement. Please reward points if it helps.

*Types declaration for error file.

TYPES : BEGIN OF t_error,

matnr TYPE mara-matnr,

text(100) TYPE c,

END OF t_error.

*internal table to hold data for error report

DATA: it_error TYPE STANDARD TABLE OF t_error WITH HEADER LINE.

*Internal table to store messages from Call Transaction.

DATA : it_bdcmsgcoll TYPE STANDARD TABLE OF bdcmsgcoll WITH HEADER LINE.

*Internal table to hold bdc data

DATA : it_bdctab TYPE STANDARD TABLE OF bdcdata WITH HEADER LINE.

DATA : v_lines TYPE i, " No. of lines

v_lin TYPE i, " No. of lines

v_lines1 TYPE i, " No. of lines

v_error TYPE i, " No. of error postings

v_success TYPE i," No. of successful postings

v_mode(1) TYPE c VALUE 'N'," Call Transaction mode

v_update(1) VALUE 'S',"Calltransaction update mode

v_tcode TYPE tstc-tcode VALUE 'XK15',"Transaction code

v_head(7)," For header

v_mesg(120)." Message

CALL TRANSACTION v_tcode USING it_bdctab

MODE v_mode

UPDATE v_update

MESSAGES INTO it_bdcmsgcoll.

IF sy-subrc <> 0.

v_error = v_error + 1.

DESCRIBE TABLE it_bdcmsgcoll LINES v_lin.

READ TABLE it_bdcmsgcoll INDEX v_lin.

*--- Formats message returned by Call transaction.

PERFORM format_message.

**--- Perform error processing

it_error-matnr = it_a501-matnr.

it_error-text = v_mesg.

APPEND it_error.

CLEAR it_error.

FORM format_message.

CLEAR v_mesg.

*Function module to get the message

CALL FUNCTION 'FORMAT_MESSAGE'

EXPORTING

id = it_bdcmsgcoll-msgid

lang = sy-langu

no = it_bdcmsgcoll-msgnr

v1 = it_bdcmsgcoll-msgv1

v2 = it_bdcmsgcoll-msgv2

v3 = it_bdcmsgcoll-msgv3

v4 = it_bdcmsgcoll-msgv4

IMPORTING

msg = v_mesg

EXCEPTIONS

not_found = 1

OTHERS = 2.

IF sy-subrc <> 0.

MESSAGE i000 WITH 'Message could not be formatted'(014).

ENDIF.

ENDFORM. " FORMAT_MESSAGE