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

FB01: BDC

Former Member
0 Likes
557

Hi to all Experts,

I need to write BDC FOR FB01 Transaction. if any body has sample one to do, it would be a greate help for me. pls.send me sample one if u have any .

As it is urgent , pls.help me in this regard.\

Regards,

Kiran Kumar Revu.

2 REPLIES 2
Read only

Former Member
0 Likes
477

Hi kumar,

you can find no of threads for ur post,

just go to search option provide ur post and enter

No need to wait for answers to ur question.

All the best

Thanks

Naveen khan

Read only

Former Member
0 Likes
477

hi Kumar,

use this sample code after getting the flat file data into your internal table ITAB.

&----


*& Form Create_session

&----


  • text

----


  • Create Session

----


form create_session .

*Create the Session

call function 'BDC_OPEN_GROUP'

exporting

client = sy-mandt

group = S_name

keep = c_x

user = sy-uname.

endform. " Create_session

form build_bdc_data_trans1 .

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'

itab-bldat. " Document Date

perform bdc_field using 'BKPF-BLART'

itab-blart. " Doc Type

perform bdc_field using 'BKPF-BUKRS'

itab-bukrs. " Company code

perform bdc_field using 'BKPF-BUDAT'

itab-budat. " Posting Date

perform bdc_field using 'BKPF-WAERS'

itab-waers. " Currency type

perform bdc_field using 'BKPF-XBLNR'

itab-xblnr.

perform bdc_field using 'BKPF-BKTXT'

itab-bktxt.

perform bdc_field using 'RF05A-NEWBS'

itab-newbs.

perform bdc_field using 'RF05A-NEWKO'

itab-newko.

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'

itab-wrbtr. " Amount

perform bdc_field using 'BSEG-ZUONR'

itab-zuonr.

perform bdc_field using 'BSEG-SGTXT'

itab-sgtxt. "Emp name

perform bdc_field using 'RF05A-NEWBS'

itab-newbs.

perform bdc_field using 'RF05A-NEWKO'

itab-newko.

  • subscr '0002' for Cost Center

perform bdc_dynpro using 'SAPLKACB' '0002'.

perform bdc_field using 'BDC_OKCODE'

'=ENTE'.

perform bdc_field using 'COBL-KOSTL'

itab-kostl.

perform bdc_field using 'COBL-PERNR'

itab-pernr.

  • 3rd Screen for Vendor Ac data

perform bdc_dynpro using 'SAPMF05A' '0302'.

perform bdc_field using 'BDC_CURSOR'

'BSEG-SGTXT'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'BSEG-WRBTR'

itab-wrbtr. " Amt

perform bdc_field using 'BSEG-ZUONR'

itab-zuonr.

perform bdc_field using 'BSEG-SGTXT'

itab-sgtxt.

perform bdc_field using 'BDC_OKCODE'

'=BU'.

endform.

&----


*& Form Insert_bdc_data

&----


  • text

----


  • Insert BDC data into the session

----


form insert_bdc_data .

  • Insert BDC data

call function 'BDC_INSERT'

exporting

tcode = c_fb01

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.

*Refresh bdc structured table

refresh i_bdcdata.

endform. " Insert_bdc_data

&----


*& Form close_session

&----


  • text

----


  • Close the Session.

----


form close_session .

  • Close the Session

call function 'BDC_CLOSE_GROUP'.

endform. " close_session

&----


*& Form bdc_dynpro

&----


  • text

----


*Populating Prog name, dynpros

----


form bdc_dynpro using pv_prog type bdc_prog

pv_dynp type bdc_dynr.

wa_bdcdata-program = pv_prog. " Program name

wa_bdcdata-dynpro = pv_dynp. " Screen number

wa_bdcdata-dynbegin = c_x. " Screen Activation

append wa_bdcdata to i_bdcdata.

clear wa_bdcdata.

endform. " bdc_dynpro

&----


*& Form bdc_field

&----


  • text

----


  • Populating Tech. field names and values into the dynpros

----


form bdc_field using pv_fname type any

pv_fval type any.

wa_bdcdata-fnam = pv_fname. " field name

wa_bdcdata-fval = pv_fval. " field value

append wa_bdcdata to i_bdcdata.

clear wa_bdcdata.

endform. " bdc_field

<b>Reward points if useful</b>

Chandra