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 Overwite in AIAB

Former Member
0 Kudos
313

Dear Gurus,

I am Developing one BDC in Asset under settlement T.CODE : AIAB.

My requirement is Each Main Asset No allowing multiple line items.But My BDC only

allowing one line items only.(when i upload 10 line items Automatically 9 line

items will be overwrtied and 10 th line items only stored in first line item places.)

But SAP manually entered in allowing in (999 line items)

How do i resolve this issue?

This is my code.

report ZFI_AUS

no standard page heading line-size 255.

*include bdcrecx1.

include ZFI_BDC001.

types : begin of t_itab,

BUKRS(004) type c,

anln1(012) type c,

konty(004) type c,

anln2(012) type c,

prozs(005) type c,

betrr(010) type c,

end of t_itab.

DATA : i_itab TYPE STANDARD TABLE OF t_itab with header line,

w_itab TYPE t_itab.

DATA : l_row TYPE i VALUE 0.

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

  • Selection Screen *

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

SELECTION-SCREEN BEGIN OF BLOCK file WITH FRAME TITLE text-002.

SELECTION-SCREEN SKIP.

SELECTION-SCREEN BEGIN OF LINE.

SELECTION-SCREEN COMMENT 5(16) text-002.

SELECTION-SCREEN POSITION 25.

PARAMETERS : p_file1 TYPE localfile.

SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN END OF BLOCK file.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file1.

PERFORM file_selection.

start-of-selection.

perform data_upload.

perform open_group.

loop at i_itab.

*perform bdc_transaction using 'AIAB'.

PERFORM bdc_dynpro USING 'SAPMA15B' '0110'.

PERFORM bdc_field USING 'BDC_CURSOR'

'AICOM-ANLN1'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=AUSF'.

PERFORM bdc_field USING 'AICOM-BUKRS'

'KSL'.

PERFORM bdc_field USING 'AICOM-ANLN1'

i_itab-anln1.

PERFORM bdc_field USING 'AICOM-ANLN2'

'0'.

PERFORM bdc_field USING 'P_DISVAR'

'1SAP'.

PERFORM bdc_field USING 'ANLB-AFABE'

'1'.

PERFORM bdc_dynpro USING 'SAPMSSY0' '0120'.

PERFORM bdc_field USING 'BDC_CURSOR'

'07/03'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=&ALL'.

PERFORM bdc_dynpro USING 'SAPMSSY0' '0120'.

PERFORM bdc_field USING 'BDC_CURSOR'

'07/03'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=BURG'.

perform bdc_dynpro using 'SAPLSPO2' '0100'.

perform bdc_field using 'BDC_OKCODE'

'=OPT2'.

PERFORM bdc_dynpro USING 'SAPLKOBS' '0130'.

PERFORM bdc_field USING 'BDC_CURSOR'

'COBRB-PROZS(01)'.

PERFORM bdc_field USING 'BDC_OKCODE'

'/00'.

PERFORM bdc_field USING 'COBRB-KONTY(01)'

'FXA'.

PERFORM bdc_field USING 'DKOBR-EMPGE(01)'

  • '160101'.

i_itab-anln2.

PERFORM bdc_field USING 'COBRB-PROZS(01)'

  • '100'.

i_itab-prozs.

PERFORM bdc_field USING 'COBRB-BETRR(01)'

  • '100'.

i_itab-betrr.

PERFORM bdc_dynpro USING 'SAPLKOBS' '0130'.

PERFORM bdc_field USING 'BDC_CURSOR'

'COBRB-KONTY(01)'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=BACK'.

PERFORM bdc_dynpro USING 'SAPMSSY0' '0120'.

PERFORM bdc_field USING 'BDC_CURSOR'

'07/03'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=BUCH'.

PERFORM bdc_dynpro USING 'SAPLSPO1' '0200'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=YES'.

l_row = l_row + 1.

PERFORM bdc_transaction USING 'AIAB'.

  • PERFORM bdc_transaction USING 'AIAB'.

endloop.

*enddo.

perform close_group.

*perform close_dataset using dataset.

&----


*& Form FILE_SELECTION

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM FILE_SELECTION .

CALL FUNCTION 'F4_FILENAME'

