07-28-2008 9:53 AM
hie guys i have my bdc program that is able to pick and append data to the internal table but wen creating the batch data it dumps saying there is no data. The condition were the dump occurs is:
----
Insert field *
----
FORM bdc_field USING fnam fval.
IF fval <> nodata.
CLEAR bdcdata.
bdcdata-fnam = fnam.
bdcdata-fval = fval.
APPEND bdcdata.
ENDIF.
ENDFORM. "BDC_FIELD
fval will have a value but the dump still occurs. please assist me.
the full code for the program is below:
*----
P R O G R A M H E A D E R
*----
Program ID : Z_COST_CENTRE_BUDGET_UPLOAD
Version : 1.0
SAP Version : ECC 5.0
Program Name : Z_COST_CENTRE_BUDGET_UPLOAD
Created by : IPCHIKOVORE
Created on : 18.07.2008
Program Type : Report
Message Class : ZPRIN
Description : Cost Centre Budget Upload
*----
*----
C H A N G E H I S T O R Y
*----
Change Id :
Author : IPCHIKOVORE
Changed On : 00000000
Description :
*----
&----
*& Report Z_COST_CENTRE_BUDGET_UPLOAD
&----
REPORT z_cost_centre_budget_upload.
----
*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_ccentre TYPE it_ccntr_budget OCCURS 0 WITH HEADER LINE.
DATA: BEGIN OF it_line OCCURS 0,
line(1000),
END OF it_line.
DATA: pfile TYPE string.
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,
it_final TYPE it_ccntr_budget OCCURS 0 WITH HEADER LINE,
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.
*include bdcrecx1.
*----
*TAB DECLARATION
*----
DATA: tab TYPE c VALUE cl_abap_char_utilities=>horizontal_tab.
*----
*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 itab_ccentre.
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_ccentre.
LOOP AT itab_ccentre INTO it_final.
CONDENSE it_final-fr_period NO-GAPS.
SHIFT it_final-fr_period LEFT DELETING LEADING '0'.
SHIFT it_final-to_period LEFT DELETING LEADING '0'.
CONDENSE it_final-to_period NO-GAPS.
CONDENSE it_final-plnd_costs NO-GAPS.
APPEND it_final.
ENDLOOP.
ENDFORM. " get_data
&----
*& Form post_charges
&----
text
----
--> p1 text
<-- p2 text
----
FORM post_charges .
*----
*OPEN GROUP
*----
PERFORM open_group.
LOOP AT it_final.
*----
*SCREEN 1000 INITIAL SCREEN MAINTAIN ATTRIBUTES
*----
REFRESH bdcdata.
CLEAR bdcdata.
PERFORM bdc_dynpro USING 'SAPLKPP0' '1000'.
PERFORM bdc_field USING 'KPP0B-VALUE(01)'
'0'.
it_final-version.
PERFORM bdc_field USING 'KPP0B-VALUE(02)'
it_final-fr_period.
PERFORM bdc_field USING 'KPP0B-VALUE(03)'
it_final-to_period.
PERFORM bdc_field USING 'KPP0B-VALUE(04)'
it_final-f_year.
PERFORM bdc_field USING 'KPP0B-VALUE(05)'
it_final-ccentre.
PERFORM bdc_field USING 'KPP0B-VALUE(11)'
it_final-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)'
it_final-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
07-28-2008 10:06 AM
Hi,
Either check with the BDC recording and run it again in SHDB or try to check wether the internal table you are using is being cleaerd or refreshed any where.
Thanks & Regards,
Chandralekha.
07-28-2008 12:25 PM
i have amended my code and removed the refresh bdc_data part. but the dump still occurs. is it possible to input batch data?? i noticed that the fields are like KPPOB-VALUE(01)..KPPOB-VALUE(02)..KPPOB-VALUE(03)....from my recording. if possible can anyone assist me with sample code for cost centre budget upload transaction code KP06 and profit centre 7KE1???
06-15-2009 10:46 AM