Collect message into internal table

Hi,
does any one knows how BAPIs or CALL TRANSACTIONs collect messages into internal table.
My problem is that some BI with CALL TRANSACTION doesn't collect right message into return table and I would like to collect this last message after CALL TRANSACTION and therefore be sure that everything went OK.....
thx
mario

hi
good
check this
Call Transaction p_trans using ZBDC_Table
                               Mode p_mode
                             Update p_update
                      Messages into p_messages.
     Move sy-subrc to w__subrc.
   Scan the messages in YDCRAISES to see if we need to
   change the message class.
     Loop at p_messages.
          Select single msgtyp
            into w__msgtp
            from zdcraise
           where tcode  = p_messages-tcode  and
                 msgid  = p_messages-msgid  and
                 msgnr  = p_messages-msgnr.
          If sy-subrc = 0.
             Move w__msgtp to p_messages-msgtyp.
             Modify p_messages.
          EndIf.
     EndLoop.
   Dump the message table ?
     If w__ydcset-dumpmsg = True.
thanks
mrutyun^

Similar Messages

  • How to save message into internal table?

    Hi,everyone!
    I have a problem when I'm coding.I want to store messages into a internal table.Can you help me?
    Thanks!

    Hello Feng
    If you are already working on SAP basis release >= 6.20 I would recommend the most versatile message handler of all: interface <b>IF_RECA_MESSAGE_LIST</b>
    Perhaps you will find the following sample report ZUS_SDN_APOLLO_13
    (see also: <a href="https://wiki.sdn.sap.com/wiki/display/profile/2007/07/09/MessageHandling-FindingtheNeedleintheHaystack">Message Handling - Finding the Needle in the Haystack</a>) useful.
    *& Report  ZUS_SDN_APOLLO_13
    REPORT  zus_sdn_apollo_13
      LINE-SIZE 200.
    TYPE-POOLS: abap.
    TYPES: BEGIN OF ty_s_outtab.
    TYPES:   status     TYPE exception.
    INCLUDE TYPE bapiret2  AS msg.
    TYPES: END OF ty_s_outtab.
    TYPES: ty_t_outtab  TYPE STANDARD TABLE OF ty_s_outtab
                        WITH DEFAULT KEY.
    DATA:
      gs_layout         TYPE lvc_s_layo,
      gt_outtab         TYPE ty_t_outtab.
    DATA:
      gd_title          TYPE lvc_title,
      gd_msgv           TYPE symsgv,
      gd_msg            TYPE bapi_msg,
      gs_msg            TYPE recamsg,
      gs_return         TYPE bapiret2,
      gt_return         TYPE bapirettab,
      go_msglist        TYPE REF TO if_reca_message_list,
      go_random         TYPE REF TO cl_random_number,
      gif_random        TYPE REF TO if_random_number.
    PARAMETERS:
      p_opt1  RADIOBUTTON GROUP radi  DEFAULT 'X',
      p_opt2  RADIOBUTTON GROUP radi,
      p_opt3  RADIOBUTTON GROUP radi.
    SELECTION-SCREEN ULINE.
    PARAMETERS:
      p_opt4  RADIOBUTTON GROUP radi,
      p_opt5  RADIOBUTTON GROUP radi,
      p_opt6  RADIOBUTTON GROUP radi.
    SELECTION-SCREEN ULINE.
    PARAMETERS:
      p_count    TYPE numc3     DEFAULT '4',
      p_level    TYPE ballevel  DEFAULT '7'.
    DEFINE mac_build_msg.
      clear: gs_msg.
      gs_msg-msgty = &5.
      gs_msg-msgid = '00'.
      gs_msg-msgno = '398'.
      gs_msg-msgv1 = &1.
      gs_msg-msgv2 = &2.
      gs_msg-msgv3 = &3.
      gs_msg-msgv4 = &4.
      gs_msg-detlevel = &6.
    END-OF-DEFINITION.
    *  msgty
    *  msgid
    *  msgno
    *  msgv1
    *  msgv2
    *  msgv3
    *  msgv4
    *  msgv1_src
    *  msgv2_src
    *  msgv3_src
    *  msgv4_src
    *  detlevel
    *  probclass
    *  alsort
    *  time_stmp
    *  msg_count
    *  context
    *  params
    START-OF-SELECTION.
      " Create message handler
      go_msglist = cf_reca_message_list=>create( ).
      " Create random number instance
      CREATE OBJECT go_random TYPE cl_random_number.
      gif_random ?= go_random.
      gif_random->init( ).
      PERFORM message_handling_1.
      PERFORM message_handling_2.
      PERFORM message_handling_3.
      PERFORM message_handling_4.
    END-OF-SELECTION.
    *&      Form  MESSAGE_HANDLING_1
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM message_handling_1 .
      CHECK ( p_opt1 = abap_true ).
      gd_title = 'Information System 1 (IS1)'.
      SET TITLEBAR 'TITLE' WITH gd_title.
      WRITE: / 'Apollo 13 Mission'.
      WRITE: / syst-uline.
      WRITE: / 'Take-Off             -> ok'.
      WRITE: / 'Leaving Orbit        -> ok'.
      WRITE: / 'Trajectory           -> ok'.
      WRITE: /.
      FORMAT COLOR COL_NEGATIVE.
      WRITE: / 'Explosion happened   -> not ok'.
      WRITE: / 'Command and Service module (CSM) -> damaged'.
      FORMAT RESET.
      WRITE: / 'Lunar module (LM)    -> not affected, ok'.
      MESSAGE text-hou TYPE 'S'.
    ENDFORM.                    " MESSAGE_HANDLING_1
    *&      Form  message_handling_2
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM message_handling_2 .
    * define local data
      DATA:
        ld_success(6)  TYPE n,
        ld_warning(6)  TYPE n,
        ld_failure(6)  TYPE n,
        ld_total(6)    TYPE n.
      CHECK ( p_opt2 = abap_true ).
      gd_title = 'Information System 2 (IS2)'.
      SET TITLEBAR 'TITLE' WITH gd_title.
      PERFORM generate_messages.  " simulation of messages
      CALL METHOD go_msglist->get_list_as_bapiret
        IMPORTING
          et_list = gt_return.
      " Calculate message types and total
      ld_total   = 0.
      ld_success = 0.
      ld_warning = 0.
      ld_failure = 0.
    " Print messages as WRITE list
      LOOP AT gt_return INTO gs_return.
        IF ( gs_return-type = 'E' ).
          ADD 1 TO ld_failure.
        ELSEIF ( gs_return-type = 'W' ).
          ADD 1 TO ld_warning.
        ELSE.
          ADD 1 TO ld_success.
        ENDIF.
      ENDLOOP.
      ld_total = ld_success + ld_warning + ld_failure.
      WRITE: / 'Total Message =', ld_total.
      WRITE: / 'Failures      =', ld_failure.
      WRITE: / 'Warnings      =', ld_warning.
      WRITE: / 'Successes     =', ld_success.
      WRITE: / syst-uline.
      SKIP.
    " Colouring depending on message type
      LOOP AT gt_return INTO gs_return.
        IF ( gs_return-type = 'E' ).
          FORMAT COLOR COL_NEGATIVE.
        ELSEIF ( gs_return-type = 'W' ).
          FORMAT COLOR COL_TOTAL.
        ELSE.
          FORMAT RESET.
        ENDIF.
        WRITE: / gs_return-type, gs_return-message+0(100).
      ENDLOOP.
    ENDFORM.                    " message_handling_2
    *&      Form  message_handling_3
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM message_handling_3 .
    * define local data
      DATA:
        ls_outtab    TYPE ty_s_outtab.
      DATA:
        ld_success(6)  TYPE n,
        ld_warning(6)  TYPE n,
        ld_failure(6)  TYPE n,
        ld_total(6)    TYPE n.
      CHECK ( p_opt3 = abap_true ).
      gd_title = 'Information System 3 (IS3)'.
      SET TITLEBAR 'TITLE' WITH gd_title.
      PERFORM generate_messages.  " simulation of messages
      CALL METHOD go_msglist->get_list_as_bapiret
        IMPORTING
          et_list = gt_return.
      REFRESH: gt_outtab.
      " Calculate message types and total
      ld_total   = 0.
      ld_success = 0.
      ld_warning = 0.
      ld_failure = 0.
    " Define the logic for setting exception status (LED)
      LOOP AT gt_return INTO gs_return.
        CLEAR: ls_outtab.
        ls_outtab-msg = gs_return.
        IF ( gs_return-type = 'E' ).
          ls_outtab-status = '1'.  " red
          ADD 1 TO ld_failure.
        ELSEIF ( gs_return-type = 'W' ).
          ls_outtab-status = '2'.  " yellow
          ADD 1 TO ld_warning.
        ELSE.
          ls_outtab-status = '3'.  " green
          ADD 1 TO ld_success.
        ENDIF.
        APPEND ls_outtab TO gt_outtab.
      ENDLOOP.
      ld_total = ld_failure + ld_warning + ld_success.
      CLEAR: gs_layout.
      gs_layout-cwidth_opt = abap_true.
      gs_layout-zebra      = abap_true.
      gs_layout-excp_fname = 'STATUS'.
      gs_layout-excp_led   = abap_true.
      gs_layout-smalltitle = abap_true.
      CONCATENATE 'T(' ld_total   ')  '
                  'E(' ld_failure ')  '
                  'W(' ld_warning ')  '
                  'S(' ld_success ')  '
        INTO gd_title SEPARATED BY space.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
        EXPORTING
          i_structure_name = 'BAPIRET2'
          i_grid_title     = gd_title
          is_layout_lvc    = gs_layout
        TABLES
          t_outtab         = gt_outtab
        EXCEPTIONS
          OTHERS           = 1.
    ENDFORM.                    " message_handling_3
    *&      Form  message_handling_4
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM message_handling_4 .
    * define local data
      CHECK ( p_opt4 = abap_true   OR
              p_opt5 = abap_true   OR
              p_opt6 = abap_true ).
      IF ( p_opt4 = abap_true ).
        gd_title = 'Information System 4 (IS4)'.
        SET TITLEBAR 'TITLE' WITH gd_title.
      ELSEIF ( p_opt5 = abap_true ).
        gd_title = 'Information System 5 (IS5)'.
        SET TITLEBAR 'TITLE' WITH gd_title.
      ELSE.
        gd_title = 'Information System 6 (IS6)'.
        SET TITLEBAR 'TITLE' WITH gd_title.
      ENDIF.
      PERFORM generate_messages.  " simulation of messages
      PERFORM display_log.
    ENDFORM.                    " message_handling_4
    *&      Form  GENERATE_MESSAGES
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM generate_messages .
    * define local data
      mac_build_msg 'Apollo 13 Mission: Spacecraft'
                     space space space 'I' '1'.
    **  DEFINE mac_build_msg.
    **    clear: gs_msg.
    **    gs_msg-msgty = &5.
    **    gs_msg-msgid = '00'.
    **    gs_msg-msgno = '398'.
    **    gs_msg-msgv1 = &1.
    **    gs_msg-msgv2 = &2.
    **    gs_msg-msgv3 = &3.
    **    gs_msg-msgv4 = &4.
    **    gs_msg-detlevel = &6.
    **  END-OF-DEFINITION.
      go_msglist->add( is_message = gs_msg ).
      DO 6 TIMES.
        CASE syst-index.
          WHEN '1'.
            mac_build_msg 'Command and Service Module (CSM)'
               space space space 'I' '2'.
          WHEN '2'.
            mac_build_msg 'Lunar Module (LM)' space space space 'I' '2'.
          WHEN '3'.
            mac_build_msg 'Additional Module (M-1)'
              space space space 'I' '2'.
          WHEN '4'.
            mac_build_msg 'Additional Module (M-2)'
              space space space 'I' '2'.
          WHEN '5'.
            mac_build_msg 'Additional Module (M-3)'
              space space space 'I' '2'.
          WHEN '6'.
            mac_build_msg 'Additional Module (M-4)'
              space space space 'I' '2'.
          WHEN OTHERS.
            EXIT.
        ENDCASE.
        go_msglist->add( is_message = gs_msg ).
    "   recursive call of routine
        PERFORM generate_messages_1 USING syst-index 'Modul' '3'.
      ENDDO.
    ENDFORM.                    " GENERATE_MESSAGES
    *&      Form  GENERATE_MESSAGES_1
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM generate_messages_1
                         USING
                            value(ud_index)     TYPE i
                            value(ud_msgv)      TYPE symsgv
                            value(ud_detlevel)  TYPE ballevel.
    * define local data
      DATA:
        ld_integer         TYPE i,
        ld_msgty           TYPE symsgty,
        ld_msgv            TYPE symsgv,
        ld_detlevel        TYPE ballevel.
      DO p_count TIMES.
        WRITE syst-index TO ld_msgv NO-ZERO LEFT-JUSTIFIED.
        IF ( ud_detlevel = '3' ).
          CONCATENATE ud_msgv ld_msgv INTO ld_msgv
            SEPARATED BY space.
        ELSE.
          CONCATENATE ud_msgv ld_msgv INTO ld_msgv
            SEPARATED BY '.'.
        ENDIF.
        CONDENSE ld_msgv.
        gd_msgv = ld_msgv.
        IF ( ud_index = 1 ).
          ld_integer = gif_random->get_random_int( 300 ).
          IF ( ld_integer = 1 ).
            ld_msgty = 'E'.
            CONCATENATE gd_msgv 'failed' INTO gd_msgv SEPARATED BY ' -> '.
          ELSEIF ( ld_integer BETWEEN 1 AND 10 ).
            ld_msgty = 'W'.
            CONCATENATE gd_msgv 'check(?)' INTO gd_msgv SEPARATED BY ' -> '.
          ELSE.
            ld_msgty = 'S'.
            CONCATENATE gd_msgv 'OK' INTO gd_msgv SEPARATED BY ' -> '.
          ENDIF.
        ELSE.
          ld_msgty = 'S'.
          CONCATENATE gd_msgv 'OK' INTO gd_msgv SEPARATED BY ' -> '.
        ENDIF.
        mac_build_msg gd_msgv space space space ld_msgty ud_detlevel.
        go_msglist->add( is_message = gs_msg ).
        IF ( ud_detlevel < p_level ).
          ld_detlevel = ud_detlevel + 1.
          PERFORM generate_messages_1 USING ud_index ld_msgv ld_detlevel.
        ENDIF.
      ENDDO.
    ENDFORM.                    " GENERATE_MESSAGES_1
    *&      Form  DISPLAY_LOG
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM display_log .
    * define local data
      DATA:
        ld_handle           TYPE balloghndl,
        lt_log_handles      TYPE bal_t_logh,
        ls_profile          TYPE bal_s_prof.
    " Get log handle of collected message list
      ld_handle = go_msglist->get_handle( ).
      APPEND ld_handle TO lt_log_handles.
      IF ( p_opt4 = 'X' ).
    *   get a display profile which describes how to display messages
        CALL FUNCTION 'BAL_DSP_PROFILE_DETLEVEL_GET'
          IMPORTING
            e_s_display_profile = ls_profile.  " tree & ALV list
      ELSEIF ( p_opt5 = 'X' ).
    *   get standard profile to display one log
        CALL FUNCTION 'BAL_DSP_PROFILE_SINGLE_LOG_GET'
          IMPORTING
            e_s_display_profile = ls_profile.
      ELSE.
        CALL FUNCTION 'BAL_DSP_PROFILE_NO_TREE_GET'
          IMPORTING
            e_s_display_profile = ls_profile.
      ENDIF.
    * set report to allow saving of variants
      ls_profile-disvariant-report = sy-repid.
    *   when you use also other ALV lists in your report,
    *   please specify a handle to distinguish between the display
    *   variants of these different lists, e.g:
      ls_profile-disvariant-handle = 'LOG'.
      CALL FUNCTION 'BAL_DSP_LOG_DISPLAY'
        EXPORTING
          i_s_display_profile          = ls_profile
          i_t_log_handle               = lt_log_handles
        EXCEPTIONS
          profile_inconsistent         = 1
          internal_error               = 2
          no_data_available            = 3
          no_authority                 = 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.                    " DISPLAY_LOG
    Regards
      Uwe

  • Problem in collecting Spool data into internal table

    Hi ,
    i need to download  spool request data into internal table,
    after collecting i need to loop it and delete some records,
    for this i am using  Fm  RSPO_RETURN_ABAP_SPOOLJOB
    but getting some extra spaces and lines,unable to get right format.
    please help me in this issue to prepare internal table like normal internal table with spool id.
    Regards
    sarath

    Hi ,
    Thanks for the reply,
    My requirement is like i need to collect all the records from the spool to Internal table and
    after that based on one field in the internal table i have to separate error records by deleting sucess records from that internal table(from spool),
    for that i have to loop the internal table and need to count the error records, after that download to excel and mail functionalities
    required for that .
    so please help me in this.
    Regards
    sarath

  • Issue with uploading XML file from application server into internal table

    i Need to fetch the XML file from the application server and place into internal table and i am getting error message while using the functional module   SMUM_XML_PARSE and the error message is "line   1 col   1-unexpected symbol; expected '<', '</', entity reference, character data, CDATA section, processing instruction or comment" and could you please let me know how to resolve this issue?  
        TYPES: BEGIN OF T_XML,
                 raw(2000) TYPE C,
               END OF T_XML.
    DATA:GW_XML_TAB TYPE  T_XML.
    DATA:  GI_XML_TAB TYPE TABLE OF T_XML INITIAL SIZE 0.
    DATA:GI_STR TYPE STRING.
    data:  GV_XML_STRING TYPE XSTRING.
    DATA: GI_XML_DATA TYPE  TABLE OF SMUM_XMLTB INITIAL SIZE 0.
    data:GI_RETURN TYPE STANDARD TABLE OF BAPIRET2.
        OPEN DATASET LV_FILE1 FOR INPUT IN TEXT MODE ENCODING DEFAULT.
        IF SY-SUBRC NE 0.
          MESSAGE 'File does not exist' TYPE 'E'.
        ELSE.
          DO.
    * Transfer the contents from the file to the work area of the internal table
            READ DATASET LV_FILE1 INTO GW_XML_TAB.
            IF SY-SUBRC EQ 0.
              CONDENSE GW_XML_TAB.
    *       Append the contents of the work area to the internal table
              APPEND GW_XML_TAB TO GI_XML_TAB.
            ELSE.
              EXIT.
            ENDIF.
          ENDDO.
        ENDIF.
    * Close the file after reading the data
        CLOSE DATASET LV_FILE1.
        IF NOT GI_XML_TAB IS INITIAL.
          CONCATENATE LINES OF GI_XML_TAB INTO GI_STR SEPARATED BY SPACE.
        ENDIF.
    * The function module is used to convert string to xstring
        CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
          EXPORTING
            TEXT   = GI_STR
          IMPORTING
            BUFFER = GV_XML_STRING
          EXCEPTIONS
            FAILED = 1
            OTHERS = 2.
        IF SY-SUBRC <> 0.
          MESSAGE 'Error in the XML file' TYPE 'E'.
        ENDIF.
      ENDIF.
      IF GV_SUBRC = 0.
    * Convert XML to internal table
        CALL FUNCTION 'SMUM_XML_PARSE'
          EXPORTING
            XML_INPUT = GV_XML_STRING
          TABLES
            XML_TABLE = GI_XML_DATA
            RETURN    = GI_RETURN.
      ENDIF.
      READ TABLE GI_RETURN TRANSPORTING NO FIELDS WITH KEY TYPE = 'E'.
      IF SY-SUBRC EQ 0.
        MESSAGE 'Error converting the input XML file' TYPE 'E'.
      ELSE.
        DELETE GI_XML_DATA WHERE TYPE <> 'V'.
        REFRESH GI_RETURN.
      ENDIF.

    Could you please tel me  why the first 8 lines were removed, till <Soap:Body and also added the line <?xml version="1.0" encoding="UTF-8"?> in the beggining .
    Becuase there will be lot of  XML files will be coming from the Vendor daily and that should be uploaded in the application server and should update in the SAP tables based on the data in the XML file.
    what information i need to give to vendor that do not add the first 8 lines in the XML file and add the line in the beggining <?xml version="1.0" encoding="UTF-8"?>   ??????
    Is there any other way we can do with out removing the lines?

  • Getting Issue while uploading CSV file into internal table

    Hi,
    CSV file Data format as below
         a             b               c              d           e               f
    2.01E14     29-Sep-08     13:44:19     2.01E14     SELL     T+1
    actual values of column   A is 201000000000000
                     and  columen D is 201000000035690
    I am uploading above said CSV file into internal table using
    the below coding:
    TYPES: BEGIN OF TY_INTERN.
            INCLUDE STRUCTURE  KCDE_CELLS.
    TYPES: END OF TY_INTERN.
    CALL FUNCTION 'KCD_CSV_FILE_TO_INTERN_CONVERT'
        EXPORTING
          I_FILENAME      = P_FILE
          I_SEPARATOR     = ','
        TABLES
          E_INTERN        = T_INTERN
        EXCEPTIONS
          UPLOAD_CSV      = 1
          UPLOAD_FILETYPE = 2
          OTHERS          = 3.
      IF SY-SUBRC <> 0.
        MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    am getting all columns data into internal table,
    getting problem is columan A & D. am getting values into internal table for both; 2.01E+14. How to get actual values without modifying the csv file format.
    waiting for your reply...
    thanks & regards,
    abhi

    Hi Saurabh,
    Thanks for your reply.
    even i can't double click on those columns.
    b'se the program needs be executed in background there can lot of csv file in one folder. No manual interaction on those csv files.
    regards,
    abhi

  • Upload excel data into Internal table

    Hi,
    I'm trying to upload excel data into internal table, well the excel file layout will be different on each run of the report.
    Excel file will have 60 columns and 500 record limit. I can upload the excel data using 'ALSM_EXCEL_TO_INTERNAL_TABLE' and 'KCD_EXCEL_OLE_TO_INT_CONVERT' but the output table is generates 60 lines for each record i.e.., 60 * 500 = 30,000 which could cause performance.
    I try with the FM 'TEXT_CONVERT_XLS_TO_SAP', but this will only work if the file structure is static. It didn't work for dynamic file layout. Even GUI_UPLOAD doesn't work to upload excel file, it will work if I convert the file to Tab delimited file.
    Please advise if you know any alternate procedure to upload excel data into internal table.
    Thanks,
    Kumar.

    Moderator message - Cross post locked
    Rob

  • Read local folder, return filenames into internal table

    Assume I have 3 files in c:\abc folder:
    a1.xls
    a2.xls
    a6.xls
    Is there a fm or code sample to pass in folder name (ie c:\abc) and returns a1.xls, a2.xls and a6.xls into internal table?

    Use Class CL_GUI_FRONTEND_SERVICES Method DIRECTORY_LIST_FILES to get list of file in a folder . FILE_TABLE will give the table with list of files
    data: begin of itab ,
            file(26) type c,
          end of itab.
    data: tab type table of itab.
    data : cnt type i.
    CALL METHOD CL_GUI_FRONTEND_SERVICES=>DIRECTORY_LIST_FILES
      EXPORTING
        DIRECTORY                   = 'C:\temp'
    *    FILTER                      = '*.*'
    *    FILES_ONLY                  =
    *    DIRECTORIES_ONLY            =
      CHANGING
        FILE_TABLE                  = tab
        COUNT                       = cnt
    *  EXCEPTIONS
    *    CNTL_ERROR                  = 1
    *    DIRECTORY_LIST_FILES_FAILED = 2
    *    WRONG_PARAMETER             = 3
    *    ERROR_NO_GUI                = 4
    *    NOT_SUPPORTED_BY_GUI        = 5
    *    others                      = 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.

  • How to transfer excel files(on ftp server) into internal table?

    hello,everyone
    pls tell me how to transfer excel files those on a ftp server into internal table?
    ps.i know the function 'ftp_server_to_r3',it can help to transfer flat file.

    Hi,
    I believe you want to get the data from the FTP Server to R3.
    I am also sending the code. Have a look and it would help you.
    First get the Password and user name and the FTP Server Path where file is stored and FTP Server Host name
    FUNCTION zfi_ftp_get.
    *"*"Local Interface:
    *"  IMPORTING
    *"     VALUE(I_FILENAME) TYPE  C
    *"  TABLES
    *"      T_BLOB STRUCTURE  ZFI_TLM_LENGTH OPTIONAL " is a table type with a field called line of length 992
    *"      RETURN STRUCTURE  BAPIRET2 OPTIONAL
      DATA : i_password(30)     TYPE c,
             i_user(30)         TYPE c,
             i_host(30)         TYPE c,
             i_rfc_destination  TYPE rfcdes-rfcdest,
             i_length           TYPE i,
             i_folder_path(100) TYPE c.
      DATA:   lv_blob_length   TYPE i.
      DATA:   lv_length        TYPE i,  "Password length
              lv_key           TYPE i VALUE 26101957,
              lv_password(30)  TYPE c,
              lv_ftp_handle    TYPE i,
              lv_cmd(80)       TYPE c.
      DATA: BEGIN OF result OCCURS 0,
            line(100) TYPE c,
            END OF result.
      TYPES: BEGIN OF ty_dummy,
             line(392) TYPE c,
           END   OF ty_dummy.
      DATA: lt_dummy TYPE TABLE OF ty_dummy,
            ls_dummy LIKE LINE  OF lt_dummy.
      i_password        = 'vnhdh'.
      i_user            = 'sdkgd'.
      i_host            = 'sbnksbg'.
      i_rfc_destination = 'SAPFTP'.
      i_length          = '992'.
      i_folder_path     = '/hioj/hohjk/hh'.
      lv_length = STRLEN( i_password ).
      CALL FUNCTION 'HTTP_SCRAMBLE'
        EXPORTING
          SOURCE      = i_password
          sourcelen   = lv_length
          key         = lv_key
        IMPORTING
          destination = lv_password.
      CALL FUNCTION 'FTP_CONNECT'
        EXPORTING
          user            = i_user
          password        = lv_password
          host            = i_host
          rfc_destination = i_rfc_destination
        IMPORTING
          handle          = lv_ftp_handle
        EXCEPTIONS
          not_connected   = 1
          OTHERS          = 2.
      IF sy-subrc = 1.
        return-type = 'E' .
        return-message = 'FTP Connection not Successful'.
        APPEND return.
      ELSEIF sy-subrc = 2.
        return-type = 'E' .
        return-message = 'FTP Connection not Successful'.
        APPEND return.
      ELSEIF sy-subrc EQ 0.
        return-type = 'S' .
        return-message = 'FTP Connection Successful'.
        APPEND return.
        CONCATENATE 'cd' i_folder_path INTO lv_cmd SEPARATED BY space.
        CALL FUNCTION 'FTP_COMMAND'
          EXPORTING
            handle        = lv_ftp_handle
            command       = lv_cmd
          TABLES
            data          = result
          EXCEPTIONS
            command_error = 1
            tcpip_error   = 2.
        IF sy-subrc = 1.
          return-type = 'E' .
          return-message = 'Command Error Occured during open of FTP Folder'.
          APPEND return.
        ELSEIF sy-subrc = 2.
          return-type = 'E' .
          return-message = 'TCIP Error Occured during open of FTP Folder'.
          APPEND return.
        ELSE.
          REFRESH t_blob.
          lv_blob_length = 992.
          TRANSLATE i_filename TO LOWER CASE.
          CALL FUNCTION 'FTP_SERVER_TO_R3'
            EXPORTING
              handle      = lv_ftp_handle
              fname       = i_filename         
            IMPORTING
              blob_length = lv_blob_length
            TABLES
              blob        = lt_dummy.
          t_blob[] = lt_dummy[].
        ENDIF.
      ENDIF.
    ENDFUNCTION.
    Regards
    Sajid
    Edited by: shaik sajid on Nov 16, 2010 7:25 AM

  • Uploading data into internal table

    hi all ,
    i;m uploading the file using Function module  ALSM_EXCEL_TO_INTERNAL_TABLE  . problem now is  when i given lower cae in excel it is not taking . when i use upper case then it is taking from excel and putting into internal table  . now i need to take records from excel even it is lower case . can u pls suggest how to proceed and help . Thanks

    CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
        EXPORTING
          filename                = pa_f
          i_begin_col             = co_x  " column num shd start take as 1
          i_begin_row             = co_y "row number shd start take based on the heading in excel sheet
          i_end_col               = co_n13 "end column is 13 here
          i_end_row               = co_50000 "endrow is 50000 here
        TABLES
          intern                  = ta_file
        EXCEPTIONS
          inconsistent_parameters = 1
          upload_ole              = 2
          OTHERS                  = 3.
      IF sy-subrc EQ 0.
        LOOP AT ta_file INTO wa_file.
          AT NEW row.
          Clear the  work area
            CLEAR wa_file.
          ENDAT.
        Check the Columen numbers and move the file data in to work area of Task.
        For Column  One
          IF wa_file-col =  '1'.
            MOVE wa_file-value TO wa_ztemp_employee-employeid.
          ENDIF.
        For Column Two
          IF wa_file-col = '2'.
            MOVE wa_file-value TO wa_ztemp_employee-employe_name.
          ENDIF.
          AT END OF row.
          The Data Transfer from work area to Internal table
            APPEND wa_ztemp_employee TO ta_ztemp_employee.
          Clear the  work area
            CLEAR wa_ztemp_employee.
          ENDAT.
        ENDLOOP.
       ELSE.
      MESSAGE e004 DISPLAY LIKE 'I'.
    try this code
    u will get
    Regards
    Edited by: Rasheed salman on Nov 28, 2008 6:33 AM

  • Upload data from flat file into internal table

    Hi friends,
    I want to upload the data from a flat file into internal table , but the problem is that all the columns in that flat file are seperated by "|" character instead of tabs.
    Plz help me out.........

    HEllo,
    DO like this.
      CALL FUNCTION 'GUI_UPLOAD'
      EXPORTING
      FILENAME = LV_FILENAME
      FILETYPE = 'ASC'
      HAS_FIELD_SEPARATOR = 'X'  " Check here
    * HEADER_LENGTH = '1'
    * READ_BY_LINE = 'X'
    * DAT_MODE = ' '
    * CODEPAGE = ' '
    * IGNORE_CERR = ABAP_TRUE
    * REPLACEMENT = '#'
    * CHECK_BOM = ' '
    * IMPORTING
    * FILELENGTH =
    * HEADER =
      TABLES
      DATA_TAB = IT_COJRNL
      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.
    VAsanth

  • Problem to upload the data into internal table record length more than 6000

    Hi all
            I stuck with this problem from past 3 days. I have to upload the data from excel sheet. iam making it tab delimited and trying to upload from gui_upload. but in the structure of file, we have, one field of 4000 characters, and other fields of 255 characters.
    how can i upload this into internal table . From excel sheet or from tab delimeted or any other format? or any special function module is there?  while iam doing this its truncating the datat 255 characters and not uploading the other fields also...
    can any one of you help me out. ASAP
    thnks in advance

    from one of the forum iam just pasting code which it is used in lsmw, try the same logic in ur code hope it can work.
    you have to create multiple lines with do...enddo loop., like this:
    (assuming excel_long_text-text is 924 characters long, 7 lines X 132 char)
    __GLOBAL_DATA__
    data: offset type i,
    text_132(132) type c.
    __BEGIN_OF_RECORD__ Before Using Conversion Rules
    Rule : Default Settings Modified
    Code: /sapdmc/ltxtl = init_/sapdmc/ltxtl.
    CLEAR offset.
    DO 7 TIMES.
    text_132 = excel_long_text-text+offset(132).
    offset = offset + 132.
    __END_OF_RECORD__ After Using Conversion Rules
    Rule : Default Settings Modified
    Code: transfer_record.
    ENDDO.
    also check this
    COMMIT_TEXT
    To load long text into SAP
    READ_TEXT
    To load long text into SAP

  • Error while reading excel file from application server into internal table.

    Hi experts,
    My requirement is to read an excel file from application server into internal table.
    Hence I have created an excel file fm_test_excel.xls in desktop and uploaded to app server using CG3Z tcode (as BIN file type).
    Now in my program I have used :
    OPEN DATASET v_filename FOR INPUT IN text mode encoding default.
    DO.
    READ DATASET v_filename INTO wa_tab.
    The statement OPEN DATASET works fine but I get a dump (conversion code page error) at READ DATASET statement.
    Error details:
    A character set conversion is not possible.
    At the conversion of a text from codepage '4110' to codepage '4103':
    - a character was found that cannot be displayed in one of the two
    codepages;
    - or it was detected that this conversion is not supported
    The running ABAP program 'Y_READ_FILE' had to be terminated as the conversion
    would have produced incorrect data.
    The number of characters that could not be displayed (and therefore not
    be converted), is 445. If this number is 0, the second error case, as
    mentioned above, has occurred.
    An exception occurred that is explained in detail below.
    The exception, which is assigned to class 'CX_SY_CONVERSION_CODEPAGE', was not
    caught and
    therefore caused a runtime error.
    The reason for the exception is:
    Characters are always displayed in only a certain codepage. Many
    codepages only define a limited set of characters. If a text from a
    codepage should be converted into another codepage, and if this text
    contains characters that are not defined in one of the two codepages, a
    conversion error occurs.
    Moreover, a conversion error can occur if one of the needed codepages
    '4110' or '4103' is not known to the system.
    If the conversion error occurred at read or write of  screen, the file
    name was '/usr/sap/read_files/fm_test_excel.xls'. (further information about
    the file: "X 549 16896rw-rw----201105170908082011051707480320110517074803")
    Also let me know whether this is the proper way of reading excel file from app server, if not please suggest an alternative .
    Regards,
    Karthik

    Hi,
    Try to use OPEN DATASET v_filename FOR INPUT IN BINARY mode encoding default. instead of OPEN DATASET v_filename FOR INPUT IN text mode encoding default.
    As I think you are uploading the file in BIN format to Application server and trying to open text file.
    Regards,
    Umang Mehta

  • How to convert xml file into internal table in ABAP Mapping.

    Hi All,
    I am trying with ABAP mapping. I have one scenario in which I'm using below xml file as a sender from my FTP server.
    <?xml version="1.0" encoding="UTF-8" ?>
    - <ns0:MTO_ABAP_MAPPING xmlns:ns0="http://Capgemini/Mumbai/sarsingh">
      <BookingCode>2KY34R</BookingCode>
    - <Passenger>
      <Name>SARVESH</Name>
      <Address>THANE</Address>
      </Passenger>
    - <Passenger>
      <Name>RAJESH</Name>
      <Address>POWAI</Address>
      </Passenger>
    - <Passenger>
      <Name>CARRON</Name>
      <Address>JUHU</Address>
      </Passenger>
    - <Flight>
      <Date>03/03/07</Date>
      <AirlineID>UA</AirlineID>
      <FlightNumber>125</FlightNumber>
      <From>LAS</From>
      <To>SFO</To>
      </Flight>
      </ns0:MTO_ABAP_MAPPING>
    AT the receiver side I wnat to concatenate the NAME & ADDRESS.
    I tried Robert Eijpe's weblog (/people/r.eijpe/blog/2005/11/21/xml-dom-processing-in-abap-part-ii--convert-an-xml-file-into-an-abap-table-using-sap-dom-approach)
    but couldnt succeed to convert the xml file into internal table perfectly.
    Can anybody help on this. 
    Thanks in advance!!
    Sarvesh

    Hi Sarvesh,
    The pdf has details of ABAP mapping. The example given almost matches the xml file you want to be converted.
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/xi/3.0/how to use abap-mapping in xi 3.0.pdf
    Just in case you have not seen this
    regards
    Vijaya

  • 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.

  • Function module to get data into internal table from Excel file sheets

    Hi,
    I have to upload customers from excel file.
    we are donloading customer data excel file sheets.
    Customer data in 1 sheet, tax data the other sheet of same excel file, Customer master-Credit data in other sheet of same excel file.
    so i have 3-4 sheet in one excel file.
    now my requirement is to get the data from excel file into internal table.
    is there any function module.
    Thanks & Regards

    I am sending you the idea with an example how you can upload data from an EXCEL file into an internal table. I am not sure if you can take data from different sheet in the same EXCEL file. I think that this is not possible (try it )
    Upload the data into an internal table, like the way that I am describing in the above:
      DATA: L_MAX_COL_NB TYPE I.
      DATA: l_file_name LIKE RLGRAP-FILENAME.
    Just to be sure that is the correct type for the FM.
      l_file_name = P_FILE_NAME.
      L_MAX_COL_NB = 58.  "Maximum nb of colums that the FM can read.
      CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
           EXPORTING
                FILENAME                = l_file_name
                I_BEGIN_COL             = 1
                I_BEGIN_ROW             = 2
                I_END_COL               = L_MAX_COL_NB
                I_END_ROW               = 9999
           TABLES
                INTERN                  = PT_EXCEL
           EXCEPTIONS
                INCONSISTENT_PARAMETERS = 1
                UPLOAD_OLE              = 2
                OTHERS                  = 3.
      IF SY-SUBRC <> 0.
      ENDIF.
    Now you should upload the data into your own itab. The Function Module will return to you all the an itab
    from all fields and columns. Define the structure of the uploading file into SE11 - Data Dictionary. Then read the fieldcatalog of this structure. In the code that I am sending to you, I am insearting an empty line into the internal table and then I am assigning this line into a corresponding field-symbol. Then I am able to change the working area - so and the line of the itab. Propably you could you the statement APPEND INITIAL LINE TO (your_table_name) ASSIGNING <your_field_symbol>, but the example was written in an old SAP version.
      FIELD-SYMBOLS:
                     <F_REC> LIKE WA_UPLOAD_FILE,      "working are of the uploading file
                     <F_FIELD> TYPE ANY.
      DATA: COLUMN_INT TYPE I,
            C_FIELDNAME(30) TYPE C.
      PERFORM GET_FIELDCATOLG TABLES FIELDCAT
                               USING 'ZECO_CHARALAMBOUS_FILE'.
      LOOP AT PT_EXCEL.
        AT NEW ROW.
          ASSIGN WA_UPLOAD_FILE TO <F_REC>.
        ENDAT.
        COLUMN_INT = PT_EXCEL-COL.
        READ TABLE FIELDCAT INTO WA_FIELDCAT INDEX COLUMN_INT.
        CONCATENATE '<F_REC>-' WA_FIELDCAT-FIELDNAME INTO C_FIELDNAME.
        ASSIGN (C_FIELDNAME) TO <F_FIELD>.
        <F_FIELD> = PT_EXCEL-VALUE.
        AT END OF ROW.
          APPEND WA_UPLOAD_FILE TO GT_UPLOAD_FILE.
          CLEAR WA_UPLOAD_FILE.
        ENDAT.
      ENDLOOP.
    With Regards
    George
    Edited by: giorgos michaelaris on Mar 4, 2010 3:44 PM

Maybe you are looking for

  • Report Painter - copy sections

    I am doing a report with some sections in the Report Painter. Is it possoble to copy a section to a new section? Regards

  • BW configuration in dev server

    hi all Due to money constraints company are planning to implement Biw in the same system as development or in prd .Please can anyone post how to configure a client as a biw client in the same system on dev or on prd thanks

  • Synchronising ABAP and J2EE accounts

    Hi All We are currently having a small issue with our ABAP and Java stacks on BI, basically when we create a user in the ABAP stack it does not appear in the JAVA Engine unless we reboot the whole thing. Is there something that needs to be configured

  • Script with 2 pages

    hi there, I have a script with two pages......... both the pages have windows..... header,main,footer. script is triggering well with header in both pages. But i can see footer only in second page but not in the first page. How to get the footer in f

  • Copy and paste doesn't work well in Microfsoft Office

    When I want to copy and paste text in a document I select the text with my trackpad. Because I have to do it repetitive and quickly I use the apple c button while my finger is on the trackpad. I discovered it is not possible to have your finger on th