Skip to Content
0
Former Member
Aug 14, 2007 at 06:56 PM

BDC for FB50L...URGENT

32 Views

Hi,

I am doing the BDC for FB50L but the code doesn't seem to execute...it is giving errors...

I am attaching the code...Please review it and help me....its really urgent...

Your help will be really appreciated...

REPORT ZTEST_BDC_PARK_ACC_GL.

DATA:

t_document_line_item_main LIKE bapiacgl09 OCCURS 100,

t_document_line_item_enhn LIKE bapiacextc OCCURS 100,

t_document_line_item_amnt LIKE bapiaccr09 OCCURS 100,

t_return LIKE bapiret2 OCCURS 100,

wa_document_header LIKE bapiache09,

wa_document_line_item_main LIKE bapiacgl09,

wa_document_line_item_enhn LIKE bapiacextc,

wa_document_line_item_amnt LIKE bapiaccr09,

wa_return LIKE bapiret2.

DATA: it_bdcdata TYPE TABLE OF bdcdata,

it_messages TYPE TABLE OF bdcmsgcoll,

wa_messages TYPE bdcmsgcoll,

options TYPE ctu_params.

DATA: idx TYPE i,

ch3(5) TYPE c,

fname(40) TYPE c.

DATA: indate TYPE d,

intdate TYPE D.

CLEAR wa_document_header.

wa_document_header-obj_type = space. "

wa_document_header-obj_key = space.

wa_document_header-obj_sys = space.

wa_document_header-bus_act = 'RFBU'.

wa_document_header-username = 'INFAUSRTEST'.

wa_document_header-header_txt = 'BAPI__POST'.

wa_document_header-comp_code = '1001'.

wa_document_header-doc_date = '20070814'.

wa_document_header-pstng_date = '20070814'.

CLEAR wa_document_header-trans_date.

CLEAR wa_document_header-fisc_year.

CLEAR wa_document_header-fis_period.

wa_document_header-doc_type = 'SY'.

wa_document_header-ref_doc_no = 'REQUIRED'.

wa_document_header-ac_doc_no = space.

wa_document_header-obj_key_r = space.

wa_document_header-reason_rev = space.

wa_document_header-compo_acc = space.

wa_document_header-ref_doc_no_long = space.

wa_document_header-acc_principle = 'LGAP'.

wa_document_header-neg_postng = space.

wa_document_header-obj_key_inv = space.

wa_document_header-bill_category = space.

  • Fill Line Item #1

CLEAR: wa_document_line_item_main, wa_document_line_item_enhn, wa_document_line_item_amnt.

  • Fill Main Portion Of Accounting Line Item

wa_document_line_item_main-itemno_acc = '1'. "Accounting Document Line Item Number

wa_document_line_item_main-gl_account = '2412001067'."HKONT - Account

wa_document_line_item_main-item_text = 'Test BAPI'. "SGTXT - Item Text

wa_document_line_item_main-doc_type = space. "BLART - Document Type

wa_document_line_item_main-comp_code = space. "BUKRS - Company Code

wa_document_line_item_main-pstng_date = '20070814'. "BUDAT - Posting Date

wa_document_line_item_main-alloc_nmbr = space. "ZUONR - Allocation Number

wa_document_line_item_main-costcenter = space. "KOSTL - Cost Center

wa_document_line_item_main-profit_ctr = space. "PRCTR - Profit Center

wa_document_line_item_main-de_cre_ind = 'D'. "NEWBS - Posting Key / Debit Credit Indicator

wa_document_line_item_main-trade_id = space. "RASSC - Company ID Of Trading Partner

***************************************************************************************************

  • Fill Amount Portion Of Accounting Line Item

wa_document_line_item_amnt-itemno_acc = '1'. "Accounting Document Line Item Number

wa_document_line_item_amnt-curr_type = '00'. "Currency Type

wa_document_line_item_amnt-currency = 'USD'. "WAERS - Currency Key

wa_document_line_item_amnt-amt_doccur = '239959'. "WRBTR - Amount In Document Currency Type

***************************************************************************************************

APPEND: wa_document_line_item_main TO t_document_line_item_main,

wa_document_line_item_amnt TO t_document_line_item_amnt.

  • Fill Next Line Item #2

CLEAR: wa_document_line_item_main, wa_document_line_item_enhn, wa_document_line_item_amnt.

  • Fill Main Portion Of Accounting Line Item

wa_document_line_item_main-itemno_acc = '2'. "Accounting Document Line Item Number

wa_document_line_item_main-gl_account = '2412001067'."HKONT - Account

wa_document_line_item_main-item_text = 'Test BAPI'. "SGTXT - Item Text

wa_document_line_item_main-doc_type = space. "BLART - Document Type

wa_document_line_item_main-comp_code = space. "BUKRS - Company Code

