Skip to Content

BDC: Downloading the data to UNIX file

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.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jan 28, 2008 at 03: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.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 28, 2008 at 03:26 PM

    hi

    good

    check this

    autounix.sh

    #!/bin/ksh

    1. 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'

    1. 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'

    1. Execute the zip command

    /usr/local/bin/pkzip -add -pass=test123 $s_backuppath$s_filename $s_unixfile1 $s_unixfile2 $s_unixfile3

    1. 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^

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 29, 2008 at 01: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

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.