Application Development 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: 

DATA TRANSFER USING BDC

Former Member
0 Kudos

HOW CAN WE FINDOUT MISSING RECORD WHEN WE UPLOAD DATA INTO SAP USING BDC (SESSION & CALL TRANSACTION)

1 ACCEPTED SOLUTION

former_member181962
Active Contributor
0 Kudos

In SEsssion method, you don't need to worry. When you process the session in sm35, the error log will have the records for which errros are ther.

In call transaction method, you have to check if sy-subrc = 0 or not.

YOu can collect the messages that tell us the reason for the failure using the command

call transaction < tcode> using it_bdcdata messages into it_bdcmsgcoll...

if sy-subrc <> 0.

call function 'FORMAT_MESSAGE'.......

importing message....

write:/ message.

endif.

Regards,

Ravi

3 REPLIES 3

former_member181962
Active Contributor
0 Kudos

In SEsssion method, you don't need to worry. When you process the session in sm35, the error log will have the records for which errros are ther.

In call transaction method, you have to check if sy-subrc = 0 or not.

YOu can collect the messages that tell us the reason for the failure using the command

call transaction < tcode> using it_bdcdata messages into it_bdcmsgcoll...

if sy-subrc <> 0.

call function 'FORMAT_MESSAGE'.......

importing message....

write:/ message.

endif.

Regards,

Ravi

Former Member
0 Kudos

hi,

u can check missing or unprocessed records ,in SESSION method directly.

in SM35 u can check ERROR LOG.

for CALL TRANSACTION u have to catch them explicitly.

u have to use BDCMSGCOLL for this.looping bdcmsgcoll and catch them using

FORMAT_MESSAGES ALSO.

U CAN CATCH THEM LIKE THIS ALSO.

after call transaction logic check sy-subrc

if sy-subrc<> 0.

use gui_download and transfer all unprocessed records into a file.

check below coding.i cought errors using BDCMSGCOLL & i opened session for checking error records.

report zsr_bdc .

data:begin of w_input1,

g_data(200) type c,

end of w_input1,

t_input1 like standard table of w_input1 initial size 0,

begin of w_input,

ekorg(4) type c,

ktokk(4) type c,

anred(15) type c,

name1(30) type c,

sortl(10) type c,

land1(3) type c,

spras(2) type c,

waers(5) type c,

end of w_input,

t_input like standard table of w_input initial size 0,

g_string type string,

g_flag,

t_bdcdata type standard table of bdcdata initial size 0,

t_bdcmsgcoll type standard table of bdcmsgcoll,

w_bdcdata type bdcdata,

w_bdcmsgcoll type bdcmsgcoll.

parameters: p_file type ibipparms-path.

at selection-screen on value-request for p_file.

call function 'F4_FILENAME'

  • EXPORTING

  • PROGRAM_NAME = SYST-CPROG

  • DYNPRO_NUMBER = SYST-DYNNR

  • FIELD_NAME = ' '

importing

file_name = p_file

.

g_string = p_file.

*include bdcrecx1.

start-of-selection.

call function 'GUI_UPLOAD'

exporting

filename = g_string

filetype = 'ASC'

  • HAS_FIELD_SEPARATOR = 'X'

  • HEADER_LENGTH = 0

  • READ_BY_LINE = 'X'

  • DAT_MODE = ' '

  • CODEPAGE = ' '

  • IGNORE_CERR = ABAP_TRUE

  • REPLACEMENT = '#'

  • CHECK_BOM = ' '

  • IMPORTING

  • FILELENGTH =

  • HEADER =

tables

data_tab = t_input1

  • EXCEPTIONS

  • FILE_OPEN_ERROR = 1

  • FILE_READ_ERROR = 2

  • NO_BATCH = 3

  • GUI_REFUSE_FILETRANSFER = 4

  • INVALID_TYPE = 5

  • NO_AUTHORITY = 6

  • UNKNOWN_ERROR = 7

  • BAD_DATA_FORMAT = 8

  • HEADER_NOT_ALLOWED = 9

  • SEPARATOR_NOT_ALLOWED = 10

  • HEADER_TOO_LONG = 11

  • UNKNOWN_DP_ERROR = 12

  • ACCESS_DENIED = 13

  • DP_OUT_OF_MEMORY = 14

  • DISK_FULL = 15

  • DP_TIMEOUT = 16

  • OTHERS = 17

.

if sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

endif.

loop at t_input1 into w_input1.

split w_input1-g_data at ',' into w_input-ekorg

w_input-ktokk

w_input-anred

w_input-name1

w_input-sortl

w_input-land1

w_input-spras

w_input-waers.

append w_input to t_input.

endloop.

*perform open_group.

loop at t_input into w_input.

refresh t_bdcdata.

perform bdc_dynpro using 'SAPMF02K' '0107'.

perform bdc_field using 'BDC_CURSOR'

'RF02K-KTOKK'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'RF02K-EKORG'

