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: 

To create same fime name that uploaded frm desktop in application server

Former Member
0 Kudos

Hi all

i have to upload an file(tab delmited) and have to create a file in application server. And the file name needs to be created dynamically on server. can anyone plz suggest the method for doing this...

thanks in advance.

6 REPLIES 6

Former Member
0 Kudos

Use function GUI_UPLOAD to upload the file to an internal tale.

To write to application server use -

OPEN DATASET <FILENAME>

TRANSFER ITAB TO ,FILENAME>.

To dynamically generate files names use transaction "FILE" to create logical file name with variable parameters ( Time / User )

Use Function FILE_NAME_GET to get the new unique filename

Cheers

0 Kudos

to gui_upload you would have passed the file name (along with complete path) take this value and pass it to function

SO_SPLIT_FILE_AND_PATH

to split the file name and path and

in OPEN DATASET <FILENAME> use the file name returned by SO_SPLIT_FILE_AND_PATH.

Regards

Raja

0 Kudos

Hi sanjay

can u plz send me some example code for this. it will be an great help.

Thanks

Former Member
0 Kudos

Hi Anu,

If you want to generate the file name dynamically, then

First define Logical file name using the transaction 'FILE'. In that, give the physical file name with place holders (for ex: test_<PARAM_1><PARAM_2>).

In FM 'FILE_GET_NAME', you can assign the values for the place holders <PARAM_1><PARAM_2> using the parameters PARAMETER_1, PARAMETER_2 and PARAMETER_3 and this FM exports the file name in the Export parameter <FILE_NAME>.

And u can use the statements OPEN DATASET <FILE_NAME> and TRANSFER DATASET <FILE_NAME> to pass the data to the application server.

Regards,

Phani

Message was edited by: Phani Kumar Sivapuram

0 Kudos

hi

can you plz sed me some sample code for this. It will be a great help.

thanks

0 Kudos

Hi,

After creating the Logical file using FILE transaction, Follow these steps

1. Fill the place holders with the values according to the requirement. Lets suppose that if you want your file name to be filled with current date and current time, fill two local variables,

LV_PARAM_1 = SY-DATUM.

LV_PARAM_2 = SY-UZEIT.

2. Now Use the FM


     CALL FUNCTION 'FILE_GET_NAME'
  EXPORTING
    LOGICAL_FILENAME              = LV_LFNAME 
                                  " Name of logical file
    PARAMETER_1                   = LV_PARAM_1
    PARAMETER_2                   = LV_PARAM_2
*   PARAMETER_3                   = 
*   USE_PRESENTATION_SERVER       = ' '
*   WITH_FILE_EXTENSION           = ' '
*   USE_BUFFER                    = ' '
*   ELEMINATE_BLANKS              = 'X'
 IMPORTING
*   EMERGENCY_FLAG                =
*   FILE_FORMAT                   =
   FILE_NAME                     = LV_FILENAME
                   " This parameter consists new file name
* EXCEPTIONS
*   FILE_NOT_FOUND                = 1
*   OTHERS                        = 2
          .
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
   

3. Now, the importing parameter 'LV_FILENAME' consists of the new file name that is generated dynamically based on system date and time.

Hope this helps you.

Regards,

Phani