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

unable to create batch input

prince_isaac
Active Participant
0 Likes
436

could the error generated be because of the file?? the code is as follows:

a<u>sset upload</u>

report ZAST_UPL line-size 255.

data: remaining_life_yrs type p,

remaining_life_periods type p,

days type p,

remainder type p,

useful_life type p,

useful_period type p.

include bdcrecx1.

parameters: pfile type rlgrap-filename.

tables: ankb.

*data: pfile1 type string.

TYPES: begin of t_datatab ,

assets_class(10),

c_code(4),

description(50),

add_description(50),

serial(18),

capitalisation(8),

c_centre(10),

plant(4),

asset_location(10),

amount1(13),

amount2(13),

end of t_datatab.

data: begin of t_datatabfinal occurs 0,

assets_class(10),

c_code(4),

description(50),

add_description(50),

serial(18),

capitalisation(8),

c_centre(10),

plant(4),

asset_location(10),

amount1(13),

amount2(13),

end of t_datatabfinal.

data : assets_class1(4) value '0000',

class_asset(8).

data : date_diff type p, earliest type C, timediff type p.

data : a_new type d, b_new type d.

data : capitalisation type string.

DATA: it_datatab TYPE STANDARD TABLE OF t_datatab,

wa_datatab TYPE t_datatab.

DATA: wa_record TYPE t_datatab,

it_record TYPE STANDARD TABLE OF t_datatab INITIAL SIZE 0.

DATA: itab LIKE alsmex_tabline OCCURS 0 WITH HEADER LINE.

DATA: gd_currentrow TYPE i.

  • At selection screen

AT SELECTION-SCREEN ON VALUE-REQUEST FOR pfile.

CALL FUNCTION 'F4_FILENAME'

EXPORTING

field_name = 'PFILE'

IMPORTING

file_name = pfile.

data: itab like ALSMEX_TABLINE occurs 0 with header line.

*pfile1 = pfile.

START-OF-SELECTION.

CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'

EXPORTING

FILENAME = pfile

I_BEGIN_COL = '1'

I_BEGIN_ROW = '1' "Column headers not required

I_END_COL = '11'

I_END_ROW = '4'

TABLES

INTERN = itab

  • EXCEPTIONS

  • INCONSISTENT_PARAMETERS = 1

  • UPLOAD_OLE = 2

  • OTHERS = 3

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

  • Sort table by rows and colums

SORT itab BY row col.

  • Get first row retrieved

READ TABLE itab INDEX 1.

  • Set first row retrieved to current row

gd_currentrow = itab-row.

LOOP AT itab.

  • Reset values for next row

IF itab-row NE gd_currentrow.

APPEND wa_datatab TO it_record.

CLEAR wa_datatab.

gd_currentrow = itab-row.

ENDIF.

CASE itab-col.

WHEN '0001'.

wa_datatab-assets_class = itab-value.

WHEN '0002'.

wa_datatab-c_code = itab-value.

WHEN '0003'.

wa_datatab-description = itab-value.

WHEN '0004'.

wa_datatab-add_description = itab-value.

WHEN '0005'.

wa_datatab-serial = itab-value.

WHEN '0006'.

wa_datatab-capitalisation = itab-value.

WHEN '0007'.

wa_datatab-c_centre = itab-value.

WHEN '0008'.

wa_datatab-plant = itab-value.

WHEN '0009'.

wa_datatab-asset_location = itab-value.

WHEN '0010'.

wa_datatab-amount1 = itab-value.

WHEN '0011'.

wa_datatab-amount2 = itab-value.

WHEN OTHERS.

ENDCASE.

ENDLOOP.

APPEND wa_datatab TO it_record.

LOOP AT it_record INTO t_datatabfinal.

APPEND t_datatabfinal.

ENDLOOP.

start-of-selection.

refresh bdcdata.

clear bdcdata.

perform open_group.

Loop at t_datatabfinal.

data: stop(1),

date1(8).

stop = `.`.

concatenate assets_class1 t_datatabfinal-assets_class into class_asset.

concatenate t_datatabfinal-capitalisation(2) stop t_datatabfinal-capitalisation2(2) stop t_datatabfinal-capitalisation6(2) into date1.

select * from ankb where ANLKL = class_asset

and AFABE = '01'

and afasl = 'LINS'.

if sy-subrc = 0 .

useful_life = ankb-NDJAR.

useful_period = ankb-NDPER.

endif.

useful_life = useful_life * 365.

useful_period = useful_period * 30.

endselect.

perform bdc_dynpro using 'SAPLAIST' '0105'.

perform bdc_field using 'BDC_CURSOR'

'ANLA-BUKRS'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'ANLA-ANLKL' "TOPICK Asset class

t_datatabfinal-assets_class.

  • '4000'.

perform bdc_field using 'ANLA-BUKRS' "TOPICK Company code

t_datatabfinal-c_code.

  • '2000'.

