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: 

Trouble With ALV Grid Control

Former Member
0 Kudos

Hi guys.

I have the following problem with ALV Grid Controls.

I was following the SAP Documentation online at: http://help.sap.com/saphelp_nw70ehp3/helpdata/en/4e/ba23f5250f568be10000000a421937/frameset.htm 

Hence, I derived a program as shown below. But the problem is, the Screen loads without any data. Is it a problem of refreshing? Or am I doing something wrong? The documentation mentions to create the 'CustomControl' object within the PBO Module of Screen (which I did).  And refreshing the AlvGrid doesn't seem to be helping either.

ABAP Program - Method Doesn't WOrk

REPORT ZHELLOWORLD.

TABLES: ZDBTABLE.

DATA: AlvGridRefVar TYPE REF TO CL_GUI_ALV_GRID,

      CustomContainer TYPE REF TO CL_GUI_CUSTOM_CONTAINER,

      itab_ZDBTABLE TYPE STANDARD TABLE OF ZDBTABLE.

START-OF-SELECTION.

  CALL SCREEN 60.

SELECT ZDBTABLE~code qty

  FROM   ZDBTABLE

  INTO   CORRESPONDING FIELDS OF TABLE itab_ZDBTABLE.

CALL METHOD AlvGridRefVar->SET_TABLE_FOR_FIRST_DISPLAY

  EXPORTING I_STRUCTURE_NAME = 'ZDBTABLE'

  CHANGING IT_OUTTAB = itab_ZDBTABLE.

MODULE init OUTPUT.          " Called By PBO Of Screen 60

  SET PF-STATUS 'ZHELLOWORLD_STATUS01'.

  IF CustomContainer IS INITIAL.

    CREATE OBJECT CustomContainer

      EXPORTING CONTAINER_NAME = 'CONTAINER'.

    CREATE OBJECT AlvGridRefVar

      EXPORTING I_PARENT = CustomContainer.

  ENDIF.

ENDMODULE.

MODULE exit INPUT.            " Called By PAI Of Screen 60

  LEAVE PROGRAM.

ENDMODULE.

However, If I modify the program above so that,  'CustomContainer' object is created in the 'Start-of-selection', and call 'Screen 60' at the end, the output seems fine!

ABAP Program - This Method Works

REPORT ZHELLOWORLD.

TABLES: ZDBTABLE.

DATA: AlvGridRefVar TYPE REF TO CL_GUI_ALV_GRID,

      CustomContainer TYPE REF TO CL_GUI_CUSTOM_CONTAINER,

      itab_ZDBTABLE TYPE STANDARD TABLE OF ZDBTABLE.

START-OF-SELECTION.

  IF CustomContainer IS INITIAL.

    CREATE OBJECT CustomContainer

      EXPORTING CONTAINER_NAME = 'CONTAINER'.

    CREATE OBJECT AlvGridRefVar

      EXPORTING I_PARENT = CustomContainer.

  ENDIF.

SELECT ZDBTABLE~code qty

  FROM   ZDBTABLE

  INTO   CORRESPONDING FIELDS OF TABLE itab_ZDBTABLE.

CALL METHOD AlvGridRefVar->SET_TABLE_FOR_FIRST_DISPLAY

  EXPORTING I_STRUCTURE_NAME = 'ZDBTABLE'

  CHANGING IT_OUTTAB = itab_ZDBTABLE.

CALL SCREEN 60.

MODULE init OUTPUT.                    

  SET PF-STATUS 'ZHELLOWORLD_STATUS01'.

ENDMODULE.

MODULE exit INPUT.

  LEAVE PROGRAM.

ENDMODULE.


So, what is the problem with the first approach? Am I doing something wrong? Any input would be appreciated!

Thank you all for your time in advance.

Sole Developer.

PS: Using the command CALL METHOD AlvGridRefVar->REFRESH_TABLE_DISPLAY.

1 ACCEPTED SOLUTION

former_member194152
Contributor
0 Kudos

You need to create instance of custom container and assigned instance of grid class to PBO module of screen 60.

Refer program BCALV_GRID_DEMO for more understanding.

This you need to do because if you are calling screen immeditaely PBO will called and then you need to write further logic for ALV Grid processing.

9 REPLIES 9

former_member194152
Contributor
0 Kudos

You need to create instance of custom container and assigned instance of grid class to PBO module of screen 60.

Refer program BCALV_GRID_DEMO for more understanding.

