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 - Session method

Former Member
0 Likes
721

HI all,

While uploading the data using session method, system is not taking second record from the flat file (TXT), upto first record its uploading well and again its taking the same record.

What changes to be done?

7 REPLIES 7
Read only

Former Member
0 Likes
678

check ur code itself.

u have to do like this.

loop at itab.

BDC insert.

endloop.

Read only

naimesh_patel
Active Contributor
0 Likes
678

Hello,

Can you paste your code ?? So, have a better look.

regards,

Naimesh

Read only

0 Likes
678

Herewith i've attached my coding for session method.

REPORT ZTAPAS2

NO STANDARD PAGE HEADING LINE-SIZE 255.

*INCLUDE ZBDCRECX.

DATA: BEGIN OF RECORD OCCURS 0,

BLDAT_001(010),

BLART_002(002),

BUKRS_003(004),

BUDAT_004(010),

MONAT_005(002),

WAERS_006(005),

  • DOCID_007(010),

NEWBS_008(002),

NEWKO_009(017),

WRBTR_010(016),

  • MWSKZ_011(002),

GSBER_012(004),

ZTERM_013(004),

  • ZFBDT_014(010),

SGTXT_015(050),

NEWBS_016(002),

NEWKO_017(017),

WRBTR_018(016),

FMORE_019(001),

GSBER_020(004),

END OF RECORD.

PARAMETERS : P_GRP(12) TYPE C OBLIGATORY.

START-OF-SELECTION.

PERFORM UPLOAD_DATA TABLES RECORD.

PERFORM OPEN_GROUP USING P_GRP.

LOOP AT RECORD.

PERFORM BDC_DYNPRO USING 'SAPMF05A' '0100'.

PERFORM BDC_FIELD USING 'BDC_CURSOR'

'RF05A-NEWKO'.

PERFORM BDC_FIELD USING 'BDC_OKCODE'

'/00'.

PERFORM BDC_FIELD USING 'BKPF-BLDAT'

RECORD-BLDAT_001.

PERFORM BDC_FIELD USING 'BKPF-BLART'

RECORD-BLART_002.

PERFORM BDC_FIELD USING 'BKPF-BUKRS'

RECORD-BUKRS_003.

PERFORM BDC_FIELD USING 'BKPF-BUDAT'

RECORD-BUDAT_004.

PERFORM BDC_FIELD USING 'BKPF-MONAT'

RECORD-MONAT_005.

PERFORM BDC_FIELD USING 'BKPF-WAERS'

RECORD-WAERS_006.

*perform bdc_field using 'FS006-DOCID'

  • record-DOCID_007.

PERFORM BDC_FIELD USING 'RF05A-NEWBS'

RECORD-NEWBS_008.

PERFORM BDC_FIELD USING 'RF05A-NEWKO'

RECORD-NEWKO_009.

PERFORM BDC_DYNPRO USING 'SAPMF05A' '0301'.

PERFORM BDC_FIELD USING 'BDC_CURSOR'

'RF05A-NEWUM'.

PERFORM BDC_FIELD USING 'BDC_OKCODE'

'/00'.

PERFORM BDC_FIELD USING 'BSEG-WRBTR'

RECORD-WRBTR_010.

*perform bdc_field using 'BSEG-MWSKZ'

  • record-MWSKZ_011.

PERFORM BDC_FIELD USING 'BSEG-GSBER'

RECORD-GSBER_012.

PERFORM BDC_FIELD USING 'BSEG-ZTERM'

RECORD-ZTERM_013.

*perform bdc_field using 'BSEG-ZFBDT'

  • record-ZFBDT_014.

PERFORM BDC_FIELD USING 'BSEG-SGTXT'

RECORD-SGTXT_015.

PERFORM BDC_FIELD USING 'RF05A-NEWBS'

RECORD-NEWBS_016.

PERFORM BDC_FIELD USING 'RF05A-NEWKO'

RECORD-NEWKO_017.

PERFORM BDC_DYNPRO USING 'SAPMF05A' '0300'.

PERFORM BDC_FIELD USING 'BDC_CURSOR'

'BSEG-WRBTR'.

PERFORM BDC_FIELD USING 'BDC_OKCODE'

'=BU'.

PERFORM BDC_FIELD USING 'BSEG-WRBTR'

RECORD-WRBTR_018.

PERFORM BDC_FIELD USING 'DKACB-FMORE'

RECORD-FMORE_019.

PERFORM BDC_DYNPRO USING 'SAPLKACB' '0002'.

PERFORM BDC_FIELD USING 'BDC_CURSOR'

'COBL-GSBER'.

PERFORM BDC_FIELD USING 'BDC_OKCODE'

'=ENTE'.

PERFORM BDC_FIELD USING 'COBL-GSBER'

