‎2007 Sep 18 12:40 PM
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.
‎2007 Sep 18 1:01 PM
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
‎2007 Sep 18 1:30 PM
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