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: 

Problem in BDC: Not Picking the second entry of file

Former Member
0 Kudos

Dear Friends,

I have been working on a BDC and have been facing a problem. This code uploads the first entry of my file properly but repeats the same entry again second time, doesn't refresh or take the second entry of the file.

Please have a look at the code & suggest the necessary corrections.

Regards,

Alok.

************************************************************************

report ZFBPS_BDC

no standard page heading line-size 255.

************

data: bdcdata1 like bdcdata occurs 0 with header line.

data : vf_index type i.

*************

*include bdcrecx1.

DATA: BEGIN OF ENTRIES OCCURS 0,

RECNO(5),

NEWBS(2),

NEWKO(17),

NEWNUM(1),

WRBTR(13),

GSBER(4),

KOSTL(10),

SECCO(4),

ZFBDT(8),

zuonr(18),

SGTXT(50),

FMORE(1),

HKONT(10),

PRCTR(10),

AUFNR(3),

MWSKZ(2),

XBLNR(16),

BKTXT(25),

END OF ENTRIES.

DATA: TEMP(8),

DOCDATE(8),

SPLGL(1),

PKEY(2),

GL(17),

VCHAMT(13),

BUSAREA(4),

SECCODE(4),

FBDT(8),

zzuonr(18),

COSTCEN(10),

AUFNR(3),

SGTXT(50).

*********************************

data : vf_start_col type i value '1', "start column

vf_start_row type i value '1', "start row

vf_end_col type i value '256', "maximum column

vf_end_row type i value '65536', "maximum row

p_text(20). "stores error messages

  • Internal Table

data : it_excel type kcde_cells occurs 0 with header line.

*/ Field symbol

field-symbols : <fs>.

parameters: p_file LIKE rlgrap-filename MEMORY ID M01,

NOHEADER AS CHECKBOX.

parameters: COMPANY(4) TYPE C DEFAULT 'SCL',

GROUP(12) TYPE C DEFAULT 'BDCTEST',

USER(12) TYPE C DEFAULT SY-UNAME,

KEEP(1) TYPE C DEFAULT 'X',

POSTDATE LIKE SY-DATUM DEFAULT SY-DATUM,

DOC_TYPE(2) TYPE C DEFAULT 'KR',

HOLDDATE LIKE SY-DATUM.

*****************************************

***********************************************upload data from excel

CALL FUNCTION 'KCD_EXCEL_OLE_TO_INT_CONVERT'

EXPORTING

filename = p_file

i_begin_col = VF_START_COL

i_begin_row = VF_START_ROW

i_end_col = VF_END_COL

i_end_row = VF_END_ROW

tables

intern = IT_EXCEL

EXCEPTIONS

INCONSISTENT_PARAMETERS = 1

UPLOAD_OLE = 2

OTHERS = 3 .

IF sy-subrc <> 0.

WRITE: / 'EXCEL UPLOAD FAILED :', p_file, SY-SUBRC.

else.

sort it_excel by row col.

loop at it_excel.

IF NOHEADER = 'X'

AND It_EXCEL-row = 1.

CONTINUE.

ENDIF.

vf_index = it_excel-col.

assign component vf_index of structure ENTRIES to <fs>.

move it_excel-value to <fs>.

at end of row.

append ENTRIES.

clear ENTRIES.

endat.

endloop.

endif.

*************************************************************

start-of-selection.

LOOP AT ENTRIES.

WRITE: / ENTRIES-RECNO,

ENTRIES-NEWBS,

ENTRIES-NEWKO,

ENTRIES-NEWNUM,

ENTRIES-WRBTR,

ENTRIES-GSBER,

ENTRIES-SECCO,

ENTRIES-ZFBDT,

ENTRIES-ZUONR,

ENTRIES-SGTXT.

ENDLOOP.

WRITE: / 'THIS IS THE BDC PROGRAM FOR SAMTEL'.

perform bdc_dynpro using 'SAPMF05A' '0100'.

perform bdc_field using 'BDC_OKCODE' '/00'.

PERFORM BDC_FIELD USING 'BDC_CURSOR' 'RF05A-NEWKO'.

TEMP = POSTDATE.

DOCDATE = TEMP+6(2).

DOCDATE2(2) = TEMP4(2).

DOCDATE4(4) = TEMP0(4).

*PERFORM BDC_FIELD USING 'BKPF-BLDAT' DOCDATE.

