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

Change in field length after using conversion routine

former_member192842
Participant
0 Likes
1,248

Hi experts,

I have created dynamic internal table based on table name.Fetch the values from the table based on certain condition and then download. Now while downloading the user wants conversion routine for certain fields in that internal table.

For testing purpose i created a dynamic internal table for table S800, fetched the values from table. Now before downloading i need to use conversion routine for field "TPLNR'. The problem is the length of field TPLNR is 30. After using conversion routine the length of data may be 40.

In this case how to handle. Is it possible to change the length of field TPLNR in dynamic internal table to 40 dynamically or is any other way.

Please advice

Thanks

Anand

3 REPLIES 3
Read only

Tomas_Buryanek
Product and Topic Expert
Product and Topic Expert
0 Likes
737

I guess your problem is that output length is different than length of data element?

You can dynamicaly get output length and create dynamic table with that

Sample code:


DATA: go_elemdescr TYPE REF TO cl_abap_elemdescr.

DATA: l_tplnr TYPE tplnr,

           l_length TYPE i.

go_elemdescr ?= cl_abap_elemdescr=>describe_by_data( l_tplnr ).

l_length = go_elemdescr->output_length.

-- Tomas --
Read only

0 Likes
737

Hi,

Thanks for the reply.

Actually in need to download the table <fs_table>. But before downloading need to use conversion routine for TPLNR. Here <fs_table> is created dynamically based on table S800

Loop at <fs_table> into <fs_wa>.

ASSIGN COMPONENT 'TPLNR' OF STRUCTURE <fs_wa> TO <fs_tplnr>.

CALL FUNCTION 'CONVERSION_EXIT_TPLNR_OUTPUT'

   EXPORTING

     input     = <fs_tplnr>

   IMPORTING

     output    = <fs_tplnr>

endloop.

While doing this found out that the data in <fs_tplnr>  is wrong because the length of <fs_tplnr> is only 30 but the data after conversion is 38.

Im only having problem with that TPLNR field in the dynamic internal table. Is it possible only change the length of the TPLNR field. or else how can i create another dynamic internal table of S800 with the length of TPLNR as 40.

Thanks in advance

Anand

Read only

0 Likes
737

how can i create another dynamic internal table of S800 with the length of TPLNR as 40.

You can do this and there are MANY tutorials and examples. This one should help:

Example - create a dynamic internal table - Code Gallery - SCN Wiki

But if you need that conversion only for download. Maybe you can convert it to some generic field/string table right away. Depeneds on which format you downloading? Some kind of CSV?

What I mean:

1) conversion exit output

2) concatenate fields of one line to string

3) append to string table

4) download...

and no need to create another dynamic table...

-- Tomas --