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

application server

Former Member
0 Likes
1,096

gud morning,

I want to know ,how to place a file on application server and also how to extract a file from application server.

can anybody help me out??

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,056

Hi,

If you want to do through coding use below statements

OPEN DATASET

READ DATASET

TRANSFER

CLOSE DATASET

8 REPLIES 8
Read only

former_member156446
Active Contributor
0 Likes
1,056

>welcome to SDN

>award points for useful answers

CG3Z / CG3Y transactions are used to upload and download from application serve AL11

programatically

OPEN DATASET p_ufile FOR INPUT IN TEXT MODE.

IF sy-subrc <> 0.

EXIT.

ENDIF.

DO.

READ DATASET p_ufile INTO wa_file.

IF sy-subrc <> 0.

EXIT.

ENDIF.

ASSIGN wa_file TO <wa_table>.

APPEND <wa_table> TO p_table.

CLEAR wa_file.

ENDDO.

-


OPEN DATASET p_ufile FOR OUTPUT IN TEXT MODE.

IF sy-subrc <> 0.

EXIT.

ENDIF.

LOOP AT p_output INTO wa_file.

TRANSFER wa_file TO p_ufile.

CLEAR wa_file.

ENDLOOP.

CLOSE DATASET p_ufile.

Read only

Former Member
0 Likes
1,057

Hi,

If you want to do through coding use below statements

OPEN DATASET

READ DATASET

TRANSFER

CLOSE DATASET

Read only

Former Member
0 Likes
1,056

Place a file on application server

1. Open dataset (using abap code)

2. Get OS access and copy paste the file (no coding reqd)

3. Use tcode CG3Z (no coding reqd)

SAP provides transaction CG3Y & CG3Z for upload & download from presentation/application server

Regards.

Read only

Former Member
0 Likes
1,056

sample code to download the file on to appls server

REPORT ZGILL_AS message-id rp .

parameters: P_DSNI(75) TYPE C MODIF ID ABG DEFAULT

'/usr/local/sapdata/amit.dat' LOWER CASE.

data: begin of itab occurs 0,

pernr(8),

sp1(1) value ',',

werks(4),

sp2(1) value ',',

persg(1),

sp3(1) value ',',

persk(2),

end of itab.

OPEN DATASET P_DSNI FOR OUTPUT IN LEGACY TEXT MODE.

PERFORM FETCH_DATA.

&----


*& Form FETCH_DATA

&----


text

-


--> p1 text

<-- p2 text

-


FORM FETCH_DATA .

SELECT * FROM PA0001 WHERE PERNR IN S_PERNR.

MOVE-CORRESPONDING PA0001 TO ITAB.

TRANSFER ITAB TO P_DSNI.

APPEND ITAB.

ENDSELECT.

CLOSE DATASET P_DSNI.

ENDFORM. " FETCH_DATA

Check this sample code to read the data from application server...

DATA:

len TYPE i,

text(30) type c,

dir(30) TYPE c VALUE '/tmp/test.txt'.

DATA: begin of data OCCURS 0,

matnr type matnr,

werks type werks_d,

end of data.

START-OF-SELECTION.

CLEAR: text.

OPEN DATASET dir FOR INPUT IN TEXT MODE.

DO.

READ DATASET dir INTO text.

IF SY-SUBRC 0.

EXIT.

ENDIF.

SPLIT TEXT AT '|' INTO DATA-MATNR DATA-WERKS.

APPEND DATA.

ENDDO.

WRITE: / text.

CLOSE DATASET dir.

Read only

Former Member
0 Likes
1,056

Hi,

Using open datasets we can create a file in application server or we can read a file from application server.

if you want to create a file in application server please follow this code.

open dataset <filename> for output.with this statement a file with the given file name will be created in application server,

if you want to check the file name in applicartion server

just execute the transaction code AL11-sap directories.

there you can find the local file existing in application server,

if you want to read data from local file existing in application server then follow this code,

open dataset <filename> for input.with this file is open and ready for reading.,

read dataset file into internal table.with this data can read from file into internal table.

transfer file into internal table.with this statement the data will keep into internal table according to the fields requirement.

close dataset

NOTE : the key word which doesnot return SY-SUBRC in ABAP is TRANSFER keyword.Regards,swami

Read only

Former Member
0 Likes
1,056

hi,

When u r using CG3y, CG3z some times u wll find some spaces with #symbol.

Better u use this transcation to upload and download the file to app or presentation sever SXDA_TOOLS

Options:

Project type should be - DXPROJECT

Program type -BAPI

Program should - CREATE

then press copy push button.

If this is help full regard points.

Read only

Former Member
0 Likes
1,056

Hi

I do not want to use open and close data sets to download/upload excels from/to application server , I would like to use transactions CG3Y/CG3Z .

Can anybody provide me the prerequistes or key points to be taken care of while using this transactions as i was not able to upload using CG3Z.

Also can we place an excel with list of values enabled to few feilds on the apllication server .If yes , how can we do it ?

Any pointers regarding the same would be of great help.

Regards

Sukumari

Read only

Former Member
0 Likes
1,056

REPORT Y_RAJ_UTIL5.

PARAMETERS: P_LOGFIL LIKE FILETEXTCI-FILEINTERN. "Log input file

PARAMETERS: P_PHYFIL LIKE RFPDO-RFBIFILE "Phy input file

LOWER CASE.

data: txt(5000).

DATA : BEGIN OF I_DATA_TAB OCCURS 0,

ROW(5000) TYPE C,

END OF I_DATA_TAB.

*-- Function to get Physical file path

if not P_LOGFIL is initial.

CALL FUNCTION 'FILE_GET_NAME'

EXPORTING

CLIENT = SY-MANDT

LOGICAL_FILENAME = P_LOGFIL

  • ELEMINATE_BLANKS = 'X'

IMPORTING

  • EMERGENCY_FLAG =

  • FILE_FORMAT =

FILE_NAME = P_PHYFIL

EXCEPTIONS

FILE_NOT_FOUND = 1

OTHERS = 2 .

IF SY-SUBRC <> 0.

WRITE:/15 TEXT-001.

  • STOP.

ENDIF.

endif.

concatenate p_phyfil txt into p_phyfil.

*Open the Data File

OPEN DATASET P_PHYFIL FOR INPUT IN TEXT MODE ENCODING DEFAULT.

IF SY-SUBRC <> 0.

WRITE: / 'ERROR IN OPENING OUTPUT FILE', P_PHYFIL.

else.

DO.

READ DATASET P_PHYFIL INTO I_DATA_TAB.

IF SY-SUBRC = 0.

APPEND I_DATA_TAB.

CLEAR I_DATA_TAB.

  • Fills the internal table for processing

ELSE.

  • -- EXIT from the loop

EXIT.

ENDIF.

ENDDO.

CLOSE DATASET P_PHYFIL.

IF NOT I_DATA_TAB[] IS INITIAL.

call function 'DOWNLOAD' tables

data_tab = i_DATA_TAB.

ENDIF.

ENDIF.

Reward points if help full