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: 

how to get values into internal table dynamically after uploading the file

Former Member
0 Kudos

hi folks

i have a requirement i.e. once i upload the file using the method gui_upload we generally use split command and send the values in to internal table fields.

example : SPLIT it_itab AT c_semicolon INTO

it_itab-matnr

it_itab-werks

it_itab-stlan

it_itab-stlal

but here i must not give those fields rather it must be sent dynamically.

so can someone let me know how i can work on this.

thanks in advance

5 REPLIES 5

Former Member
0 Kudos

do let me know...

still waiting for reply...

0 Kudos

You can check this link: http://www.sap-img.com/ab030.htm

~Satya

naimesh_patel
Active Contributor
0 Kudos

You can save the result set of values in the table instead of the respective fields. Once you have values in the internal table, you can assign them to respective field dynamically.

Check this example code form on-line help:


DATA: str1 TYPE string, 
      str2 TYPE string, 
      str3 TYPE string, 
      itab TYPE TABLE OF string, 
      text TYPE string. 

text = `What a drag it is getting old`. 

SPLIT text AT space INTO: str1 str2 str3, 
                          TABLE itab. 

Regards,

Naimesh Patel

Former Member
0 Kudos

Hi Michael,

After reading your requirement, It seemed to me that internal table fields will be passed dynamically

at the time of execution.

In such cases we can go for field symbol concept. We need to create dynamic internal table using the fieldcatalog for the list of fields.

here is a small piece of code for that assuming that you are passing the table of fieldcatalog l_t_fieldcat(build same as we do for ALV list creation).

data: l_t_str type chart128, "Take another type if you need more chars.

wa_str like line of l_t_str.

data: l_t_data type ref to data,

l_s_new_line type ref to data,

field-symbols: <fs_1> type standard table,

<fs_2> type any,

<fs_field_1> type any.

call method cl_alv_table_create=>create_dynamic_table

exporting

it_fieldcatalog = l_t_fieldcat

importing

ep_table = l_t_data

exceptions

generate_subpool_dir_full = 1

others = 2.

assign l_t_data->* to <fs_1>.

create data l_s_new_line like line of <fs_1>.

assign l_s_new_line->* to <fs_2>.

clear l_t_str[].

SPLIT it_itab AT c_semicolon into table l_t_str.

loop at l_t_str into wa_str.

read table l_t_fieldcat into wa_fieldcat index sy-tabix.

assign component wa_fieldcat-fieldname of structure <fs_2> to <fs_field_1>.

<fs_field_1> = wa_str.

endloop.

append <fs_2> to <fs_1>.

free <fs_2>.

internal table <fs_1> will have the desired data.

Hope it will be helpful for you.

Regards,

Atul

0 Kudos

hi atul

sdn was down for last oneweek so didnt check ur thread.i m working on putting that logic will update onc ei get some result