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

how to use dynamic internal table when using gui_upload?

Former Member
0 Likes
1,855

Hi Experts,

my scenario is like i have header data, item data and serial numbers.

so with respect to the quantity in unit of measure ,there will be number of serial numbers..

i have declared the dynamic internal table,but i am not getting the logic to change the structure accordingly with respect to the flat file entries..

is it possible to do or its not possible....any suggestion!!!!i have declared like this....

TYPES: BEGIN OF ty_final,

bldat TYPE string, "Document Date

budat TYPE string, "Psting Date

bktxt TYPE string, "Document Header Text

werks TYPE string, "Plant

lgort TYPE string, "Storage Location

matnr TYPE string, "Material Number

erfmg TYPE string, "Quantity in Unit Of Entry

anln1 TYPE string, "Asset Number

anln2 TYPE string, "Asset Subnumber

sernr TYPE string, "serial Number

END OF ty_final.

DATA : it_final TYPE TABLE OF ty_final,

wa_final TYPE ty_final.

FIELD-SYMBOLS : <fs_final> TYPE table.

ASSIGN it_final TO <fs_final>.

after this i called gui upload and passed internal table it_final..

but i have to change the internal table structure dynamically before the upload function.so that it will match with the flat file...

Regards

Karthick

1 ACCEPTED SOLUTION
Read only

kesavadas_thekkillath
Active Contributor
0 Likes
1,397

Did you mean it this way ????



types:begin of ty1,
      f1 type c,
      f2 type c,
end of ty1.

types:begin of ty2,
      f1 type char02,
      f2 type char02,
end of ty1.

data:it1 type table of ty1,
     it2 type table of ty2.

field-symbols:<fs_tab> type standard table.


if op1 = 'X'.
assign it1 to <fs_tab>.
else.
assign it2 to <fs_tab>.
endif.

10 REPLIES 10
Read only

Former Member
0 Likes
1,397

Hi,

Can you tell on what basis your flat file is going to change ?

How many types of flat file will you require to upload ?

Regards,

Madhukar Shetty

Read only

0 Likes
1,397

Hi madhukar

i have only one flat file..i am doing uploading for mb1a transaction..

my flat file is like

document date posting date docheader text plant storage location material quantityinunit of measure assetno subassetno serialno

with respect to quantity n number of serial number will be there.

in that i have to pass serial number only dyanamicaly ....

is that possible...

Read only

MarcinPciak
Active Contributor
0 Likes
1,397

There are at least two approaches you can use to change/generate new dynamic-structured table. Either with [RTTI + RTTS|https://wiki.sdn.sap.com/wiki/display/Snippets/CreatingFlatandComplexInternalTablesDynamicallyusingRTTI] or using [CL_ALV_TABLE_CREATE|http://www.sdn.sap.com/irj/scn/advancedsearch?query=cl_alv_table_create] . In this one just determine fieldcatalog of current table and change it accordingly, then regenarate table.

There are plenty of examples in SCN for this. You should not face difficulties applying this.

Regards

Marcin

Read only

0 Likes
1,397

hi marctin,

i am not getting why i have to use field catalog?i am doing uploading for mb1a transaction..

and cant iuse the way i used to declare dynamic internal table?

Read only

Former Member
0 Likes
1,397

hi,

data : ifc type lvc_t_fcat.

call method cl_alv_table_create=>create_dynamic_table

exporting

it_fieldcatalog = ifc

importing

ep_table = dy_table.

assign dy_table->* to <dyn_table>.

  • Create dynamic work area and assign to FS

create data dy_line like line of <dyn_table>.

assign dy_line->* to <dyn_wa>.

regards,

Sri

Read only

0 Likes
1,397

hi sridhar,

i m not just getting whhy i have to use field catalog?

the way i declared the dynamic internal table is wrong?

Read only

kesavadas_thekkillath
Active Contributor
0 Likes
1,398

Did you mean it this way ????



types:begin of ty1,
      f1 type c,
      f2 type c,
end of ty1.

types:begin of ty2,
      f1 type char02,
      f2 type char02,
end of ty1.

data:it1 type table of ty1,
     it2 type table of ty2.

field-symbols:<fs_tab> type standard table.


if op1 = 'X'.
assign it1 to <fs_tab>.
else.
assign it2 to <fs_tab>.
endif.

Read only

0 Likes
1,397

hi keshav,

s this way only....i have already put how i declared!!!!!!!

Read only

Former Member
0 Likes
1,397

Partly solved but thanks for the kind help and tips provided by the experts..

Read only

Former Member
0 Likes
1,397

i used the function module TEXT_CONVERT_XLS_TO_SAP but it's showing field symbol is not assigned in runtime