perform bdc_dynpro using 'SAPLAIST' '1000'.

perform bdc_field using 'BDC_OKCODE'

'=TAB02'.

perform bdc_field using 'ANLA-TXT50' "TOPICK Asset description

t_datatabfinal-description.

  • 'Compaq Evo D3102'.

perform bdc_field using 'ANLA-TXA50' "TOPICK Additional asset description

t_datatabfinal-add_description.

  • 'Desktop Computer'.

perform bdc_field using 'ANLA-SERNR' "TOPICK Serial number

t_datatabfinal-serial.

  • 'V309LB42A259'.

perform bdc_field using 'RA02S-XHIST'

'X'.

  • perform bdc_field using 'BDC_CURSOR'

  • 'ANLA-AKTIV'.

perform bdc_field using 'ANLA-AKTIV' "TOPICK Asset capitalization

date1.

  • '13.10.03'.

perform bdc_dynpro using 'SAPLAIST' '1000'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

  • perform bdc_field using 'BDC_CURSOR'

  • 'ANLZ-KOSTL'.

perform bdc_field using 'ANLZ-KOSTL'

t_datatabfinal-c_centre.

  • '203000'.

perform bdc_dynpro using 'SAPLAIST' '1000'.

perform bdc_field using 'BDC_OKCODE'

'=ALTD'.

perform bdc_field using 'BDC_CURSOR'

'ANLZ-STORT'.

  • perform bdc_field using 'ANLZ-GSBER' "TOPICK Business area

  • t_datatabfinal-bus_area.

  • 'B008'.

perform bdc_field using 'ANLZ-KOSTL' "TOPICK Cost center

t_datatabfinal-c_centre.

  • '203000'.

perform bdc_field using 'ANLZ-WERKS' "TOPICK Plant

t_datatabfinal-plant.

  • '2001'.

perform bdc_field using 'ANLZ-STORT' "TOPICK Asset location

t_datatabfinal-asset_location.

  • '001'.

perform bdc_field using 'ANLZ-FISTL' "TOPICK Funds center

t_datatabfinal-c_centre.

  • '203000'.

perform bdc_dynpro using 'SAPLALTD' '1100'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

  • perform bdc_field using 'BDC_CURSOR'

  • 'RALT_DYNP_STRUC-ANBTR01(06)'.

perform bdc_field using 'RALT_DYNP_STRUC-ANBTR01(01)'

t_datatabfinal-amount1.

  • ' 450000'.

perform bdc_field using 'RALT_DYNP_STRUC-ANBTR01(06)'

t_datatabfinal-amount2.

  • ' 25000'.

perform bdc_dynpro using 'SAPLALTD' '1100'.

perform bdc_field using 'BDC_CURSOR'

'ANLA-ANLN1'.

perform bdc_field using 'BDC_OKCODE'

'=BUCH'.

perform bdc_transaction using 'AS91'.

concatenate t_datatabfinal-capitalisation4(4) t_datatabfinal-capitalisation2(2) t_datatabfinal-capitalisation(2) into capitalisation.

a_new = '20070701'. "Date format is YYYYMMDD

b_new = capitalisation. "Date format is YYYYMMDD

CALL FUNCTION '/SDF/CMO_DATETIME_DIFFERENCE'

EXPORTING

date1 = a_NEW

time1 = '000000'

date2 = b_NEW

time2 = '000000'

IMPORTING

DATEDIFF = date_diff

EXCEPTIONS

INVALID_DATETIME = 1

OTHERS = 2.

IF sy-subrc <> 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

***calculation of remaining life in years and periods for the asset***

remaining_life_yrs = ( useful_life - date_diff ) div 365.

remainder = ( useful_life - date_diff ) mod 365.

remaining_life_periods = remainder div 30.

perform bdc_dynpro using 'SAPLAIST' '0100'.

perform bdc_field using 'BDC_CURSOR'

'ANLA-ANLN1'.

perform bdc_field using 'BDC_OKCODE'

'=D190'.

  • perform bdc_field using 'ANLA-ANLN1'

  • '40006'.

perform bdc_field using 'ANLA-ANLN2'

'0'.

perform bdc_field using 'ANLA-BUKRS'

t_datatabfinal-c_code.

  • '2000'.

perform bdc_dynpro using 'SAPLAIST' '1000'.

perform bdc_field using 'BDC_OKCODE'

'=BUCH'.

perform bdc_field using 'BDC_CURSOR'

'ANLB-AFABG(01)'.

perform bdc_field using 'ANLB-NDJAR(01)'

remaining_life_yrs.

  • ' 1'.

perform bdc_field using 'ANLB-NDPER(01)'

remaining_life_periods.

  • ' 8'.

perform bdc_field using 'ANLB-AFABG(01)'

'01.07.2007'.

perform bdc_transaction using 'AS92'.

endloop.

perform close_group.

1 REPLY 1
Read only

prince_isaac
Active Participant
0 Likes
352

Formatting error in file. resolved.