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: 

BDC for FB01

Former Member
0 Kudos
365

Hai,

can anyone tell me the BDC for invoice creation in FI. Please send me the recording and any sample code. Because iam trying for it.

Thanks

Avi.

1 ACCEPTED SOLUTION

Former Member
0 Kudos
121

Hi,

You can try this recording.

<b>

include bdcrecx1.

parameters: dataset(132) lower case.

      • DO NOT CHANGE - the generated data section - DO NOT CHANGE ***

*

  • If it is nessesary to change the data section use the rules:

  • 1.) Each definition of a field exists of two lines

  • 2.) The first line shows exactly the comment

  • '* data element: ' followed with the data element

  • which describes the field.

  • If you don't have a data element use the

  • comment without a data element name

  • 3.) The second line shows the fieldname of the

  • structure, the fieldname must consist of

  • a fieldname and optional the character '_' and

  • three numbers and the field length in brackets

  • 4.) Each field must be type C.

*

      • Generated data section with specific formatting - DO NOT CHANGE ***

data: begin of record,

  • data element: BLDAT

BLDAT_001(010),

  • data element: BLART

BLART_002(002),

  • data element: BUKRS

BUKRS_003(004),

  • data element: BUDAT

BUDAT_004(010),

  • data element: MONAT

MONAT_005(002),

  • data element: WAERS

WAERS_006(005),

  • data element: XBLNR

XBLNR_007(016),

  • data element: BKTXT

BKTXT_008(025),

  • data element: SAEOBJART

DOCID_009(010),

  • data element: NEWBS

NEWBS_010(002),

  • data element: NEWKO

NEWKO_011(017),

  • data element: WRBTR

WRBTR_012(016),

  • data element: DZTERM

ZTERM_013(004),

  • data element: DZBD1T

ZBD1T_014(003),

  • data element: DZFBDT

ZFBDT_015(010),

  • data element: DZLSPR

ZLSPR_016(001),

  • data element: DZUONR

ZUONR_017(018),

  • data element: SGTXT

SGTXT_018(050),

  • data element: DMBE2

DMBE2_019(016),

  • data element: XREF1

XREF1_020(012),

  • data element: XREF2

XREF2_021(012),

  • data element: NEWBS

NEWBS_022(002),

  • data element: NEWKO

NEWKO_023(017),

  • data element: WRBTR

WRBTR_024(016),

  • data element: MWSKZ

MWSKZ_025(002),

  • data element: XMWST

XMWST_026(001),

  • data element: MENGE_D

MENGE_027(017),

  • data element: MEINS

MEINS_028(003),

  • data element: VALUT

VALUT_029(010),

  • data element: DZUONR

ZUONR_030(018),

  • data element: SGTXT

SGTXT_031(050),

  • data element: FMORE

FMORE_032(001),

  • data element: KOSTL

KOSTL_033(010),

  • data element: AUFNR

AUFNR_034(012),

  • data element: DMBE2

DMBE2_035(016),

  • data element: XREF1

XREF1_036(012),

  • data element: XREF2

XREF2_037(012),

  • data element: XREF3

XREF3_038(020),

end of record.

      • End generated data section ***

start-of-selection.

perform open_dataset using dataset.

perform open_group.

do.

read dataset dataset into record.

if sy-subrc <> 0. exit. endif.

perform bdc_dynpro using 'SAPMF05A' '0100'.

perform bdc_field using 'BDC_CURSOR'

'BKPF-WAERS'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'BKPF-BLDAT'

record-BLDAT_001.

perform bdc_field using 'BKPF-BLART'

record-BLART_002.

perform bdc_field using 'BKPF-BUKRS'

record-BUKRS_003.

perform bdc_field using 'BKPF-BUDAT'

record-BUDAT_004.

perform bdc_field using 'BKPF-MONAT'

record-MONAT_005.

perform bdc_field using 'BKPF-WAERS'

record-WAERS_006.

perform bdc_field using 'BKPF-XBLNR'

record-XBLNR_007.

perform bdc_field using 'BKPF-BKTXT'

record-BKTXT_008.

perform bdc_field using 'FS006-DOCID'

record-DOCID_009.

perform bdc_field using 'RF05A-NEWBS'

record-NEWBS_010.

perform bdc_field using 'RF05A-NEWKO'

record-NEWKO_011.

perform bdc_dynpro using 'SAPMF05A' '0302'.

perform bdc_field using 'BDC_CURSOR'

'BSEG-SGTXT'.

perform bdc_field using 'BDC_OKCODE'

'=ZK'.

perform bdc_field using 'BSEG-WRBTR'

record-WRBTR_012.

perform bdc_field using 'BSEG-ZTERM'

record-ZTERM_013.

perform bdc_field using 'BSEG-ZBD1T'

record-ZBD1T_014.

perform bdc_field using 'BSEG-ZFBDT'

record-ZFBDT_015.

perform bdc_field using 'BSEG-ZLSPR'

record-ZLSPR_016.

perform bdc_field using 'BSEG-ZUONR'

record-ZUONR_017.

perform bdc_field using 'BSEG-SGTXT'