wa_document_line_item_main-pstng_date = '20070814'. "BUDAT - Posting Date

wa_document_line_item_main-alloc_nmbr = space. "ZUONR - Allocation Number

wa_document_line_item_main-costcenter = space. "KOSTL - Cost Center

wa_document_line_item_main-profit_ctr = space. "PRCTR - Profit Center

wa_document_line_item_main-de_cre_ind = 'C'. "NEWBS - Posting Key / Debit Credit Indicator

wa_document_line_item_main-trade_id = space. "RASSC - Company ID Of Trading Partner

***************************************************************************************************

  • Fill Enhancement Portion Of Accounting Line Item

  • Fill Amount Portion Of Accounting Line Item

wa_document_line_item_amnt-itemno_acc = '2'. "Accounting Document Line Item Number

wa_document_line_item_amnt-curr_type = '00'. "Currency Type

wa_document_line_item_amnt-currency = 'USD'. "WAERS - Currency Key

wa_document_line_item_amnt-amt_doccur = '-239959'. "WRBTR - Amount In Document Currency Type

***************************************************************************************************

APPEND: wa_document_line_item_main TO t_document_line_item_main,

wa_document_line_item_amnt TO t_document_line_item_amnt.

*************************BDC PROGRAM**************************************************************

PERFORM bdc_dynpro TABLES it_bdcdata USING 'SAPMF05A' wa_document_header-comp_code .

PERFORM bdc_field TABLES it_bdcdata USING 'BDC_OKCODE'

'=BP'.

MOVE wa_document_header-doc_date TO indate.

CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'

EXPORTING

date_external = indate

IMPORTING

date_internal = intdate.

PERFORM bdc_field TABLES it_bdcdata USING 'ACGL_HEAD-BLDAT'

INTDATE.

perform bdc_field TABLES it_bdcdata USING 'ACGL_HEAD-WAERS'

wa_document_line_item_amnt-currency.

MOVE wa_document_header-pstng_date TO indate.

CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'

EXPORTING

date_external = indate

IMPORTING

date_internal = intdate.

PERFORM bdc_field TABLES it_bdcdata USING 'ACGL_HEAD-BUDAT'

INTDATE.

perform bdc_field TABLES it_bdcdata USING 'ACGL_HEAD-XBLNR'

wa_document_header-ref_doc_no.

PERFORM bdc_field TABLES it_bdcdata USING 'ACGL_HEAD-BKTXT'

wa_document_header-header_txt.

LOOP AT t_document_line_item_main INTO wa_document_line_item_main.

idx = idx + 1.

ch3 = idx.

CONCATENATE 'ACGL_ITEM-HKONT(' ch3 ')' INTO fname.

CONDENSE fname.

PERFORM bdc_field TABLES it_bdcdata USING fname

wa_document_line_item_main-gl_account.

CONCATENATE 'ACGL_ITEM-SHKZG(' ch3 ')' INTO fname.

CONDENSE fname.

PERFORM bdc_field TABLES it_bdcdata USING fname

wa_document_line_item_main-de_cre_ind.

CONCATENATE 'ACGL_ITEM-WRBTR(' ch3 ')' INTO fname.

CONDENSE fname.

PERFORM bdc_field TABLES it_bdcdata USING fname

wa_document_line_item_amnt-amt_doccur.

CONCATENATE 'ACGL_ITEM-SGTXT(' ch3 ')' INTO fname.

CONDENSE fname.

PERFORM bdc_field TABLES it_bdcdata USING fname

wa_document_line_item_main-item_text .

ENDLOOP.

options-dismode = 'A'.

options-nobinpt = 'X'.

CALL TRANSACTION 'FB50' USING it_bdcdata MESSAGES INTO

it_messages OPTIONS FROM options.

*----


*

  • Start new screen

*

*----


*

FORM bdc_dynpro TABLES it_bdcdata STRUCTURE bdcdata USING program

dynpro

.

DATA: wa_bdcdata TYPE bdcdata.

wa_bdcdata-program = program.

wa_bdcdata-dynpro = dynpro.

wa_bdcdata-dynbegin = 'X'.

APPEND wa_bdcdata TO it_bdcdata.

ENDFORM. "BDC_DYNPRO

*----


*

  • Insert field

*

*----


*

FORM bdc_field TABLES it_bdcdata STRUCTURE bdcdata USING fnam fval.

DATA: wa_bdcdata TYPE bdcdata.

IF fval <> space.

CLEAR wa_bdcdata.

wa_bdcdata-fnam = fnam.

wa_bdcdata-fval = fval.

APPEND wa_bdcdata TO it_bdcdata.

ENDIF.

ENDFORM. "BDC_FIELD

**************************************************************************************************************************************************************************

Please suggest....

Thanks