RECORD-GSBER_020.

PERFORM BDC_TRANSACTION USING 'F-22'.

ENDLOOP.

PERFORM CLOSE_GROUP.

DATA: BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE,

BDCMODE TYPE C.

----


  • FORM OPEN_GROUP *

----


FORM OPEN_GROUP USING P_GROUP.

SKIP.

WRITE: /(20) 'Create group'(I01), P_GROUP.

SKIP.

  • open batchinput group

CALL FUNCTION 'BDC_OPEN_GROUP'

EXPORTING

CLIENT = SY-MANDT

GROUP = P_GROUP

USER = SY-UNAME

KEEP = 'X'.

  • holddate = holddate.

WRITE: /(30) 'BDC_OPEN_GROUP'(I02),

(12) 'returncode:'(I05),

SY-SUBRC.

ENDFORM. "open_group

----


  • FORM BDC_TRANSACTION *

----


FORM BDC_TRANSACTION USING TCODE.

DATA: L_MSTRING(480).

DATA: L_SUBRC LIKE SY-SUBRC.

CALL FUNCTION 'BDC_INSERT'

EXPORTING

TCODE = TCODE

TABLES

DYNPROTAB = 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.

  • batch input session

WRITE: / 'BDC_INSERT'(I03), TCODE,

'returncode:'(I05), SY-SUBRC,

'RECORD:', SY-INDEX.

ENDFORM. "bdc_transaction

----


  • CLOSE GROUP *

----


FORM CLOSE_GROUP.

  • close batchinput group

CALL FUNCTION 'BDC_CLOSE_GROUP'.

WRITE: /(30) 'BDC_CLOSE_GROUP'(I04),

(12) 'returncode:'(I05),

SY-SUBRC.

ENDFORM. "close_group

----


  • Start new screen *

----


FORM BDC_DYNPRO USING PROGRAM DYNPRO.

CLEAR BDCDATA.

BDCDATA-PROGRAM = PROGRAM.

BDCDATA-DYNPRO = DYNPRO.

BDCDATA-DYNBEGIN = 'X'.

APPEND BDCDATA.

ENDFORM. "bdc_dynpro

----


  • Insert field *

----


FORM BDC_FIELD USING FNAM FVAL.

CLEAR BDCDATA.

BDCDATA-FNAM = FNAM.

BDCDATA-FVAL = FVAL.

APPEND BDCDATA.

ENDFORM. "bdc_field

&----


*& Form UPLOAD_DATA

&----


FORM UPLOAD_DATA TABLES T_ITAB.

REFRESH: RECORD.

CLEAR : RECORD.

CALL FUNCTION 'UPLOAD'

EXPORTING

  • CODEPAGE = ' '

FILENAME = 'C:\'

FILETYPE = 'DAT'

  • ITEM = ' '

  • FILEMASK_MASK = ' '

  • FILEMASK_TEXT = ' '

  • FILETYPE_NO_CHANGE = ' '

  • FILEMASK_ALL = ' '

  • FILETYPE_NO_SHOW = ' '

  • LINE_EXIT = ' '

  • USER_FORM = ' '

  • USER_PROG = ' '

  • SILENT = 'S'

  • IMPORTING

  • FILESIZE =

  • CANCEL =

  • ACT_FILENAME =

  • ACT_FILETYPE =

TABLES

DATA_TAB = RECORD

EXCEPTIONS

CONVERSION_ERROR = 1

  • INVALID_TABLE_WIDTH = 2

  • INVALID_TYPE = 3

  • NO_BATCH = 4

  • UNKNOWN_ERROR = 5

  • GUI_REFUSE_FILETRANSFER = 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.

ENDFORM. " UPLOAD_DATA

Read only

0 Likes
678

Hello,

Write:

Refresh BDCDATa.

after

WRITE: / 'BDC_INSERT'(I03), TCODE,

'returncode:'(I05), SY-SUBRC,

'RECORD:', SY-INDEX.

Regards,

Naimesh

Read only

Former Member
0 Likes
678

Hi,

If you are using 'session method', bdc_insert fm needs tobe called inside the loop endloop,

Rgds,

Read only

Former Member
0 Likes
678

Hi,

Use a <b>Loop</b>... for filling your <b>BDC internal table</b>(BDCDATA) and then call <b>BDC_INSERT</b>.... then <b>Endloop</b>.

Read only

Former Member
0 Likes
678

hi,

there could be problem with the flatfile,

before going for data transfer,

just try to use,

GUI_UPLOAD function,and

loop at itab.

write:/...

endloop.

and...,check the flatfile on the screen,

if there is any problem with the flatfile,

correct all the fields to tab space,

i hope you will get it,

best of luck,

regards,

kcc