2007 Mar 23 6:05 AM
hi experts,
please send me proper solution for uploading data from application server,
Regards
Yogesh
2007 Mar 23 6:06 AM
U need to use
OPEN DATASET <NAME> IN TEXT MODE...
READ DATASET <NAME>......
CLOSE DATASET <NAME>...
Go through this link...
http://help.sap.com/saphelp_47x200/helpdata/en/d3/2e974d35c511d1829f0000e829fbfe/frameset.htm
In this
ABAP programming language -->
Saving data externally --->
working with files --->
working with files on Application server -->
****************************************************
<b>Sample codes:</b>
the following program shows how you can write internal tables into a file:
DATA FNAME(60) VALUE 'myfile'.
TYPES: BEGIN OF LINE,
COL1 TYPE I,
COL2 TYPE I,
END OF LINE.
TYPES ITAB TYPE LINE OCCURS 10.
DATA: LIN TYPE LINE,
TAB TYPE ITAB.
DO 5 TIMES.
LIN-COL1 = SY-INDEX.
LIN-COL2 = SY-INDEX ** 2.
APPEND LIN TO TAB.
ENDDO.
OPEN DATASET FNAME FOR OUTPUT.
LOOP AT TAB INTO LIN.
TRANSFER LIN TO FNAME.
ENDLOOP.
CLOSE DATASET FNAME.
OPEN DATASET FNAME FOR INPUT.
DO.
READ DATASET FNAME INTO LIN.
IF SY-SUBRC <> 0.
EXIT.
ENDIF.
WRITE: / LIN-COL1, LIN-COL2.
ENDDO.
CLOSE DATASET FNAME.
The output is:
1 1
2 4
3 9
4 16
5 25
******************************************
Reading data from File...
DATA FNAME(60) VALUE 'myfile'.
DATA: TEXT1(4) VALUE '1234 ',
TEXT2(8) VALUE '12345678',
TEXT3(2),
LENG TYPE I.
OPEN DATASET FNAME FOR OUTPUT IN TEXT MODE.
TRANSFER: TEXT1 TO FNAME,
TEXT2 TO FNAME.
CLOSE DATASET FNAME.
OPEN DATASET FNAME FOR INPUT IN TEXT MODE.
DO 2 TIMES.
READ DATASET FNAME INTO TEXT3 LENGTH LENG.
WRITE: / TEXT3, LENG.
ENDDO.
CLOSE DATASET FNAME.
The output appears as follows:
12 4
12 8
regards,
sai ramesh
2007 Mar 23 6:06 AM
U need to use
OPEN DATASET <NAME> IN TEXT MODE...
READ DATASET <NAME>......
CLOSE DATASET <NAME>...
Go through this link...
http://help.sap.com/saphelp_47x200/helpdata/en/d3/2e974d35c511d1829f0000e829fbfe/frameset.htm
In this
ABAP programming language -->
Saving data externally --->
working with files --->
working with files on Application server -->
****************************************************
<b>Sample codes:</b>
the following program shows how you can write internal tables into a file:
DATA FNAME(60) VALUE 'myfile'.
TYPES: BEGIN OF LINE,
COL1 TYPE I,
COL2 TYPE I,
END OF LINE.
TYPES ITAB TYPE LINE OCCURS 10.
DATA: LIN TYPE LINE,
TAB TYPE ITAB.
DO 5 TIMES.
LIN-COL1 = SY-INDEX.
LIN-COL2 = SY-INDEX ** 2.
APPEND LIN TO TAB.
ENDDO.
OPEN DATASET FNAME FOR OUTPUT.
LOOP AT TAB INTO LIN.
TRANSFER LIN TO FNAME.
ENDLOOP.
CLOSE DATASET FNAME.
OPEN DATASET FNAME FOR INPUT.
DO.
READ DATASET FNAME INTO LIN.
IF SY-SUBRC <> 0.
EXIT.
ENDIF.
WRITE: / LIN-COL1, LIN-COL2.
ENDDO.
CLOSE DATASET FNAME.
The output is:
1 1
2 4
3 9
4 16
5 25
******************************************
Reading data from File...
DATA FNAME(60) VALUE 'myfile'.
DATA: TEXT1(4) VALUE '1234 ',
TEXT2(8) VALUE '12345678',
TEXT3(2),
LENG TYPE I.
OPEN DATASET FNAME FOR OUTPUT IN TEXT MODE.
TRANSFER: TEXT1 TO FNAME,
TEXT2 TO FNAME.
CLOSE DATASET FNAME.
OPEN DATASET FNAME FOR INPUT IN TEXT MODE.
DO 2 TIMES.
READ DATASET FNAME INTO TEXT3 LENGTH LENG.
WRITE: / TEXT3, LENG.
ENDDO.
CLOSE DATASET FNAME.
The output appears as follows:
12 4
12 8
regards,
sai ramesh
2007 Mar 23 6:07 AM
press f1 on open data in SE38 , u will get Infomation in SAP itself.
Regards
prabhu
2007 Mar 23 6:07 AM
Use open dataset to upload data from application server.
ex:
G_file is path here.
OPEN DATASET G_FILE FOR INPUT IN TEXT MODE
ENCODING DEFAULT
IGNORING CONVERSION ERRORS.
IF SY-SUBRC EQ 0.
CONCATENATE 'FILENAME : ' G_FILE INTO I_MSG1.
APPEND I_MSG1.
DO.
READ DATASET G_FILE INTO RECORD.
IF SY-SUBRC = 0.
SPLIT RECORD AT ',' INTO I_TAB-BUKRS I_TAB-EBELN
I_TAB-BLDAT I_TAB-XBLNR I_TAB-LIFNR I_TAB-AMOUNT
I_TAB-CURR I_TAB-BUSAREA
I_TAB-BKTXT I_TAB-DMBTR I_TAB-MENGE I_TAB-SRNO.
MOVE-CORRESPONDING I_TAB TO I_TAB1.
ELSE.
EXIT.
ENDIF.
APPEND I_TAB1.
CLEAR: I_TAB, I_TAB1.
ENDDO.
ENDIF.
CLOSE DATASET G_FILE.
2007 Mar 23 6:07 AM
Use transaction cg3y if the data needs to be saved on the desktop from the application server.
Other wise if required in the program, you can use the OPEN DATASET and CLOSE DATASET statements.
Hope it helps.
Regards,
Himanshu.
2007 Mar 23 6:11 AM
Hi Yogesh,
DATA:
BEGIN OF rec OCCURS 0,
text(30) TYPE C,
END OF rec.
OPEN DATASET '/usr.test.txt in TEXT MODE.
DO.
READ DATASET '/usr/test.txt' INTO rec.
IF sy-subrc <> 0.
EXIT.
ENDIF.
APPEND rec.
ENDDO.
CLOSE DATASET .
Reagrds,
Priyanka.
2007 Mar 23 6:11 AM
Yogesh,
DATA : s_filename(400) value 'file path'
I_TEMP(400),
DO.
READ DATASET s_filename INTO I_TEMP.
IF SY-SUBRC <> 0.
EXIT.
ELSE.
move I_TEMP to I_FINALTAB.
append I_FINALTAB.
clear I_FINALTAB.
ENDIF.
ENDDO.
CLOSE DATASET s_filename .
clear v_flag.
******To download the file in presentation server.
CALL FUNCTION 'WS_DOWNLOAD'
EXPORTING
CODEPAGE = 'IBM'
FILENAME = T_PATH
FILETYPE = 'ASC'
TABLES
DATA_TAB = I_FINALTAB.
IF SY-SUBRC <> 0.
MESSAGE e013(zmamin) WITH 'Unable to download the File'.
ELSE.
MESSAGE i013(zmamin) WITH 'File downloaded Successfully'.
LEAVE.
ENDIF.
Don't forget to reward if useful...