record-SGTXT_018.

perform bdc_dynpro using 'SAPMF05A' '0332'.

perform bdc_field using 'BDC_CURSOR'

'RF05A-NEWKO'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'BSEG-DMBE2'

record-DMBE2_019.

perform bdc_field using 'BSEG-XREF1'

record-XREF1_020.

perform bdc_field using 'BSEG-XREF2'

record-XREF2_021.

perform bdc_field using 'RF05A-NEWBS'

record-NEWBS_022.

perform bdc_field using 'RF05A-NEWKO'

record-NEWKO_023.

perform bdc_dynpro using 'SAPMF05A' '0300'.

perform bdc_field using 'BDC_CURSOR'

'BSEG-MWSKZ'.

perform bdc_field using 'BDC_OKCODE'

'=ZK'.

perform bdc_field using 'BSEG-WRBTR'

record-WRBTR_024.

perform bdc_field using 'BSEG-MWSKZ'

record-MWSKZ_025.

perform bdc_field using 'BKPF-XMWST'

record-XMWST_026.

perform bdc_field using 'BSEG-MENGE'

record-MENGE_027.

perform bdc_field using 'BSEG-MEINS'

record-MEINS_028.

perform bdc_field using 'BSEG-VALUT'

record-VALUT_029.

perform bdc_field using 'BSEG-ZUONR'

record-ZUONR_030.

perform bdc_field using 'BSEG-SGTXT'

record-SGTXT_031.

perform bdc_field using 'DKACB-FMORE'

record-FMORE_032.

perform bdc_dynpro using 'SAPLKACB' '0002'.

perform bdc_field using 'BDC_CURSOR'

'COBL-AUFNR'.

perform bdc_field using 'BDC_OKCODE'

'=ENTE'.

perform bdc_field using 'COBL-KOSTL'

record-KOSTL_033.

perform bdc_field using 'COBL-AUFNR'

record-AUFNR_034.

perform bdc_dynpro using 'SAPMF05A' '0330'.

perform bdc_field using 'BDC_CURSOR'

'BSEG-CCBTC'.

perform bdc_field using 'BDC_OKCODE'

'=BU'.

perform bdc_field using 'BSEG-DMBE2'

record-DMBE2_035.

perform bdc_field using 'BSEG-XREF1'

record-XREF1_036.

perform bdc_field using 'BSEG-XREF2'

record-XREF2_037.

perform bdc_field using 'BSEG-XREF3'

record-XREF3_038.

perform bdc_transaction using 'FB01'.

enddo.

perform close_group.

perform close_dataset using dataset.

</b>

Cheers

Manju

2 REPLIES 2

Former Member
0 Kudos
122

Hi,

You can try this recording.

<b>

include bdcrecx1.

parameters: dataset(132) lower case.

      • DO NOT CHANGE - the generated data section - DO NOT CHANGE ***

*

  • If it is nessesary to change the data section use the rules:

  • 1.) Each definition of a field exists of two lines

  • 2.) The first line shows exactly the comment

  • '* data element: ' followed with the data element

  • which describes the field.

  • If you don't have a data element use the

  • comment without a data element name

  • 3.) The second line shows the fieldname of the

  • structure, the fieldname must consist of

  • a fieldname and optional the character '_' and

  • three numbers and the field length in brackets

  • 4.) Each field must be type C.

*

      • Generated data section with specific formatting - DO NOT CHANGE ***

data: begin of record,

  • data element: BLDAT

BLDAT_001(010),

  • data element: BLART

BLART_002(002),

  • data element: BUKRS

BUKRS_003(004),

  • data element: BUDAT

BUDAT_004(010),

  • data element: MONAT

MONAT_005(002),

  • data element: WAERS

WAERS_006(005),

  • data element: XBLNR

XBLNR_007(016),

  • data element: BKTXT

BKTXT_008(025),

  • data element: SAEOBJART

DOCID_009(010),

  • data element: NEWBS

NEWBS_010(002),

  • data element: NEWKO

NEWKO_011(017),

  • data element: WRBTR

WRBTR_012(016),

  • data element: DZTERM

ZTERM_013(004),

  • data element: DZBD1T

ZBD1T_014(003),

  • data element: DZFBDT

ZFBDT_015(010),

  • data element: DZLSPR

ZLSPR_016(001),

  • data element: DZUONR

ZUONR_017(018),

  • data element: SGTXT

SGTXT_018(050),

  • data element: DMBE2

DMBE2_019(016),

  • data element: XREF1

XREF1_020(012),

  • data element: XREF2

XREF2_021(012),

  • data element: NEWBS

NEWBS_022(002),

  • data element: NEWKO

NEWKO_023(017),

  • data element: WRBTR

WRBTR_024(016),

  • data element: MWSKZ

MWSKZ_025(002),

  • data element: XMWST

XMWST_026(001),

  • data element: MENGE_D

MENGE_027(017),

  • data element: MEINS

MEINS_028(003),

  • data element: VALUT

VALUT_029(010),

  • data element: DZUONR

ZUONR_030(018),

  • data element: SGTXT

SGTXT_031(050),

  • data element: FMORE

