08-23-2007 8:40 AM
Hi,
i am working on a upload program. Here we are passing data from excel sheet. I was using GUI_UPLOAD and its not working in the background. in my yesterday thread i got the reply to use OPEN DATASET and READ DATASET. I just need to confirm that do we have any other FM to achieve this functionality.
Please give me the piece of code if you are having for DATASET operation for excel file upload.
This is quite urgent. Need a quick reply.
Thanks a lot.
SAM.
08-23-2007 8:43 AM
Hii..
This is the Program code for Application Server files.
Data has to be in a Txt file.
REPORT YRP00_20 .
DATA : IT_CARR TYPE TABLE OF SCARR,
WA_CARR TYPE SCARR.
parameters : p_dsn(30) DEFAULT 'AIRLINE.TXT'. "Give the path on App server
DATA : V_TEXT(40).
START-OF-SELECTION.
**Writing data to file
OPEN DATASET P_DSN FOR OUTPUT
IN TEXT MODE ENCODING DEFAULT.
IF SY-SUBRC NE 0.
WRITE:/ 'FILE NOT OPENED' .
EXIT.
ELSE.
SELECT * FROM SCARR INTO TABLE IT_CARR.
LOOP AT IT_CARR INTO WA_CARR.
TRANSFER WA_CARR TO P_DSN.
ENDLOOP.
CLOSE DATASET P_DSN.
ENDIF.
***reading from file
OPEN DATASET P_DSN FOR INPUT
IN TEXT MODE ENCODING DEFAULT.
IF SY-SUBRC = 0.
DO.
READ DATASET P_DSN INTO WA_CARR.
IF SY-SUBRC NE 0.
EXIT.
ENDIF.
WRITE:/ WA_CARR-CARRID,
WA_CARR-CARRNAME.
ENDDO.
CLOSE DATASET P_DSN.
ENDIF.