Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

BDC For T-Code F-02

Dear Friends,

Do anybody has the code for BDC for Transaction Code F-02.

If anybody has plz send me.

Thanks & Reg,

Nishant

Tags:
Former Member
Former Member replied

try this:

REPORT zfir_f02

NO STANDARD PAGE HEADING LINE-SIZE 255.

INCLUDE bdcrecx1.

TYPES : BEGIN OF tp_flatfile,

bldat(10),

doctyp(2),

comp(4),

postdate(10),

period(2),

currency(5),

reference(16),

htext(25),

postkey(2),

account(17),

amount(16),

profit(10),

assign(18),

text(50),

busarea(4),

cost(10),

bline(10),

base(16),

postkey2(2),

account2(17),

amount2(16),

profit2(10),

assign2(18),

text2(50),

busarea2(4),

END OF tp_flatfile.

DATA : t_flatfile TYPE TABLE OF tp_flatfile WITH HEADER LINE.

DATA : g_file TYPE string.

CLASS cl_abap_char_utilities DEFINITION LOAD.

CONSTANTS:con_tab TYPE c VALUE cl_abap_char_utilities=>horizontal_tab.

SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME.

PARAMETERS : p_file LIKE rlgrap-filename OBLIGATORY.

SELECTION-SCREEN END OF BLOCK blk1.

*C-- Selection Screen VALUE-REQUEST FOR File path

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.

CALL FUNCTION 'F4_FILENAME'

EXPORTING

program_name = syst-cprog

dynpro_number = syst-dynnr

IMPORTING

file_name = p_file.

g_file = p_file.

*START-OF-SELECTION.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = g_file

filetype = 'ASC'

has_field_separator = 'X'

TABLES

data_tab = t_flatfile

EXCEPTIONS

file_open_error = 1

file_read_error = 2

no_batch = 3

gui_refuse_filetransfer = 4

invalid_type = 5

no_authority = 6

unknown_error = 7

bad_data_format = 8

header_not_allowed = 9

separator_not_allowed = 10

header_too_long = 11

unknown_dp_error = 12

access_denied = 13

dp_out_of_memory = 14

disk_full = 15

dp_timeout = 16

OTHERS = 17.

  • loop at t_flatfile.

  • write:/ t_flatfile-doctyp,t_flatfile-amount.

  • endloop.

START-OF-SELECTION.

PERFORM open_group.

LOOP AT t_flatfile.

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'

t_flatfile-bldat.

PERFORM bdc_field USING 'BKPF-BLART'

t_flatfile-doctyp.

PERFORM bdc_field USING 'BKPF-BUKRS'

t_flatfile-comp.

PERFORM bdc_field USING 'BKPF-BUDAT'

t_flatfile-postdate.

PERFORM bdc_field USING 'BKPF-MONAT'

t_flatfile-period.

PERFORM bdc_field USING 'BKPF-WAERS'

t_flatfile-currency.

PERFORM bdc_field USING 'BKPF-XBLNR'

t_flatfile-reference.

PERFORM bdc_field USING 'BKPF-BKTXT'

t_flatfile-htext.

PERFORM bdc_field USING 'FS006-DOCID'

'*'.

PERFORM bdc_field USING 'RF05A-NEWBS'

t_flatfile-postkey.

PERFORM bdc_field USING 'RF05A-NEWKO'

t_flatfile-account.

CASE t_flatfile-postkey.

WHEN '40' OR '50'.

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'

t_flatfile-amount.

PERFORM bdc_field USING 'BSEG-ZUONR'

t_flatfile-assign.

PERFORM bdc_field USING 'BSEG-SGTXT'

t_flatfile-text.

IF t_flatfile-postkey = '40' and t_flatfile-account > '300000'.

PERFORM bdc_field USING 'DKACB-FMORE'

'X'.

ENDIF.

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'

t_flatfile-busarea.

  • PERFORM bdc_field USING 'BDC_OKCODE'

  • '=ENTE'.

PERFORM bdc_field USING 'COBL-KOSTL'

t_flatfile-cost.

PERFORM bdc_field USING 'COBL-PRCTR'

t_flatfile-profit.

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 'RF05A-NEWBS'

t_flatfile-postkey2.

PERFORM bdc_field USING 'RF05A-NEWKO'

t_flatfile-account2.

PERFORM debit_credit.

WHEN '21' OR '31' OR '24' OR '34'.

**perform bdc_field using 'RF05A-NEWBS'

    • '31'.

**perform bdc_field using 'RF05A-NEWKO'

    • '25000'.

  • PERFORM bdc_field USING 'DKACB-FMORE'

  • 'X'.

  • PERFORM bdc_dynpro USING 'SAPMF05A' '0302'.

  • PERFORM bdc_field USING 'BDC_CURSOR'

  • 'RF05A-NEWKO'.

  • PERFORM bdc_field USING 'BDC_OKCODE'

  • '/00'.

  • 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'

  • t_flatfile-busarea.

  • PERFORM bdc_field USING 'COBL-KOSTL'

  • t_flatfile-cost.

PERFORM bdc_dynpro USING 'SAPMF05A' '0302'.

PERFORM bdc_field USING 'BDC_CURSOR'

'RF05A-NEWKO'.

PERFORM bdc_field USING 'BDC_OKCODE'

'/00'.

PERFORM bdc_field USING 'BSEG-WRBTR'

t_flatfile-amount.

PERFORM bdc_field USING 'BSEG-GSBER'

t_flatfile-busarea.

PERFORM bdc_field USING 'BSEG-ZFBDT'

t_flatfile-bline.

PERFORM bdc_field USING 'BSEG-SKFBT'

