10-26-2007 6:48 AM
hi,
i am new to bdc and i am working on report of it and when i press F8 the execution gives d runtime error.and d in dat msg is displayed dat file ven.txt is not opened.
if any body provides d solution to dis problem he or she will be definately rewarded..
plzz reply as it is urgent for me.
Message was edited by:
ric .s
10-26-2007 6:51 AM
which function module are you using to open the text file??
use WS_UPLOAD for uploading this file..
also the contents in the text file should be tab seperated...
check that as well...
check if there are any spaces / blank lines / special charcters in the text file...
10-26-2007 6:58 AM
hi,
dis is code:-
REPORT ZTEST1.
DATA: BDC_TAB LIKE BDCDATA OCCURS 6 WITH HEADER LINE,
INFILE(20) VALUE 'C:\Document and Settings\sysasst.ii\desktop\VEN.txt'.
DATA: BEGIN OF INREC,
VENDNUM LIKE LFA1-LIFNR,
STREET LIKE LFA1-STRAS,
END OF INREC.
PARAMETERS : DISPMODE DEFAULT 'A',
UPDAMODE DEFAULT 'S'.
START-OF-SELECTION.
OPEN DATASET INFILE FOR INPUT IN TEXT MODE ENCODING DEFAULT.
DO.
READ DATASET INFILE INTO INREC.
IF SY-SUBRC <> 0.
EXIT.
ENDIF.
PERFORM FILL_BDC_TAB.
CALL TRANSACTION 'FK02'
USING BDC_TAB
MODE 'N'
UPDATE 'A'.
IF SY-SUBRC <> 0.
WRITE: /'ERROR'.
ENDIF.
ENDDO.
CLOSE DATASET INFILE.
FORM FILL_BDC_TAB.
REFRESH BDC_TAB.
PERFORM POPULATE_BDC_TAB
USING :
'1' 'SAPMFO2K' '0106',
' ' 'RF02K-LIFNR' INREC-VENDNUM,
' ' 'RF02K-D0110' 'X',
'1' 'SAPMF02K' '0110',
' ' 'LFA1-STRAS' INREC-STREET,
' ' 'BDC_OKCODE' '/11'.
ENDFORM.
FORM POPULATE_BDC_TAB USING FLAG VAR1 VAR2.
CLEAR BDC_TAB.
IF FLAG = '1'.
BDC_TAB-PROGRAM = VAR1.
BDC_TAB-DYNPRO = VAR2.
BDC_TAB-DYNBEGIN = 'X'.
ELSE.
BDC_TAB-FNAM = VAR1.
BDC_TAB-FVAL = VAR2.
ENDIF.
APPEND BDC_TAB.
ENDFORM.
will u plzz tell me d points where i am wrong,plzz help me out and u will be definately rewarded.
10-26-2007 7:12 AM
10-26-2007 7:23 AM
hi,
i had also tried ur way also by changing it into <b>rlgrap</b> but stillis it giving d same error also.
10-26-2007 7:07 AM
10-26-2007 7:18 AM
hi,
i had tried all what u said by chaning INFILE into NFILE ,but is still is giving d runtime error:-
REPORT ZTEST1.
DATA: BDC_TAB LIKE BDCDATA OCCURS 6 WITH HEADER LINE,
NFILE(20) VALUE 'C:\Document and Settings\sysasst.ii\desktop\VEN.txt'.
DATA: BEGIN OF INREC,
VENDNUM LIKE LFA1-LIFNR,
STREET LIKE LFA1-STRAS,
END OF INREC.
PARAMETERS : DISPMODE DEFAULT 'A',
UPDAMODE DEFAULT 'S'.
START-OF-SELECTION.
OPEN DATASET NFILE FOR INPUT IN TEXT MODE ENCODING DEFAULT.
CALL FUNCTION 'BDC_OPEN_GROUP'
EXPORTING
USER = SY-UNAME
CLIENT = SY-MANDT
GROUP = SESSION
EXCEPTIONS
CLIENT_INVALID = 1
OTHERS =5.
*
DO.
READ DATASET NFILE INTO INREC.
IF SY-SUBRC <> 0.
EXIT.
ENDIF.
PERFORM FILL_BDC_TAB.
CALL TRANSACTION 'FK02'
USING BDC_TAB
MODE 'N'
UPDATE 'A'.
IF SY-SUBRC <> 0.
WRITE: /'ERROR'.
ENDIF.
ENDDO.
CLOSE DATASET NFILE.
***************************
Short text
File "C:\Document and Sett" is not open.
What happened?
Error in the ABAP Application Program
The current ABAP program "ZTEST1" had to be terminated because it has
come across a statement that unfortunately cannot be executed.
Error analysis
An exception occurred that is explained in detail below.
The exception, which is assigned to class 'CX_SY_FILE_OPEN_MODE', was not
caught and
therefore caused a runtime error.
The reason for the exception is:
When accessing the file "C:\Document and Sett", the system recognized that this
file is
not open. Therefore, the file cannot be accessed.
If u help me out of dis problem den i will definately give points ,dats promise.
10-26-2007 7:31 AM
is the path given here correct???
can you check with simpler path like c:\abc.txt?
10-26-2007 7:37 AM
hi,
i ha d tried ur way also just given d path like dat,but still it is giving runtime error dat file is not open.
my txt file looks like dis:-
LIFNR STRAS
1 12 MAIN ST.
13 123 MAIN ST.
16 10 WALNUUT ST.
dis is d file i am using.
as dis is my fist bdc program i am updating 2 records only.
plzzz help me out ..points definately given.
10-26-2007 9:04 AM
Hi..
Are u reading the Data from Application Server file. Then only u can use OPEN DATASET
otherwise for Local file u have to call the FM GUI_UPLOAD.
And.. check the changes.
REPORT ZTEST1.
DATA: BDC_TAB LIKE BDCDATA OCCURS 6 WITH HEADER LINE,
<b>INFILE TYPE STRING
VALUE 'C:\Document and Settings\sysasst.ii\desktop\VEN.txt'.</b>
DATA: BEGIN OF INREC,
VENDNUM LIKE LFA1-LIFNR,
STREET LIKE LFA1-STRAS,
END OF INREC.
PARAMETERS : DISPMODE DEFAULT 'A',
UPDAMODE DEFAULT 'S'.
START-OF-SELECTION.
OPEN DATASET INFILE FOR INPUT IN TEXT MODE ENCODING DEFAULT.
<b>if sy-subrc ne 0.
Message 'File Not Opened' Type 'S'.
Leave List-processing.
endif.
</b>
DO.
READ DATASET INFILE INTO INREC.
IF SY-SUBRC <> 0.
EXIT.
ENDIF.
PERFORM FILL_BDC_TAB.
CALL TRANSACTION 'FK02'
USING BDC_TAB
MODE 'N'
UPDATE 'A'.
IF SY-SUBRC <> 0.
WRITE: /'ERROR'.
ENDIF.
ENDDO.
CLOSE DATASET INFILE.
FORM FILL_BDC_TAB.
REFRESH BDC_TAB.
PERFORM POPULATE_BDC_TAB
USING :
'1' 'SAPMFO2K' '0106',
' ' 'RF02K-LIFNR' INREC-VENDNUM,
' ' 'RF02K-D0110' 'X',
'1' 'SAPMF02K' '0110',
' ' 'LFA1-STRAS' INREC-STREET,
' ' 'BDC_OKCODE' '/11'.
ENDFORM.
FORM POPULATE_BDC_TAB USING FLAG VAR1 VAR2.
CLEAR BDC_TAB.
IF FLAG = '1'.
BDC_TAB-PROGRAM = VAR1.
BDC_TAB-DYNPRO = VAR2.
BDC_TAB-DYNBEGIN = 'X'.
ELSE.
BDC_TAB-FNAM = VAR1.
BDC_TAB-FVAL = VAR2.
ENDIF.
APPEND BDC_TAB.
ENDFORM.
10-26-2007 9:53 AM
hi,
thanks for ur relpy but now it is not giving any runtime error but when i press F8 it says that 'FILE NOT OPENED'.
that is d problem what i am facing right now.
10-26-2007 9:57 AM
use GUI_UPLOAD instead of open dataset...
as you are uploading the file from desktop.. and not from application server
10-26-2007 10:13 AM
hi,
i had tried to change according what u said in place of dataset but it gives error:-
<b>Statement "GUI_UPLOAD" is not defined. Check your spelling . . . . . . </b>
guys plzzz help me out as it is really important to me and if u shelp me solve dis problem ,i will definately give u 10 points.
10-26-2007 11:26 PM
Use the <b>FM 'GUI_UPLOAD'</b> To upload the file from <b>your local system</b>.
use <b>OPEN DATASET</b> when you uploading file from <b>application server</b>.
for your case it should be <b>FM GUI_UPLOAD</b>.
check the relevant parameters to be passed in '<b>SE37'</b> or simply when you will do <b>call pattern</b> in your program it will show you all the parameters.
pass the appropriate parameters and make sure the <b>file name (along with path ) is correct and file format is correct.</b>
Hope it solves your problem.
Get back if you need any help.
Thanks,
Asif.
10-27-2007 5:11 AM
HI ASIF,
Thanks for your reply,when i typed FM GUI_UPLOAD the text appears to be like dis <b>FMGUI_UPLOAD</b> and when i press display button den message appears like <b>function does not exist</b> in SE37(FUNCTION MODULE BUILDER).
should i create it and about d path of file i think is ok.
plzzz do help me i will give full 10 points ,dats promise.
Message was edited by:
ric .s
Message was edited by:
ric .s