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

Error in my BDC SESSION METHOD

Former Member
0 Likes
816

Hi,

I was trying work on BDC SESSION METHOD AND MY TCODE IS XK01.

Here is my code can some one tell me where i am doing wrong becoz its not giving the output as I expected. And I am uploading a tab delimeter file.

report ZAN_BDCVENDOR

no standard page heading line-size 255.

include bdcrecx1.

DATA: I_BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE.

DATA: BEGIN OF RECORD OCCURS 0,

LIFNR(016),

BURKS(004),

EKORG(004),

KTOKK(004),

AKONT(010),

FDGRV(010),

WAERS(005),

END OF RECORD.

start-of-selection.

perform open_group.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = 'C:\VENDOR.TXT'

FILETYPE = 'ASC'

tables

data_tab = RECORD

.

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 RECORD.

perform bdc_dynpro using 'SAPMF02K' '0100'.

perform bdc_field using 'BDC_CURSOR'

'USE_ZAV'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'RF02K-LIFNR'

'8765'.

perform bdc_field using 'RF02K-BUKRS'

'1000'.

perform bdc_field using 'RF02K-EKORG'

'1000'.

perform bdc_field using 'RF02K-KTOKK'

'0001'.

perform bdc_field using 'USE_ZAV'

'X'.

perform bdc_dynpro using 'SAPMF02K' '0210'.

perform bdc_field using 'BDC_CURSOR'

'LFB1-FDGRV'.

perform bdc_field using 'BDC_OKCODE'

'=UPDA'.

perform bdc_field using 'LFB1-AKONT'

'160000'.

perform bdc_field using 'LFB1-FDGRV'

'A1'.

perform bdc_dynpro using 'SAPMF02K' '0310'.

perform bdc_field using 'BDC_CURSOR'

'LFM1-WAERS'.

perform bdc_field using 'BDC_OKCODE'

'=UPDA'.

perform bdc_field using 'LFM1-WAERS'

'usd'.

perform bdc_transaction using 'XK01'.

ENDLOOP.

perform close_group.

CALL FUNCTION 'BDC_OPEN_GROUP'

EXPORTING

CLIENT = SY-MANDT

  • DEST = FILLER8

GROUP = 'SESSION1'

  • HOLDDATE = FILLER8

  • KEEP = FILLER1

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.

WRITE 'ERROR IN OPEN_GROUP'.

ENDIF.

CALL FUNCTION 'BDC_INSERT'

  • EXPORTING

  • TCODE = TCODE

  • POST_LOCAL = NOVBLOCAL

  • PRINTING = NOPRINT

  • SIMUBATCH = ' '

  • CTUPARAMS = ' '

TABLES

dynprotab = I_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.

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.

I appreciate

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
704

Hi,

i guess, the error is due to, u didnt pass the TCODE parameter in BDC_INSERT FM.

Try by passing it...

CALL FUNCTION 'BDC_INSERT'

  • EXPORTING

    • TCODE = TCODE*

  • POST_LOCAL = NOVBLOCAL

  • PRINTING = NOPRINT

  • SIMUBATCH = ' '

  • CTUPARAMS = ' '

TABLES

dynprotab = I_BDCDATA

  • EXCEPTIONS

  • INTERNAL_ERROR = 1

  • NOT_OPEN = 2

  • QUEUE_ERROR = 3

  • TCODE_INVALID = 4

  • PRINTING_INVALID = 5

  • POSTING_INVALID = 6

  • OTHERS = 7

Hope it works!!

Regards,

Pavan

6 REPLIES 6
Read only

Former Member
0 Likes
704

Hi,

Try to execute your BDC in foreground mode so you can see if there's an error in your BDC steps.

CALL TRANSACTION <TCODE> USING I_BDCDATA

MODE 'A'

UPDATE 'S'.

Hope this helps.

Regards,

Leonard Chomi.

Read only

Former Member
0 Likes
705

Hi,

i guess, the error is due to, u didnt pass the TCODE parameter in BDC_INSERT FM.

Try by passing it...

CALL FUNCTION 'BDC_INSERT'

  • EXPORTING

    • TCODE = TCODE*

  • POST_LOCAL = NOVBLOCAL

  • PRINTING = NOPRINT

  • SIMUBATCH = ' '

  • CTUPARAMS = ' '

TABLES

dynprotab = I_BDCDATA

  • EXCEPTIONS

  • INTERNAL_ERROR = 1

  • NOT_OPEN = 2

  • QUEUE_ERROR = 3

  • TCODE_INVALID = 4

  • PRINTING_INVALID = 5

  • POSTING_INVALID = 6

  • OTHERS = 7

Hope it works!!

Regards,

Pavan

Read only

0 Likes
704

I passed the tcode. but still the same.

I would appreciate if any body can send one sample example which is working perfectly on the session method.

Read only

0 Likes
704

Hi,

did u check ur I_BDCDATA? is it filled?

check the table in run time before the BDC_INSERT FM

Regards,

Pavan

Read only

Former Member
0 Likes
704

Hi,

U should call 'CALL FUNCTION 'BDC_OPEN_GROUP' before the LOOP.

Hope it works!!

Regards,

Pavan

Read only

Former Member
0 Likes
704

Hi,

You need to first call the FM OPEN_BDC_GROUP in loop of itab BDC_INSERT and at last BDC_CLOSE_GROUP.

[SAP ABAP BDC Code|http://sap.niraj.tripod.com/id12.html]