Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

ISSUE IN SINGLE PROGRAM FOR TABLE UPLOAD

former_member421418
Participant
0 Kudos

Hi Experts ,

My client asked to need one common program to Upload data to custom tables . so i have created a program like below .

  DATA lv_string    TYPE string .

  DATA: lit_dowld TYPE STANDARD TABLE OF gty_downld,

        lwa_dowld TYPE gty_downld.



  FIELD-SYMBOLS: <lfs_string> TYPE any.



*--- Create dynamic internal table

  CREATE DATA gt_data TYPE TABLE OF (p_table).

  ASSIGN gt_data->* TO <ft_data>.



*--- Create dynamic work area

  CREATE DATA gs_data TYPE (p_table).

  ASSIGN gs_data->* TO <fs_data>.



  PERFORM fetch_feilds_of_table .



  LOOP AT git_fields INTO wit_fields.



    iw_fld-field  wit_fields-fieldname .

    APPEND iw_fld TO it_fld .

    CLEAR : iw_fld .



  ENDLOOP .





*get data from table .

  SELECT * FROM (p_table) INTO TABLE  <ft_data> .



  CONCATENATE p_file1 '\' p_table '.XLS' INTO gv_file1 .



  CALL FUNCTION 'GUI_DOWNLOAD'

    EXPORTING

*     BIN_FILESIZE            =

      filename                = gv_file1

*     filetype                = 'ASC'

*     APPEND                  = ' '

      write_field_separator   = 'X'

    TABLES

      data_tab                = <ft_data>

      fieldnames              = it_fld

    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

      OTHERS                  = 22.



  IF sy-subrc <> 0.

    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

        WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

  ELSE .

    MESSAGE 'File has been downloaded successfully'(002) TYPE gc_s.

    LEAVE LIST-PROCESSING.

  ENDIF.

This program is working fine but the problem here is client will upload data Through text file with out the field of MANDT and no values of it , I checked with out this field but above program is not working .

Can YOu please advise how to approach this

Thanks

Kiran

4 REPLIES 4

former_member197916
Active Participant
0 Kudos

hi,

I am not clear about your problem but you as far as I have understood you need to

move your data to another internal table changing mandt field and use that internal table in fm.

pranay570708
Active Contributor
0 Kudos

Hi,

First read all entries from text file into an internal table (itab1). Then create an internal table(itab2) with the type same of database table. Move all entries from  itab1 to itab2 using loop statement and modify the mandt value.

Loop at itab1 into wa_itab1.

MOVE-CORRESPONDING wa_itab1 to wa_itab2.

wa_itab2-mandt = sy-mandt.

append wa_itab2 to itab2.

endloop.

And, now upload itab2.

0 Kudos


Hi Pranay ,

Here the problem is this is not for one particular table this is a common program for all the table uploads user can give any table in the selection screen , data should go and upload into that table .

Regards

Kiran

0 Kudos

But you can read table name from selection screen and make an internal table of that type.