05-23-2006 8:44 AM
hi friends,
has anyone worked on uploading data from excel to sap table TCODE [IL01,IE01] its a PM Module
here we upload data for field RMCLF-CLASS
if any one has worked plz give me follow to do recording for this transaction
thanks
shiva
05-23-2006 9:04 AM
Hi Shiva,
The first part of your requirement can be done this way.
You can convert the excel file to internal table. Refer the following sample code.
*..............................................................
*: Description :
*: -
:
*: This is a simple example program to get data from an excel :
*: file and store it in an internal table.
*:............................................................:
REPORT zupload_excel_to_itab.
TYPE-POOLS: truxs.
PARAMETERS: p_file TYPE rlgrap-filename.
TYPES: BEGIN OF t_datatab,
col1(30) TYPE c,
col2(30) TYPE c,
col3(30) TYPE c,
END OF t_datatab.
DATA: it_datatab type standard table of t_datatab,
wa_datatab type t_datatab.
DATA: it_raw TYPE truxs_t_text_data.
At selection screen
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
field_name = 'P_FILE'
IMPORTING
file_name = p_file.
***********************************************************************
*START-OF-SELECTION.
START-OF-SELECTION.
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
I_FIELD_SEPERATOR =
i_line_header = 'X'
i_tab_raw_data = it_raw " WORK TABLE
i_filename = p_file
TABLES
i_tab_converted_data = it_datatab[] "ACTUAL DATA
EXCEPTIONS
conversion_failed = 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.
***********************************************************************
END-OF-SELECTION.
END-OF-SELECTION.
LOOP AT it_datatab INTO wa_datatab.
WRITE:/ wa_datatab-col1,
wa_datatab-col2,
wa_datatab-col3.
ENDLOOP.
The following code was developed for IL08, but it should work for IL01. Anyway, it'll start you off:
&----
*& Form FILL_BDC
&----
form fill_bdc.
clear bdcdata.
refresh bdcdata.
if r_create = 'X'.
Initial screen
perform dynpro using:
'X' 'SAPMILO0' '1110', "Create Func loc:Initial screen
' ' 'IFLO-TPLNR' file_int-tplnr,
' ' 'RILO0-TPLKZ' file_int-tplkz,
' ' 'IFLO-FLTYP' file_int-fltyp,
' ' 'RILO0-TPLCP' ' ',
' ' 'IRLO-TRPNR' ' ',
' ' 'RILO0-TPLMA_DFLT' file_int-tplma,
' ' 'BDC_OKCODE' '/06'. "Location
else.
perform dynpro using:
'X' 'SAPMILO0' '1110', "Change Func loc:Initial screen
' ' 'IFLO-TPLNR' file_int-tplnr,
' ' 'RILO0-TPLKZ' file_int-tplkz,
' ' 'BDC_OKCODE' '/06'. "Location
endif.
Location data
perform dynpro using:
'X' 'SAPMILO0' '2120', "Create Func loc:Location data
' ' 'IFLO-PLTXT' file_int-pltxt,
' ' 'ILOA-SWERK' file_int-swerk,
' ' 'ILOA-STORT' ' ',
' ' 'ILOA-MSGRP' ' ',
' ' 'ILOA-BEBER' ' ',
' ' 'RILA0-ARBPL' file_int-arbpl,
' ' 'ILOA-ABCKZ' ' ',
' ' 'ILOA-EQFNR' ' ',
' ' 'ILOA-VKORG' file_int-vkorg,
' ' 'ILOA-VTWEG' file_int-vtweg,
' ' 'ILOA-SPART' file_int-spart,
' ' 'ILOA-ANLNR' ' ',
' ' 'ILOA-ANLUN' ' ',
' ' 'ILOA-GSBER' file_int-gsber,
' ' 'ILOA-KOSTL' file_int-kostl,
' ' 'ILOA-PROID' ' ',
' ' 'ILOA-DAUFN' ' ',
' ' 'ILOA-AUFNR' ' ',
' ' 'BDC_CURSOR' 'ILOA-SWERK',"Cursor on maintenance plant
' ' 'BDC_OKCODE' '/07'. "PM data
' ' 'BDC_OKCODE' '/16'. "Data origin
Data origin (maintenance plant)
if file_int-swerki = '1'.
perform dynpro using:
'X' 'SAPMILO0' '6033', "Data Origin:Change
' ' 'RILO0-INHER_MA' 'X',
' ' 'BDC_OKCODE' '/07'. "Continue
else.
perform dynpro using:
'X' 'SAPMILO0' '6033', "Data Origin:Change
' ' 'RILO0-INHER_NO' 'X',
' ' 'BDC_OKCODE' '/07'. "Continue
endif.
Location data
perform dynpro using:
'X' 'SAPMILO0' '2120', "Create Func loc:Location data
' ' 'BDC_CURSOR' 'ILOA-BUKRS',"Cursor on company code
' ' 'BDC_OKCODE' '/16'. "Data origin
Data origin (company code)
if file_int-bukrsi = '1'.
perform dynpro using:
'X' 'SAPMILO0' '6042', "Data Origin:Change
' ' 'RILO0-INHER_MA' 'X',
' ' 'BDC_OKCODE' '/07'. "Continue
else.
perform dynpro using:
'X' 'SAPMILO0' '6042', "Data Origin:Change
' ' 'RILO0-INHER_NO' 'X',
' ' 'BDC_OKCODE' '/07'. "Continue
endif.
Location data
perform dynpro using:
'X' 'SAPMILO0' '2120', "Create Func loc:Location data
' ' 'BDC_CURSOR' 'ILOA-GSBER',"Cursor on business area
' ' 'BDC_OKCODE' '/16'. "Data origin
Data origin (business area)
if file_int-bukrsi = '1'.
perform dynpro using:
'X' 'SAPMILO0' '6038', "Data Origin:Change
' ' 'RILO0-INHER_MA' 'X',
' ' 'BDC_OKCODE' '/07'. "Continue
else.
perform dynpro using:
'X' 'SAPMILO0' '6038', "Data Origin:Change
' ' 'RILO0-INHER_NO' 'X',
' ' 'BDC_OKCODE' '/07'. "Continue
endif.
Location data
perform dynpro using:
'X' 'SAPMILO0' '2120', "Create Func loc:Location data
' ' 'BDC_CURSOR' 'ILOA-VKORG',"Cursor on sales organization
' ' 'BDC_OKCODE' '/16'. "Data origin
Data origin (business area)
if file_int-bukrsi = '1'.
perform dynpro using:
'X' 'SAPMILO0' '6047', "Data Origin:Change
' ' 'RILO0-INHER_MA' 'X',
' ' 'BDC_OKCODE' '/07'. "Continue
else.
perform dynpro using:
'X' 'SAPMILO0' '6047', "Data Origin:Change
' ' 'RILO0-INHER_NO' 'X',
' ' 'BDC_OKCODE' '/07'. "Continue
endif.
Location data
perform dynpro using:
'X' 'SAPMILO0' '2120', "Create Func loc:Location data
' ' 'BDC_OKCODE' '/07'. "PM data
PM data
perform dynpro using:
'X' 'SAPMILO0' '2130', "Create Func loc:PM data
' ' 'IFLO-POSNR' ' ',
' ' 'RILO0-SUBMT' ' ',
' ' 'RILO0-IWERK' file_int-iwerk,
' ' 'RILO0-INGRP' file_int-ingrp,
' ' 'RILO0-GEWRK' file_int-gewrk,
' ' 'RILO0-WERGW' file_int-wergw,
' ' 'RILO0-RBNR' ' ',
' ' 'RILO0-BEGRU' ' ',
' ' 'IFLO-DATAB' ' ',
' ' 'BDC_CURSOR' 'RILO0-GEWRK', "Cursor on main wrk centre
' ' 'BDC_OKCODE' '/16'. "Data origin
DATA ORIGIN
if file_int-ppsidi = '1'.
perform dynpro using:
'X' 'SAPMILO0' '6006', "Data Origin:Change
' ' 'RILO0-INHER_MA' 'X',
' ' 'BDC_OKCODE' '/07'. "Continue
else.
perform dynpro using:
'X' 'SAPMILO0' '6006', "Data Origin:Change
' ' 'RILO0-INHER_NO' 'X',
' ' 'BDC_OKCODE' '/07'. "Continue
endif.
Back to PM data - save or check
if p_test = 'X'.
perform dynpro using:
'X' 'SAPMILO0' '2130', "Create Func loc:Location data
' ' 'BDC_OKCODE' '/03'. "Back
perform dynpro using: "Popup
'X' 'SAPLSPO1' '0100',
' ' 'BDC_CURSOR' 'SPOP-OPTION2'."Choose no
else.
perform dynpro using:
'X' 'SAPMILO0' '2130', "Create Func loc:Location data
' ' 'BDC_OKCODE' '/11'. "Save
endif.
endform. " FILL_BDC
Hope it was useful.
Thanks,
Susmitha
Dont forget to reward points for useful answers.
05-23-2006 9:05 AM
contect ur functional consultant they will help u in recording ...