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

File upload to Application server

Former Member
0 Likes
10,474

Hi Guys,

I am using the application server file to create the sales order using BAPI, if BAPI through the any error records, i need to create error file and upload into Application server.

Now i could able to create the sales order, but i need to further developement for uploading the file to Application server. could any one please provide step by step process to upload the file into Application server.

Thanks,

Gourisankar.

Hi Guys,

I am using the application server file to create the sales order using BAPI, if BAPI through the any error records, i need to create error file and upload into Application server.

Now i could able to create the sales order, but i need to further developement for uploading the file to Application server. could any one please provide step by step process to upload the file into Application server.

Thanks,

Gourisankar.

10 REPLIES 10
Read only

Former Member
0 Likes
5,135

this you can do by using trancation cg3z .

and ther is one FM also

ARCHIVFILE_CLIENT_TO_SERVER

copy to default location as in working folder of server

this will definately do .

Ankit

Read only

0 Likes
5,135

Dear ,

U can also used open data set and closed data set

but the thing is some time there is space error arrived which you can easily solved by separating it by spaces .

OPEN DATASET dsn2 FOR APPENDING IN TEXT MODE ENCODING DEFAULT.
          LOOP AT it_excel2 INTO wa_excel2.
            CONCATENATE  wa_excel2-pur_doc
                         wa_excel2-po_item
                         wa_excel2-header_txt  INTO w_char SEPARATED BY c_tab.
            TRANSFER w_char TO dsn2.
          ENDLOOP.
      CLOSE DATASET dsn2.

thanks ankit

Read only

Former Member
0 Likes
5,135

Refer following code

*__Open Application Server File

OPEN DATASET PFNAME1 FOR OUTPUT IN TEXT MODE.

IF SY-SUBRC NE 0.

MESSAGE E001(SY) WITH 'Error while opening File'.

EXIT.

ELSE.

*---Data is downloaded to the application server file path

LOOP AT GI_UPDATE ."INTO wa_tab2.

TRANSFER GI_UPDATE TO PFNAME1.

ENDLOOP.

ENDIF.

*--Close the Application server file (Mandatory).

CLOSE DATASET PFNAME1.

Regards,

Pritish

Read only

Former Member
0 Likes
5,135

hi,

try this code it will download the file in application server:

here :

v_file is file path

it_tline is internal table has all data to be downloaded:

open dataset v_file for output in binary  mode.

        if not sy-subrc is initial.
          retcode = sy-subrc.
          exit.
        endif.

        loop at it_tline.
          transfer it_tline to v_file.
        endloop.

        close dataset v_file.

regards

rahul

Read only

Former Member
0 Likes
5,135

HI,

Check this..

OPEN DATASET filename FOR OUTPUT IN TEXT MODE
                ENCODING DEFAULT MESSAGE msg.   
IF SY-SUBRC EQ 0.
LOOP AT ITAB.
  l_string = itab.
   TRANSFER_l_string TO filename.
ENDLOOP.
  CLOSE DATASET filename.
ENDIF.

Read only

former_member203501
Active Contributor
0 Likes
5,135

ho do like this ...

use tcode cg3z give the file name of front end and application server path

or use open dataset in the code..

Read only

Former Member
0 Likes
5,135

hi,

please refer this

http://www.sapdev.co.uk/file/file_uptabsap.htm

use OPEN DATASET ,TRANSFER ,and ClOSE DATASET

thanks

Read only

Former Member
0 Likes
5,135

Hi check for BAPI return messages. loop through bapiret2 structure, search for error messages with msgid = 'E' and populate the internal table it_text_data with the error messages and other fields(whatever detials you want to have in the file ), then use the following code to write to appliacation server,

OPEN DATASET l_filename FOR OUTPUT IN TEXT MODE.

IF sy-subrc NE 0.

RAISE open_file.

ENDIF.

LOOP AT it_text_data. " into l_text_data.

TRANSFER it_text_data TO l_filename.

ENDLOOP.

CLOSE DATASET l_filename.

You can check if the file has been written to application server in AL11 transaction,

Read only

Former Member
0 Likes
5,135

hi

hope this will help u .

~linganna

Read only

Former Member
0 Likes
5,135

hi,

You can use the following code to upload file on application server

DATA: file TYPE string VALUE 'mara.txt'.

OPEN DATASET file FOR INPUT IN TEXT MODE ENCODING DEFAULT .

DO.

READ DATASET file INTO wa_download1.

IF sy-subrc = 0.

APPEND wa_download1 TO gi_download1.

ELSE.

EXIT.

ENDIF.

ENDDO.

CLOSE DATASET file.

Regards,

Manish