Application Development 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: 

Upload File from Application server for BDC

Former Member
0 Kudos

Hi all,

please help me in how to create the file on the application server.

how to upload from the application server.

will it change the functionality of the BDC loading programming.

thanks

ekta

1 ACCEPTED SOLUTION

varma_narayana
Active Contributor
0 Kudos

Hi Ekta..

For accessing Application Server files : Check these commands (F1 HELP)

1. OPEN DATASET

2. READ DATASET

3. CLOSE DATASET

<b>reward if Helpful</b>

13 REPLIES 13

varma_narayana
Active Contributor
0 Kudos

Hi Ekta..

For accessing Application Server files : Check these commands (F1 HELP)

1. OPEN DATASET

2. READ DATASET

3. CLOSE DATASET

<b>reward if Helpful</b>

gopi_narendra
Active Contributor
0 Kudos

Check these tcodes

CG3Y - Download appl.server file to frontend

CG3Z - Upload file from frontend to appl. server

Or else You can use

Open Dataset

Read Dataset

<transfer>

Close Dateset

to get the data from Appl. Server to your presentation server.

Vice Versa you can use

Open Dataset

Write Dataset

Close Dataset

to write data to the Appl. Server from your program

Use of this does not effect the BDC in any way.

Regards

Gopi

Former Member
0 Kudos

hi ekta

ITS A SAMPLE USE

OPEN DATA SET P_PATH FOR OUTPUT

IN TEXT MODE

ENDCODING DEFAULT

MESSAGE V_MESSAGE

LOOP AT ITAB

TRANSFER ITAB TO P_PATH

ENDLOOP

CLOSE DATASET....

former_member480923
Active Contributor
0 Kudos

Please refer to the following code

REPORT  zuploadtab                    .

PARAMETERS: p_infile  LIKE rlgrap-filename
OBLIGATORY DEFAULT  ‘/usr/sap/’..

DATA: ld_file LIKE rlgrap-filename.

*Internal tabe to store upload data
TYPES: BEGIN OF t_record,
name1 like pa0002-VORNA,
name2 like pa0002-name2,
age   type i,
END OF t_record.
DATA: it_record TYPE STANDARD TABLE OF t_record INITIAL SIZE 0,
wa_record TYPE t_record.

*Text version of data table
TYPES: begin of t_uploadtxt,
name1(10) type c,
name2(15) type c,
age(5)  type c,
end of t_uploadtxt.
DATA: wa_uploadtxt TYPE t_uploadtxt.

*String value to data in initially.
DATA: wa_string(255) type c.

constants: con_tab TYPE x VALUE ‘09′.


*START-OF-SELECTION
START-OF-SELECTION.
ld_file = p_infile.
OPEN DATASET ld_file FOR INPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc NE 0.
ELSE.
DO.
CLEAR: wa_string, wa_uploadtxt.
READ DATASET ld_file INTO wa_string.
IF sy-subrc NE 0.
EXIT.
ELSE.
SPLIT wa_string AT con_tab INTO wa_uploadtxt-name1
wa_uploadtxt-name2
wa_uploadtxt-age.
MOVE-CORRESPONDING wa_uploadtxt TO wa_upload.
APPEND wa_upload TO it_record.
ENDIF.
ENDDO.
CLOSE DATASET ld_file.
ENDIF.

************************************************************************
*END-OF-SELECTION
END-OF-SELECTION.

loop at it_record into wa_record.
write:/     sy-vline,
(10) wa_record-name1, sy-vline,
(10) wa_record-name2, sy-vline,
(10) wa_record-age, sy-vline.
endloop.

Hope That Helps

Anirban M.

Former Member
0 Kudos

Hi,

You can find sample codes in the following links:

best regards,

Thangesh

Former Member
0 Kudos

first create a file in legacy system i.e on flat file (or)excel sheet the upload it by callin function module GUI_UOPLOAD, from application server you can upload usin g cCALLTRANSACTION (OR) SESSION (OR) DIRETINPUT (OR) LSMW.

if it helps you allot me points.

Former Member
0 Kudos

hello..

u can use OPEN DATASET, READ DATASET AND CLOSE DATASET from application serner.

Former Member
0 Kudos

Hi,

Try to use this syntax for writing reading from application server

for writing

OPEN DATASET L_FILENAME FOR <b>OUTPUT</b> IN TEXT MODE.

for reading

OPEN DATASET L_FILENAME FOR <b>INPUT</b> IN TEXT MODE.

AND FOR downloading application server file we have 2 transaction

CG3Y , CG3Z using this transaction we can download to descktop or any place in ur system

Reward me a points if it is use full answer

praveen

Former Member
0 Kudos

Hi Ekta,

check the follwoing:

<b>For downloading file on application server:</b>


 OPEN DATASET v_file FOR APPENDING IN TEXT MODE ENCODING DEFAULT.

  IF sy-subrc = 0.

    LOOP AT it_data INTO x_data.

      TRANSFER l_data TO v_file.

    ENDLOOP.

    CLOSE DATASET v_file.

<b>For uploading file from application server</b>

OPEN DATASET v_file FOR INPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc NE 0.
error message.
ELSE.
DO.
READ DATASET v_file INTO x_file.
IF sy-subrc NE 0.
EXIT.

ELSE.
append x_file TO it_file.
ENDIF.
ENDDO.
CLOSE DATASET v_file.

Reward points if helpful answer.

Ashvender.

Former Member
0 Kudos

Hi Ekta,

Access the flat file from application server you should use DATA SETS.

For example

DATA: FILE_PATH TYPE STRING.

FILE_PATH = 'c:/bdc_train3.prn'. " This is application server file path.

START-OF-SELECTION.

PERFROM start.

FORM start.

OPEN DATASET FILE_PATH FOR INPUT IN TEXT MODE ENCODING DEFAULT.

IF SY-SUBRC = 0.

DO.

READ DATASET FILE_PATH INTO ITAB1.

IF ITAB1-RESNO NE SPACE.

APPEND ITAB1.

ELSE.

EXIT.

ENDIF.

ENDDO.

ENDIF.

ENDFORM.

ITAB1 IS internal table.

IF USEFULL REWARD

Former Member
0 Kudos

Hi Ekta

try this

<b>

OPEN DATASET dataset name FOR INPUT IN Text/Binary MODE.

IF sy-subrc NE 0.

READ DATASET dataset name INTO wa.

APPEND wa TO itab.

ENDIF.

CLOSE DATASET dataset name. //optional

OPEN DATASET dataset name FOR OUTPUT IN Text/Binary MODE.

IF sy-subrc NE 0.

Transfer dataset name INTO itab.

ENDIF.

CLOSE DATASET dataset name. //optional</b>

REWARD IF USEFUL...!

Former Member
0 Kudos

to upload/download files on an application server , u should use the following syntax...

OPEN DATASET dset FOR access IN mode [position]

[ os_addition]

[error_handling].

This statement opens the file specified in dset for the access specified in access in a storage mode specified in mode. For dset, a character-type data object is expected, which contains the platform-specific name of the file.

Use additions position, os_addition and error_handling to determine the position at which to open the file, to specify platform-specific additions and to influence error handling.

TRANSFER dobj TO dset [LENGTH len]

[NO END OF LINE].

then followed by

CLOSE DATASET dset.

Former Member
0 Kudos

I thank all of the people who have helped me in solving this issue

thanks

ekta