*PERFORM BDC_FIELD USING 'BKPF-BLART' DOC_TYPE.

*PERFORM BDC_FIELD USING 'BKPF-BUKRS' COMPANY.

*PERFORM BDC_FIELD USING 'BKPF-WAERS' 'INR'.

*PERFORM BDC_FIELD USING 'BKPF-BUDAT' DOCDATE.

*PERFORM BDC_FIELD USING 'BKPF-XBLNR' 'Deepak'.

*PERFORM BDC_FIELD USING 'BKPF-BKTXT' 'Sahib'.

LOOP AT ENTRIES.

REFRESH BDCDATA1.

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' DOCDATE.

PERFORM BDC_FIELD USING 'BKPF-BLART' DOC_TYPE.

PERFORM BDC_FIELD USING 'BKPF-BUKRS' COMPANY.

PERFORM BDC_FIELD USING 'BKPF-WAERS' 'INR'.

PERFORM BDC_FIELD USING 'BKPF-BUDAT' DOCDATE.

PERFORM BDC_FIELD USING 'BKPF-XBLNR' 'Deepak'.

PERFORM BDC_FIELD USING 'BKPF-BKTXT' 'Sahib'.

perform bdc_field using 'RF05A-NEWBS'

ENTRIES-NEWBS.

perform bdc_field using 'RF05A-NEWKO'

ENTRIES-NEWKO.

perform bdc_dynpro using 'SAPMF05A' '0300'.

perform bdc_field using 'BDC_CURSOR'

'BSEG-SGTXT'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'BSEG-WRBTR'

ENTRIES-WRBTR.

perform bdc_field using 'BSEG-ZUONR'

ENTRIES-ZUONR.

perform bdc_field using 'BSEG-SGTXT'

ENTRIES-SGTXT.

perform bdc_field using 'DKACB-FMORE'

ENTRIES-FMORE.

perform bdc_dynpro using 'SAPLKACB' '0002'.

perform bdc_field using 'BDC_CURSOR'

'COBL-KOSTL'.

perform bdc_field using 'BDC_OKCODE'

'=ENTE'.

perform bdc_field using 'COBL-GSBER'

ENTRIES-GSBER.

perform bdc_field using 'COBL-KOSTL'

ENTRIES-KOSTL.

perform bdc_dynpro using 'SAPMF05A' '0300'.

perform bdc_field using 'BDC_CURSOR'

'RF05A-NEWKO'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'BSEG-WRBTR'

ENTRIES-WRBTR.

perform bdc_field using 'BSEG-ZUONR'

ENTRIES-ZUONR.

perform bdc_field using 'BSEG-SGTXT'

ENTRIES-SGTXT.

perform bdc_field using 'RF05A-NEWBS'

ENTRIES-NEWBS.

perform bdc_field using 'RF05A-NEWKO'

ENTRIES-NEWKO.

perform bdc_field using 'DKACB-FMORE'

ENTRIES-FMORE.

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'

ENTRIES-GSBER.

perform bdc_field using 'COBL-KOSTL'

ENTRIES-KOSTL.

perform bdc_field using 'COBL-PRCTR'

ENTRIES-PRCTR.

perform bdc_dynpro using 'SAPMF05A' '0300'.

perform bdc_field using 'BDC_CURSOR'

'RF05A-NEWKO'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'BSEG-WRBTR'

ENTRIES-WRBTR.

perform bdc_field using 'BSEG-SGTXT'

ENTRIES-SGTXT.

perform bdc_field using 'RF05A-NEWBS'

ENTRIES-NEWBS.

perform bdc_field using 'RF05A-NEWKO'

ENTRIES-NEWKO.

perform bdc_field using 'DKACB-FMORE'

ENTRIES-FMORE.

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'

ENTRIES-GSBER.

perform bdc_dynpro using 'SAPMF05A' '0300'.

perform bdc_field using 'BDC_CURSOR'

'BSEG-WRBTR'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'BSEG-WRBTR'

ENTRIES-WRBTR.

perform bdc_field using 'DKACB-FMORE'

ENTRIES-FMORE.

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'

ENTRIES-GSBER.

perform bdc_dynpro using 'SAPMF05A' '0300'.

perform bdc_field using 'BDC_CURSOR'

'RF05A-NEWKO'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'BSEG-WRBTR'

