Skip to Content

In many occasion, data needs to be loaded to SAP BW through flat file.

But flat file load from local desktop is not possible through process chain(Process chain will failed to extract from Local desktop).

In order to resolve this issue, flat file needs to be uploaded to application server and then process chain can be triggered at its scheduled time.

Process chain will not fail if flat file is loaded from application server.

Program to load file to application server:

TYPE-POOLS : vrm.

DATA:  param TYPE vrm_id,
       values     TYPE vrm_values,
       value LIKE LINE OF values.

*Parameter Declaration

PARAMETERS: p_file TYPE localfile OBLIGATORY.

*File selection from local desktop

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.

  DATA: ifile TYPE filetable.
  DATA: xfile LIKE LINE OF ifile.
  DATA: rc TYPE i.

  CALL METHOD cl_gui_frontend_services=>file_open_dialog
    EXPORTING
      initial_directory = ‘C:\’
    CHANGING
      file_table        = ifile
      rc                = rc.

  READ TABLE ifile INTO xfile INDEX 1.
  CHECK sy-subrc = 0.
  p_file = xfile-filename.

*Local file upload to Application server

END-OF-SELECTION.
  DATA: p_file_path LIKE sapb-sappfad.

  p_file_path = p_file.

      CALL FUNCTION ‘ARCHIVFILE_CLIENT_TO_SERVER’
      EXPORTING
        path             = p_file_path
       targetpath       = ‘abc.CSV’

*     EXCEPTIONS

*       ERROR_FILE       = 1

*       OTHERS           = 2

.

While executing the above program, selection screen displayed to choose the file from local desktop as shown below:

/wp-content/uploads/2012/10/img1_143817.jpg

Click on F4 option to choose the file from desktop.

/wp-content/uploads/2012/10/img2_143818.jpg

Click on Execute.

/wp-content/uploads/2012/10/img3_143819.jpg

In order to check the file is successfully loaded, please goto T-code AL11.

/wp-content/uploads/2012/10/img4_143820.jpg

Docubel click the directory “DIR_SAPUSERS”

/wp-content/uploads/2012/10/img5_143821.jpg

Now, we can able to see the flat file that has been loaded to application server.

Now this file can be used to load through process chain.

To report this post you need to login first.

9 Comments

You must be Logged on to comment or reply to a post.

    1. Karthick Arulmani Post author

      Yes. You can use it. But please test your code and use it based on your requirement. I will not be responsible for any outcome by using this code. Its just my way of developing code.

      Regards

      Karthick.

      (0) 
  1. Harish Allachervu

    As SAP already given FM ARCHIVFILE_CLIENT_TO_SERVER for this purpose,

    what is point of creating Z program? are automating flat-file upload with your program?

    Thanks & Regards,

    Harish

    (0) 
    1. Karthick Arulmani Post author

      I have designed this based on end user perspective to make user friendly..just to remember T-code for flat file upload..not to remember the FM name.

      Regards

      Karthick.

      (0) 

Leave a Reply