This you need to do because if you are calling screen immeditaely PBO will called and then you need to write further logic for ALV Grid processing.

0 Kudos

Hmm....Guess you are right! I must also call the method from the PBO of the Screen. I altered the code and the following works.

This Method Works

REPORT ZHELLOWORLD.

TABLES: ZDBTABLE.

DATA: AlvGridRefVar TYPE REF TO CL_GUI_ALV_GRID,

      CustomContainer TYPE REF TO CL_GUI_CUSTOM_CONTAINER,

      itab_ZDBTABLE TYPE STANDARD TABLE OF ZDBTABLE.

DATA: text TYPE C LENGTH 20.

START-OF-SELECTION.

  SELECT ZDBTABLE~code qty

    FROM   ZDBTABLE

    INTO   CORRESPONDING FIELDS OF TABLE itab_ZDBTABLE.

CALL SCREEN 60.

MODULE init OUTPUT.

  SET PF-STATUS 'ZHELLOWORLD_STATUS01'.

  IF CustomContainer IS INITIAL.

    CREATE OBJECT CustomContainer

      EXPORTING CONTAINER_NAME = 'CONTAINER'.

    CREATE OBJECT AlvGridRefVar

      EXPORTING I_PARENT = CustomContainer.

  ENDIF.

  CALL METHOD AlvGridRefVar->SET_TABLE_FOR_FIRST_DISPLAY

    EXPORTING I_STRUCTURE_NAME = 'ZDBTABLE'

    CHANGING IT_OUTTAB = itab_ZDBTABLE.

ENDMODULE.

MODULE exit INPUT.

  LEAVE PROGRAM.

ENDMODULE.

Thanks a lot.

Sole Developer.

reachdebopriya
Active Participant
0 Kudos

Hi,

REPORT ZHELLOWORLD.

TABLES: ZDBTABLE.


DATA: AlvGridRefVar TYPE REF TO CL_GUI_ALV_GRID,

      CustomContainer TYPE REF TO CL_GUI_CUSTOM_CONTAINER,

      itab_ZDBTABLE TYPE STANDARD TABLE OF ZDBTABLE.


START-OF-SELECTION.

  IF CustomContainer IS BOUND.

    CREATE OBJECT CustomContainer

      EXPORTING CONTAINER_NAME = 'CONTAINER'.


    CREATE OBJECT AlvGridRefVar

      EXPORTING I_PARENT = CustomContainer.

  ENDIF.


SELECT ZDBTABLE~code qty

  FROM   ZDBTABLE

  INTO   CORRESPONDING FIELDS OF TABLE itab_ZDBTABLE.

CALL SCREEN 60.

MODULE init OUTPUT.                    

  SET PF-STATUS 'ZHELLOWORLD_STATUS01'.

CALL METHOD AlvGridRefVar->SET_TABLE_FOR_FIRST_DISPLAY

  EXPORTING I_STRUCTURE_NAME = 'ZDBTABLE'

  CHANGING IT_OUTTAB = itab_ZDBTABLE.

ENDMODULE.

** You need to create a button in the PF-Status and in PAI need to give LEAVE PROGRAM against ** the button.
MODULE exit INPUT.

  LEAVE PROGRAM.

ENDMODULE.

Regards,

Debopriya Ghosh

0 Kudos

I have already done that!!

Anyways. Thanks for the reply!

Former Member
0 Kudos

Hi,

you are calling screen 60 and it calls PBO of screen 60 so in PBO of screen 60 you are creating container objects its fine. But you are not displaying any thing there as i wont execute

CALL METHOD AlvGridRefVar->SET_TABLE_FOR_FIRST_DISPLAY

  EXPORTING I_STRUCTURE_NAME = 'ZDBTABLE'

  CHANGING IT_OUTTAB = itab_ZDBTABLE.

MODULE init OUTPUT.          " Called By PBO Of Screen 60

  SET PF-STATUS 'ZHELLOWORLD_STATUS01'.

So you can write this logic in PBO of 60 after creation of the objects.

In the second case you are calling both in start of selection so it will execute both the code.

thanks.

0 Kudos

Hmm...SO basically, when a Screen is called, the START-OF-SELECTION is dropped. Until the Screen exists??? Or an execute is performed within?

0 Kudos

Ya until you go back to the previous screen using leave to screen 0. or exit.

0 Kudos

Ok thanks again!

0 Kudos

You are welcome.......