IMPORTING

file_name = p_file1.

ENDFORM. " FILE_SELECTION

&----


*& Form DATA_UPLOAD

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM DATA_UPLOAD .

CALL FUNCTION 'WS_UPLOAD'

EXPORTING

filename = p_file1

filetype = 'DAT'

TABLES

data_tab = i_itab

EXCEPTIONS

conversion_error = 1

file_open_error = 2

file_read_error = 3

invalid_type = 4

no_batch = 5

unknown_error = 6

invalid_table_width = 7

gui_refuse_filetransfer = 8

customer_error = 9

no_authority = 10

OTHERS = 11.

IF sy-subrc EQ 0 .

WRITE:/ 'Program : ', SY-CPROG.

WRITE:/ 'Filename: ', p_file1.

WRITE AT /1(119) sy-uline.

ELSE .

  • MESSAGE 'Conversion Error'.

ENDIF.

ENDFORM. " DATA_UPLOAD

4 REPLIES 4

Former Member
0 Kudos
84

hello Raja,

it looks like you are not incrementing the row number variable (or incrementing it but not using it).

like the variable l_row (which i assume you used for the row number). its not being used in the BDC part.

you might try using something like:

concatenate 'COBRB-KONTY(' + lv_row + ')' into lv_string

(lv_string being a locally declared string variable)

and then call the BDC as:

PERFORM bdc_field USING 'BDC_CURSOR'

lv_string.

PERFORM bdc_field USING lv_string

'FXA'.

What i'm basically suggesting is that you use the lv_row variable for each field where the row number changes dynamically. Also, loop through all the line items for each Main Asset number and THEN call the bdc_transaction subroutine. meaning, if you have 10 line items, put all of them togrther in one transaction call.

Thanks

Aritra

0 Kudos
84

HI Biswas,

i will try but same problem.can u explain clear Or Just change the coding.when i declare lv_string type please change the Coding .

regards,

raj

0 Kudos
84

Hi Raj,

For example,your code it says:

PERFORM bdc_field USING 'COBRB-KONTY(01)'

'FXA'.

PERFORM bdc_field USING 'DKOBR-EMPGE(01)'

i_itab-anln2.

PERFORM bdc_field USING 'COBRB-BETRR(01)'

i_itab-betrr.

the 01 indicates first row. so that needs to be changed for each item.

so if u have 10 items, that number in the bracket shoud vary from 01 to 10.

currently, whats happening in your code is that the data is written every time into the first row, so all the previously existing data is lost (overwritten) since the row postion is hard-coded as '01'.

Now for every Main asset number, you start the counter lv_row from 1 and loop though for each item number (say 10 items in total).

declare lv_row as:

data: lv_row(02) type n.

use the following type of coding for EACH item level variable (below exmple is for DKOBR-EMPGE) :

concatenate DKOBR-EMPGE(' + lv_row + ')' into lv_string1

(lv_string1 being a locally declared string variable)

PERFORM bdc_field USING 'BDC_CURSOR'

lv_string. "this will position the cursor on the row number

PERFORM bdc_field USING lv_string

i_itab-anln2. "this will put the required value into the cell of that row

this way there will be 20 performs in all (2 each for every value of COBRB-KONTY)

similarly do the coding for COBRB-PROZS, COBRB-BETRR (all the item level fields)

overall structure should look like:

LOOP AT t_itab.

AT NEW asset number. "when the asset number changes

refresh BDC table

first screen

-- enter header data

ENDAT.

next screen

-- enter item data

AT END OF asset number. "when all the data for an asset number has been read

call transaction AIAB

ENDAT.

ENDLOOP.

what you are currently doing in your code is calling the transaction for EACH item number of each asset.Using the AT NEW/AT END controls allows you to build the BDC table and call the AIAB transaction for EACH main asset number.

while running the BDC, put a Breakpoint just before the transaction call and analyse the data in the BDC table where the data is stored. Match the item level data with all the data in the internal table t_itab. Check that the item level field names and values appear multiple times.

Let me know if this was any help.

former_member482868
Discoverer
0 Kudos
84

this Solution worked for uploading AIAB through XL?

Can you please post the solution here .

sridhar.