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

problem with OOP ALV

Former Member
0 Likes
1,075

hi everybody

I have created a screen for my ALV but when executing it, a blank screen is appearing

does anybody know why?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,047

I created a plain screen may be, thats why?

i just went to se51, created a screen, thats it

Its wrong , I guess, can anybody suggest me a solution, Im a bit new to screen dynpro etc

12 REPLIES 12
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
1,047

Have you create a container in your screen and give it a name? Have you created the objects in the PBO of your program.

DATA: ALV_CONTAINER  TYPE REF TO CL_GUI_CUSTOM_CONTAINER.
DATA: ALV_GRID       TYPE REF TO CL_GUI_ALV_GRID.

MODULE STATUS_0100 OUTPUT.

  SET PF-STATUS '0100'.
  SET TITLEBAR '0100'.


* Create Controls
  CREATE OBJECT ALV_CONTAINER
         EXPORTING
               CONTAINER_NAME    = 'ALV_CONTAINER'.  "<<-- SHould be the name of the container on the screen.

  CREATE OBJECT ALV_GRID
         EXPORTING
               I_PARENT          =  ALV_CONTAINER.

.....

Regards,

Rich Heilman

Read only

RaymondGiuseppi
Active Contributor
0 Likes
1,047

How did you proceed, did you create a custom container then create a ([cl_gui_custom_container|https://www.sdn.sap.com/irj/sdn/advancedsearch?cat=sdn_all&query=cl_gui_custom_container&adv=false&sortby=cm_rnd_rankvalue#]) object with this control as parent and then a ([cl_gui_alv_grid|https://www.sdn.sap.com/irj/sdn/advancedsearch?cat=sdn_all&query=cl_gui_alv_grid&adv=false&sortby=cm_rnd_rankvalue#]) attached to this container or did you use ([cl_gui_docking_container|https://www.sdn.sap.com/irj/sdn/advancedsearch?cat=sdn_all&query=cl_gui_docking_container&adv=false&sortby=cm_rnd_rankvalue#]) or did you use the new ([cl_salv_table|https://www.sdn.sap.com/irj/sdn/advancedsearch?cat=sdn_all&query=cl_salv_table&adv=false&sortby=cm_rnd_rankvalue#])?

Regards

Read only

Former Member
0 Likes
1,047

Hi

You might have missed creating the GRID instance

*Grid Instance for the display

CREATE OBJECT obj_grid

EXPORTING

i_parent = obj_container.

here you have to pass the obj_container as your container name or instance of the container

Regards

Pavan

Read only

Former Member
0 Likes
1,047

If you give the container name Wrong then you will get an empty screen.

Read only

Former Member
0 Likes
1,048

I created a plain screen may be, thats why?

i just went to se51, created a screen, thats it

Its wrong , I guess, can anybody suggest me a solution, Im a bit new to screen dynpro etc

Read only

0 Likes
1,047

Hi,

Use Key word Call screen 'XXX'. in your program

Then Double click on the screen number it leads to screen painter

Then go to layout

select custom control and then drag it to the screen area.

Givve a name to the container

Then In PBO

Create an instance of the cl_gui_custom_container

pass the name to this container that is given to the custon sontainer in SE51

Then create an instance of the grid as said in previous thread

Then call methos set_table_for_first_display.

If you still face any problem then go to the where used list of the class cl_gui_alv_grid... You will understand better..

Regards

Pavan

Read only

0 Likes
1,047

Go to SE51 and add a custom container to your screen. note the name of the container, then in your abap use

DATA: cont TYPE REF TO cl_gui_custom_container,
      grid TYPE REF TO cl_gui_alv_grid.
      
CREATE OBJECT: cont exporting container_name = <container>,
               grid EXPORTING i_parent = cont.
               
CALL METHOD grid->set_table_for_first_display (...)

Regards

Read only

0 Likes
1,047

with out creating the custom control you can create the ALV using the Docking conainer. For this you just need only screen , check it once.

REPORT  ztest_oo_a.
 
DATA: it_flight TYPE sflight_tab1.
DATA: dock TYPE REF TO cl_gui_docking_container,
      grid TYPE REF TO cl_gui_alv_grid.
 
SELECT *
  FROM sflight
  INTO TABLE it_flight
  UP TO 20 ROWS.
 
CALL SCREEN 100.
 
*&---------------------------------------------------------------------*
*&      Module  STATUS_0100  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
  SET PF-STATUS 'SATR'.
 
 
  CREATE OBJECT dock
    EXPORTING
      repid     = sy-repid
      dynnr     = '100'
      extension = '1500'
    EXCEPTIONS
      cntl_error                  = 1
      cntl_system_error           = 2
      create_error                = 3
      lifetime_error              = 4
      lifetime_dynpro_dynpro_link = 5
      OTHERS                      = 6
      .
  IF sy-subrc ne  0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
               WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.
  CREATE OBJECT grid EXPORTING i_parent = dock.
 
  CALL METHOD grid->set_table_for_first_display
    EXPORTING
      i_structure_name              = 'SFLIGHT'
    CHANGING
      it_outtab                     = it_flight
    EXCEPTIONS
      invalid_parameter_combination = 1
      program_error                 = 2
      too_many_lines                = 3
      OTHERS                        = 4.
  IF sy-subrc ne 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
               WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.
 
ENDMODULE.                 " STATUS_0100  OUTPUT
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_0100  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE user_command_0100 INPUT.
 
  CASE ucomm.
 
    WHEN 'BACK'.
      LEAVE TO SCREEN 0.
  ENDCASE.
 
ENDMODULE.                 " USER_COMMAND_0100  INPUT

Flow Logic..

PROCESS BEFORE OUTPUT.
 MODULE STATUS_0100.
*
PROCESS AFTER INPUT.
 MODULE USER_COMMAND_0100.

and Don't create any control on the screen. just create an empty screen. thats all.

Read only

former_member69765
Contributor
0 Likes
1,047

Hi...

The same is explained in an tutorial on http://www.abaplearning.com/index.php?view=category&id=12%3Aabap-control-frameworks&option=com_conte...

(Tutorials are free for all..)

And a code example is also given here : http://www.abaplearning.com/index.php?option=com_content&view=section&id=2&Itemid=14

(Code samples are only for registered users.. you will have to register...)

Cheers..

Read only

Former Member
0 Likes
1,047

Hii!

I think while defining container on screen you have specified different name then what you have assigned to container class.Compare your program with my sample program and find where have you done the mistake.


REPORT  z_alv1.

DATA:
  w_carrid TYPE sflight-carrid,
  w_connid TYPE sflight-connid.

DATA:
  r_cont TYPE REF TO cl_gui_custom_container,
  r_grid TYPE REF TO cl_gui_alv_grid.

DATA:
  t_fieldcat TYPE lvc_t_fcat,
  fs_fieldcat LIKE LINE OF t_fieldcat.

TYPES:
  BEGIN OF types_flight,
    carrid   TYPE sflight-carrid,
    connid   TYPE sflight-connid,
    fldate   TYPE sflight-fldate,
    price    TYPE sflight-price,
    currency TYPE sflight-currency,
  END OF types_flight.

DATA:
  fs_flight TYPE types_flight,
  t_flight LIKE
     TABLE OF
           fs_flight.

SELECT-OPTIONS:
  s_carrid FOR w_carrid,
  s_connid FOR w_connid.


START-OF-SELECTION.

  PERFORM get_data.
  CALL SCREEN '0100'.

*&---------------------------------------------------------------------
*
*&      Form  get_data
*&---------------------------------------------------------------------
*
*       text
*----------------------------------------------------------------------
*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------
*
FORM get_data .
  SELECT carrid
         connid
         fldate
         price
         currency
    FROM sflight
    INTO TABLE t_flight
   WHERE carrid IN s_carrid
     AND connid IN s_connid.


ENDFORM.                    " get_data
*&---------------------------------------------------------------------
*
*&      Module  STATUS_0100  OUTPUT
*&---------------------------------------------------------------------
*
*       text
*----------------------------------------------------------------------
*
MODULE status_0100 OUTPUT.
  SET PF-STATUS 'STATUS1'.
  SET TITLEBAR 'TITLE1'.
ENDMODULE.                 " STATUS_0100  OUTPUT
*&---------------------------------------------------------------------
*
*&      Module  USER_COMMAND_0100  INPUT
*&---------------------------------------------------------------------
*
*       text
*----------------------------------------------------------------------
*
MODULE user_command_0100 INPUT.

  CASE sy-ucomm.
    WHEN 'BACK'.
      LEAVE TO SCREEN '0'.
  ENDCASE.

ENDMODULE.                 " USER_COMMAND_0100  INPUT
*&---------------------------------------------------------------------
*
*&      Module  alv_grid  OUTPUT
*&---------------------------------------------------------------------
*
*       text
*----------------------------------------------------------------------
*
MODULE alv_grid OUTPUT.
  CREATE OBJECT r_cont
    EXPORTING

      container_name              = 'CONTAINER_1'
    EXCEPTIONS
      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 r_grid
    EXPORTING
      i_parent          = r_cont
    EXCEPTIONS
      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.

  PERFORM build_fieldcat.

  CALL METHOD r_grid->set_table_for_first_display
    CHANGING
      it_outtab                     = t_flight
      it_fieldcatalog               = t_fieldcat
*      IT_SORT                       =
*      IT_FILTER                     =
    EXCEPTIONS
      OTHERS                        = 4
          .
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
              WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.

ENDMODULE.                 " alv_grid  OUTPUT
*&---------------------------------------------------------------------
*
*&      Form  build_fieldcat
*&---------------------------------------------------------------------
*
*       text
*----------------------------------------------------------------------
*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------
*
FORM build_fieldcat .
  fs_fieldcat-fieldname = 'CARRID'.
  fs_fieldcat-tabname   = 'T_FLIGHT'.
  fs_fieldcat-scrtext_m = 'Airline Carrier ID'.
  APPEND fs_fieldcat TO t_fieldcat.

  CLEAR fs_fieldcat.
  fs_fieldcat-fieldname = 'CONNID'.
  fs_fieldcat-tabname   = 'T_FLIGHT'.
  fs_fieldcat-lzero     = '1'.
  fs_fieldcat-scrtext_m = 'Flight Conn ID'.
  APPEND fs_fieldcat TO t_fieldcat.

  CLEAR fs_fieldcat.
  fs_fieldcat-fieldname = 'FLDATE'.
  fs_fieldcat-tabname   = 'T_FLIGHT'.
  fs_fieldcat-scrtext_m = 'Flight Date'.
  APPEND fs_fieldcat TO t_fieldcat.

  CLEAR fs_fieldcat.
  fs_fieldcat-fieldname = 'PRICE'.
  fs_fieldcat-tabname   = 'T_FLIGHT'.
  fs_fieldcat-scrtext_m = 'Price'.
  APPEND fs_fieldcat TO t_fieldcat.

  CLEAR fs_fieldcat.
  fs_fieldcat-fieldname = 'CURRENCY'.
  fs_fieldcat-tabname   = 'T_FLIGHT'.
  fs_fieldcat-scrtext_m = 'Currency'.
  APPEND fs_fieldcat TO t_fieldcat.

ENDFORM.                    " build_fieldcat

Regards

Abhijeet

Read only

uwe_schieferstein
Active Contributor
0 Likes
1,047

Hello Sia

Using a docking container you do not even need to instantiate the container within your dynpro flow logic. I prefer to create the container within the main program and then link it to the target screen.

For an example see report ZUS_SDN_TWO_ALV_GRIDS in


* Link the docking container to the target dynpro
  CALL METHOD go_docking->link
    EXPORTING
      repid                       = syst-repid
      dynnr                       = '0100'
*      CONTAINER                   =
    EXCEPTIONS
      OTHERS                      = 4.
  IF sy-subrc  0.
*   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.
 
 
* NOTE: dynpro does not contain any elements
  CALL SCREEN '0100'.
* Flow logic of dynpro (does not contain any dynpro elements):
*
*PROCESS BEFORE OUTPUT.
*  MODULE STATUS_0100.
**
*PROCESS AFTER INPUT.
*  MODULE USER_COMMAND_0100.

Regards

Uwe

Read only

Former Member
0 Likes
1,047

hi,

check for created screen activated or not. if not first activate the screen , then check for ..... passing the parameter values to the container name and i_parent are type compatable or not.

regards,

Ashok Revoori