t_flatfile-base.

PERFORM bdc_field USING 'BSEG-ZUONR'

t_flatfile-assign.

PERFORM bdc_field USING 'BSEG-SGTXT'

t_flatfile-text.

PERFORM bdc_field USING 'RF05A-NEWBS'

t_flatfile-postkey2.

PERFORM bdc_field USING 'RF05A-NEWKO'

t_flatfile-account2.

  • 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 debit_credit.

  • 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'

  • t_flatfile-amount2.

  • PERFORM bdc_field USING 'BSEG-ZUONR'

  • t_flatfile-assign2.

  • PERFORM bdc_field USING 'BSEG-SGTXT'

  • t_flatfile-text2.

  • 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'

  • t_flatfile-busarea2.

    • PERFORM bdc_field USING 'COBL-KOSTL'

    • t_flatfile-cost.

  • PERFORM bdc_field USING 'COBL-PRCTR'

  • t_flatfile-profit2.

  • PERFORM bdc_dynpro USING 'SAPMF05A' '0300'.

  • PERFORM bdc_field USING 'BDC_CURSOR'

  • 'RF05A-NEWKO'.

  • PERFORM bdc_field USING 'BDC_OKCODE'

  • '=BU'.

  • PERFORM bdc_dynpro USING 'SAPLKACB' '0002'.

  • PERFORM bdc_field USING 'BDC_CURSOR'

  • 'COBL-GSBER'.

  • PERFORM bdc_field USING 'BDC_OKCODE'

  • '=ENTE'.

WHEN '01' OR '11' OR '04' OR '14' OR '07' OR '17'.

*perform bdc_field using 'RF05A-NEWBS'

  • '11'.

*perform bdc_field using 'RF05A-NEWKO'

  • '1'.

PERFORM bdc_dynpro USING 'SAPMF05A' '0301'.

PERFORM bdc_field USING 'BDC_CURSOR'

'BSEG-SGTXT'.

PERFORM bdc_field USING 'BDC_OKCODE'

'/00'.

PERFORM bdc_field USING 'BSEG-WRBTR'

t_flatfile-amount.

PERFORM bdc_field USING 'BSEG-MWSKZ'

'**'.

PERFORM bdc_field USING 'BSEG-GSBER'

t_flatfile-busarea.

IF NOT t_flatfile-bline IS INITIAL.

PERFORM bdc_field USING 'BSEG-ZFBDT'

t_flatfile-bline.

ENDIF.

IF NOT t_flatfile-base IS INITIAL.

PERFORM bdc_field USING 'BSEG-SKFBT'

t_flatfile-base.

ENDIF.

PERFORM bdc_field USING 'BSEG-ZUONR'

t_flatfile-assign.

PERFORM bdc_field USING 'BSEG-SGTXT'

t_flatfile-text.

PERFORM bdc_field USING 'RF05A-NEWBS'

t_flatfile-postkey2.

PERFORM bdc_field USING 'RF05A-NEWKO'

t_flatfile-account2.

PERFORM debit_credit.

ENDCASE.

*perform bdc_dynpro using 'SAPMF05A' '0301'.

*perform bdc_field using 'BDC_CURSOR'

  • 'BSEG-WRBTR'.

*perform bdc_field using 'BDC_OKCODE'

  • '=AB'.

*perform bdc_field using 'BSEG-WRBTR'

  • '3,000.00'.

*perform bdc_field using 'BSEG-MWSKZ'

  • '**'.

*perform bdc_field using 'BSEG-GSBER'

  • 'VUSO'.

*perform bdc_field using 'BSEG-ZFBDT'

  • '19.07.2005'.

*perform bdc_field using 'BSEG-SKFBT'

  • '3,000.00'.

*perform bdc_field using 'BSEG-ZUONR'

  • 'ASSIGN'.

*perform bdc_field using 'BSEG-SGTXT'

  • 'TEXT'.

  • 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'

  • 'REF'.

*perform bdc_field using 'BKPF-BKTXT'

  • 'text'.

PERFORM bdc_transaction USING 'F-02'.

ENDLOOP.

PERFORM close_group.

&----


*& Form debit_credit

&----


  • text

----


FORM debit_credit.

**SRINI

IF t_flatfile-postkey = '40' OR t_flatfile-postkey = '50'.

PERFORM bdc_dynpro USING 'SAPLKACB' '0002'.

PERFORM bdc_field USING 'BDC_CURSOR'

'COBL-GSBER'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=ENTE'.

ENDIF.

***SRINI

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'

t_flatfile-amount2.

PERFORM bdc_field USING 'BSEG-ZUONR'

t_flatfile-assign2.

PERFORM bdc_field USING 'BSEG-SGTXT'

t_flatfile-text2.

PERFORM bdc_dynpro USING 'SAPLKACB' '0002'.

PERFORM bdc_field USING 'BDC_CURSOR'

  • 'COBL-KOSTL'.

'COBL-GSBER'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=ENTE'.

PERFORM bdc_field USING 'COBL-GSBER'

t_flatfile-busarea2.

  • PERFORM bdc_field USING 'COBL-KOSTL'

  • t_flatfile-cost.

PERFORM bdc_field USING 'COBL-PRCTR'

t_flatfile-profit2.

PERFORM bdc_dynpro USING 'SAPMF05A' '0300'.

PERFORM bdc_field USING 'BDC_CURSOR'

'RF05A-NEWKO'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=BU'.

PERFORM bdc_dynpro USING 'SAPLKACB' '0002'.

PERFORM bdc_field USING 'BDC_CURSOR'

'COBL-GSBER'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=ENTE'.

ENDFORM. "debit_credit

regards,

Bikash

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question