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

IF g_custom_container IS INITIAL

Former Member
0 Likes
1,456

IF g_custom_container IS INITIAL.

CREATE OBJECT g_custom_container

EXPORTING

CONTAINER_NAME = 'CCCONTAINER'.

CREATE OBJECT GRID1

EXPORTING

I_PARENT = g_custom_container.

ENDIF.

in the above code what for this line used.<b>

IF g_custom_container IS INITIAL</b>

and after excuting what is the value assigned to g_custom_container.

IF g_custom_container IS INITIAL.

CREATE OBJECT g_custom_container

EXPORTING

CONTAINER_NAME = 'CCCONTAINER'.

CREATE OBJECT GRID1

EXPORTING

I_PARENT = g_custom_container.

ENDIF.

in the above code what for this line used.<b>

IF g_custom_container IS INITIAL</b>

and after excuting what is the value assigned to g_custom_container.

6 REPLIES 6
Read only

Former Member
0 Likes
1,076

IF g_custom_container IS INITIAL .

This line is checking if the object g_custom_control has already been created or not. YOu shouldn't create an object if it is already there.

Regards,

Ravi

Read only

Former Member
0 Likes
1,076

If the container is created already it wont create it furtehr.

Eg: u remove teh IF condition and run ur report it will owrk, but when u click on the grid or scroll or do any operation again the outplut will get generated in the grid.

To avoid this <b>we have to do this check</b>.

Read only

Former Member
0 Likes
1,076

<b>and after excuting what is the value assigned to g_custom_container.</b>

g_custom_container will contain the reference to the container, debug and check the value

Read only

seshatalpasai_madala
Product and Topic Expert
Product and Topic Expert
0 Likes
1,076

Hi,

Since container object generally contains your CONTROL objects like ALV etc you should create this object only once. If you create it in every ntry to your PBO then a new container is getting created and you will see a fresh screen every time which is wrong since you are working on the previous screen that screen should be preserved means this container object should exist so you create once and use it every time till you exit the program.

<b>

and after excuting what is the value assigned to g_custom_container.</b>

In your screen you would have created a custom container you are passing the name of your custom container in this create object statement.

Regards,

sesh

Message was edited by:

Seshatalpasai Madala

Read only

Former Member
0 Likes
1,076

1.g_customer_conatiner is reference to to cl_gui_custom_container,

by putting a statement g_custom_container IS INITIAL,

a check is made that is memory is allocated to object g_customer_conatiner .

indirectly saying above statement checks whether it has been created or not.

If the memory already allocated then do not allocate/create it once again.

2. A momory location will be assigned to g_custom_container.

i.e. a area on screen will be allocated to g_customer_container.

then by ALV grid will be displayed in the container area by follwoing statements:-

CREATE OBJECT GRID1

EXPORTING

I_PARENT = g_custom_container

Read only

uwe_schieferstein
Active Contributor
0 Likes
1,076

Hello Pavan

The only thing that can be added to the previous answers is that there is a more <b>specific</b> ABAP statement available to check if an instance of a class is available:

  IF ( g_customer_container IS BOUND ).
* ... Container instance is already there -> do nothing 

  ELSE.
*  ... create the custom container instance
  ENDIF.

Regards

Uwe