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

oops in alv

Former Member
0 Likes
1,129

hi friends,

now i am doing one ALV report with oops . i created alv_grid object .. here asking i_parent exporting parameter . What is i_parent .. here what should i give.

and also it's giving runtime error like "Access via NULL object reference not possible " Please give the solution..

Regards,

kumar

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,089

Hi Kumaresan,

Maybe u have not created the object for container thats y its giving a dump.

<b>CREAE OBJECT CCONATINER IMPORTING NAME = Containername</b>

If ur using alv_grid->set_table_for_first_display method u should give the <b>container name in the i_parent and and structure name in i_structure_name if u have a structure already defined in DDIC or else u have to populate the fieldcatalog and pass it to i_fieldcatalog</b>.

Thanks & Regards

Santhosh

hi friends,

now i am doing one ALV report with oops . i created alv_grid object .. here asking i_parent exporting parameter . What is i_parent .. here what should i give.

and also it's giving runtime error like "Access via NULL object reference not possible " Please give the solution..

Regards,

kumar

9 REPLIES 9
Read only

Former Member
0 Likes
1,089

chk the standard program BCALV_EDIT_05

Read only

Former Member
0 Likes
1,090

Hi Kumaresan,

Maybe u have not created the object for container thats y its giving a dump.

<b>CREAE OBJECT CCONATINER IMPORTING NAME = Containername</b>

If ur using alv_grid->set_table_for_first_display method u should give the <b>container name in the i_parent and and structure name in i_structure_name if u have a structure already defined in DDIC or else u have to populate the fieldcatalog and pass it to i_fieldcatalog</b>.

Thanks & Regards

Santhosh

Read only

0 Likes
1,089

hi,

thanks santhosh .. ur answere was very helpful for me .. i got the answere.

Thanks a lot .

regards,

kumar

Read only

sonu_p2
Active Participant
0 Likes
1,089

Hello Kumaresan,

I_parent should be the <b>name of the container</b> which u defined

Just refer the code which I am sending :---

PROGRAM ZSAC_DBCLK_ALVOO MESSAGE-ID ZSAC_PUR_MSG.

type-pools : slis.

tables :

ekko, "Purchasing Document Header

ekpo. "Purchasing Document Item

DATA : s_container type ref to cl_gui_custom_container,

s_grid type ref to cl_gui_alv_grid,

gt_fieldcat type lvc_t_fcat,

gs_fieldcat like line of gt_fieldcat.

DATA : s_container1 type ref to cl_gui_custom_container,

s_grid1 type ref to cl_gui_alv_grid,

gt_fieldcat1 type lvc_t_fcat,

gs_fieldcat1 like line of gt_fieldcat1.

TYPES : BEGIN OF IT_EKKO_STRUCT,

ebeln TYPE ekko-ebeln, "Purchasing Document Number

bukrs TYPE ekko-bukrs, "Company Code

END OF IT_EKKO_STRUCT.

DATA : IT_EKKO TYPE TABLE OF IT_EKKO_STRUCT,

IT_EKKO_WA LIKE LINE OF IT_EKKO.

DATA: ok_code TYPE sy-ucomm ,

TXT_PURDOC LIKE ekpo-ebeln.

TYPES : BEGIN OF IT_EKPO_STRUCT,

ebeln TYPE ekpo-ebeln,

ebelp TYPE ekpo-ebelp,

matnr TYPE ekpo-matnr,

werks TYPE ekpo-werks,

kunnr TYPE ekpo-kunnr,

bukrs TYPE ekko-bukrs,

END OF IT_EKPO_STRUCT.

DATA : IT_EKPO TYPE TABLE OF IT_EKPO_STRUCT,

IT_EKPO_WA LIKE LINE OF IT_EKPO.

----


  • CLASS Z_MAIN DEFINITION

----


*

----


CLASS Z_MAIN DEFINITION.

PUBLIC SECTION.

METHODS : SELECTION , FIRSTDIS ,SECONDDIS.

METHODS on_dblclick FOR EVENT double_click OF cl_gui_alv_grid IMPORTING e_row.

ENDCLASS. "Z_MAIN DEFINITION

----


  • CLASS Z_MAIN IMPLEMENTATION

----


*

----


CLASS Z_MAIN IMPLEMENTATION.

METHOD SELECTION.

SELECT ebeln ebelp matnr werks kunnr

FROM EKPO

INTO CORRESPONDING FIELDS OF TABLE IT_EKPO

WHERE ebeln = TXT_PURDOC.

SELECT ebeln bukrs

FROM ekko

INTO CORRESPONDING FIELDS OF TABLE it_ekko

WHERE ebeln = TXT_PURDOC.

ENDMETHOD. "SELECTION

METHOD FIRSTDIS.

PERFORM fld_cat.

IF s_container is INITIAL.

CREATE OBJECT s_container

EXPORTING container_name = 'SS_CONTAINER'.

CREATE OBJECT s_grid

EXPORTING i_parent = s_container.

CALL METHOD s_grid->set_table_for_first_display

CHANGING

it_outtab = it_ekko

it_fieldcatalog = gt_fieldcat.

