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: 

Calling 2 cont from single subroutine. prob. with formal,actual param.

Former Member
0 Kudos

i am trying a simple concept of two custom container with alv on 1 screen.

see declarations:


field-symbols :<fs_o> type any, "two field symbols.

               <fs_g> type any.

I have written the code of creating object of class custom container and calling method of class

cl_gui_alv_grid in 1 subroutine.

i have 2 custom container on 1 screen

CUST1

CUST2

***** After calling screen 9002 ---------------------------


MODULE STATUS_9002 OUTPUT.

   SET PF-STATUS 'xxxxxxxx'.

   SET TITLEBAR 'ZDD'.

assign 'CUST1' to <FS_o>.

assign 'grid1' to <FS_g>.

     perform grid1 changing  <fs_o> <fs_g>.

     perform display_grid1.

     assign 'CUST2' to <FS_o>.

assign 'grid2' to <FS_g>.

     perform grid1 changing <fs_o> changing  <fs_g>.

     perform display_grid1.

ENDMODULE.                 " STATUS_9002  OUTPUT


FORM GRID1 changing o1 type ref to cl_gui_custom_container

         g1 type ref to cl_gui_alv_grid.

CREATE OBJECT O1

   EXPORTING

  CONTAINER_NAME              = 'CUST'

EXCEPTIONS

     CNTL_ERROR                  = 1

     CNTL_SYSTEM_ERROR           = 2

     CREATE_ERROR                = 3

     LIFETIME_ERROR              = 4

     LIFETIME_DYNPRO_DYNPRO_LINK = 5

     others                      = 6

     .

IF SY-SUBRC <> 0.

  MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

CREATE OBJECT GRID1

   EXPORTING

     I_PARENT          = obj1

   EXCEPTIONS

     ERROR_CNTL_CREATE = 1

     ERROR_CNTL_INIT   = 2

     ERROR_CNTL_LINK   = 3

     ERROR_DP_CREATE   = 4

     others            = 5

     .

IF SY-SUBRC <> 0.

  MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

ENDFORM.                

In short i dont want to write code to create object and methods for every instance of the class cl_gui_alv_grid,

just 1 subroutine and passing values for diff containers CUST1 & CUST2.

With this code the report is getting Dump.

Runtime Errors         PERFORM_CONFLICT_TYPE.

Please help me with the code having correct formal and actual parameters.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

hi Abhishek

you need difine two container and grid, as blow:

   data: obj_wcl_container01 type ref to cl_gui_custom_container,
           obj_wcl_alv01          type ref to cl_gui_alv_grid,

           obj_wcl_container02 type ref to cl_gui_custom_container,

           obj_wcl_alv02          type ref to cl_gui_alv_grid.

 

     perform grid1 using 'CUST1' changing obj_wcl_container01 obj_wcl_alv01.

     perform display_grid1.

 

     perform grid1 using 'CUST2' changing obj_wcl_container02 obj_wcl_alv02.

     perform display_grid1.

FORM GRID1 using cust type string changing o1 type ref to cl_gui_custom_container

         g1 type ref to cl_gui_alv_grid.

CREATE OBJECT o1

   EXPORTING

  CONTAINER_NAME              = cust

     EXCEPTIONS

     CNTL_ERROR                  = 1

     CNTL_SYSTEM_ERROR           = 2

     CREATE_ERROR                = 3

     LIFETIME_ERROR              = 4

     LIFETIME_DYNPRO_DYNPRO_LINK = 5

     others                      = 6

     .

IF SY-SUBRC <> 0.

  MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

CREATE OBJECT g1

   EXPORTING

     I_PARENT          = o1

   EXCEPTIONS

     ERROR_CNTL_CREATE = 1

     ERROR_CNTL_INIT   = 2

     ERROR_CNTL_LINK   = 3

     ERROR_DP_CREATE   = 4

     others            = 5

     .

IF SY-SUBRC <> 0.

  MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

ENDFORM.             

regards,

Archer

3 REPLIES 3

Former Member
0 Kudos

hi Abhishek

you need difine two container and grid, as blow:

   data: obj_wcl_container01 type ref to cl_gui_custom_container,
           obj_wcl_alv01          type ref to cl_gui_alv_grid,

           obj_wcl_container02 type ref to cl_gui_custom_container,

           obj_wcl_alv02          type ref to cl_gui_alv_grid.

 

     perform grid1 using 'CUST1' changing obj_wcl_container01 obj_wcl_alv01.

     perform display_grid1.

 

     perform grid1 using 'CUST2' changing obj_wcl_container02 obj_wcl_alv02.

     perform display_grid1.

FORM GRID1 using cust type string changing o1 type ref to cl_gui_custom_container

         g1 type ref to cl_gui_alv_grid.

CREATE OBJECT o1

   EXPORTING

  CONTAINER_NAME              = cust

     EXCEPTIONS

     CNTL_ERROR                  = 1

     CNTL_SYSTEM_ERROR           = 2

     CREATE_ERROR                = 3

     LIFETIME_ERROR              = 4

     LIFETIME_DYNPRO_DYNPRO_LINK = 5

     others                      = 6

     .

IF SY-SUBRC <> 0.

  MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

CREATE OBJECT g1

   EXPORTING

     I_PARENT          = o1

   EXCEPTIONS

     ERROR_CNTL_CREATE = 1

     ERROR_CNTL_INIT   = 2

     ERROR_CNTL_LINK   = 3

     ERROR_DP_CREATE   = 4

     others            = 5

     .

IF SY-SUBRC <> 0.

  MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

ENDFORM.             

regards,

Archer

nabheetscn
Active Contributor
0 Kudos

You should pass cpntainer name also plus you shoudl have two containers

0 Kudos

Search for BC*ALV* for better examples and SAP way of doing things:)