2008 Jul 16 6:21 AM
i friend i want to code for file handling in sap and one more question how i can handle to mainfram data in sap pls give me a code ASAP.
BY
2008 Jul 16 3:16 PM
Do proggram like this for creating the data n the application server.
DATA :File (30) type c VALUE 'file'.
TEXT1(4) VALUE '1234 ',
LENG TYPE I.
OPEN DATASET file FOR OUTPUT IN TEXT MODE.
TRANSFER: TEXT1 TO FNAME,
CLOSE DATASET File.
Regards,
Prasad
2008 Jul 16 8:27 AM
Hi,
here is the example:
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
2008 Jul 16 8:31 AM
Hii!
Check out this sapmle code
REPORT z_FILE2.
DATA: fname(40),
w_line TYPE i VALUE 1.
DATA:
BEGIN OF fs_flight,
carrid LIKE sflight-carrid,
connid LIKE sflight-connid,
fldate LIKE sflight-fldate,
END OF fs_flight.
DATA:
t_flight LIKE
TABLE OF
fs_flight.
DATA:
t_flight1 LIKE
TABLE OF
fs_flight.
SELECT-OPTIONS:
s_carrid FOR fs_flight-carrid,
s_connid FOR fs_flight-connid.
fname = '.\ztest2.xls'.
PERFORM get_flight_data.
OPEN DATASET fname FOR OUTPUT IN BINARY MODE." ENCODING DEFAULT.
LOOP AT t_flight INTO fs_flight.
TRANSFER fs_flight TO fname.
ENDLOOP.
IF sy-subrc EQ 0.
WRITE: 'File Opened On Apps Server'.
ELSE.
WRITE: 'File could not be opened'.
ENDIF.
CLOSE DATASET fname.
*&---------------------------------------------------------------------*
*& Form get_flight_data
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form get_flight_data .
SELECT carrid
connid
fldate
FROM sflight
INTO TABLE t_flight
WHERE carrid IN s_carrid
AND connid IN s_connid.
endform. " get_flight_data
Regards
Abhijeet
2008 Jul 16 3:16 PM
Do proggram like this for creating the data n the application server.
DATA :File (30) type c VALUE 'file'.
TEXT1(4) VALUE '1234 ',
LENG TYPE I.
OPEN DATASET file FOR OUTPUT IN TEXT MODE.
TRANSFER: TEXT1 TO FNAME,
CLOSE DATASET File.
Regards,
Prasad