FMORE_032(001),

  • data element: KOSTL

KOSTL_033(010),

  • data element: AUFNR

AUFNR_034(012),

  • data element: DMBE2

DMBE2_035(016),

  • data element: XREF1

XREF1_036(012),

  • data element: XREF2

XREF2_037(012),

  • data element: XREF3

XREF3_038(020),

end of record.

      • End generated data section ***

start-of-selection.

perform open_dataset using dataset.

perform open_group.

do.

read dataset dataset into record.

if sy-subrc <> 0. exit. endif.

perform bdc_dynpro using 'SAPMF05A' '0100'.

perform bdc_field using 'BDC_CURSOR'

'BKPF-WAERS'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'BKPF-BLDAT'

record-BLDAT_001.

perform bdc_field using 'BKPF-BLART'

record-BLART_002.

perform bdc_field using 'BKPF-BUKRS'

record-BUKRS_003.

perform bdc_field using 'BKPF-BUDAT'

record-BUDAT_004.

perform bdc_field using 'BKPF-MONAT'

record-MONAT_005.

perform bdc_field using 'BKPF-WAERS'

record-WAERS_006.

perform bdc_field using 'BKPF-XBLNR'

record-XBLNR_007.

perform bdc_field using 'BKPF-BKTXT'

record-BKTXT_008.

perform bdc_field using 'FS006-DOCID'

record-DOCID_009.

perform bdc_field using 'RF05A-NEWBS'

record-NEWBS_010.

perform bdc_field using 'RF05A-NEWKO'

record-NEWKO_011.

perform bdc_dynpro using 'SAPMF05A' '0302'.

perform bdc_field using 'BDC_CURSOR'

'BSEG-SGTXT'.

perform bdc_field using 'BDC_OKCODE'

'=ZK'.

perform bdc_field using 'BSEG-WRBTR'

record-WRBTR_012.

perform bdc_field using 'BSEG-ZTERM'

record-ZTERM_013.

perform bdc_field using 'BSEG-ZBD1T'

record-ZBD1T_014.

perform bdc_field using 'BSEG-ZFBDT'

record-ZFBDT_015.

perform bdc_field using 'BSEG-ZLSPR'

record-ZLSPR_016.

perform bdc_field using 'BSEG-ZUONR'

record-ZUONR_017.

perform bdc_field using 'BSEG-SGTXT'

record-SGTXT_018.

perform bdc_dynpro using 'SAPMF05A' '0332'.

perform bdc_field using 'BDC_CURSOR'

'RF05A-NEWKO'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'BSEG-DMBE2'

record-DMBE2_019.

perform bdc_field using 'BSEG-XREF1'

record-XREF1_020.

perform bdc_field using 'BSEG-XREF2'

record-XREF2_021.

perform bdc_field using 'RF05A-NEWBS'

record-NEWBS_022.

perform bdc_field using 'RF05A-NEWKO'

record-NEWKO_023.

perform bdc_dynpro using 'SAPMF05A' '0300'.

perform bdc_field using 'BDC_CURSOR'

'BSEG-MWSKZ'.

perform bdc_field using 'BDC_OKCODE'

'=ZK'.

perform bdc_field using 'BSEG-WRBTR'

record-WRBTR_024.

perform bdc_field using 'BSEG-MWSKZ'

record-MWSKZ_025.

perform bdc_field using 'BKPF-XMWST'

record-XMWST_026.

perform bdc_field using 'BSEG-MENGE'

record-MENGE_027.

perform bdc_field using 'BSEG-MEINS'

record-MEINS_028.

perform bdc_field using 'BSEG-VALUT'

record-VALUT_029.

perform bdc_field using 'BSEG-ZUONR'

record-ZUONR_030.

perform bdc_field using 'BSEG-SGTXT'

record-SGTXT_031.

perform bdc_field using 'DKACB-FMORE'

record-FMORE_032.

perform bdc_dynpro using 'SAPLKACB' '0002'.

perform bdc_field using 'BDC_CURSOR'

'COBL-AUFNR'.

perform bdc_field using 'BDC_OKCODE'

'=ENTE'.

perform bdc_field using 'COBL-KOSTL'

record-KOSTL_033.

perform bdc_field using 'COBL-AUFNR'

record-AUFNR_034.

perform bdc_dynpro using 'SAPMF05A' '0330'.

perform bdc_field using 'BDC_CURSOR'

'BSEG-CCBTC'.

perform bdc_field using 'BDC_OKCODE'

'=BU'.

perform bdc_field using 'BSEG-DMBE2'

record-DMBE2_035.

perform bdc_field using 'BSEG-XREF1'

record-XREF1_036.

perform bdc_field using 'BSEG-XREF2'

record-XREF2_037.

perform bdc_field using 'BSEG-XREF3'

record-XREF3_038.

perform bdc_transaction using 'FB01'.

enddo.

perform close_group.

perform close_dataset using dataset.

</b>

Cheers

Manju

0 Kudos
121

Dear Manju,

I have written the code similarly but unable to post last document if more than one document exist.

Can you help me if you want I shall send you the code.

Thanks,

Harish