Application Development and Automation 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: 
Read only

BDC

Former Member
0 Likes
631

Hi All,

I have developed a BDC program to upload service items for agreement numbers. TC me32k.

Program code.

report ZAMBME32K_CHANGE_CONTRACT

no standard page heading line-size 255.

include ZBDCRECX1CC.

DATA: BEGIN OF main OCCURS 0,

EVRTN(10) TYPE C,

END OF main.

DATA: BEGIN OF RECORD OCCURS 1,

EVRTN(10) TYPE C,

SRVPOS LIKE ESLL-SRVPOS,

KTEXT1(40) TYPE C,

MENGE(18) TYPE C,

MEINS(3) TYPE C,

TBTWR(15) TYPE C,

END OF RECORD.

DATA: i_var type NUM.

data: bdc_index(2) type n.

data: i(3) type n.

data: bdc_field(30) type c.

PARAMETERS: p_file1 LIKE rlgrap-filename DEFAULT 'C:\TEMP\CON_NOS.TXT'.

PARAMETERS: p_file LIKE rlgrap-filename DEFAULT 'C:\TEMP\CHANGE_CON.TXT'

.

start-of-selection.

PERFORM read_file.

perform open_group.

PERFORM upload_data.

perform close_group.

&----


*& Form read_file

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM read_file.

CALL FUNCTION 'WS_UPLOAD'

EXPORTING

filename = p_file1

filetype = 'DAT'

TABLES

data_tab = main

EXCEPTIONS

conversion_error = 1

file_open_error = 2

file_read_error = 3

invalid_table_width = 4

invalid_type = 5

no_batch = 6

unknown_error = 7

gui_refuse_filetransfer = 8

OTHERS = 9.

SORT main BY EVRTN.

IF sy-subrc <> 0.

MESSAGE i000(zco) WITH 'Error while loading the file'.

LEAVE PROGRAM.

ENDIF.

CALL FUNCTION 'WS_UPLOAD'

EXPORTING

filename = p_file

filetype = 'DAT'

TABLES

data_tab = record

EXCEPTIONS

conversion_error = 1

file_open_error = 2

file_read_error = 3

invalid_table_width = 4

invalid_type = 5

no_batch = 6

unknown_error = 7

gui_refuse_filetransfer = 8

OTHERS = 9.

SORT record BY EVRTN SRVPOS.

IF sy-subrc <> 0.

MESSAGE i000(zco) WITH 'Error while loading the file'.

LEAVE PROGRAM.

ENDIF.

ENDFORM. " read_file

&----


*& Form upload_data

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM upload_data.

LOOP AT MAIN.

clear: bdc_index.

select count(*) into i_var from ekpo

where ebeln = main-EVRTN.

*ADD CONTRACT NUMBER

perform bdc_dynpro using 'SAPMM06E' '0205'.

perform bdc_field using 'BDC_CURSOR'

'RM06E-EVRTN'.

perform bdc_field using 'BDC_OKCODE'

'=AB'.

perform bdc_field using 'RM06E-EVRTN'

MAIN-EVRTN.

perform bdc_dynpro using 'SAPMM06E' '0220'.

perform bdc_field using 'BDC_CURSOR'

'RM06E-EBELP'.

perform bdc_field using 'BDC_OKCODE'

'=NP'.

perform bdc_field using 'RM06E-EBELP'

'1'.

perform bdc_dynpro using 'SAPMM06E' '0220'.

perform bdc_field using 'BDC_CURSOR'

'EKPO-TXZ01(02)'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'RM06E-EBELP'

i_var.

perform bdc_field using 'RM06E-EPSTP(02)'

'D'.

perform bdc_field using 'EKPO-KNTTP(02)'

'U'.

perform bdc_field using 'EKPO-TXZ01(02)'

'service'.

perform bdc_dynpro using 'SAPLMLSP' '0201'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

***ADD SUB-ITEMS (SERVICE SPECIFICATIONS)

bdc_index = 1.

i = 1.

loop at record where EVRTN = main-EVRTN.

clear bdc_field.

concatenate 'ESLL-SRVPOS(' bdc_index ')' into bdc_field.

condense bdc_field no-gaps.

perform bdc_field using BDC_FIELD

RECORD-SRVPOS.

clear bdc_field.

concatenate 'ESLL-MENGE(' bdc_index ')' into bdc_field.

condense bdc_field no-gaps.

perform bdc_field using BDC_FIELD

RECORD-MENGE.

clear bdc_field.

concatenate 'ESLL-MEINS(' bdc_index ')' into bdc_field.

condense bdc_field no-gaps.

perform bdc_field using BDC_FIELD

RECORD-MEINS.

clear bdc_field.

concatenate 'ESLL-TBTWR(' bdc_index ')' into bdc_field.

condense bdc_field no-gaps.

perform bdc_field using BDC_FIELD

RECORD-TBTWR.

if i = 15.

perform bdc_dynpro using 'SAPLMLSP' '0201'.

perform bdc_field using 'BDC_OKCODE'

'=P+'.

i = 1.

bdc_index = 1.

endif.

bdc_index = bdc_index + 1.

i = i + 1.

endloop.

perform bdc_dynpro using 'SAPLMLSP' '0201'.

perform bdc_field using 'BDC_OKCODE'

'=SAV'.

perform bdc_field using 'BDC_CURSOR'

'ESLL-KTEXT1(01)'.

perform bdc_field using 'RM11P-NEW_ROW'

'1'.

perform bdc_transaction using 'ME32K'.

free record.

ENDLOOP.

ENDFORM. " upload_data

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

If I have 50 service items, everytime items from 16 to 29 are skipped and rest all are uplaoded.

Please suggest.

Thanks,

Pratibha.

4 REPLIES 4
Read only

Former Member
0 Likes
576

Hi ,

try <b>BAPI_AGREEMENT_MAINTAIN</b> and see Documentation for more iNfo.

Regards

Prabhu

Read only

Former Member
0 Likes
576

Hai Pratibha

There is no form for 'open_group' & 'close_group'.

please provide that <b>'perform open_group.'</b>

also for <b>'perform Close_group.'</b>

Thanks & regards

Sreeni

Read only

Former Member
0 Likes
576

It could be a problem with your data file - have you checked that all lines have been imported, after the WS_UPLOAD?

Sudha

Read only

Former Member
0 Likes
576

Hi Pratibha,

How u hadled the line item part in ME32K? now i am facing the similar problem...

i am having total 19 records in my internal table but in table control page visible is 18 records...

if ur proble is resoleved on this pls send me the code..

thanks in advance

Sridhar