Application Development 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: 

not able to create subroutine pool program for below scenario

Former Member
0 Kudos
279

Hi folks,

i have an alv report in which i have one dynamic internal table, now my requirement is to create

subroutine pool in which i can pass the alv part and use this subroutine pool program in an executable program where it fetches the the required data when the executable program runs.

see my below code.

   FORM f_check_orders .
  t1 = 'Dynamic ALV display for table'.
  t2 = pt_table.
  CONCATENATE t1 t2 INTO t3 SEPARATED BY space.

  IF pt_table IS NOT INITIAL.
    CREATE DATA l_structure TYPE (pt_table).

    ASSIGN l_structure->* TO <dyn_str>.
    struc_desc ?= cl_abap_typedescr=>describe_by_data( <dyn_str> ).

    CLEAR  : ls_lvc_fieldcatalogue,
             ls_fieldcatalogue.

    REFRESH: lt_lvc_fieldcatalogue,
             lt_fieldcatalogue.

    LOOP AT struc_desc->components ASSIGNING <str_comp>.
*   Build Fieldcatalog
      ls_lvc_fieldcatalogue-fieldname = <str_comp>-name.
      ls_lvc_fieldcatalogue-ref_table = pt_table.
      APPEND ls_lvc_fieldcatalogue TO lt_lvc_fieldcatalogue.

*   Build Fieldcatalog
      ls_fieldcatalogue-fieldname = <str_comp>-name.
      ls_fieldcatalogue-ref_tabname = pt_table.
      APPEND ls_fieldcatalogue TO lt_fieldcatalogue.
    ENDLOOP.

* Create internal table dynamic
    CALL METHOD cl_alv_table_create=>create_dynamic_table
      EXPORTING
        it_fieldcatalog = lt_lvc_fieldcatalogue
      IMPORTING
        ep_table        = l_table.

    ASSIGN l_table->* TO <it_table>.
    CLEAR : <it_table>.
    REFRESH <it_table>.
  ENDIF.

  IF pt_table IS NOT INITIAL.
    SELECT * FROM (pt_table)
          INTO CORRESPONDING FIELDS OF TABLE <it_table>.
  ENDIF.
ENDFORM.                    " CHECK_ORDERS

   FORM f_pbo_100_op .

  CONSTANTS:lc_boolean TYPE sap_bool VALUE 'X'.

  DATA: lo_functions TYPE REF TO cl_salv_functions_list.

  SET PF-STATUS 'MAIN100'.
*  SET TITLEBAR  'TITLE100'.

*****Start of insert code for REFRESH functionality
  IF gv_flag = gc_one. "If refresh button is pressed

*// Get the modified data
    IF NOT pt_table Is initial.
      PERFORM f_check_orders.
    ELSE.
      PERFORM alv_display.
    ENDIF.

*// Call SET_DATA to display the changed data
    TRY.
        go_table->set_data( CHANGING t_table = <it_table> ).

      CATCH cx_salv_no_new_data_allowed INTO go_msg1.
    ENDTRY.

    gv_flag  = gc_two. "flag value changed
  ENDIF.
*****End of insert

*//Check intitally for the blank custom container
  IF go_custom_container IS INITIAL .

*// Creating custom container
    CREATE OBJECT go_custom_container
      EXPORTING
        container_name = gc_container.

*// Now call the factory method for ALV data to put on BOTTOM container
    TRY.

        CALL METHOD cl_salv_table=>factory(
          EXPORTING
            r_container  = go_bottom_container
          IMPORTING
            r_salv_table = go_table
          CHANGING
            t_table      = <it_table> ).
      CATCH cx_salv_msg INTO go_msg.
    ENDTRY.

    go_events1 = go_table->get_event( ).
    go_columns = go_table->get_columns( ).
    go_columns->set_optimize( 'X' ).

  ENDIF.

*//Display the ALV data
  go_table->display( ).


ENDFORM.                    " F_PBO_100_OP

i want to use the above logic in subroutine pool program and need to call in the executable program which will have only selection screen and this selection screen data should be passed to subroutine pool program.

Please help with sample code or modify the above code as perthe requirement.

Regards

Ravi

2 REPLIES 2

former_member209818
Active Contributor
0 Kudos
54

Hi Rocky,

Why not to create a include program to keep all your subroutines and then use that include in your Main Executable program ??

- Harshad

0 Kudos
54

no harshad,

i have done that part but requirement is to have unique subroutine pool and this subroutine pool can be accessed from any executable program.

Hence i have to do with only subroutine pool.

Regards

Rocky