REPORT CHAP2601.
* Data declarations for later use
PARAMETERS FILENAME(128) DEFAULT '/usr/tmp/testfile.dat'
LOWER CASE.
TABLES CUSTOMERS.
DATA MSG_TEXT(50).
* Get data for file transfer
DATA ALL_CUSTOMERS LIKE CUSTOMERS OCCURS 100
WITH HEADER LINE.
SELECT * FROM CUSTOMERS INTO TABLE ALL_CUSTOMERS.
SORT ALL_CUSTOMERS BY CITY.
LOOP AT ALL_CUSTOMERS.
WRITE: / ALL_CUSTOMERS-CITY,
ALL_CUSTOMERS-NAME.
ENDLOOP.
* Opening the File
OPEN DATASET FILENAME FOR OUTPUT IN TEXT MODE
MESSAGE MSG_TEXT.
IF SY-SUBRC NE 0.
WRITE: 'File cannot be opened. Reason:', MSG_TEXT.
EXIT.
ENDIF.
* Transferring Data
LOOP AT ALL_CUSTOMERS.
TRANSFER ALL_CUSTOMERS-NAME TO FILENAME.
ENDLOOP.
* Closing the File
CLOSE DATASET FILENAME.
ABAP,ABAP report,Interactive Report,ALV grid,ALV list,IDOC,User Exit,RFC,Smartform,sapscript,ABAP Performance,Remote Function Module( RFC ),Function Module,Modularization techniques,ABAP tools,ALV report Generator,ABAP Interview Questions,BDC,BAPI,ALE,BADI, EDI,InternalTable,DataStructure,LSMW,Domain,DataElement,Basis and Administration ,ABAP HR development,ABAP Debugger,BW,ExceptionHandling,Download FI, CO, MM, PP, SD, PM, PS, QM, SM, HR, BW, APO,ABAP Tutorial
Sunday, June 6, 2010
Sample ABAP program for Transferring data to a file
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment