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

regarding BDC coding

Former Member
0 Likes
732

hi friends ,

i m facing problem while uploading data from excel sheet to sap system,the fields are postking key,cmpycode,gl a/c,vendor code,vendor name,business area n amount...here below i m giving my cmplete coding part for ur help......

looking forward to an early reply...PLZ HELP ME

tables:rf02k,addr1_data,bseg,bkpf,cobl,rf05a.

data:begin of itab occurs 0,

lifnr like rf02k-lifnr,

name1 like addr1_data,

hkont like bseg-hkont,

bukrs like bkpf-bukrs,

wrbtr like bseg-wrbtr,

gsber like cobl-gsber,

newbs like rf05a-newbs,

  • bschl like kmzei-bschl,

  • bukrs like kmzei-bukrs,

  • hkont like kmzei-hkont,

  • gsber like kmzei-gsber,

  • wrbtr like kmzei-wrbtr,

end of itab.

data:begin of jtab occurs 0.

include structure bdcdata.

data:end of jtab.

data:begin of i_excel occurs 0.

include structure alsmex_tabline.

data:end of i_excel.

parameters:fname like rlgrap-filename,

ftype like rlgrap-filetype,

start type i, end type i.

at selection-screen on value-request for fname.

call function 'F4_FILENAME'

    • EXPORTING

    • PROGRAM_NAME = SYST-CPROG

    • DYNPRO_NUMBER = SYST-DYNNR

    • FIELD_NAME = ' '

IMPORTING

FILE_NAME = fname.

start-of-selection.

call function 'ALSM_EXCEL_TO_INTERNAL_TABLE'

exporting

FILENAME = fname

I_BEGIN_COL = 2

I_BEGIN_ROW = start

I_END_COL = 8

I_END_ROW = end

TABLES

INTERN = i_excel

EXCEPTIONS

INCONSISTENT_PARAMETERS = 1

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

end-of-selection.

loop at i_excel.

case i_excel-col.

when '0002'.

itab-NEWBS = i_excel-value.

when '0003'.

itab-bukrs = i_excel-value.

when '0004'.

itab-hkont = i_excel-value.

when '0005'.

itab-lifnr = i_excel-value.

when '0006'.

itab-name1 = i_excel-value.

when '0007'.

itab-gsber = i_excel-value.

when '0008'.

itab-wrbtr = i_excel-value.

endcase.

at end of row.

append itab.

clear itab.

endat.

endloop.

loop at Itab.

refresh jtab.

perform sub using 'SAPMF05A' '300'.

PERFORM sub1 using 'BDC_CURSOR' 'RF05A-NEWBS'.

PERFORM sub1 using 'BDC_OKCODE' '/00'.

PERFORM sub1 using 'RF05A-NEWBS' ITAB-NEWBS.

PERFORM sub1 using 'BKPF-BUKRS' ITAB-BUKRS.

PERFORM sub1 using 'BSEG-HKONT' ITAB-HKONT.

call transaction 'F-02' using jtab.

perform sub using 'SAPMF02K' '100'.

PERFORM sub1 using 'BDC_CURSOR' 'RF02K-LIFNR'.

PERFORM sub1 using 'BDC_OKCODE' '/00'.

PERFORM sub1 using 'RF02K-LIFNR' ITAB-LIFNR.

PERFORM sub1 using 'ADDR1_DATA-NAME1' ITAB-NAME1.

call transaction 'XK01' using jtab.

PERFORM sub using 'SAPMF05A' '300'.

PERFORM sub1 using 'BDC_CURSOR' 'COBL-GSBER'.

PERFORM sub1 using 'BDC_OKCODE' '/00'.

PERFORM sub1 using 'COBL-GSBER' ITAB-GSBER.

PERFORM sub1 using 'BSEG-WRBTR' ITAB-WRBTR.

call transaction 'FKMT' using jtab .

endloop.

form sub using A B.

clear jtab.

jtab-program = A.

jtab-dynpro = B.

jtab-dynbegin = 'X'.

append jtab.

endform.

form sub1 using C D.

clear jtab.

jtab-fnam = C.

jtab-fval = D.

append jtab.

endform.

6 REPLIES 6
Read only

Former Member
0 Likes
681

What kind of problem your facing,can you let me know that, then only i can able to help you.

Read only

0 Likes
681

i know my coding is not right,plz check whether my coding will fulfill my o/p or not

Read only

Former Member
0 Likes
681

Ravi,

No need to write like that way...

follow this way...

in XX = put the value as like length of the fild..

example: rf02k-lifnr is of length 10

so i declaed lifnr(10) type cahr.

then declare..

data:begin of itab occurs 0,

lifnr(10) type cahr," like rf02k-lifnr,

name1(XX) type cahr," like addr1_data,

hkont(XX) type cahr," like bseg-hkont,

bukrs(XX) type cahr," like bkpf-bukrs,

wrbtr(XX) type cahr," like bseg-wrbtr,

gsber(XX) type cahr," like cobl-gsber,

newbs(XX) type cahr," like rf05a-newbs,

end of itab.

maintain the flat file in excel/text format

use to upload

CALL FUNCTION 'UPLOAD'

EXPORTING

filename = 'c:\windows\desktop\'

filetype = 'DAT'

TABLES

data_tab = itab.

loop itab.

pass records to BDC...ok

endloop.

Regards,

Ramesh.

Read only

0 Likes
681

cud u plz tell me little bit more about how records are passed to bdc.

Read only

andreas_mann3
Active Contributor
0 Likes
681

.

Read only

andreas_mann3
Active Contributor
0 Likes
681

Hi,

1) have you record your bdc with tcode SHDB

2) better use bapi (BAPI_ACC_DOCUMENT_POST ) or report rfbibl00 for posting documents

A.