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

Errors in Flat files while using BDC

Former Member
0 Likes
1,610

*Hey Experts,*

*I have made a BDC program which uploads an excel file into the system.Check the coding below*

*I tried to run the same data but i received the following error at the system status.*

*Excel file://c:\cannot be processed .on checking in details i received this*

*Message no. UX893*

*Diagnosis*

*An error occurred while attempting to process Excel file FILE://C:\Users\Administrator\Desktop\jack abaper\.*

*Check whether:*

*the file exists*

*you have authorization to process the file*

*Excel is installed and can be run*

*System Response*

*Excel file FILE://C:\Users\Administrator\Desktop\jack abaper\ is not processed. The activity is terminated.*

*Procedure*

*When the error has been corrected, restart the program.*

*is there a way for the program to check the exact cause of error,like for my case the same data i was uploading.*

*if it could tell me which row of data in the file is bringing this error.Apart from that I am to run this program in background not foreground ,please note of that while forgering a solution.*

*Does anyone have a solution for this,or a better way gladly accept?*

*Thank you my fellow abapers*

*all help is appreciated.*

*regds*

*Ja*

*Below see program>>>*

REPORT z_uploadbdc NO STANDARD PAGE HEADING LINE-SIZE 255.

TYPE-POOLS: truxs.

SELECTION-SCREEN : BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001.

PARAMETERS: p_file TYPE rlgrap-filename OBLIGATORY DEFAULT 'C:\'.

SELECTION-SCREEN : END OF BLOCK blk1.

&----


*& Global Declarations

&----


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.

TYPES: BEGIN OF ty_material,

matnr TYPE matnr,

anzahl TYPE anzahl,

eqtyp TYPE eqtyp,

servon TYPE servon,

serbis TYPE serbis,

sernr TYPE serbis,

END OF ty_material.

DATA: it_material TYPE TABLE OF ty_material,

wa_material TYPE ty_material,

it_bdcdata TYPE TABLE OF bdcdata,

wa_bdcdata TYPE bdcdata.

  • Table for messages from call transaction.

  • The table is automatically filled with messages from call transaction.

DATA BEGIN OF messtab OCCURS 10.

INCLUDE STRUCTURE bdcmsgcoll.

DATA END OF messtab.

DATA : WF_MESSAGE(100).

REFRESH MESSTAB.

&----


*& 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.

*include bdcrecx1.

&----


*& 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

i_filename = p_file

TABLES

i_tab_converted_data = it_material

EXCEPTIONS

conversion_failed = 1

OTHERS = 2.

IF sy-subrc NE 0.

MESSAGE ID sy-msgid

TYPE sy-msgty

NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

*perform open_group.

LOOP AT it_material INTO wa_material.

PERFORM bdc_dynpro USING 'SAPMIEQ0' '2000'.

PERFORM bdc_field USING 'BDC_CURSOR'

'RISA0-SERNR(01)'.

PERFORM bdc_field USING 'BDC_OKCODE'

'BU'.

PERFORM bdc_field USING 'RISA0-MATNR'

wa_material-matnr.

PERFORM bdc_field USING 'RISA0-ANZAHL'

wa_material-anzahl.

PERFORM bdc_field USING 'EQUI-EQTYP'

wa_material-eqtyp.

PERFORM bdc_field USING 'RISA0-SERVON'

wa_material-servon.

PERFORM bdc_field USING 'RISA0-SERBIS'

wa_material-serbis.

PERFORM bdc_field USING 'RISA0-SERNR(01)'

wa_material-sernr.

  • perform bdc_transaction using 'IQ04'.

CALL TRANSACTION 'IQ04' USING it_bdcdata

MODE 'A' UPDATE 'S'

MESSAGES into messtab.

REFRESH it_bdcdata.

ENDLOOP.

&----


*& Form bdc_dynpro

&----


  • text

----


  • -->PROGRAM text

  • -->DYNPRO text

----


FORM bdc_dynpro USING program dynpro.

CLEAR wa_bdcdata.

wa_bdcdata-program = program.

wa_bdcdata-dynpro = dynpro.

wa_bdcdata-dynbegin = 'X'.

APPEND wa_bdcdata TO it_bdcdata.

ENDFORM. "bdc_dynpro

&----


*& Form bdc_field

&----


  • text

----


  • -->FNAM text

  • -->FVAL text

----


FORM bdc_field USING fnam fval.

CLEAR wa_bdcdata.

wa_bdcdata-fnam = fnam.

wa_bdcdata-fval = fval.

APPEND wa_bdcdata TO it_bdcdata.

ENDFORM. "bdc_field

  • perform close_group.

Edited by: JackAbaper on Feb 8, 2012 3:11 PM

Edited by: JackAbaper on Feb 8, 2012 3:14 PM

Edited by: JackAbaper on Feb 8, 2012 3:15 PM

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,260

Hi ,

This is what you can do.

Upload the file from presentation server to the application server through CG3Z.

Then you can fetch the file from Application server to your BDC program (Which you want to run in background).

Regards,

Chandan.

7 REPLIES 7
Read only

JL23
Active Contributor
0 Likes
1,260

so you try to read a file from your local PC in a background process?

imagine you scheduled this process to run in the middle of the night and your PC is switched off.

there is no access to a local PC harddrive in a background process.

Read only

Former Member
0 Likes
1,260

Hi,

well thank you for pin pointing the path issue,well take it as testing program:) in which i want to test the concept of errors not power failure issues.

You havent answered my question yet?

regds

JA

Read only

JL23
Active Contributor
0 Likes
1,260

A batch process does not know at which computers C drive it has to search for a flat file.

A batch process can take the data from the application server, but not from the presentation server.

Only foreground processes can access the presentation server.

Read only

Former Member
0 Likes
1,260

Thanks for your answer its wise,well i want to run upload my file in application server as background job so my program wont work and the excel file cant work in application server perhaps other flat files format.

Do you have a method I can easily use to recode my program or if you have a sample of how to recode this please share?Thank you.

regds

Ja

Read only

JL23
Active Contributor
0 Likes
1,260

I usually save the Excel file as CSV or just Unicode Text file, then move this file to the application server using Windows explorer (I have a directory in the application file mounted) so I can easily move files between application and presentation server.

Read only

Former Member
0 Likes
1,261

Hi ,

This is what you can do.

Upload the file from presentation server to the application server through CG3Z.

Then you can fetch the file from Application server to your BDC program (Which you want to run in background).

Regards,

Chandan.

Read only

Former Member
0 Likes
1,260

Got the point thanks guys