01-28-2008 3:06 PM
Hi,
I have a Download Program. Here, I have tp retrieve the data from different tables and write the data to UNIX file entered in the Selection Screen.
Could someone help me..? Tell me
1. How to declare a UNIX file? I mean, what should be the reference field while declaring the UNIX file..?
2. How to transfer the data from an Internal table ITAB to a UNIX file? This data transfer should happen record by record. I mean, this transfer should happen in an internal table LOOP-ENDLOOP.
Could anyone help me in doing the same by some sam[ple code or so..
Thanks in advance.
Best Regards,
paddu.
01-28-2008 3:20 PM
Hi Paddu, check this, will guide u.
check these commands.
su - production-admin
stopsap all -> make sure that the R/3 Instance and Oracle Database stopped
startsap all -> make sure that the R/3 Instance and Oracle Database started
If the Oracle Database is not started, tried using SAPDBA
su - oracle-admin
sapdba
Options a - Startup / Shutdown Database instance
Also, Please check transaction code SM69 for more info.
Paddu, the code below is :
reading data from unix file and write the same into an internal table.
modify it as per ur requirements.
do like this
codePARAMETERS: p_unix LIKE rlgrap-filename OBLIGATORY.
DATA: v_buffer(2047) TYPE c.
DATA: BEGIN OF i_buffer OCCURS 0,
line(2047) TYPE c,
END OF i_buffer.
Open the unix file..
OPEN DATASET p_unix FOR INPUT IN TEXT MODE.
IF sy-subrc NE 0.
*
o
+ Error Message "Unable to open file.
ELSE.
DO.
CLEAR: v_buffer.
READ DATASET p_unix INTO v_buffer.
IF sy-subrc NE 0.
EXIT.
ENDIF.
MOVE v_buffer TO i_buffer.
APPEND i_buffer.
ENDDO.
ENDIF.
CLOSE DATASET p_unix.[/code]
hope this helps.
kindly reward if found helpful.
cheers,
Hema.
01-28-2008 3:20 PM
Hi Paddu, check this, will guide u.
check these commands.
su - production-admin
stopsap all -> make sure that the R/3 Instance and Oracle Database stopped
startsap all -> make sure that the R/3 Instance and Oracle Database started
If the Oracle Database is not started, tried using SAPDBA
su - oracle-admin
sapdba
Options a - Startup / Shutdown Database instance
Also, Please check transaction code SM69 for more info.
Paddu, the code below is :
reading data from unix file and write the same into an internal table.
modify it as per ur requirements.
do like this
codePARAMETERS: p_unix LIKE rlgrap-filename OBLIGATORY.
DATA: v_buffer(2047) TYPE c.
DATA: BEGIN OF i_buffer OCCURS 0,
line(2047) TYPE c,
END OF i_buffer.
Open the unix file..
OPEN DATASET p_unix FOR INPUT IN TEXT MODE.
IF sy-subrc NE 0.
*
o
+ Error Message "Unable to open file.
ELSE.
DO.
CLEAR: v_buffer.
READ DATASET p_unix INTO v_buffer.
IF sy-subrc NE 0.
EXIT.
ENDIF.
MOVE v_buffer TO i_buffer.
APPEND i_buffer.
ENDDO.
ENDIF.
CLOSE DATASET p_unix.[/code]
hope this helps.
kindly reward if found helpful.
cheers,
Hema.
01-28-2008 3:26 PM
hi
good
check this
autounix.sh
#!/bin/ksh
Declaring all the variables
s_filepath='/sap/usr/sap/trans/data/'
s_backuppath='/sap/usr/sap/trans/data/autozip/'
s_unixfile1=$s_filepath'FILE1'
s_unixfile2=$s_filepath'FILE2'
s_unixfile3=$s_filepath'FILE3'
This has been changed to accepting parameter pass in as date
#s_date=`date '+%Y%m%d'`
s_date=$1
s_filename='SAP.'$s_date'.ZIP'
s_donefilename=$s_filename'.DONE'
Execute the zip command
/usr/local/bin/pkzip -add -pass=test123 $s_backuppath$s_filename $s_unixfile1 $s_unixfile2 $s_unixfile3
Execute the FTP transfer
user='ftp'
passwd='ftp1234'
destdir='data/test'
cd $s_backuppath
ftp -in ftp-out.sapservx.com << EndHere
user $user $passwd
cd $destdir
bin
put $s_filename
rename $s_filename $s_donefilename
quit
EndHere
thanks
mrutyun^
01-29-2008 1:18 AM
Hi Paddu,
1) Declare parameter p_file LIKE rlgrap-filename OBLIGATORY.
(convert logical file to physical file using FM file_get_name)
2) Declare internal table and work area
3) OPEN DATASET <dsn> FOR OUTPUT
4) Retrieve data and store in internal table
5) For each record use statemet Transfer <f> to <dsn>
Reward point if it helps.
With Regards,
Gandhi Subramani