Skip to Content
author's profile photo Former Member
Former Member

Dynamically passing table in Subroutine

Hi,

In my requirement,I am having two performs.Both are calling the same form.Perform is passing one internal table.But the structure of the internal tables in two performs are different.But I want both the perform should call the same form.

Code:

data itab1 type standard table of mara.

data itab2 type standard table of makt.

select * from mara into table itab1.

select * from makt into table itab2.

perform display tables itab1.

perform display tables itab2.

How the form should be?

Thanks in Advance.

Regards,

J.Jayanthi

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

5 Answers

  • Best Answer
    Posted on Aug 23, 2005 at 09:21 AM

    use

    perform display using itab1.

    perform display using itab1.

    and....

    form display using itab type any table.

    endform.

    Christian

    Add a comment
    10|10000 characters needed characters exceeded

    • Since I typed it directly into this editor - there is no chance of a syntax check.

      From what I can see - <l_field> should be type any as well.

      Also...

      If you use USING you have to change the perform statement as well

      PERFORM DISPLAY USING table.

      The type conflict can occur if you pass the header line instead of the body. In this case use the brackets as indicated by someone else in a previous posting.

      The error message could have the same reason or it could be a unicode error I am not aware of. In this case change the type definition from

      FORM display using itab type ANY table

      to

      FORM display using itab type STANDARD table

      If you pass a table without a header line to a FM - make sure to use the brackets.

      call function....

      TABLES

      itab = itab[].

      Christian

  • author's profile photo Former Member
    Former Member
    Posted on Aug 23, 2005 at 09:18 AM

    If modularisation is the aim, then you can do the same thing with Function Modules, without declaring the type of the internal table in Tables in the interface of the Function Module.

    However there has to be some way to recognise the structure of the table.

    If you recognise the REUSE_ALV_LIST_DISPLAY and similar function modules, they use the field catalog to recognise the structure of the internal table , then dynamically create the internal table and list the values in ALV

    Regards,

    Subramanian V.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Aug 23, 2005 at 09:21 AM

    I have accomplished the same using function module. For one of my function module I have not defined the assosiated type and in the program I have assigned this into another internal table which is defined in the TOP include of the function module.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 23, 2005 at 09:26 AM

    Hi Jayanthi,

    Try this

    PERFORM DISPLAY TABLES ITAB1.

    PERFORM DISPLAY TABLES ITAB2.

    .

    .

    .

    .

    PERFORM DISPLAY TABLES ITAB1 STRUCTURE STRU1.

    PERFORM DISPLAY TABLES ITAB2 STRUCTURE STRU2.

    You can specify the structure dynamically using the keyword STRUCTURE.

    Thanks & Regards,

    Kathirvel

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 23, 2005 at 10:44 AM

    hi jayanthi.

    u analyse this following program , hope u will got solution for ur problem.

    DATA: itab TYPE STANDARD TABLE OF spfli,

    wa LIKE LINE OF itab.

    DATA: line(72) TYPE c,

    list LIKE TABLE OF line(72).

    START-OF-SELECTION.

    line = 'AIRPTO CITYFROM CITYTO COUNTRYFR'.

    • line = ' AIRPTO '.

    APPEND line TO list.

    SELECT DISTINCT (list)

    INTO CORRESPONDING FIELDS OF TABLE itab

    FROM spfli.

    IF sy-subrc EQ 0.

    LOOP AT itab INTO wa.

    WRITE: / wa-cityfrom, wa-cityto , wa-countryfr.

    • WRITE :/ wa-airpto.

    ENDLOOP.

    ENDIF.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.