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

BDC log

Former Member
0 Likes
669

Hi experts,

I have developed a BDC and it is working fine. User wants

a log. After running the BDC he needs the list of all materials which has been uploaded and failed during uploading.

I hav developed BDC for MM01 in Call transaction method.

Ex.:

Material Status

123456 Successfull

54654564 Successfull

65456464 Failed

Can anyone help me in this plese.

Regards

Sameer

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
637

Check sy-subrc after call transaction.

call transaction

if sy-subrc = 0.

write:/ itab-matnr, 'successfull'.

else.

write:/ itab-matnr, 'failed'.

endif.

4 REPLIES 4
Read only

Former Member
0 Likes
638

Check sy-subrc after call transaction.

call transaction

if sy-subrc = 0.

write:/ itab-matnr, 'successfull'.

else.

write:/ itab-matnr, 'failed'.

endif.

Read only

0 Likes
637

Thank U all,

U r answers are very helpfull i hav rewarded u points..

Thank u once again.

Read only

Former Member
0 Likes
637

Hi,

After CALL TRANSACTION tcode .........

IF SY-SUBRC NE 0

MOVE : itab required records to one more internal table(i_errors)

which is haveing the required error putput fields.

ENDIF.

after all functionality of program is over.

check IF NOT i_ERRORS[] IS INITIAL.

By using the WS_DOWLOAD download your erroe file .

ENDIF.

Read only

Former Member
0 Likes
637

Hai Sameer,

Usually if there are any errors in CALL TRANSACTION we send those records to SESSION METHOD by using below logic.

eg:

CALL TRANSACTION 'XK01' USING

t_bdcdata MODE 'N' .

IF sy-subrc 0.

PERFORM session_bdc.

ENDIF.

ENDLOOP.

IF s_flag = 'X'.

CALL FUNCTION 'BDC_CLOSE_GROUP'.

ENDIF.

  • This is subroutine .

FORM session_bdc .

IF s_flag = ' '.

CALL FUNCTION 'BDC_OPEN_GROUP'

EXPORTING

client = sy-mandt

group = 'vcentric'

  • holddate = filler8

keep = 'X'

user = sy-uname

prog = sy-cprog.

s_flag = 'X'.

ENDIF.

CALL FUNCTION 'BDC_INSERT'

EXPORTING

tcode = 'XK01'

TABLES

dynprotab = t_bdcdata.

ENDFORM. " SESSION_BDC

or we can send the error records on into an flat file by using the below logic.

CALL TRANSACTION 'XK01' USING

T_BDCDATA MODE 'N' MESSAGES INTO T_BDCMSG.

IF SY-SUBRC 0.

APPEND W_UPLOAD TO T_ERROR.

ENDIF.

CLEAR W_BDCMSG.

READ TABLE T_BDCMSG INTO W_BDCMSG INDEX 1.

CLEAR L_MSG.

CALL FUNCTION 'FORMAT_MESSAGE'

EXPORTING

ID = W_BDCMSG-MSGID

LANG = SY-LANGU

NO = W_BDCMSG-MSGNR

V1 = W_BDCMSG-MSGV1

V2 = W_BDCMSG-MSGV2

V3 = W_BDCMSG-MSGV3

V4 = W_BDCMSG-MSGV4

IMPORTING

MSG = L_MSG

EXCEPTIONS

NOT_FOUND = 1

OTHERS = 2.

.

IF SY-SUBRC = 0.

WRITE:/ W_UPLOAD-NAME1, '----', L_MSG.

ENDIF.

ENDLOOP.

  • this is subroutine.

FORM ERROR_RECORDS .

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

FILENAME = 'C:/ERROR.TXT'

FILETYPE = 'ASC'

WRITE_FIELD_SEPARATOR = 'X'

TABLES

DATA_TAB = T_ERROR.

ENDFORM. " ERROR_RECORDS

Reward is useful.

Regards.

Eshwar.