Quantcast
Channel: SCN : All Content - ABAP Development
Viewing all articles
Browse latest Browse all 8332

Field-symbols

$
0
0

How to split a string into a filed symbol. Iam trying as below but it showing error at the highlighted(red color) in below code.

How to solve the issue.Thanks in advance.

 

**********************************************************************
* To upload the field values
**********************************************************************
   METHOD gui_upload.
     DATA: key TYPE i.                                                           " unique key for header and item

     l_fname = p_file.
     CALL FUNCTION 'GUI_UPLOAD'
       EXPORTING
         filename                = l_fname
         filetype                = 'ASC'
       TABLES
         data_tab                = i_upload              
       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.
*Implement suitable error handling here
     ENDIF.
**********************************************************************
* same code written above is inserted
**********************************************************************
     SELECT fsetyp
                sefeld
           FROM t681e
           INTO TABLE i_t681e
          WHERE kvewe   EQ 'A'
            AND kotabnr EQ p_ctable.
**********************************************************************
*Fetching the data from the table dd04t by performing the  for all
* entries the table i_t681e and also based on the selection criteria
**********************************************************************
     IF i_t681e IS NOT INITIAL.

       SELECT rollname                                                            " data element
              scrtext_l                                                           " short description
         FROM dd04t
         INTO TABLE i_dd04t
          FOR ALL ENTRIES IN i_t681e
        WHERE rollname    i_t681e-sefeld
          AND ddlanguage  EQ 'EN'.

       i_download_headerline = c_header.
       i_download_itemline   = c_item.

       LOOP AT i_t681e INTO i_t681e_line.

         READ TABLE i_dd04t INTO i_dd04t_line WITH KEY rollname = i_t681e_line-sefeld.
         IF sy-subrc EQ 0.
           CONDENSE i_dd04t_line-scrtext_l NO-GAPS.
         ENDIF.
         CASE i_t681e_line-fsetyp.
           WHEN 'A'.
             l_pos = l_pos + 1.
             i_dyn_fcat_line-fieldname = i_dd04t_line-rollname.
             i_dyn_fcat_line-tabname   = 'I_HEADER'.
             i_dyn_fcat_line-coltext   = i_dd04t_line-scrtext_l.
*            i_dyn_fcat_line-outputlen = 20.
             i_dyn_fcat_line-col_pos   = l_pos.
             APPEND i_dyn_fcat_line TO i_dyn_fcat.
             CONCATENATE i_download_headerline i_dd04t_line-scrtext_l
                    INTO i_download_headerline SEPARATED BY cl_abap_char_utilities=>horizontal_tab.

           WHEN 'B'.
             CONCATENATE i_download_itemline i_dd04t_line-scrtext_l
                    INTO i_download_itemline SEPARATED BY cl_abap_char_utilities=>horizontal_tab.
           WHEN OTHERS.
             " Do Nothing.
         ENDCASE.
       ENDLOOP.

** Create a dynamic internal table with this structure.

       CALL METHOD cl_alv_table_create=>create_dynamic_table
         EXPORTING
           i_style_table             = 'X'
           it_fieldcatalog           = i_dyn_fcat
         IMPORTING
           ep_table                  = i_dyn_table
         EXCEPTIONS
           generate_subpool_dir_full = 1
           OTHERS                    = 2.

       IF sy-subrc EQ 0.
* Assign the new table to field symbol
         ASSIGN i_dyn_table->* TO <gfs_dyn_table>.
* Create dynamic work area for the dynamic table
         CREATE DATA i_dyn_table_line  LIKE LINE OF <gfs_dyn_table>.
         CREATE DATA i_dyn_table_line1 LIKE LINE OF <gfs_dyn_table>.
         ASSIGN i_dyn_table_line->TO <gfs_line>.
         ASSIGN i_dyn_table_line1->* TO <gfs_line1>.
       ENDIF.

   ENDIF.

       IF l_obj->i_upload IS NOT INITIAL.

         LOOP AT i_upload INTO i_upload_line FROM 3.
           l_obj->l_text i_upload_line+0(1).
**********************************************************************
*Checking whether it is header data or item data
**********************************************************************
           IF l_obj->l_text = 'H'.
             SHIFT i_upload_line LEFT BY 2 PLACES.

             SPLIT i_upload_line AT cl_abap_char_utilities=>horizontal_tab                                  
              INTO <gfs_line>.                                                                              
       
             key = key + 1.
             i_header_line-key = key.
             APPEND i_header_line TO i_header.
**********************************************************************
*Checking whether it is header data or item data
**********************************************************************
           ELSEIF l_obj->l_text = 'I'.

             SPLIT i_upload_line  AT cl_abap_char_utilities=>horizontal_tab INTO i_item_line-item
                                                                                   i_item_line-matnr
                                                                                   i_item_line-kfrst
                                                                                   i_item_line-amount
                                                                                   i_item_line-currency
                                                                                   i_item_line-validfrom
                                                                                   i_item_line-validto.
             i_item_line-key = key.
             APPEND i_item_line TO i_item.

           ENDIF.                                                                   " if l_obj->l_text .....
         ENDLOOP.                                                                   " loop at i_upload

       ENDIF.                                                                       " if i_upload is not initial

     ENDMETHOD.                                                                     " gui_upload


Viewing all articles
Browse latest Browse all 8332

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>