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: 

Build the output file problem

former_member251546
Participant
0 Kudos

Hi,

good day guys

we dev the interface for stock information for mmi interface. For build output file. we coded as below as. but i need to build the out put file with Alias. how to do it?plz let me know


FORM build_output_filename .
  CLEAR outfile.
*This directory must be changed to make use of ALIAS FTP_DIR, as       *
*the directory name is different between Dev, QA and Prod              *
  CONCATENATE 'D:/FTP/MMI/MMISTOCK/BABZAPART'       "here out put file
               sy-datum sy-timlo
               '.txt'
          INTO outfile.
ENDFORM. 

Edited by: balaji kiran on Apr 12, 2010 2:33 PM

1 ACCEPTED SOLUTION

raymond_giuseppi
Active Contributor
0 Kudos

Define the alias via FILE transaction, read [Creating and Defining Logical Paths |http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3deb358411d1829f0000e829fbfe/frameset.htm] and [Creating and Defining Logical Filenames|http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3df8358411d1829f0000e829fbfe/frameset.htm]

In your program, use the FM FILE_GET_NAME, read first [Using Logical Files in ABAP Programs|http://help.sap.com/saphelp_nw04/helpdata/en/9f/db95e635c111d1829f0000e829fbfe/frameset.htm]. The FM accept 2 parameters to be included in the actual file name, so you should not get any problem.

NB: The file PATH is maintained via transaction FILE, create a logical file name definition like

D:/FTP/MMI/MMISTOCK/BABZAPART<PARAM_1><PARAM_2>.txt

Regards,

Raymond

10 REPLIES 10

Former Member
0 Kudos

hi Balaji ,

Method 1 : There is a table called PATH , where we used to maintain our , Please check in your Environment ( DEV , QA, LIVE ) its available.

you can retrieve path directly and dynamically from there.

Method 2 :

we can keep one either a parameter for passing the file name.

or

we can keep three Option button ( DEV , QA , Live ) .

based on a given file name or based on a selection , you can form the file name dynamically.

Edited by: Prasath Arivazhagan on Apr 12, 2010 2:47 PM

0 Kudos

thank you.

if i want use the "ALIAS FTP_DIR" for the output file..

how to use it?

Plz let me know?

Regards

0 Kudos

hi balaji ,

to connect to FTP there are some FM , which you can use....

CALL FUNCTION 'FTP_CONNECT'

EXPORTING

user =

password =

  • ACCOUNT =

host =

rfc_destination =

  • GATEWAY_USER =

  • GATEWAY_PASSWORD =

  • GATEWAY_HOST =

  • IMPORTING

  • HANDLE =

  • EXCEPTIONS

  • NOT_CONNECTED = 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.

to connect from FTP.

now put your file from sap server to the destination machine.

and pass to the fm FTP command list

CALL FUNCTION 'FTP_COMMAND_LIST'

EXPORTING

handle =

  • IMPORTING

  • COMMAND_INDEX =

tables

data =

commands =

  • EXCEPTIONS

  • TCPIP_ERROR = 1

  • COMMAND_ERROR = 2

  • DATA_ERROR = 3

  • OTHERS = 4

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

finally call fm FTP disconnect to disconnect the FTP.

hope this help.

take help of where used of these FM and use accordingly.

CALL FUNCTION 'FTP_DISCONNECT'

EXPORTING

handle =

.

hope this helps,

thanks

tanmaya

0 Kudos

Hi,

Also there is FM FTP_R3_to_server that wil upload the file from R3 to FTP and FTP_Server_to_R3 which will get file from R3.

Go through the following programs.

RSFTP002

RSFTP003

RSFTP004

RSFTP006

RSFTP007

RSFTP009

thanks,

tanmaya

Former Member
0 Kudos

hi,

you can create the parameter in that parameter ask the user to pass the path...or you can pass different paths as per requirement and do like this.


FORM build_output_filename .
  CLEAR outfile.
l_path =  'D:/FTP/MMI/MMISTOCK/BABZAPART'.
*This directory must be changed to make use of ALIAS FTP_DIR, as       *
*the directory name is different between Dev, QA and Prod              *
  CONCATENATE      l_path "here out put file
               sy-datum sy-timlo
               '.txt'
          INTO outfile.
ENDFORM. 

hope this helps,

thanks and regards

tanmaya

raymond_giuseppi
Active Contributor
0 Kudos

Define the alias via FILE transaction, read [Creating and Defining Logical Paths |http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3deb358411d1829f0000e829fbfe/frameset.htm] and [Creating and Defining Logical Filenames|http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3df8358411d1829f0000e829fbfe/frameset.htm]

In your program, use the FM FILE_GET_NAME, read first [Using Logical Files in ABAP Programs|http://help.sap.com/saphelp_nw04/helpdata/en/9f/db95e635c111d1829f0000e829fbfe/frameset.htm]. The FM accept 2 parameters to be included in the actual file name, so you should not get any problem.

NB: The file PATH is maintained via transaction FILE, create a logical file name definition like

D:/FTP/MMI/MMISTOCK/BABZAPART<PARAM_1><PARAM_2>.txt

Regards,

Raymond

0 Kudos

Hi,

Good day Mr.Rymond

If u dont mind, do u have sample code..if uve ,plz send it

I understand the concept.

thank you.

0 Kudos

First create the logical file name with 2 parameters as i wrote before, then in your program use

CALL FUNCTION 'FILE_GET_NAME'
     EXPORTING
          logical_filename = 'FTP_DIR'
          parameter_1      = sy-datum
          parameter_2      = sy-uzeit
     IMPORTING
          file_name        = filename
     EXCEPTIONS
          file_not_found   = 1
          OTHERS           = 2.

And use this filename with GUI_(UP|DOWN)LOAD FMs or CL_GUI_FRONTEND_SERVICES class.

You can also use special variable in the file name definitions, so you don't have any longer to use parameters for date and time, define logical filename as

D:/FTP/MMI/MMISTOCK/BABZAPART<DATE><TIME>.txt

Regards,

Raymond

Former Member
0 Kudos

Hi Kiran,

See class CL_GUI_FRONTEND_SERVICES .

for ur requirement it may be Useful.

regards,

Raghava Channooru.

Former Member
0 Kudos

Hi Balaji ,

Some more information on this.

As i mentioned in my last post , you can get the File path from the TABLE PATH

Just login to your system ---> open the table PATH

--- > go for F4 help on field PATHINTERN with Z* ---> if any path maintained for your interface you will get record like below ( Path will be maintained as mentioned below )

PATHINTERN -- FILESYS -- PATHEXTERN

ZINF -- UNIX -- /oracle/Live/abap/<FILENAME>

if so , you can retrieve that particular record and just replace <FILENAME> with your file name , then you will complete path dynamically.

example : /oracle/Live/abap/EXAMPLE_FILE.txt

below is the Code for retrieving such info.



"selection screen 
TABLES : PATH.
PARAMETER      : fname LIKE rlgrap-filename Default 'SAMPLE.txt'.

* Get the File Name with Application path
 
if fname is initial.     "if the file name is not given in the selection screen  picking from PATH

 CLEAR : path.

  SELECT SINGLE * FROM  path WHERE  pathintern  = 'ZINF'
          AND    filesys     = sy-opsys.
  IF sy-subrc NE 0.
    SELECT SINGLE * FROM  path  WHERE  pathintern  = 'ZINF'
           AND    filesys   = 'UNIX'.    " Condtion may vary based on your requirement
  ENDIF.

   REPLACE '<FILENAME>' WITH 'EXAMPLE_FILE' INTO path-pathextern.

    CONCATENATE path-pathextern sy-datum+6(2) '-' sy-datum+4(2) '-'
                     sy-datum+0(4) '.txt'
          INTO fname.    
 Endif.

    • Furthur processing ----- >