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 FB50L...URGENT

Former Member
0 Kudos

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

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Thanks

Mahesh

19 REPLIES 19

Former Member
0 Kudos

Thanks

Mahesh

Former Member
0 Kudos

I am getting errors like: ACGL_ITEM_SGTXT is not contained in screen SAPMF05A..if i comment it it says for the other fields also the same thing but it happens only for item data...

0 Kudos

Mahesh,

it s a different scenario here...it is not taking the items...could u please review the code...

Thanks

Guys Please help....its really urgent for me...

Message was edited by:

Sam williams

Message was edited by:

Sam williams

0 Kudos

hI,

I am refreshing the message just in case someone can help me...its really urgent for me..

Thanks

0 Kudos

Hi Sam,

I am not in front of system, but can you tell me is all the data in FB50L is on the same screen. As you are using bdc_dynpro only once.

Why can't you use BAPI for the same.

Regards,

Atish

0 Kudos

I have checked the code...the problem is because of the concatenation of SGTXT and the line item number CH3. Try to change the declaration of CH3(5) to CH3(2) and check the output. It is having extra space while populating the value.

ACGL_ITEM-SGTXT( 1) which has to changed to ACGL_ITEM-SGTXT(1)

-Kriss

0 Kudos

Thanks Kriss...I made the change and now it is taking values in the other fields but for ACGL_ITEM-WRBTR i am getin a error message: ACGL_ITEM-WRBTR(2) input value is longer then screen field.

What else can i do...

Thanks again....appreciated...

0 Kudos

yes atish,

all the data is on the same screen...i am having a difficult time trying to get this resolved...

i cannot use BAPI becoz my manager wants me to use BDC for parking...

I am new to this...so trying real hard....

I know u are always helpful buddy...

Thanks

0 Kudos

Hi Sam,

Change this ch3(5) TYPE c,

to

ch3(2) TYPE n

Regards,

Atish

0 Kudos

WRBTR is failing because BDCDATA-FVAL is not able to get the value from WRBTR. Try declaring character variable and pass the value to character variable. Then use character variable to send data into IT_BDCDATA table.

This works but I dont know how far it is good to use.

-Kriss

0 Kudos

Hi kriss and Atish,

is it becoz of conflict between BAPIWRBTR(23) and WRBTR(13)....as i chked the size of both and there is difference...how can i make changes in the code so that i am using data of type WRBTR...

conversion between BAPIWRBTR and WRBTR has to be done i think...

i tried passing value directly to ACGL_ITEM-WRBTR and it works

Please suggest...

0 Kudos

Hi Sam,

Better pass value directly.

Regards,

Atish

0 Kudos

Atish,

There can be many values for this field not just one...so i cannot pass it directly...

if there are 10 line items then 10 values right

0 Kudos

Hi Sam,

Better you define the field with the same type whihc is there in the screen. If it is CHAR13 on screen then define it as CHAR13 only and move it. I am not in front of SAP so can not correct your code.

Can you tell me how you created this program, as I told you go through SHDB, is it the same or some other way.

Regards,

Atish

0 Kudos

Hey Atish,

Thru SHDB...allright i will try doing that...

but one more thing in the BDC program it is not prompting for the company code window...neither it is changing the company code...the company code that i choose in the previous run is only there...how can i populate company code value...

0 Kudos

Have you used character field for WRBTR to pass the value to BDCDATA table FVAL field?

-Kriss

0 Kudos

Hey Kriss,

I am not sure how can i pass the value to character field...i did try it once but it doesnt seem to work...can u show me an example of what u r trying to say...

thanks for the concern and ur effort...

0 Kudos

data : amount(16).

This below statement is not passing value wa_document_line_item_amnt-amt_doccur into it_bdcdata-fval. So try to move it to a character field and then use the perform statement.

PERFORM bdc_field TABLES it_bdcdata USING fname

wa_document_line_item_amnt-amt_doccur.

change it to:

WRITE wa_document_line_item_amnt-amt_doccur TO AMOUNT.

PERFORM bdc_field TABLES it_bdcdata USING fname AMOUNT.

-Kriss

0 Kudos

HI all,

I made the changes that u told...but amt_doccur is still not working...What else can i do....

Please suggest...

Cheers: Sam