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

Setting Target Application server

Former Member
0 Likes
637

Hi Experts,

I have a program which will take a file from PC. It will format the records of the file and write it to a Unix file. Now the requirement is I want this Unix file needs to be created always in specified Application server. What generally happens is, It will create the file in the Application server currently user has logged in. My requirement is irrespective of Current Application server that user has logged, I want file always be created in specified application server. Is there any function module to set the Target Application server from the program.

Please advise in this. Points will be awarded for the same

4 REPLIES 4
Read only

Former Member
0 Likes
540

DATA: BEGIN OF MTAB_DATA OCCURS 0,

LINE(132) TYPE C,

END OF MTAB_DATA.

DATA: MC_PASSWORD(20) TYPE C,

MI_KEY TYPE I VALUE 26101957,

MI_PWD_LEN TYPE I,

MI_HANDLE TYPE I.

START-OF-SELECTION.

*-- Your SAP-UNIX FTP password (case sensitive)

MC_PASSWORD = 'password'.

DESCRIBE FIELD MC_PASSWORD LENGTH MI_PWD_LEN.

*-- FTP_CONNECT requires an encrypted password to work

CALL 'AB_RFC_X_SCRAMBLE_STRING'

ID 'SOURCE' FIELD MC_PASSWORD ID 'KEY' FIELD MI_KEY

ID 'SCR' FIELD 'X' ID 'DESTINATION' FIELD MC_PASSWORD

ID 'DSTLEN' FIELD MI_PWD_LEN.

CALL FUNCTION 'FTP_CONNECT'

EXPORTING

*-- Your SAP-UNIX FTP user name (case sensitive)

USER = 'userid'

PASSWORD = MC_PASSWORD

*-- Your SAP-UNIX server host name (case sensitive)

HOST = 'unix-host'

RFC_DESTINATION = 'SAPFTP'

IMPORTING

HANDLE = MI_HANDLE

EXCEPTIONS

NOT_CONNECTED = 1

OTHERS = 2.

CHECK SY-SUBRC = 0.

CALL FUNCTION 'FTP_COMMAND'

EXPORTING

HANDLE = MI_HANDLE

COMMAND = '<b>dir</b>'

TABLES

DATA = MTAB_DATA

EXCEPTIONS

TCPIP_ERROR = 1

COMMAND_ERROR = 2

DATA_ERROR = 3

OTHERS = 4.

IF SY-SUBRC = 0.

LOOP AT MTAB_DATA.

WRITE: / MTAB_DATA.

ENDLOOP.

ELSE.

  • do some error checking.

WRITE: / 'Error in FTP Command'.

ENDIF.

CALL FUNCTION 'FTP_DISCONNECT'

EXPORTING

HANDLE = MI_HANDLE

EXCEPTIONS

OTHERS = 1.

In the Above Program, Unix command DIR was uesd to see the file list, if you want to Create the file use CAT command istead of the DIR command

To FTP using ABAP, you can have a look at the standard program 'RSEPSFTP'.

Read only

0 Likes
540

Hi,

I hope your code will solve it. I could understand your code as it is in zigszag. Can you give one sample code flow for this.

Regards,

Yellappa.

Read only

0 Likes
540

HI

Sorry for that check this link for the code..

Thanks

Mahesh

Read only

0 Likes
540

Hi,

Your link is very useful to me. I have rewarded the points for the same. Thanks for your help