cancel
Showing results for 
Search instead for 
Did you mean: 

creating a new file in application server

Former Member
0 Kudos

hai,

please rectify this, how to create a file in application server ?

can any one forward a sample code for creating a file in application server.

hazam

Accepted Solutions (0)

Answers (6)

Answers (6)

Former Member
0 Kudos

Refer this thread

http://www.sapdevelopment.co.uk/file/file_updownpop.htm

http://www.sapdevelopment.co.uk/file/file_downloadsap.htm

Reward points and close the thread if ur problem got solved.

Former Member
0 Kudos

Hi Hazam,

You need to create new file using statements OPEN DATASET and CLOSEDATASET.

After "Open Dataset"

You need to transfer data into file using statement TRANSFER.

Then "Close Dataset".

sbhutani1
Contributor
0 Kudos

Hi hazam,

You can use these statements

OPEN DATASET

TRANSFER

CLOSE DATASET

or you can refer to this link

http://www.kabai.com/abaps/z33.htm

Regards

Sumit Bhutani

Ps reward points if helpful

Former Member
0 Kudos

hii

Use

<b>CG3Y and CG3Z transaction

USe AL11 to view file</b>

Reading and Writing a text file from and to the application server

  • sy-subrc = 0 Record read from file

  • sy-subrc = 4 End of file reached

data: w_dataset1(27) value '/var/textfile.txt',

w_dataset2(27) value '/var/outfile.txt'.

data:begin of itab1 occurs 0, "Text file format

matnr(18), "MATERIAL NUMBER

bwkrs(4), "PLANT

end of itab1.

*Uploading of text file from Application server.

<b>open dataset w_dataset1 for input in text mode.</b>

do.

if sy-subrc <> 0.

exit.

endif.

<b>read dataset w_dataset1 into itab1.</b>

append itab1.

clear itab1.

enddo.

close dataset w_dataset1.

*Downloading of text file to Application server.

<b>open dataset w_dataset2 for output in text mode.</b>

loop at itable.

<b>transfer itable to w_dataset2.</b>

endloop.

<b>close dataset w_dataset2.</b>

hope this helps

Thanks&Regards

Naresh

Former Member
0 Kudos

Hi Hazam,

Please check the below code.


Data :   P_UFILE(60)                   " Unix File name
         TYPE C
         value '/emn_R3/hr/ben_age25_dep'.
         
    CLEAR GD_SUBRC.
    <b>OPEN DATASET</b> GD_FILE FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
    IF SY-SUBRC <> 0.
      GD_SUBRC = SY-SUBRC.
      gs_error-pernr = gs_0021-pernr.
      gs_error-ename = gd_ename.
      gs_error-mess
           = 'Can not open File:'(017) + gd_file.
      append gs_error to gt_error.
      clear gs_error.

*      CLEAR GD_MSG1.
*      CONCATENATE 'Can not open File:'(017)
*                   GD_FILE
*        INTO GD_MSG1.
*      WRITE : / GD_MSG1.
    ELSE.
      LOOP AT GT_BODY INTO GS_BODY.
        <b>TRANSFER</b> GS_BODY TO GD_FILE.
      ENDLOOP.
      <b>CLOSE DATASET</b> GD_FILE.
    ENDIF.

 

Hope this will help you.

Thanks&Regards,

Siri.

Message was edited by: Srilatha T

Former Member
0 Kudos

Also Check TCode FILE

Regards

Siddharth

Former Member
0 Kudos

Hi,

You can create an Application server file by using

<b>Open dataset <filename> for output </b>

Thanks,

Rashmi.

Former Member
0 Kudos

Hi Hazam,

You can create a file on Application server using ABAP statements <b>OPEN DATASET, TRANSFER and CLOSEDATASET</b>.

The code for creating a file on application server is as follows.

*---Open Dataset

OPEN DATASET <app_server_file> FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.

IF sy-subrc NE 0.

MESSAGE i000 WITH 'Unable to open app_server_file'.

ELSE.

LOOP AT it_record.

TRANSFER it_record TO <app_server_file>.

ENDLOOP.

ENDIF.

*---Close Dataset

CLOSE DATASET <app_server_file>.

Thanks,

Vinay