w_input-ekorg.

perform bdc_field using 'RF02K-KTOKK'

w_input-ktokk.

perform bdc_dynpro using 'SAPMF02K' '0110'.

perform bdc_field using 'BDC_CURSOR'

'LFA1-SPRAS'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'LFA1-ANRED'

w_input-anred.

perform bdc_field using 'LFA1-NAME1'

w_input-name1.

perform bdc_field using 'LFA1-SORTL'

w_input-sortl.

perform bdc_field using 'LFA1-LAND1'

w_input-land1.

perform bdc_field using 'LFA1-SPRAS'

w_input-spras.

perform bdc_dynpro using 'SAPMF02K' '0120'.

perform bdc_field using 'BDC_CURSOR'

'LFA1-KUNNR'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_dynpro using 'SAPMF02K' '0130'.

perform bdc_field using 'BDC_CURSOR'

'LFBK-BANKS(01)'.

perform bdc_field using 'BDC_OKCODE'

'=ENTR'.

perform bdc_dynpro using 'SAPMF02K' '0310'.

perform bdc_field using 'BDC_CURSOR'

'LFM1-WAERS'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'LFM1-WAERS'

w_input-waers.

perform bdc_dynpro using 'SAPMF02K' '0320'.

perform bdc_field using 'BDC_CURSOR'

'RF02K-LIFNR'.

perform bdc_field using 'BDC_OKCODE'

'=ENTR'.

perform bdc_dynpro using 'SAPLSPO1' '0300'.

perform bdc_field using 'BDC_OKCODE'

'=YES'.

call transaction 'MK01' using t_bdcdata

mode 'N'

update 'S'

messages into t_bdcmsgcoll.

if sy-subrc <> 0.

if g_flag is initial.

call function 'BDC_OPEN_GROUP'

exporting

client = sy-mandt

  • DEST = FILLER8

group = 'ZSKCL'

  • HOLDDATE = FILLER8

keep = 'X'

user = sy-uname

  • RECORD = FILLER1

  • PROG = SY-CPROG

  • IMPORTING

  • QID =

  • EXCEPTIONS

  • CLIENT_INVALID = 1

  • DESTINATION_INVALID = 2

  • GROUP_INVALID = 3

  • GROUP_IS_LOCKED = 4

  • HOLDDATE_INVALID = 5

  • INTERNAL_ERROR = 6

  • QUEUE_ERROR = 7

  • RUNNING = 8

  • SYSTEM_LOCK_ERROR = 9

  • USER_INVALID = 10

  • OTHERS = 11

.

if sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

endif.

g_flag = 'X'.

endif.

call function 'BDC_INSERT'

exporting

tcode = 'XK01'

  • POST_LOCAL = NOVBLOCAL

  • PRINTING = NOPRINT

  • SIMUBATCH = ' '

  • CTUPARAMS = ' '

tables

dynprotab = t_bdcdata

  • EXCEPTIONS

  • INTERNAL_ERROR = 1

  • NOT_OPEN = 2

  • QUEUE_ERROR = 3

  • TCODE_INVALID = 4

  • PRINTING_INVALID = 5

  • POSTING_INVALID = 6

  • OTHERS = 7

.

if sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

endif.

endif.

endloop.

if g_flag = 'X'.

call function 'BDC_CLOSE_GROUP'

  • EXCEPTIONS

  • NOT_OPEN = 1

  • QUEUE_ERROR = 2

  • OTHERS = 3

.

if sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

endif.

endif.

loop at t_bdcmsgcoll into w_bdcmsgcoll.

write: w_bdcmsgcoll-dyname,

w_bdcmsgcoll-dynumb,

w_bdcmsgcoll-msgtyp,

w_bdcmsgcoll-msgspra,

w_bdcmsgcoll-msgid,

w_bdcmsgcoll-msgnr,

w_bdcmsgcoll-msgv1,

w_bdcmsgcoll-msgv2,

w_bdcmsgcoll-msgv3,

w_bdcmsgcoll-msgv4.

endloop.

*perform bdc_transaction using 'MK01'.

*perform close_group.

&----


*& Form bdc_dynpro

&----


  • text

----


  • -->P_0156 text

  • -->P_0157 text

----


form bdc_dynpro using value(p_0156)

value(p_0157).

clear w_bdcdata.

w_bdcdata-program = p_0156.

w_bdcdata-dynpro = p_0157.

w_bdcdata-dynbegin = 'X'.

append w_bdcdata to t_bdcdata.

Former Member
0 Kudos

Hi,

for session method u can cathch errors directly by clicking on the error logs.

For CALL TRANSACTION u can catch errors by creating a strcture of BDCMSGCOLL and use it in ur call transaction statement..

u will not be able to get message texts in that BDCMSGCOLL .. message text is saved in table t100 .. so use either FORMAT_MESSAGE fm or read table t00 for all entries in bdcmsgcoll for all entries in bdcmsgcoll where(specify messege id and message type)