ENDIF.

ENDMETHOD. "FIRSTDIS

METHOD SECONDDIS.

PERFORM fld_cat1.

IF s_container1 is INITIAL.

CREATE OBJECT s_container1

EXPORTING container_name = 'SP_CONTAINER'.

CREATE OBJECT s_grid1

EXPORTING i_parent = s_container1.

CALL METHOD s_grid1->set_table_for_first_display

CHANGING

it_outtab = it_ekpo

it_fieldcatalog = gt_fieldcat1.

ENDIF.

ENDMETHOD. "SECONDDIS

METHOD on_dblclick.

READ TABLE it_ekko INDEX e_row INTO it_ekko_wa.

LEAVE TO SCREEN 0400.

ENDMETHOD. "on_dblclick

ENDCLASS. "Z_MAIN IMPLEMENTATION

&----


*& Module STATUS_0100 OUTPUT

&----


  • text

----


MODULE STATUS_0100 OUTPUT.

ENDMODULE. " STATUS_0100 OUTPUT

&----


*& Module USER_COMMAND_0100 INPUT

&----


  • text

----


MODULE USER_COMMAND_0100 INPUT.

DATA : obj1 type ref to Z_MAIN.

CREATE OBJECT : obj1.

CASE SY-UCOMM.

WHEN 'SEARCH'.

CALL METHOD obj1->SELECTION.

LEAVE TO SCREEN 0300.

WHEN 'CANCEL'.

LEAVE PROGRAM.

WHEN 'BACK'.

LEAVE TO SCREEN 0.

ENDCASE.

ENDMODULE. " USER_COMMAND_0100 INPUT

&----


*& Module STATUS_0300 OUTPUT

&----


  • text

----


MODULE STATUS_0300 OUTPUT.

SET PF-STATUS 'ALV1'.

CALL METHOD obj1->FIRSTDIS.

SET HANDLER obj1->on_dblclick FOR s_grid.

ENDMODULE. " STATUS_0300 OUTPUT

&----


*& Form fld_cat

&----


  • text

----


FORM fld_cat.

gs_fieldcat-fieldname = 'EBELN'.

gs_fieldcat-tabname = 'IT_EKKO'.

gs_fieldcat-reptext = 'Purchasing Document'.

gs_fieldcat-outputlen = 20.

APPEND gs_fieldcat TO gt_fieldcat.

CLEAR gs_fieldcat.

gs_fieldcat-fieldname = 'BUKRS'.

gs_fieldcat-tabname = 'IT_EKKO'.

gs_fieldcat-reptext = 'Company Code'.

gs_fieldcat-outputlen = 20.

APPEND gs_fieldcat TO gt_fieldcat.

CLEAR gs_fieldcat.

ENDFORM. "fld_cat

&----


*& Form fld_cat1

&----


  • text

----


FORM fld_cat1.

gs_fieldcat1-fieldname = 'EBELN'.

gs_fieldcat1-tabname = 'IT_EKPO'.

gs_fieldcat1-reptext = 'Purchasing Document'.

gs_fieldcat1-outputlen = 20.

APPEND gs_fieldcat1 TO gt_fieldcat1.

CLEAR gs_fieldcat1.

gs_fieldcat1-fieldname = 'EBELP'.

gs_fieldcat1-tabname = 'IT_EKPO'.

gs_fieldcat1-reptext = 'Item Number'.

gs_fieldcat1-outputlen = 20.

APPEND gs_fieldcat1 TO gt_fieldcat1.

CLEAR gs_fieldcat1.

gs_fieldcat1-fieldname = 'MATNR'.

gs_fieldcat1-tabname = 'IT_EKPO'.

gs_fieldcat1-reptext = 'Material Number'.

gs_fieldcat1-outputlen = 20.

APPEND gs_fieldcat1 TO gt_fieldcat1.

CLEAR gs_fieldcat1.

gs_fieldcat1-fieldname = 'WERKS'.

gs_fieldcat1-tabname = 'IT_EKPO'.

gs_fieldcat1-reptext = 'Plant'.

gs_fieldcat1-outputlen = 20.

APPEND gs_fieldcat1 TO gt_fieldcat1.

CLEAR gs_fieldcat1.

ENDFORM. "fld_cat1

&----


*& Module STATUS_0400 OUTPUT

&----


  • text

----


MODULE STATUS_0400 OUTPUT.

SET PF-STATUS 'ALV2'.

CALL METHOD obj1->SECONDDIS.

ENDMODULE. " STATUS_0400 OUTPUT

&----


*& Module USER_COMMAND_0300 INPUT

&----


  • text

----


MODULE USER_COMMAND_0300 INPUT.

*

ENDMODULE. " USER_COMMAND_0300 INPUT

&----


*& Module USER_COMMAND_0400 INPUT

&----


  • text

----


MODULE USER_COMMAND_0400 INPUT.

ENDMODULE. " USER_COMMAND_0400 INPUT

Hope this will definitely help u:

<b>Dont forget to reward points :-)</b>

Cheers,

Sachin

Read only

Former Member
0 Likes
1,089

hi sachin,

