Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

How to create file interface.

Former Member
0 Likes
2,603

How to create file interface. ?

My requirement is i am getting data from client sap system to create a file ABC.txt .

by using 1) open data set

2) transfer

3) close data set

So how to write code in open data set ,transfer, close data set.

In SAP enterprise system by using

1) open data set

2) read datset

3) close data set.

So how to write code in open data set ,read datset, close data set.

any one can send me Code .

4 REPLIES 4
Read only

former_member187255
Active Contributor
0 Likes
1,508

Naveen,

Check the example.....

<a href="http://www.geocities.com/ResearchTriangle/1635/abap32.html">http://www.geocities.com/ResearchTriangle/1635/abap32.html</a>

Read only

0 Likes
1,508

hi ,

This solution is recommended only if the database table is NOT a standard SAP database table .

i want to solution standard SAP database table .

Read only

Former Member
0 Likes
1,508
DATA: file TYPE string VALUE `flights.dat`, 
      wa   TYPE spfli. 

FIELD-SYMBOLS TYPE x. 

OPEN DATASET file FOR OUTPUT IN BINARY MODE. 

SELECT * 
       FROM spfli 
       INTO wa. 
  ASSIGN wa TO CASTING. 
  TRANSFER TO file. 
ENDSELECT. 

CLOSE DATASET file.

****************************************

DATA: file          TYPE string VALUE `flights.dat`, 
      hex_container TYPE x LENGTH 1000, 
      len           TYPE i. 

FIELD-SYMBOLS <spfli> TYPE spfli. 

DESCRIBE FIELD <spfli> LENGTH len IN BYTE MODE. 

OPEN DATASET file FOR INPUT IN BINARY MODE. 

ASSIGN hex_container TO <spfli> CASTING. 

DO. 
  READ DATASET file INTO hex_container MAXIMUM LENGTH len. 
  IF sy-subrc = 0. 
    WRITE: / <spfli>-carrid, 
             <spfli>-connid, 
             <spfli>-countryfr, 
             <spfli>-cityfrom, 
             <spfli>-cityto, 
             <spfli>-fltime, 
             <spfli>-distance. 
  ELSE. 
    EXIT. 
  ENDIF. 
ENDDO. 

CLOSE DATASET file.

Read only

Former Member
0 Likes
1,508

hi

good

open dataset->

DATA FNAME(60) VALUE 'myfile'.

DATA: TEXT1(12) VALUE 'abcdefghijkl',

TEXT2(5),

LENG TYPE I.

OPEN DATASET FNAME FOR OUTPUT IN BINARY MODE.

TRANSFER TEXT1 TO FNAME.

CLOSE DATASET FNAME.

OPEN DATASET FNAME FOR INPUT IN BINARY MODE.

DO.

READ DATASET FNAME INTO TEXT2 LENGTH LENG.

WRITE: / SY-SUBRC, TEXT2, LENG.

IF SY-SUBRC <> 0.

EXIT.

ENDIF.

ENDDO.

CLOSE DATASET FNAME.

data transfer->

During data transfer, data is transferred from an external system into the SAP system. You can use data transfer when you:

&#9679; Transfer data from an external system into an SAP system as it is installed.

&#9679; Transfer data regularly from an external system into an SAP system. Example: If data for some departments in your company is input using a system other than the SAP system, you can still integrate this data in the SAP system. To do this, you export the data from the external system and use a data transfer method to import it into the SAP system.

http://help.sap.com/saphelp_nw04s/helpdata/en/fa/097008543b11d1898e0000e8322d00/content.htm

reward point if helpful.

thanks

mrutyun^