Skip to Content

How to pass table's structure to a subroutine in other include

Dear Experts, Good Day!

I have 8 different programs for which I have to display ALV output. I just wanted to use SALV class for displaying ALV.

And these 8 programs are having 2 common includes like 1st for common global declarations and 2nd for common subroutines.

Now I want to build a common subroutine where all the ALV display part contains. And I want to just call CREATE_ALV by passing the output table from all 8 different programs.

So, I just want to prepare the output table and call the subroutine in common include to display ALV.

Note: I cannot create different structures in data dictionary, as then I will be in need to create many data elements for headings. I just want to send the output table structure from my calling program.

Please suggest/help me how to achieve this?

Thanks and Regards,

Vijay

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    Posted on Aug 09, 2016 at 07:45 AM

    Hi,

    like this you can make use of subroutine of external program.
    PERFORM <Subroutine> IN PROGRAM ( <program name> ) USING <actual parameters> IF FOUND.

    or you can define a common subroutine by making use of DATA REFERENCE or field symbols something like this

    like :

    within subroutine..

    FIELD-SYMBOLS : <ITAB> TYPE ANY TABLE / STANDARD TABLE.

    if sy-repid = 'PROGRAM 1'.

    ASSIGN '(PROGRAM 1)ITAB[]' TO <ITAB>.

    elseif sy-repid = 'PROGRAM 2'.

    ASSIGN '(PROGRAM 2)ITAB[]' TO <ITAB>.

    endif.

    thank you!!

    Add a comment
    10|10000 characters needed characters exceeded

    • Hi Rossi,

      Thanks for correcting me. I have changed my code as you suggested and working fine.

      Silly mistake 😊

      FORM display_alv TABLES t_tab_output TYPE STANDARD TABLE.

      TRY.

      cl_salv_table=>factory(

      IMPORTING

      r_salv_table = l_rcl_alv_table

      CHANGING

      t_table = t_tab_output[] ).

      CATCH cx_salv_msg.

      ENDTRY.

      *-- alv Display

      l_rcl_alv_table->display( ).

      ENDFORM. "DISPLAY_ALV

      Thank you.

      Vijay

  • Posted on Aug 09, 2016 at 06:10 AM

    Hi Vijay,

    In common include you can write like this...

    perform XXXXXX in program (sy-repid) if found using XXXXX.

    after that call this subroutine in programs

    form XXXXXX using XXXXX.

    endform.

    Regards

    Raj

    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.