Itab to text file

Hi ,
Someone please tell me how I can put the data from an internal table into a text
Thanks

Hi,
Use the standard FM: GUI_DOWNLOAD, give file type as 'ASC'.
Regards
Subramanian

Similar Messages

  • Data from itab to be store in text file in desktop

    hi
    i am tyring to store the data from itab into a text file in desktop,but its now owrking.
    i am using open dataset statment,but no where data is storing.My code:
    TYPES : BEGIN OF ST_DEMO,
    REG_NO(10) TYPE C,
    NAME(20)   TYPE C,
    ADDR(20)   TYPE C,
    END OF ST_DEMO.
    DATA : WA_DEMO TYPE ST_DEMO,
    IT_DEMO TYPE TABLE OF ST_DEMO,
    L_FNAME TYPE dxfile-filename .
    PARAMETERS: P_FNAME(128) TYPE C DEFAULT '\usr\sap\put\vipin.txt' OBLIGATORY.
    L_FNAME = P_FNAME.
    WA_DEMO-REG_NO = '100001'.
    WA_DEMO-NAME = 'ANAND'.
    WA_DEMO-ADDR = 'NAGARKOVIL'.
    APPEND WA_DEMO TO IT_DEMO.
    OPEN DATASET L_FNAME FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
    WRITE :5 'REG NUM',16 'NAME',37 'ADDRESS' .
    LOOP AT IT_DEMO INTO WA_DEMO.
      IF SY-SUBRC = 0.
        TRANSFER WA_DEMO TO L_FNAME.
        WRITE :/5 WA_DEMO-REG_NO,16 WA_DEMO-NAME,37 WA_DEMO-ADDR.
      ENDIF.
    ENDLOOP.
    close DATASET L_FNAME.
    please tell me where is the prob?I wan to schedule it for background job.
    regds
    vipin

    hi
    here is the code for :  "data from itab to be store in text file in desktop"
    TABLES: vbak.    " standard table
    *                           Type Pools                                 *
    TYPE-POOLS: slis.
    *                     Global Structure Definitions                     *
    *-- Structure to hold data from table CE1MCK2
    TYPES: BEGIN OF tp_itab1,
           vbeln LIKE vbap-vbeln,
           posnr LIKE vbap-posnr,
           werks LIKE vbap-werks,
           lgort LIKE vbap-lgort,
           END OF tp_itab1.
    *-- Data Declaration
    DATA: t_itab1 TYPE TABLE OF tp_itab1.
    DATA : i_fieldcat TYPE slis_t_fieldcat_alv.
    *                    Selection  Screen                                 *
    *--Sales document-block
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-t01.
    SELECT-OPTIONS: s_vbeln FOR vbak-vbeln.
    SELECTION-SCREEN END OF  BLOCK b1.
    *--Display option - block
    SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-t02.
    PARAMETERS: alv_list RADIOBUTTON GROUP g1,
                alv_grid RADIOBUTTON GROUP g1.
    SELECTION-SCREEN END OF  BLOCK b2.
    *file download - block
    SELECTION-SCREEN BEGIN OF BLOCK b3 WITH FRAME TITLE text-t03.
    PARAMETERS: topc AS CHECKBOX,
                p_file TYPE rlgrap-filename.
    SELECTION-SCREEN END OF  BLOCK b3.
    *                      Initialization.                                *
    *                      At Selection Screen                            *
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
      CALL FUNCTION 'F4_DXFILENAME_4_DYNP'
        EXPORTING
          dynpfield_filename = 'P_FILE'
          dyname             = sy-cprog
          dynumb             = sy-dynnr
          filetype           = 'P'      "P-->Physical
          location           = 'P'     "P Presentation Srever
          server             = space.
    AT SELECTION-SCREEN ON s_vbeln.
      PERFORM vbeln_validate.
    *                           Start Of Selection                         *
    START-OF-SELECTION.
    *-- Fetching all the required data into the internal table
      PERFORM select_data.
    *                           End Of Selection                           *
    END-OF-SELECTION.
      IF t_itab1[] IS NOT INITIAL.
        IF topc IS NOT INITIAL.
          PERFORM download.
          MESSAGE 'Data Download Completed' TYPE 'S'.
        ENDIF.
        PERFORM display.
      ELSE.
        MESSAGE 'No Records Found' TYPE 'I'.
      ENDIF.
    *                           Top Of Page Event                          *
    TOP-OF-PAGE.
    *& Form           :      select_data
    * Description     : Fetching all the data into the internal tables
    *  parameters    :  none
    FORM select_data .
      SELECT vbeln
         posnr
         werks
         lgort
         INTO CORRESPONDING  FIELDS OF TABLE t_itab1
         FROM vbap
         WHERE  vbeln IN s_vbeln.
      IF sy-subrc <> 0.
        MESSAGE 'Enter The Valid Sales Document Number'(t04) TYPE 'I'.
        EXIT.
      ENDIF.
    ENDFORM.                    " select_data
    *& Form        : display
    *  decription  : to display data in given format
    * parameters   :  none
    FORM display .
      IF alv_list = 'X'.
        PERFORM build_fieldcat TABLES i_fieldcat[]
                               USING :
    *-Output-field Table      Len  Ref fld Ref tab Heading    Col_pos
       'VBELN'       'T_ITAB1'     10   'VBAP'  'VBELN'    ''            1,
       'POSNR'       'T_ITAB1'     6    'VBAP'  'POSNR'    ''            2,
       'WERKS'       'T_ITAB1'     4    'VBAP'  'WERKS'    ''            3,
       'LGORT'       'T_ITAB1'     4    'VBAP'  'LGORT'    ''            4.
        CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
          EXPORTING
            i_callback_program       = sy-repid
    *        i_callback_pf_status_set = c_pf_status
            i_callback_user_command  = 'USER_COMMAND '
    *        it_events                = t_alv_events[]
            it_fieldcat              = i_fieldcat[]
          TABLES
            t_outtab                 = t_itab1[]
          EXCEPTIONS
            program_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.
      ENDIF.
      IF alv_grid = 'X'.
        PERFORM build_fieldcat TABLES i_fieldcat[]
                                 USING :
    *-Output-field Table      Len  Ref fld Ref tab Heading    Col_pos
         'VBELN'       'T_ITAB1'     10   'VBAP'  'VBELN'    ''            1,
         'POSNR'       'T_ITAB1'     6    'VBAP'  'POSNR'    ''            2,
         'WERKS'       'T_ITAB1'     4    'VBAP'  'WERKS'    ''            3,
         'LGORT'       'T_ITAB1'     4    'VBAP'  'LGORT'    ''            4.
        CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
          EXPORTING
            i_callback_program       = sy-repid
    *        i_callback_pf_status_set = c_pf_status
            i_callback_user_command  = 'USER_COMMAND '
            it_fieldcat              = i_fieldcat
          TABLES
            t_outtab                 = t_itab1[]
        EXCEPTIONS
       program_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.
      ENDIF.
    ENDFORM.                    " display
    *& Form        : vbeln_validate
    *  description : to validate sales document number
    * parameters   :  none
    FORM vbeln_validate .
      DATA: l_vbeln TYPE vbak-vbeln.
      SELECT SINGLE vbeln
        FROM vbak
        INTO l_vbeln
        WHERE vbeln IN s_vbeln.
      IF sy-subrc NE 0.
        MESSAGE 'ENTER THE VALID SALES DOCUMENT NO:' TYPE 'I'.
        EXIT.
      ENDIF.
    ENDFORM.                    " vbeln_validate
    *& Form       :build_fieldcat
    * Description : This routine fills field-catalogue
    *  Prameters  : none
    FORM build_fieldcat TABLES  fpt_fieldcat TYPE slis_t_fieldcat_alv
                        USING   fp_field     TYPE slis_fieldname
                                fp_table     TYPE slis_tabname
                                fp_length    TYPE dd03p-outputlen
                                fp_ref_tab   TYPE dd03p-tabname
                                fp_ref_fld   TYPE dd03p-fieldname
                                fp_seltext   TYPE dd03p-scrtext_l
                                fp_col_pos   TYPE sy-cucol.
    *-- Local data declaration
      DATA:   wl_fieldcat TYPE slis_fieldcat_alv.
    *-- Clear WorkArea
      wl_fieldcat-fieldname       = fp_field.
      wl_fieldcat-tabname         = fp_table.
      wl_fieldcat-outputlen       = fp_length.
      wl_fieldcat-ref_tabname     = fp_ref_tab.
      wl_fieldcat-ref_fieldname   = fp_ref_fld.
      wl_fieldcat-seltext_l       = fp_seltext.
      wl_fieldcat-col_pos         = fp_col_pos.
    *-- Update Field Catalog Table
      APPEND wl_fieldcat  TO  fpt_fieldcat.
    ENDFORM.                    "build_fieldcat
    *& Form        : download
    *  description : To Download The Data
    *  Parameters  :  none
    FORM download .
      DATA: l_file TYPE string.
      l_file = p_file.
      CALL FUNCTION 'GUI_DOWNLOAD'
        EXPORTING
          filename                = l_file
          filetype                = 'ASC'
        TABLES
          data_tab                = t_itab1
        EXCEPTIONS
          file_write_error        = 1
          no_batch                = 2
          gui_refuse_filetransfer = 3
          invalid_type            = 4
          no_authority            = 5
          unknown_error           = 6.
      IF sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    " download
    hope it will help you
    regards
    rahul

  • Downloading a text file from application server

    Hi Freinds,
    I am genarating a text file in our application server (Folder /usr/sap/dbi/) I need to download this text file in my destop pc or some other windows server.
    What do I have to do? What is the procedure, Pls help.
    If someone have sample code, pls send.
    We are running SAP ECC5.0 on an iSeries (AS/400) Database DB2/400.
    Regards
    Thanura

    Hi,
    try this:
    REPORT ZGRO_TEST.
    DATA: DATEI_A(30) TYPE C VALUE '/tmp/matnr.txt'.
    DATA: DATEI_PC TYPE STRING VALUE 'C:\MATNR.TXT'.
    DATA: ITAB        TYPE TABLE OF MARA WITH HEADER LINE.
    START-OF-SELECTION.
      PERFORM DATEI_EINLESEN.
      PERFORM DATEI_DOWNLOAD.
    FORM DATEI_EINLESEN.
      OPEN DATASET DATEI_A FOR INPUT IN TEXT MODE.
      IF SY-SUBRC NE 0. STOP. ENDIF.
      DO.
        READ DATASET DATEI_A INTO ITAB.
        IF SY-SUBRC <> 0. EXIT. ENDIF.
        APPEND ITAB.
      ENDDO.
      CLOSE DATASET DATEI_A.
      IF SY-SUBRC NE 0. STOP. ENDIF.
    ENDFORM.                    "DATEI_EINLESEN
    FORM DATEI_DOWNLOAD.
    Datei downloaden
      CALL METHOD CL_GUI_FRONTEND_SERVICES=>GUI_DOWNLOAD
        EXPORTING
          FILENAME                = DATEI_PC
          FILETYPE                = 'ASC'
        CHANGING
          DATA_TAB                = ITAB[]
        EXCEPTIONS
          FILE_WRITE_ERROR        = 1
          NO_BATCH                = 2
          GUI_REFUSE_FILETRANSFER = 3
          INVALID_TYPE            = 4
          NO_AUTHORITY            = 5
          UNKNOWN_ERROR           = 6
          HEADER_NOT_ALLOWED      = 7
          SEPARATOR_NOT_ALLOWED   = 8
          FILESIZE_NOT_ALLOWED    = 9
          HEADER_TOO_LONG         = 10
          DP_ERROR_CREATE         = 11
          DP_ERROR_SEND           = 12
          DP_ERROR_WRITE          = 13
          UNKNOWN_DP_ERROR        = 14
          ACCESS_DENIED           = 15
          DP_OUT_OF_MEMORY        = 16
          DISK_FULL               = 17
          DP_TIMEOUT              = 18
          FILE_NOT_FOUND          = 19
          DATAPROVIDER_EXCEPTION  = 20
          CONTROL_FLUSH_ERROR     = 21
          NOT_SUPPORTED_BY_GUI    = 22
          ERROR_NO_GUI            = 23
          OTHERS                  = 24.
      IF SY-SUBRC NE 0. STOP. ENDIF.
    ENDFORM.                    "DATEI_DOWNLOAD
    Regards, Dieter

  • Data read from text file(notepad) not enterd into  particular field

    Hi frends, I have used function "F4_FILENAME" and "GUI_UPLOAD" to upload a text file in notepad on my desktop to an internal table in SAP.after that i used the folowing code line  to copy data from one table to other:
    " insert tab2 from table itab accepting duplicate keys. "
    But my problem is that in tab2 i have total 5 fields.In notepad file i have written following two words:
    achal
    mehra
    now when i copy the data from itab to tab2 , it shows word "achal" in the field 1 of 1st row and "mehra" in field 1 of 2nd row only.
    what i want is to store "a" in field1 "c" in field2 and so on in row 1.
    similarly "m" in the second row and field1.
    PLZ guide me.I am new to ABAP.

    thnx frend but dear ur code has syntax error.Actually I am new to ABAP. I am using following code as a part of my program :
    CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
       FILENAME = d_file
       FILETYPE =  'ASC'
       HAS_FIELD_SEPARATOR = ''
       HEADER_LENGTH = 0
       READ_BY_LINE = 'X'
       DAT_MODE = ' '
         TABLES
         DATA_TAB = itab
         LOOP AT gt_file2 INTO lwa.
         EXCEPTIONS
           FILE_OPEN_ERROR = 1
           FILE_READ_ERROR = 2
           NO_BATCH = 3
           GUI_REFUSE_FILETRANSFER = 4
           INVALID_TYPE = 5
           NO_AUTHORITY = 6
           UNKNOWN_ERROR = 7
           BAD_DATA_FORMAT = 8
           HEADER_NOT_ALLOWED =9
           SEPARATOR_NOT_ALLOWED = 10
           HEADER_TOO_LONG = 11
           UNKNOWN_DP_ERROR = 12
           ACCESS_DENIED = 13
           DP_OUT_OF_MEMORY = 14
           DISK_FULL = 15
           DP_TIMEOUT = 16
           OTHERS = 17.
          IF SY-SUBRC <> 0.
                    ENDIF.
          loop at itab.
            Write:/ ITAB.
            endloop.
    insert zlfa4 from table itab .
    plz guide me where i shud use ur code and plz write the exact syntax for me if u can.

  • Multiple tables in GUI_DOWNLOAD in same text file

    Hi,
    Can anybody tell me how to pass multiple internal tables for download in same text file. And also each table output should start with NEW LINE. Please help me in executing this functionality.
    Thanks,
    Amol

    I'm not sure that I understand correctly but :
    - if you mean that the first line before your table should be NEW LINE, then before Appending your new internal table (itab2) into the consolidated one (itab), you could just do something like :
    itab-text = 'NEW LINE'.
    append itab.
    And then
    append itab2 into itab.
    - if you mean that the first line of your new table should begin you NEW LINE then it could be something like that :
    read table itab2 index 1.
    concatenate 'NEW LINE' itab2-text into itab2-text.
    modify itab2 transporting text index 1.
    append itab2 into itab.
    Hope it helps,
    Regards,
    Sylvie

  • How to get data of tabulated text file into internal table

    hi all,
    i want to get data from tabulated text file(notepad) into internal table. i searched in SCN and got lot of post regarding  how to convert excel file into internal table but i didnt get posts regarding text file.
    thanks
    SAchin

    try:
    DATA: BEGIN OF tabulator,
            x(1) TYPE x VALUE '09',
          END OF tabulator.
      READ DATASET file INTO wa.
    split wa at tabulator into table itab.
    A.

  • How to send a text file attachment through mail in ECC 6.0

    Hi Friends,
    As per the requirement, I need to send a ALV report result as text file attachment to user in ECC 6.0 . I know how to do in 4.6C version. But the same code is not working here in ECC 6.0.
    Generally to get the data in new row in the text file we use below code in 4.6c.
    data: c_value type x value ' 0D '.
    concatenate c_value itab-line into itab-line.
    By using above code, we get each row of the itab in a new line in text file.
    Same code is not working in ECC6.0 as it is not supporting  to concatenate bytes with characters. Getting the error like " field c_value should be diclared as type C or I or N or T or P"
    Even I have used function module NLS_STRING_CONVERT_TO_SYS to convert hexa to char. It is converting the value' 0D' to ' # '. But it is not working.
    Could you please suggest me that how can get each row of itab as a new line in text file in ECC 6.0.
    Itab value:
    abcdefdfldjfñlkdsjfñldsjfdsñljñla
    fdsljfñldskjfldsñkjfñldsjfñldsajñld
    vcxusfcxusfcusafcxusafcusafcdsauc
    Actual result currently coming in text file:
    abcdefdfldjfñlkdsjfñldsjfdsñljñlafdsljfñldskjfldsñkjfñldsjfñldsajñldvcxusfcxusfcusafcxusafcusafcdsauc
    Expected result in text file:
    abcdefdfldjfñlkdsjfñldsjfdsñljñla
    fdsljfñldskjfldsñkjfñldsjfñldsajñld
    vcxusfcxusfcusafcxusafcusafcdsauc
    Please do the needful.
    Thanks
    Kumar

    hi,
    Try this function Module
    CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1 '
    *example code
    ******* Create Message Body Title and Description****************
      i_objtxt = 'test with pdf-Attachment!'.
      append i_objtxt.
      describe table i_objtxt lines v_lines_txt.
      read table i_objtxt index v_lines_txt.
      wa_doc_chng-obj_name = 'smartform'.
      wa_doc_chng-expiry_dat = sy-datum + 10.
      wa_doc_chng-obj_descr = 'smartform'.
      wa_doc_chng-sensitivty = 'F'.
      wa_doc_chng-doc_size = v_lines_txt * 255.
    **** Main Text*****************************
      clear i_objpack-transf_bin.
      i_objpack-head_start = 1.
      i_objpack-head_num = 0.
      i_objpack-body_start = 1.
      i_objpack-body_num = v_lines_txt.
      i_objpack-doc_type = 'RAW'.
      append i_objpack.
    **** Attachment (pdf-Attachment)*************
      i_objpack-transf_bin = 'X'.
      i_objpack-head_start = 1.
      i_objpack-head_num = 1.
      i_objpack-body_start = 1.
      i_objpack-body_num = v_lines_bin.
      i_objpack-doc_type = 'PDF'.
      i_objpack-obj_name = 'smartform'.
      concatenate i_objpack-obj_name i_objpack-doc_type into
    i_objpack-obj_descr separated by '.'.
    *  I_OBJPACK-OBJ_DESCR = 'test'.
      i_objpack-doc_size =  v_lines_bin * 255 .
      append i_objpack.
    * Länge des Attachment ermitteln
      clear i_reclist.
      i_reclist-receiver = 'email address'.
      i_reclist-rec_type = 'U'.
      i_reclist-express = 'X'.
      data: tab_lines like sy-tabix.
      describe table i_objbin lines tab_lines.
      append i_reclist.
      call function 'SO_NEW_DOCUMENT_ATT_SEND_API1'
        exporting
          document_data              = wa_doc_chng
          put_in_outbox              = 'X'
          commit_work                = 'X'
        tables
          packing_list               = i_objpack
          object_header              = wa_objhead
          contents_bin               = i_objbin
          contents_txt               = i_objtxt
          receivers                  = i_reclist
        exceptions
          too_many_receivers         = 1
          document_not_sent          = 2
          document_type_not_exist    = 3
          operation_no_authorization = 4
          parameter_error            = 5
          x_error                    = 6
          enqueue_error              = 7
          others                     = 8.
      if sy-subrc <> 0.
        write:/ 'Error When Sending the File', sy-subrc.
      else.
        write:/ 'Mail sent'.
      endif.

  • How to read number of ';' in a text file

    I have a text file with size 2kb. The file has names seperated by ';' . For example John, Smith; David, Putnam; etc ..
    Now I have to read the file and find out how many ';' are there.
    I tried GUI_upload to read the text file and I think I did not get whole data.
    and
    loop at itab.
    if itab-names cs ';' .
    find ALL OCCURRENCES OF REGEX ';' IN itab-names MATCH COUNT  mcnt.
    l_mstring = itab-names .
    endif.
    endloop.
    I'm just getting count as 3
    Edited by: P V on Feb 21, 2008 9:57 PM

    DATA : tot_count TYPE i,
               mcnt TYPE i.
    loop at itab.
    if itab-names cs ';' .
    find ALL OCCURRENCES OF REGEX ';' IN itab-names MATCH COUNT mcnt.
    tot_count = tot_count + mcnt.
    endif.
    endloop.
    You will get total number of ; available in file in the field tot_count.
    Regards
    Sudhir Atluru

  • Sending text files as attachments in mails

    Hi Experts,
    I want to send some content in a text file as an attachment in the mail. Can anybody provide me the sample code for this.
    points guaranteed.
    thanks
    sanakr

    HI
    Check this one
    first create a Include report with the following coding
    *&  Include           ZPA1_INCLFOR_MAIL                                *
    * Data
    DATA: docdata LIKE sodocchgi1,
    objpack LIKE sopcklsti1 OCCURS 1 WITH HEADER LINE,
    objhead LIKE solisti1 OCCURS 1 WITH HEADER LINE,
    objtxt LIKE solisti1 OCCURS 10 WITH HEADER LINE,
    objbin LIKE solisti1 OCCURS 10 WITH HEADER LINE,
    objhex LIKE solix OCCURS 10 WITH HEADER LINE,
    reclist LIKE somlreci1 OCCURS 1 WITH HEADER LINE.
    DATA: tab_lines TYPE i,
    doc_size TYPE i,
    att_type LIKE soodk-objtp.
    DATA: listobject LIKE abaplist OCCURS 1 WITH HEADER LINE.
    * FORM
    FORM ml_customize USING objname objdesc.
    *----------- Clear Variables
    CLEAR docdata.
    REFRESH objpack.
    CLEAR objpack.
    REFRESH objhead.
    REFRESH objtxt.
    CLEAR objtxt.
    REFRESH objbin.
    CLEAR objbin.
    REFRESH objhex.
    CLEAR objhex.
    REFRESH reclist.
    CLEAR reclist.
    REFRESH listobject.
    CLEAR listobject.
    CLEAR tab_lines.
    CLEAR doc_size.
    CLEAR att_type.
    *--------- Set Variables
    docdata-obj_name = objname.
    docdata-obj_descr = objdesc.
    ENDFORM. "ml_customize
    * FORM
    FORM ml_addrecp USING preceiver prec_type.
    CLEAR reclist.
    reclist-receiver = preceiver.
    reclist-rec_type = prec_type.
    APPEND reclist.
    ENDFORM. "ml_customize
    * FORM
    FORM ml_addtxt USING ptxt.
    CLEAR objtxt.
    objtxt = ptxt.
    APPEND objtxt.
    ENDFORM. "ml_customize
    * FORM
    FORM ml_prepare USING bypassmemory whatatt_type whatname.
    IF bypassmemory = ''.
    *--------- Fetch List From Memory
    CALL FUNCTION 'LIST_FROM_MEMORY'
    TABLES
    listobject = listobject
    EXCEPTIONS
    OTHERS = 1.
    IF sy-subrc <> 0.
    MESSAGE ID '61' TYPE 'E' NUMBER '731'
    WITH 'LIST_FROM_MEMORY'.
    ENDIF.
    CALL FUNCTION 'TABLE_COMPRESS'
    * IMPORTING
    * COMPRESSED_SIZE =
    TABLES
    in = listobject
    out = objbin
    EXCEPTIONS
    OTHERS = 1
    IF sy-subrc <> 0.
    MESSAGE ID '61' TYPE 'E' NUMBER '731'
    WITH 'TABLE_COMPRESS'.
    ENDIF.
    ENDIF.
    * Header Data
    * Already Done Thru FM
    * Main Text
    * Already Done Thru FM
    * Packing Info For Text Data
    DESCRIBE TABLE objtxt LINES tab_lines.
    READ TABLE objtxt INDEX tab_lines.
    docdata-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objtxt ).
    CLEAR objpack-transf_bin.
    objpack-head_start = 1.
    objpack-head_num = 0.
    objpack-body_start = 1.
    objpack-body_num = tab_lines.
    objpack-doc_type = 'TXT'.
    APPEND objpack.
    * Packing Info Attachment
    att_type = whatatt_type..
    DESCRIBE TABLE objbin LINES tab_lines.
    READ TABLE objbin INDEX tab_lines.
    objpack-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objbin ).
    objpack-transf_bin = 'X'.
    objpack-head_start = 1.
    objpack-head_num = 0.
    objpack-body_start = 1.
    objpack-body_num = tab_lines.
    objpack-doc_type = att_type.
    objpack-obj_name = 'ATTACHMENT'.
    objpack-obj_descr = whatname.
    APPEND objpack.
    * Receiver List
    * Already done thru fm
    ENDFORM. "ml_prepare
    * FORM
    FORM ml_dosend.
    CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
    EXPORTING
    document_data = docdata
    put_in_outbox = 'X'
    commit_work = 'X' "used from rel. 6.10
    * IMPORTING
    * SENT_TO_ALL =
    * NEW_OBJECT_ID =
    TABLES
    packing_list = objpack
    object_header = objhead
    contents_bin = objbin
    contents_txt = objtxt
    * CONTENTS_HEX = objhex
    * OBJECT_PARA =
    * object_parb =
    receivers = reclist
    EXCEPTIONS
    too_many_receivers = 1
    document_not_sent = 2
    document_type_not_exist = 3
    operation_no_authorization = 4
    parameter_error = 5
    x_error = 6
    enqueue_error = 7
    OTHERS = 8
    IF sy-subrc <> 0.
    MESSAGE ID 'SO' TYPE 'S' NUMBER '023'
    WITH docdata-obj_name.
    ENDIF.
    ENDFORM. "ml_customize
    * FORM
    FORM ml_spooltopdf USING whatspoolid.
    DATA : pdf LIKE tline OCCURS 0 WITH HEADER LINE.
    *-------------- Call Function
    CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'
    EXPORTING
    src_spoolid = whatspoolid
    TABLES
    pdf = pdf
    EXCEPTIONS
    err_no_otf_spooljob = 1
    OTHERS = 12.
    *------------- Convert
    PERFORM doconv TABLES pdf objbin.
    ENDFORM. "ml_spooltopdf
    * FORM
    FORM doconv TABLES
    mypdf STRUCTURE tline
    outbin STRUCTURE solisti1.
    *-------- Data
    DATA : pos TYPE i.
    DATA : len TYPE i.
    *------------ Loop And Put Data
    LOOP AT mypdf.
    pos = 255 - len.
    IF pos > 134. "length of pdf_table
    pos = 134.
    ENDIF.
    outbin+len = mypdf(pos).
    len = len + pos.
    IF len = 255. "length of out (contents_bin)
    APPEND outbin.
    CLEAR: outbin, len.
    IF pos < 134.
    outbin = mypdf+pos.
    len = 134 - pos.
    ENDIF.
    ENDIF.
    ENDLOOP.
    IF len > 0.
    APPEND outbin.
    ENDIF.
    ENDFORM. "doconv
    Then include that report in the following report and copy the same code and paste it there
    *& Report  ZPA_TEMP147                                                 *
    REPORT  ZPA_TEMP147                             .
    INCLUDE zpa1_inclfor_mail.
    * DATA
    DATA : itab LIKE tline OCCURS 0 WITH HEADER LINE.
    DATA : file_name TYPE string.
    data : path like PCFILE-PATH.
    data : extension(5) type c.
    data : name(100) type c.
    * SELECTION SCREEN
    PARAMETERS : receiver TYPE somlreci1-receiver lower case.
    PARAMETERS : p_file LIKE rlgrap-filename
    OBLIGATORY.
    * AT SELECTION SCREEN
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
    CLEAR p_file.
    CALL FUNCTION 'F4_FILENAME'
    IMPORTING
    file_name = p_file.
    * START-OF-SELECTION
    START-OF-SELECTION.
    PERFORM ml_customize USING 'Tst' 'Testing'.
    PERFORM ml_addrecp USING receiver 'U'.
    PERFORM upl.
    PERFORM doconv TABLES itab objbin.
    PERFORM ml_prepare USING 'X' extension name.
    PERFORM ml_dosend.
    SUBMIT rsconn01
    WITH mode EQ 'INT'
    AND RETURN.
    * FORM
    FORM upl.
    file_name = p_file.
    CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
    filename = file_name
    filetype = 'BIN'
    TABLES
    data_tab = itab
    EXCEPTIONS
    file_open_error = 1
    file_read_error = 2
    no_batch = 3
    gui_refuse_filetransfer = 4
    invalid_type = 5
    no_authority = 6
    unknown_error = 7
    bad_data_format = 8
    header_not_allowed = 9
    separator_not_allowed = 10
    header_too_long = 11
    unknown_dp_error = 12
    access_denied = 13
    dp_out_of_memory = 14
    disk_full = 15
    dp_timeout = 16
    OTHERS = 17.
    path = file_name.
    CALL FUNCTION 'PC_SPLIT_COMPLETE_FILENAME'
    EXPORTING
    complete_filename = path
    * CHECK_DOS_FORMAT =
    IMPORTING
    * DRIVE =
    EXTENSION = extension
    NAME = name
    * NAME_WITH_EXT =
    * PATH =
    EXCEPTIONS
    INVALID_DRIVE = 1
    INVALID_EXTENSION = 2
    INVALID_NAME = 3
    INVALID_PATH = 4
    OTHERS = 5
    ENDFORM. "upl
    Regards
    Pavan

  • Execute code from a text file ...

    Hello ,  Would like to know whether it is possible to have my ABAP code in a text file in desktop and then execute the code by reading it into an ITAB in another ABAP program .
    Note : Pl. dont suggest how to upload and create a new program . I dont want to create a new program after uploading into ITAB using INSERT or function modules . I want to execute the code as part of the uploading program only . So that once the execution is complete the uploaded code will not be available in the SAP system.
    Thanks in advance ,
    Jee.R

    >
    jeeva R wrote:
    > Note : Pl. dont suggest how to upload and create a new program . I dont want to create a new program after uploading into ITAB using INSERT or function modules . I want to execute the code as part of the uploading program only . So that once the execution is complete the uploaded code will not be available in the SAP system.
    Oh dear.  The only solution to your requirement is, sadly, to upload and create a new program, and then one further step.  There is no other way.  So it looks like you'll have to do without.
    matt

  • Header in text file.

    Hi expert,
    wn i m downloading a text file into presentation server , hw can i add header there for heading of the particular fieds which is showing in file.plz suggest.
    thanx and regards...
    sunil.

    hello,
    you can try doing as mentioned above
    however, in some cases, the datatype of the internal table may not allow you to entire the text header string that you need
    in such cases you can use this method
    what i have done here, is to make a simple internal table with text values to insert the text
    i used that table with the FM first
    then i called the function module again and passed the data
    in the second call, i set the append parameter to 'X'.
    types: begin of header_type,
      field1(20),
      field2(20),
      field3(20),
    end of header_type.
    data: it_header type header_type occurs 0 with header line.
    it_header-field1 = 'field_1'.
    it_header-field2 = 'field_2'.
    it_header-field3 = 'field_3'.
    append it_header.
    CALL FUNCTION 'GUI_DOWNLOAD'
      EXPORTING
        filename              = 'c:\test_xls.xls'
        filetype              = 'ASC'
        write_field_separator = 'X'
        DAT_MODE              = 'X'
        TRUNC_TRAILING_BLANKS = 'X'
      TABLES
        data_tab              = it_header.
    CALL FUNCTION 'GUI_DOWNLOAD'
      EXPORTING
        filename              = 'c:\test_xls.xls'
        filetype              = 'ASC'
        append                = 'X'
        write_field_separator = 'X'
        DAT_MODE              = 'X'
        TRUNC_TRAILING_BLANKS = 'X'
      TABLES
        data_tab              = itab.

  • Problem in text file attachment while sending to lotusnotes

    Hi friends,
    Good day. I am sending the ALV report data as a text file to lotus notes. I am getting the text file as an attachment and finding data while opening it. But data is not coming properly. I am getting some space in between two rows in text file.
    I am using below code to get new line.
    data: c_val type x value ' 0D'.
    concatenate c_value itab into itab.
    Actual Result
    testtesttesttesttesttesttesttesttesttest
    testtesttesttesttesttesttesttesttesttest
    testtesttesttesttesttesttesttesttesttest
    Expected result
    testtesttesttesttesttesttesttesttesttest
    testtesttesttesttesttesttesttesttesttest
    testtesttesttesttesttesttesttesttesttest.
    Please send some code to get the lines properly.
    Thanks
    Kumar

    use this :
    data: c_val type c value CL_ABAP_CHAR_UTILITIES=>CR_LF.

  • Saving report in text file...

    Can anyone tell me how can i save the includes used in my program into text file and save them in some folder as individual textfile ? Which Function module will be used??urgently required..

    Hello Mandeep,
    following is the program to download your program into text file in a particulat folder.
    REPORT  ZTNEEL_DOWNLOAD_PROG                  .
    TABLES : tadir,trdirt.
    DATA: BEGIN OF itab OCCURS 100,
    text(75),
    END OF itab.
    data:progname type itab.
    DATA: BEGIN OF repname OCCURS 10,
    obj_name LIKE tadir-obj_name,
    END OF repname.
    PARAMETERS : devclass LIKE tadir-devclass,
    dirname(50) DEFAULT 'C:\',
    author like tadir-author.
    insert progname into repname.
    modify repname.
    DATA name LIKE rlgrap-filename.
    LOOP AT repname.
      READ REPORT repname-obj_name INTO itab.
    ****Get report title
      SELECT SINGLE * FROM trdirt WHERE name EQ repname-obj_name
      AND sprsl = 'E'.
      CONCATENATE '*' trdirt-text INTO trdirt-text.
      INSERT trdirt-text INTO itab INDEX 1.
      CONCATENATE dirname '\' repname-obj_name '.txt'
      INTO name.
    *exit.
      CALL FUNCTION 'WS_DOWNLOAD'
        EXPORTING
          filename                = name
        TABLES
          data_tab                = itab
        EXCEPTIONS
          file_open_error         = 1
          file_write_error        = 2
          invalid_filesize        = 3
          invalid_table_width     = 4
          invalid_type            = 5
          no_batch                = 6
          unknown_error           = 7
          gui_refuse_filetransfer = 8
          OTHERS                  = 9.
    ENDLOOP.
    MESSAGE i002(sy) WITH 'All the reports transfered Succefully'.
    Regards,
    Neelambari

  • Reading Text File from selection Screen and populating table (Urgent)

    Hi All,
    I have some requirment like i in my report i have to initial my Input feild from text file is it good to populate a internal table or range.
    I have three feild in a excel file that entry can more then 500
    data example
    Matnr Date             Day
    A1     10.07.2007    12
    B1     10.07.2007    10
    A1     19.07.2007    15
    C1     20.08.2007    30
    E1     11.09.2007    12
    This report for Price Protection claim.
    even u can help me out with proper table plz this is urgent.

    Hi..
    <b>parameters:</b>
      p_file(50) type c.
    <b>data:</b>
      begin of itab occurs 0,
         matnr type vbak-matnr,
         date type sy-datum,
         day(2) type n,
      end of itab.
    <b>at selection-screen on value-request for p_fname.</b>
      perform get_path.
    <b>start-of-selection.</b>
    <b>CALL FUNCTION 'GUI_UPLOAD'</b>
      <b>EXPORTING
        FILENAME                      =  p_fname
       FILETYPE                      = 'ASC'
       HAS_FIELD_SEPARATOR           = 'X'</b>
      HEADER_LENGTH                 = 0
      READ_BY_LINE                  = 'X'
      DAT_MODE                      = ' '
      CODEPAGE                      = ' '
      IGNORE_CERR                   = ABAP_TRUE
      REPLACEMENT                   = '#'
      CHECK_BOM                     = ' '
      VIRUS_SCAN_PROFILE            =
    IMPORTING
      FILELENGTH                    =
      HEADER                        =
    <b>  TABLES
        DATA_TAB                      = itab</b>
    EXCEPTIONS
      FILE_OPEN_ERROR               = 1
      FILE_READ_ERROR               = 2
      NO_BATCH                      = 3
      GUI_REFUSE_FILETRANSFER       = 4
      INVALID_TYPE                  = 5
      NO_AUTHORITY                  = 6
      UNKNOWN_ERROR                 = 7
      BAD_DATA_FORMAT               = 8
      HEADER_NOT_ALLOWED            = 9
      SEPARATOR_NOT_ALLOWED         = 10
      HEADER_TOO_LONG               = 11
      UNKNOWN_DP_ERROR              = 12
      ACCESS_DENIED                 = 13
      DP_OUT_OF_MEMORY              = 14
      DISK_FULL                     = 15
      DP_TIMEOUT                    = 16
      OTHERS                        = 17
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    This Sub routine is used to get the file name
    *There are no interface parameters passed to this subroutine.
    FORM get_path .
    CALL FUNCTION 'WS_FILENAME_GET'
    EXPORTING
       DEF_FILENAME            =  P_FNAME
      DEF_PATH               = ' '
      MASK                   = ' '
      MODE                   = ' '
      TITLE                  = ' '
    IMPORTING
       FILENAME                =  P_FNAME
      RC                     =
    EXCEPTIONS
       INV_WINSYS             = 1
       NO_BATCH               = 2
       SELECTION_CANCEL       = 3
       SELECTION_ERROR        = 4
       OTHERS                 = 5
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    ENDFORM.                    " get_path
    data:

  • DOWNLOADING A REPORT PROGRAM CODE IN TO TEXT FILE

    I HAVE ONE SIMPLE REPORT PROGRAM SAY,
    *& Report  ZTEST25
    REPORT  ZTEST25.
    DATA : A(8) TYPE C.
    A = 'ANDHRA'.
    WRITE  A.
    THE ABOVE MENTIONED REPORT PROGRAM SHOULD BE DOWNLOADED TO A TEXT FILE USING ANOTHER REPORT PROGRAM BY USING PARAMETER.
    THE OUTPUT IN THE FLAT FILE SHOULD BE:
    REPORT  ZTEST25.
    DATA : A(8) TYPE C.
    A = 'ANDHRA'.
    WRITE  A.

    here is complete code for  that
    report  z11dpk_assign1
            no standard page heading
            message-id z11dpk
            line-size  200                 "page width
            line-count 65(0).              "page length.
    T  A  B  L  E S  D  E  C  L  A  R  A  T  I  O  N                  *
    tables:  trdir,     " System Table TRDIR
             trdirt.    " Title texts for programs in
    D  A  T  A  D  E  C  L  A  R  A  T  I  O  N                       *
    Types
    Structure declaration for system table
    types: begin of struct_sys,
           name(40) type c,       " ABAP program name
           clas(4)  type c,       " Program class
           subc(1)  type c,       " Program type
           cnam(12) type c,       " Author
           cdat     type dats,    " Created on
           rstat(1) type c,       " status
           text     type repti,   " Report title
           c_box(1) type c,       " for check box
           end of struct_sys.
    Structure for internal table for report data
    types: begin of struct_report,
           line(500),
           end of struct_report.
    C  O  N  S  T  A  N  T  S  D  E  C  L  A  R  A  T  I  O  N  S
    data     : c_name(50)        type c,               " Program Name
               c_filename        like ibipparms-path,  " File name
               c_filename1       type string,          " File name
               c_ext(5)          value '.TXT',         " File extension
               c_textline(150)   type c,               " downloading status
               c_count           type c,               " no of pgm downlded
               c_count_text(100) type c.               " Text pgm downlded
    The CONSTANTS statement defines global and local constants.
    By using constants, you can read statically declared data objects,
    constants: c_const(8)        value 'UNTITLED'.
    I  N  T  E  R  N  A  L  T  A  B  L  E  D  E  C  L  A  R  A  T  I  O N
    data: it_sys    type standard table of struct_sys, " Itab for sys data
          it_report type standard table of struct_report with
          non-unique default key initial size 1000.    " Itab for rep data
    W  O  R  K  A  R  E  D  E  C  L  A  R  A  T  I  O  N  S
    data: wa_sys    type struct_sys,          " Work area for sys data
          wa_report type struct_report.       " Work area for report data
    I  N  I  T  I  A  L  I  Z  T  I  O  N
    initialization.
      clear  : wa_sys.
      refresh: it_sys,
               it_report.
      c_count = 0.
    S  E  L  E  C  T  I  O  N  -  S  C  R  E  E  N
      selection-screen  : begin of block blk3 with frame title text-015.
      selection-screen  : begin of block blk1 with frame title text-001.
      select-options    : s_name for trdir-name.              " Program name
      selection-screen  : end of block blk1.
      selection-screen  : begin of block blk2 with frame title text-002.
      parameters        : p_file type rlgrap-filename. " Path for loc folder
      selection-screen  : end of block blk2.
      selection-screen  : end of block blk3.
    A  T  S  E  L  E  C  T  I  O  N  -  S  C  R  E  E  N
    *The possible entries pushbutton for F4 appears beside the appropriate
    *fld (p_file) When the user activates this pushbutton or presses F4 for
    *the fld, the event is executed You can thus implement a self-programmed
    *possible entries routine for the input/output fields of the selection
    *screen
    at selection-screen on value-request for p_file.
    Value of Local file for upload/download is obtained by using this FM
      call function 'F4_FILENAME'
        importing
          file_name = p_file.
    S  T  A  R  T  -  O  F  -  S  E  L  E  C  T  I  O  N
    start-of-selection.
    CONCATENATE p_name '%' INTO z_name.
      select name
             clas
             subc
             cnam
             cdat
             rstat into table it_sys
                   from trdir
    *Sorts the selected records in ascending order by the specified column
    *references f1 ... fn (name)
                  where name in s_name order by name.
                  WHERE name LIKE 'Z11%'.
      if sy-subrc = 0.
        sort it_sys by name.
        clear wa_sys.
        loop at it_sys into wa_sys.
          select single text
                 into wa_sys-text
                 from trdirt
                 where name  = wa_sys-name and
                       sprsl = sy-langu.
          modify it_sys from wa_sys index sy-tabix.
          clear wa_sys.
        endloop.
      endif.
      set pf-status 'MENU_ASSIGN1'.
      uline.
      write:/    sy-vline ,
             8   sy-vline,  text-009 color 4,         " Name of the Program
             55  sy-vline,  text-003 color 4,         " Class
             62  sy-vline,  text-004 color 4,         " Type
             68  sy-vline,  text-005 color 4,         " Created By
             80  sy-vline,  text-006 color 4,         " Created On
             92  sy-vline,  text-007 color 4,         " Status
             100 sy-vline,  text-008 color 4,         " Program text
             180 sy-vline.
      clear wa_sys.
      loop at it_sys into wa_sys.
        uline.
        write:/ sy-vline,
               5   wa_sys-c_box as checkbox,
               8   sy-vline,  wa_sys-name,
               55  sy-vline,  wa_sys-clas,
               62  sy-vline,  wa_sys-subc,
               68  sy-vline,  wa_sys-cnam,
               80  sy-vline,  wa_sys-cdat,
               92  sy-vline,  wa_sys-rstat,
               100 sy-vline,  wa_sys-text,
               180 sy-vline.
      endloop.
    at user-command.
      case sy-ucomm.
        when 'BACK'.
          leave screen.
        when 'EXIT'.
          leave program.
        when 'DOWN'.
          clear wa_sys.
          do.
            clear wa_sys.
            read line sy-index field value wa_sys-c_box wa_sys-name.
            if sy-subrc <> 0.
              exit.
            endif.
    *if check box is selected.....
            if wa_sys-c_box = 'X'.
              clear c_textline.
    *Assigns the contents of the source field to the target field as a new
    *value
              write text-010    to c_textline.         " Downloading
              write wa_sys-name to c_textline+12.
              write text-011    to c_textline+53.      "to
              write c_filename1 to c_textline+56.      " file name
    FM returns the Text to be displayed on screen
              call function 'SAPGUI_PROGRESS_INDICATOR'
                exporting
                  text = c_textline.
              c_count = c_count + 1.
    Reads the program prog from the database into the internal table itab.
    The line length of table itab should be at least 72 characters
              read report wa_sys-name into it_report.
              if sy-subrc <> 0.
                exit.
              endif.
    *p_file contains the character string untitiled
    This comparison is not case sensitive
              if p_file cs c_const.        " Untitled
    the string ''(space) replaces the untitled occurrence of the search
    ignore case is used as this search is case sensitive
                replace c_const in p_file with '' ignoring case.
              endif.
    Places the fields f1 to fn (n >= 2) after g (target field).
              concatenate p_file wa_sys-name  c_ext into c_filename1.
    *Data transmission of an internal table from the server to a file on the
    PC is done by this FM.
              call function 'GUI_DOWNLOAD'
                exporting
                  filename = c_filename1
                  filetype = 'ASC'
                tables
                  data_tab = it_report.
              if sy-subrc <> 0.
                message id sy-msgid type sy-msgty number sy-msgno
                        with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
              endif.
            endif.
          enddo.
          clear c_count_text.
          write c_count  to c_count_text+1.
          write text-030 to c_count_text+4.
    Nos Of Pgms downlded successfully
          message i205 with c_count_text.
      endcase.
    T  O  P -  O  F  -  P  A  G  E
    top-of-page.
      uline.
      write:/   sy-vline,
             10 text-020 color 2,  " Fujitsu India Limited
             70 text-021 color 2.  " List of ABAP Programs
      write:/   sy-vline,
             10 text-022 color 3, sy-datum color 3,    " Date
             70 text-023 color 3, sy-pagno color 3.    " Page No
    plz reward if helpful
    vivek