what i have to do in screen 100 200 300 400 itself..

regards,

kumar

Read only

Former Member
0 Likes
1,089

hi sachin ,

where should i create SS_CONTAINER and SP_CONTAINER ..

regards,

kumar

Read only

Former Member
0 Likes
1,089

you have to create them in the screen painter.

goto the layout of ur screen painter , then create one custom container

To do that on the left hand side there is one box to create that, last but ont button

Drag and drop that to ur screen and give the name as SS_CONTAINER

Read only

jayanthi_jayaraman
Active Contributor
0 Likes
1,089

Hi,

Before creating grid,you should create object for docking or custom container.

Give parent name as that object while creating object for ALV grid.

DATA : o_alvgrid TYPE REF TO cl_gui_alv_grid,

o_dockingcontainer TYPE REF TO cl_gui_docking_container.

CREATE OBJECT o_dockingcontainer

EXPORTING

ratio = '95'.

  • create the ALV grid with the docking container as the parent.

  • i.e. the Grid will be in the container.

CREATE OBJECT o_alvgrid

EXPORTING

i_parent = o_dockingcontainer.

Message was edited by:

Jayanthi Jayaraman

Read only

Former Member
0 Likes
1,089

Hi Kumar,

go through this program.

REPORT YSIMPLEALVINTERACTIVE .

TABLES : VBAK,VBAP,LIKP,VBRK,VTTK.

PARAMETERS : P_KUNNR LIKE VBAK-KUNNR.

SELECT-OPTIONS: S_VBELN FOR VBAK-VBELN,

S_ERDAT FOR VBAK-ERDAT.

DATA:WA TYPE YLINE22,

ITAB TYPE YROW22.

DATA : REPID LIKE SY-REPID,

CONTAINER TYPE SCRFNAME VALUE 'ALVCONTROL',

CUST TYPE REF TO CL_GUI_CUSTOM_CONTAINER,

GRID TYPE REF TO CL_GUI_ALV_GRID.

*CLASS DEFINITATION.

CLASS CL_GRID DEFINITION.

PUBLIC SECTION .

METHODS: DC FOR EVENT DOUBLE_CLICK OF CL_GUI_ALV_GRID IMPORTING

E_ROW E_COLUMN.

ENDCLASS. "

*CLASS IMPLEMENTATION.

CLASS CL_GRID IMPLEMENTATION.

METHOD DC.

DATA : WA1 TYPE YLINE22.

READ TABLE ITAB INDEX E_ROW-INDEX INTO WA1.

SET PARAMETER ID 'AVN' FIELD WA1-VBELN.

CALL TRANSACTION 'VA02' AND SKIP FIRST SCREEN .

ENDMETHOD. "DC

ENDCLASS. "CL_GRID IMPLEMENTATION

  • CALLING CLASS.

DATA : OBJ_CL_GRID TYPE REF TO CL_GRID.

START-OF-SELECTION.

PERFORM CALLSUB.

IF SY-SUBRC = 0.

CALL SCREEN 100.

ELSE.

MESSAGE I000(0) WITH 'no data for your salesorder'.

ENDIF.

&----


*& Module STATUS_0100 OUTPUT

&----


  • text

----


MODULE STATUS_0100 OUTPUT.

  • SET PF-STATUS 'xxxxxxxx'.

  • SET TITLEBAR 'xxx'.

REPID = SY-REPID.

IF CUST IS INITIAL.

CREATE OBJECT CUST EXPORTING CONTAINER_NAME = CONTAINER .

CREATE OBJECT GRID EXPORTING I_PARENT = CUST.

CALL METHOD GRID->SET_TABLE_FOR_FIRST_DISPLAY

EXPORTING

I_STRUCTURE_NAME = 'YLINE22'

CHANGING

IT_OUTTAB = ITAB.

CREATE OBJECT OBJ_CL_GRID.

SET HANDLER OBJ_CL_GRID->DC FOR GRID.

ENDIF.

ENDMODULE. " STATUS_0100 OUTPUT

FORM CALLSUB.

SELECT VBAPVBELN VBAPKWMENG VBAPNETWR LIPSERDAT VTTP~ERDAT

VBRK~FKDAT INTO TABLE ITAB FROM VBAK

INNER JOIN VBAP ON VBAKVBELN = VBAPVBELN INNER JOIN LIPS ON VBAP~VBELN

= LIPSVGBEL INNER JOIN VTTP ON LIPSVBELN = VTTP~VBELN INNER JOIN VBRP

ON LIPSVBELN = VBRPVGBEL INNER JOIN VBRK ON VBRKVBELN = VBRKVBELN

WHERE

VBAK~KUNNR = P_KUNNR AND

VBAKVBELN IN S_VBELN AND VBAKERDAT IN S_ERDAT.

ENDFORM. "CALL

&----


*& Module USER_COMMAND_0100 INPUT

&----


  • text

----


MODULE USER_COMMAND_0100 INPUT.

CASE SY-UCOMM.

WHEN'EXIT'.

LEAVE PROGRAM.

ENDCASE.

ENDMODULE.

Reword some points.

Regards,

P.Naganjana reddy