Application Development and Automation 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: 
Read only

Help on gui upload

Former Member
0 Likes
1,123

HI ,

I am using GUI upload function and i get the data into table and i want to move this data to field type string how can i do that ?

Regards

Joy

DATA: gt_itab TYPE STANDARD TABLE OF char2048.

START-OF-SELECTION.

CALL METHOD cl_gui_frontend_services=>gui_upload
    EXPORTING
      filename                = gs_file
    CHANGING
      data_tab                = gt_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
      not_supported_by_gui    = 17
      error_no_gui            = 18
      OTHERS                  = 19.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,081

Sorry ! I missed some lines ..

Data: begin of t_char_file occurs 0,

string(2000),

end of t_char_file.

field-symbols: <t_char_file> type x ,

<t_file> type x.

*------ following code after gui_upload

loop at gt_itab.

assign gt_itab to <t_char_file> casting.

assign gt_itab to <t_file> casting.

<t_file> = <t_char_file>.

append t_char_file.

endloop.

HI ,

I am using GUI upload function and i get the data into table and i want to move this data to field type string how can i do that ?

Regards

Joy

DATA: gt_itab TYPE STANDARD TABLE OF char2048.

START-OF-SELECTION.

CALL METHOD cl_gui_frontend_services=>gui_upload
    EXPORTING
      filename                = gs_file
    CHANGING
      data_tab                = gt_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
      not_supported_by_gui    = 17
      error_no_gui            = 18
      OTHERS                  = 19.

7 REPLIES 7
Read only

former_member386202
Active Contributor
0 Likes
1,081

Hi,

Refer following code

types : BEGIN OF ty_s_download,

data TYPE string, "Tax Data

END OF ty_s_download.

----


  • G L O B A L D A T A D E C L A R A T I O N S

----


*Global Internal tables

DATA : gt_download TYPE STANDARD TABLE OF ty_s_download. "Download data

LOOP AT gt_tax_data INTO ls_tax_data.

  • Pass All the tax data to screen output table

ls_output-bukrs = ls_tax_data-bukrs.

ls_output-state = ls_tax_data-state.

ls_output-store = ls_tax_data-store.

ls_output-tax_type = ls_tax_data-tax_type.

ls_output-tax_rate = ls_tax_data-tax_rate.

ls_output-discount_amount = ls_tax_data-discount_amount.

lv_discount = ls_tax_data-discount_amount.

lv_tax_rate = ls_output-tax_rate.

  • Calculate Gross tax due

ls_output-gross_due = ls_tax_data-report_amount.

lv_gross_due = ls_output-gross_due.

IF NOT ls_tax_data-tax_rate IS INITIAL.

  • Calculate Taxable Purchase

ls_output-purchase = ls_output-gross_due / ls_tax_data-tax_rate.

ELSE.

ls_output-purchase = 0. "Default it to zero if the tax_rate is zero.

ENDIF.

lv_purchase = ls_output-purchase.

  • Calculate Net Tax Due

ls_output-net_due = ls_output-gross_due - ls_tax_data-discount_amount.

lv_net_due = ls_output-net_due.

  • Concatenate all field values

CONCATENATE ls_output-bukrs

ls_output-state

ls_output-store

ls_output-tax_type

lv_purchase

lv_tax_rate

lv_gross_due

lv_discount

lv_net_due

INTO ls_download-data

SEPARATED BY lc_tab.

  • Append all the downloaded tax data

APPEND ls_download TO gt_download.

  • Clear work areas

CLEAR : ls_output,

ls_tax_data,

ls_download,

lv_purchase,

lv_discount,

lv_tax_rate,

lv_net_due,

lv_gross_due.

ENDLOOP.

Regards,

Prashant

Read only

Former Member
0 Likes
1,081

Hi ,

try following code -

Data: begin of t_char_file occurs 0,

string(2000),

end of t_char_file.

field-symbols: <t_char_file> type x.

*------ following code after gui_upload

loop at gt_itab.

assign gt_itab to <t_char_file> casting.

append t_char_file.

endloop.

Read only

Former Member
0 Likes
1,082

Sorry ! I missed some lines ..

Data: begin of t_char_file occurs 0,

string(2000),

end of t_char_file.

field-symbols: <t_char_file> type x ,

<t_file> type x.

*------ following code after gui_upload

loop at gt_itab.

assign gt_itab to <t_char_file> casting.

assign gt_itab to <t_file> casting.

<t_file> = <t_char_file>.

append t_char_file.

endloop.

Read only

0 Likes
1,081

Hi Narayan,

Thanks ,

but i want the field from gt_itab to be in field str like string

and not in field type t_char_file which is table of string.

Regards

Joy

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
1,081

>

> but i want the field from gt_itab to be in field str like string

> and not in field type t_char_file which is table of string.

Hello Joy,

This is not possible using GUI_UPLOAD. In the file if you have multiple lines, you get multiple lines in your table.

You can try to upload the data as 'BIN' but in that case your data has to be of hex-type string & not normal chracter string.

Hope this is clear.

BR,

Suhas

Read only

0 Likes
1,081

Hi,

you can simply decalre your gt_itab as following.

also you need a varable of type string to loop.

data : gt_itab type table of string,

gw_itab type string.

loop at gt_itab into ge_itab.

  • do your processing here

endloop.

regards,

Rahul

Read only

Former Member
0 Likes
1,081

Hi,

you can simply decalre your gt_itab as following.

also you need a varable of type string to loop.

data : gt_itab type table of string,

gw_itab type string.

loop at gt_itab into ge_itab.

  • do your processing here

endloop.

regards,

Rahul