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

Error when creating FM.

Former Member
0 Likes
603

Hello,

I want to create a FM which will concatenate all Text from a column and give me back as Text String. I want to give the FM a table as Import parameter and export LT_DATA which is a string of text.

This is what I have done:

IMPORT Parameter has the following definiation:

T_LINES TYPE ANY TABLE.

EXPORT Parameter has the following definition:

LT_DATA TYPE STRING.

This is how my code looks like:

*"----------------------------------------------------------------------
"*"Lokale Schnittstelle:
*"  IMPORTING
*"     VALUE(T_LINES) TYPE  ANY TABLE
*"  EXPORTING
*"     VALUE(LT_DATA) TYPE  STRING
*"  EXCEPTIONS
*"      NO_DATA
*"----------------------------------------------------------------------

  FIELD-SYMBOLS: <fs_im_tab> TYPE ANY,
                 <fs_comp>   TYPE ANY.

  DATA: lt_data TYPE TABLE OF string.
  DATA: ls_data TYPE string.

  LOOP AT T_LINES ASSIGNING <fs_im_tab> .
    DO.
      ASSIGN COMPONENT sy-index OF STRUCTURE <fs_im_tab> TO <fs_comp>.
      IF sy-subrc <> 0.
        EXIT.
      ENDIF.
      IF sy-index = 1.
        ls_data = <fs_comp>.
      ELSE.
        CONCATENATE ls_data <fs_comp> INTO ls_data.
      ENDIF.
    ENDDO.
    APPEND ls_data TO lt_data.
  ENDLOOP.
ENDFUNCTION.

But when I want to activate it , I have the following error:

lt_data is already been defined. Can any body help me to solve this? <REMOVED BY MODERATOR>

Nadin

Edited by: Alvaro Tejada Galindo on Feb 29, 2008 10:23 AM

4 REPLIES 4
Read only

Former Member
0 Likes
582

The error is very descriptive.

Lt_data is already declared in your exports.

Just change the name of the lt_data table, that's it

Read only

0 Likes
582

Thank you. I have changed the lt_data to lw_data and I don't receive any errors but I don't also receive any result. What am I doing wrong from my code. my lt_lines have data in it.

Thank for any help.

Read only

0 Likes
582

You should change the type of the EXPORTING parameter LT_DATA.

You need to create a TABLE TYPE on SE11 and assign it to your parameter...Or you can use an existing one...

For example WRB_STRING_TABLE

So your code should be like this...


*"----------------------------------------------------------------------
"*"Lokale Schnittstelle:
*"  IMPORTING
*"     VALUE(T_LINES) TYPE  ANY TABLE
*"  EXPORTING
*"     VALUE(LT_DATA) TYPE  WRB_STRING_TABLE
*"  EXCEPTIONS
*"      NO_DATA
*"----------------------------------------------------------------------
 
  FIELD-SYMBOLS: <fs_im_tab> TYPE ANY,
                 <fs_comp>   TYPE ANY.
 
  DATA: ls_data TYPE string.
 
  LOOP AT T_LINES ASSIGNING <fs_im_tab> .
    DO.
      ASSIGN COMPONENT sy-index OF STRUCTURE <fs_im_tab> TO <fs_comp>.
      IF sy-subrc  0.
        EXIT.
      ENDIF.
      IF sy-index = 1.
        ls_data = <fs_comp>.
      ELSE.
        CONCATENATE ls_data <fs_comp> INTO ls_data.
      ENDIF.
    ENDDO.
    APPEND ls_data TO lt_data.
  ENDLOOP.
ENDFUNCTION.

Greetigns,

Blag.

Read only

0 Likes
582

Why don't you just move lt_data to tables?

That way just don't declare it in your function module and do whatever you want with it