‎2008 Jul 31 4:26 PM
hie guys
i have had an error on my upload program using BDC whilst trying to upload budgets for cost centres through transacode KP06. I noticed that on my recording the field is the same ie KPP0B-VALUE(01)...KPP0B-VALUE(05), is it then possible to upload to fields like this???
please assist.
the program is as below:
&----
*& Report Z_COST_CENTRE_BUDGET_UPLOAD
&----
REPORT z_cost_centre_budget_upload.
*----
*TYPE POOLS
*----
TYPE-POOLS: truxs.
----
*TYPES DECLARATIONS
----
TYPES: BEGIN OF it_ccntr_budget,
version LIKE ccss-versn,
fr_period LIKE rkpln-perbl,
to_period LIKE rkpln-perbl,
f_year LIKE ccss-gjahr,
ccentre LIKE ccss-kostl,
cst_element LIKE ccss-kstar,
plnd_costs(15),
END OF it_ccntr_budget.
*----
*INTERNAL TABLES & WORK AREAS
*----
DATA: itab_ccntr_budget01 TYPE it_ccntr_budget OCCURS 0 WITH HEADER LINE,
itab_ccntr_budget02 TYPE it_ccntr_budget OCCURS 0 WITH HEADER LINE,
itab_ccntr_budget03 TYPE it_ccntr_budget OCCURS 0 WITH HEADER LINE.
DATA: itab LIKE alsmex_tabline OCCURS 0 WITH HEADER LINE.
DATA: gd_currentrow TYPE i.
DATA: it_datatab TYPE STANDARD TABLE OF it_ccntr_budget,
wa_datatab TYPE it_ccntr_budget.
DATA: wa_record TYPE it_ccntr_budget,
it_record TYPE STANDARD TABLE OF it_ccntr_budget INITIAL SIZE 0.
*----
*INCLUDES
*----
INCLUDE zprin_bdcrecx1.
*----
*PARAMETERS
*----
PARAMETERS: p_file LIKE rlgrap-filename,
begrow TYPE i DEFAULT 1,
endrow TYPE i,
endcol TYPE i,
date LIKE bkpf-budat DEFAULT sy-datum,
usr_name LIKE syst-uname DEFAULT sy-uname,
time LIKE syst-uzeit DEFAULT sy-uzeit.
*----
*SELECTION SCREEN
*----
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
CALL FUNCTION 'F4_FILENAME' "Function to pick file
EXPORTING
field_name = 'p_file' "file
IMPORTING
file_name = p_file. "file
START-OF-SELECTION.
PERFORM get_file.
PERFORM get_data.
PERFORM post_charges.
&----
*& Form get_file
&----
text
----
--> p1 text
<-- p2 text
----
FORM get_file .
*----
*TEXT FILE TO INTERNAL TABLE
*----
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = p_file
filetype = 'ASC'
TABLES
data_tab = it_line.
*
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
*----
*EXCEL TO INTERNAL TABLE
*----
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename = p_file
i_begin_col = '1'
i_begin_row = begrow "Do not require headings
i_end_col = endcol
i_end_row = endrow
TABLES
intern = itab
EXCEPTIONS
inconsistent_parameters = 1
upload_ole = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE e010(zz) WITH text-001. "Problem uploading Excel Spreadsheet
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.
ENDFORM. " get_file
&----
*& Form get_data
&----
text
----
--> p1 text
<-- p2 text
----
FORM get_data .
LOOP AT it_line.
SPLIT it_line AT ',' INTO
itab_ccentre-version
itab_ccentre-fr_period
itab_ccentre-to_period
itab_ccentre-f_year
itab_ccentre-ccentre
itab_ccentre-cst_element
itab_ccentre-plnd_costs.
APPEND itab_ccentre.
ENDLOOP.
*----
*EXCEL INTERNAL TABLE TO WORK AREA
*----
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-version = itab-value.
WHEN '0002'.
wa_datatab-fr_period = itab-value.
WHEN '0003'.
wa_datatab-to_period = itab-value.
WHEN '0004'.
wa_datatab-f_year = itab-value.
WHEN '0005'.
wa_datatab-ccentre = itab-value.
WHEN '0006'.
wa_datatab-cst_element = itab-value.
WHEN '0007'.
wa_datatab-plnd_costs = itab-value.
WHEN OTHERS.
ENDCASE.
ENDLOOP.
APPEND wa_datatab TO itab_ccntr_budget01.
LOOP AT itab_ccntr_budget01 INTO itab_ccntr_budget02.
CONDENSE itab_ccntr_budget02-fr_period NO-GAPS.
SHIFT itab_ccntr_budget02-fr_period LEFT DELETING LEADING '0'.
SHIFT itab_ccntr_budget02-to_period LEFT DELETING LEADING '0'.
CONDENSE itab_ccntr_budget02-to_period NO-GAPS.
CONDENSE itab_ccntr_budget02-plnd_costs NO-GAPS.
APPEND itab_ccntr_budget02.
ENDLOOP.
ENDFORM. " get_data
&----
*& Form post_charges
&----
text
----
--> p1 text
<-- p2 text
----
FORM post_charges .
*----
*OPEN GROUP
*----
PERFORM open_group.
LOOP AT itab_ccntr_budget02.
*----
*SCREEN 1000 INITIAL SCREEN MAINTAIN ATTRIBUTES
*----
PERFORM bdc_dynpro USING 'SAPLKPP0' '1000'.
PERFORM bdc_field USING 'KPP0B-VALUE(01)'
itab_ccntr_budget02-version.
rkpln-perbl
perform bdc_field using 'KPP0B-VALUE(02)'
itab_ccntr_budget02-fr_period.
PERFORM bdc_field USING 'KPP0B-VALUE(02)'
itab_ccntr_budget02-fr_period.
PERFORM bdc_field USING 'KPP0B-VALUE(03)'
itab_ccntr_budget02-to_period.
PERFORM bdc_field USING 'KPP0B-VALUE(04)'
itab_ccntr_budget02-f_year.
PERFORM bdc_field USING 'KPP0B-VALUE(05)'
itab_ccntr_budget02-ccentre.
PERFORM bdc_field USING 'KPP0B-VALUE(11)'
itab_ccntr_budget02-cst_element.
PERFORM bdc_field USING 'KPP1B-ONLY'
'X'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=CSUB'.
*----
*SCREEN 0112 BUDGET AMOUNT
*----
PERFORM bdc_dynpro USING 'SAPLKPP2' '0112'.
PERFORM bdc_field USING 'Z-BDC03(01)'
itab_ccntr_budget02-plnd_costs.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=CBUC'.
PERFORM bdc_transaction USING 'KP06'.
ENDLOOP.
*----
*CLOSE GROUP
*----
PERFORM close_group.
ENDFORM. " post_charges
‎2008 Jul 31 4:31 PM
i thing u r uploading data into a table control. number in brackets tells the row in table control.
‎2008 Jul 31 4:41 PM
I would try to use the "position" button to bring up the line you want to change to the top and change it at that point.
Rob
‎2008 Aug 28 12:16 PM
To avoid errors during execution all data types should be character.