Maybe you are looking for

  • Can I use the falsh CS4 of trial version to make animation?

    Hi, I downloaded and installed Adobe Flash CS4 Professional of trial version yesterday. I want to use it to learn making animations for the web site. But after I click Start->Programs, I just saw the files Adobe Player, Adobe Device Center, Adobe Bri

  • HD Input from Blackmagic Intensity Shuttle for USB 3.0 to FMLE 3.2

    hey guys.. I am using backmagic intensity shuttle usb 3.0 capture card to capture the 1080p video. Now the problem is when I am taking video input in FMLE 3.2. It only shows the video in 720X482 Resolution and at 59.92 fps only. while selecting other

  • Two Computer Activation Limited by Suite or by Title?

    I'm wondering if the two computer limited activation is for the suite or if it can be title by title? Here's the scenario: I have three computers.  One is my central computer for doing all sorts of work, so the entire suite would be on that one.  How

  • Software update cannot connect MacOSX 10.8

    Applestore Chapelfield UK replaced my Seagate hard disk under warranty, and installed mountain lion.  On restoring from Time Machine backup everything works (as so far checked except iPhoto which expects an updated version of MacOSX10.8.  I can't get

  • HT4211 retrieving lost data

    Help! i downloaded a audio book to my iphone and accidentally deleted it... is there away to retrieve it?