Skip to Content
avatar image
Former Member

file creation

Hi,

How to create sequential file and how to check it is created or not

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • avatar image
    Former Member
    Aug 22, 2007 at 08:25 AM

    hi

    to create seq file

    use

    open dataset <filename> for output in textmode encoding default.

    here u can loop at itab and transfer the data to dataset

    close dataset.

    u can see the file in tcode AL11

    (application server files)

    ex :

    data : it_mara like table of mara with header line,

    v_rec(60),

    TAB(3) value ' ',

    coma type c value ','.

    *****************************creating file on application server************************

    select matnr

    mtart

    ernam

    matkl

    meins from mara

    into corresponding fields of

    table it_mara.

    open dataset 'matdet.txt' in text mode encoding default for output.

    if sy-subrc <> 0.

    exit.

    endif.

    loop at it_mara.

    concatenate it_mara-matnr it_mara-mtart it_mara-ernam into v_rec separated by coma.

    transfer v_rec to 'matdet.txt'.

    • transfer it_mara to 'matdet.txt'.

    endloop.

    if sy-subrc = 0.

    message i000(bctrain) with 'File created on application server'.

    endif.

    close dataset 'matdet.txt'.

    Message was edited by:

    Premalatha G

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Aug 22, 2007 at 08:27 AM

    Hi,

    can you please elaborate as what do you mean by sequential file. are you planning to downlaod it on Application server or Presentation Server.

    Regards,

    Kanchan

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi Rakesh,

      check out the below code and you shall get the solution that you are looking for,

      • Check for the existence of the file.

      CALL FUNCTION 'TMP_GUI_GET_FILE_EXIST'

      EXPORTING

      FNAME = P_IPERR "file name along with the path

      IMPORTING

      ISDIR = L_ISDIR "-------L_ISDIR is a variable of Char (1)

      EXCEPTIONS

      FILEINFO_ERROR = 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.

      IF L_ISDIR EQ C_TRUE.

      MESSAGE I000 WITH TEXT-<xxx>.

      STOP.

      ENDIF.

      ENDIF.

      • to create that file

      OPEN DATASET P_IPERR1 FOR OUTPUT IN TEXT MODE. "----P_IPERR1 is the filename in the application layer.

      CHECK SY-SUBRC EQ 0.

      CLEAR WA_ERR_REC.

      LOOP AT I_ERR_REC INTO WA_ERR_REC. "--I_ERR_REC is an internal table having the data to be written to flat file.

      IF WA_ERR_REC-DEL_FLAG = C_TRUE.

      TRANSFER WA_ERR_REC TO P_IPERR1.

      ENDIF.

      CLEAR WA_ERR_REC.

      ENDLOOP.

      CLOSE DATASET P_IPERR1.

      ENDIF.

      <b>

      Rewards points if this helps,</b>

      Kiran

      Message was edited by:

      Kiran Kumar Somaroutu

      Message was edited by:

      Kiran Kumar Somaroutu