2008 Jan 03 5:31 AM
Hi Experts,
I want to upload the data from excel sheet into abap ztable using unix script. If possible give me a sample coding for this..
Regards,
vijay
Hi Experts,
I want to upload the data from excel sheet into abap ztable using unix script. If possible give me a sample coding for this..
Regards,
vijay
2008 Jan 03 5:33 AM
hi vijay,
there is a program in the below link copy it, it may be use ful
http://www.abapprogramming.blogspot.com/2007/11/data-base-access-from-unix-file.html
reward points if useful
thanks,
swaroop
2008 Jan 03 5:47 AM
Hi Swaroop,
Thanks for ur reply, I am not able to find any unix script to load the ztable in the above link. my req. is the ztable should be loaded using unix script......
2008 Jan 03 6:27 AM
hi vijay see the code below
REPORT YFTP1 .
FTP by abap.
This program passses host, user, source/target
directory and file parameters to a UNIX script which
in turn gets the required file from the host by ftp.
The unix script should look like this:
*
#! /bin/sh
ftp -n $1 << !!
user $2 $3
cd .. <-- only for mainframe ftp
get $4 $5
quit
!!
*
placed in the adm path, preferably under
/sapmnt//exe. In order to make this program
work please create sapcpic/manager cpic user and
apply note no. 41770.
PARAMETERS: HOST(10) OBLIGATORY LOWER CASE,
USER(8) OBLIGATORY LOWER CASE,
PASSWORD(8) OBLIGATORY LOWER CASE,
SRC_FILE(45) OBLIGATORY LOWER CASE,
TRG_FILE(45) DEFAULT '/usr/sap/trans/data/??????' OBLIGATORY LOWER CASE,
BIN AS CHECKBOX.
DATA: JC(8), FLG(1), B(128), PRNAME(128), LOGFILE(30), AAA(40).
DATA: BEGIN OF A,
1(12), 2(10), 3(10), 4(47), 5(47),
END OF A.
IF HOST = 'zxaq'.
IF BIN = 'X'.
PRNAME = 'ftp_bin_vms'.
ELSE.
PRNAME = 'ftp_asc_vms'.
ENDIF.
ELSE.
IF BIN = 'X'.
PRNAME = '/usr/sap/trans/bin/ftp_bin_unix'.
ELSE.
PRNAME = '/usr/sap/trans/bin/ftp_asc_unix'.
ENDIF.
ENDIF.
A-1 = HOST.
A-2 = USER.
A-3 = PASSWORD.
A-4 = SRC_FILE.
A-5 = TRG_FILE.
CONDENSE A.
B = A.
CALL FUNCTION 'JOB_OPEN'
EXPORTING
JOBNAME = 'FTP'
IMPORTING
JOBCOUNT = JC.
CALL FUNCTION 'JOB_SUBMIT'
EXPORTING
AUTHCKNAM = SY-UNAME
EXTPGM_NAME = PRNAME
EXTPGM_PARAM = B
EXTPGM_SYSTEM = 'jupiter'
JOBCOUNT = JC
JOBNAME = 'FTP'.
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
JOBCOUNT = JC
JOBNAME = 'FTP'
STRTIMMED = 'X'
TARGETSYSTEM = 'jupiter'
IMPORTING
JOB_WAS_RELEASED = FLG.
LOGFILE = '/tmp/ftp.log'.
DO.
OPEN DATASET LOGFILE FOR INPUT IN TEXT MODE.
IF SY-SUBRC = 0. EXIT. ENDIF.
ENDDO.
DO.
READ DATASET LOGFILE INTO AAA.
IF SY-SUBRC = 0. WRITE / AAA. ENDIF.
IF AAA = 'FTP completed'. EXIT. ENDIF.
ENDDO.
CLOSE DATASET LOGFILE.
delete dataset logfile.
now the file is in the application server which you can upload in your internal table and update the database table....
thnkx
bhanu
2008 Jan 03 6:55 AM
Hi Bhanu,
Actually my excel file exist in appln server. I want to read the data from appln server and load into ztable using unix script
2008 Jan 03 7:06 AM
i guess the unix commands will be the same,
i you dont know unix then you can find out the commands like get, put, lcd.
you can use these commands to get file from your unix server nd put them into ztable.
also check ftp_command,
ftp_open,
ftp_close
its just using FTP u you can update your database. \
and for ftp you need unix commands like put, lcd
thnkx
hope this helps you
bhanu
2008 Feb 13 3:45 PM
Hi Vijay,
i too have almost same requirement... can u pls tell me how did u achieve this?
Regards
Giri