ENTRIES-WRBTR.

perform bdc_field using 'BSEG-SGTXT'

ENTRIES-SGTXT.

perform bdc_field using 'RF05A-NEWBS'

ENTRIES-NEWBS.

perform bdc_field using 'RF05A-NEWKO'

ENTRIES-NEWKO.

perform bdc_field using 'DKACB-FMORE'

ENTRIES-FMORE.

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'

ENTRIES-GSBER.

perform bdc_dynpro using 'SAPMF05A' '0300'.

perform bdc_field using 'BDC_CURSOR'

'RF05A-NEWKO'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'BSEG-WRBTR'

ENTRIES-WRBTR.

perform bdc_field using 'BSEG-SGTXT'

ENTRIES-SGTXT.

perform bdc_field using 'RF05A-NEWBS'

ENTRIES-NEWBS.

perform bdc_field using 'RF05A-NEWKO'

ENTRIES-NEWKO.

perform bdc_field using 'DKACB-FMORE'

ENTRIES-FMORE.

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'

ENTRIES-GSBER.

perform bdc_dynpro using 'SAPMF05A' '0300'.

perform bdc_field using 'BDC_CURSOR'

'RF05A-NEWKO'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'BSEG-WRBTR'

ENTRIES-WRBTR.

perform bdc_field using 'BSEG-SGTXT'

ENTRIES-SGTXT.

perform bdc_field using 'RF05A-NEWBS'

ENTRIES-NEWBS.

perform bdc_field using 'RF05A-NEWKO'

ENTRIES-NEWKO.

perform bdc_field using 'DKACB-FMORE'

ENTRIES-FMORE.

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'

ENTRIES-GSBER.

perform bdc_dynpro using 'SAPMF05A' '0302'.

perform bdc_field using 'BDC_CURSOR'

'BSEG-SGTXT'.

perform bdc_field using 'BDC_OKCODE'

'=AB'.

perform bdc_field using 'BSEG-HKONT'

ENTRIES-HKONT.

perform bdc_field using 'BSEG-WRBTR'

ENTRIES-WRBTR.

perform bdc_field using 'BSEG-MWSKZ'

ENTRIES-MWSKZ.

perform bdc_field using 'BSEG-ZFBDT'

ENTRIES-ZFBDT.

perform bdc_field using 'BSEG-SGTXT'

ENTRIES-SGTXT.

perform bdc_dynpro using 'SAPLFWTD' '0100'.

perform bdc_field using 'BDC_CURSOR'

'WITH_ITEM-WT_WITHCD(01)'.

perform bdc_field using 'BDC_OKCODE'

'=GO'.

perform bdc_dynpro using 'SAPMF05A' '0700'.

perform bdc_field using 'BDC_CURSOR'

'RF05A-NEWBS'.

perform bdc_field using 'BDC_OKCODE'

'=BS'.

perform bdc_field using 'BKPF-XBLNR'

ENTRIES-XBLNR.

perform bdc_field using 'BKPF-BKTXT'

ENTRIES-BKTXT.

perform bdc_dynpro using 'SAPMF05A' '0700'.

perform bdc_field using 'BDC_CURSOR'

'RF05A-NEWBS'.

perform bdc_field using 'BDC_OKCODE'

'=BU'.

perform bdc_field using 'BKPF-XBLNR'

ENTRIES-XBLNR.

perform bdc_field using 'BKPF-BKTXT'

ENTRIES-BKTXT.

perform bdc_field using 'BDC_OKCODE'

'=YES'.

call transaction 'FB01' using bdcdata1 mode 'A'.

ENDLOOP.

----


  • Start new screen *

----


form bdc_dynpro using program dynpro.

clear bdcdata1.

bdcdata1-program = program.

bdcdata1-dynpro = dynpro.

bdcdata1-dynbegin = 'X'.

append bdcdata1.

endform.

----


  • Insert field *

----


form bdc_field using fnam fval.

clear bdcdata1.

bdcdata1-fnam = fnam.

bdcdata1-fval = fval.

append bdcdata1.

endform.

2 REPLIES 2

Former Member
0 Kudos

Hi, maybe this problem has got to do with the refresh and clearing of the internal table? Hope this helps

Former Member
0 Kudos

Hi

You better use LSMW instaed of using BDC for FB01 Transaction. The Problem is not with REFRESH.

Regards,

Anji