‎2013 Sep 11 4:39 PM
Hi Friends,
Am displaying an ALV as shown below for ex.
| tables |
|---|
| mara |
| makt |
| marc |
| mvke |
on clicking on each table it should open a modal dialog box with any five fields from the corresponding table which is maintained as lt_mara, lt_makt, lt_marc etc.
generally we will display modal dialog box by creating screen fields in screen painter. for displaying 4 tables i need to create 4 different screens.
this is for sample scenario. but in my case the tables are not fixed i mean i may have 100 tables, so for each table i cant create screen painter. i want it to be dynamically create the screens which will have the respective internal table fields on the screen. please help me with this issue, and if you have not understand my question please do let me know.
‎2013 Sep 11 5:57 PM
Hi, I will try to help you.
Like you said, whatever the selected table, you want to display a fixed number of fields (5 as you said)?
If yes, you can create a modal screen with five CHAR fields and change it's attributes (text, length, matchcode) in PBO according to the selected table using LOOP AT SCREEN.
For it, use a generic workarea/table and after you move to the according internal table, considering the selected table name in the ALV.
‎2013 Sep 11 6:40 PM
Hi Heber,
again it is in dynamic, i dont know about how many fields will be there in my table, its dynamic.
‎2013 Sep 11 9:23 PM
http://scn.sap.com/message/6704538#6704538
Ok, in the above link you can find a way to build a complete dynamic screen using GENERATE DYNPRO statement, but this statement is not supported by SAP and it's purpose is for internal use only. That doesn't mean you can't use it, by the way.
Also, you can check tcode SE16 to see how it build screens very similar to your requirement.
‎2013 Sep 11 9:25 PM
Hi,
If it needs to be dynamic, then why don't you use on of the available ALV classes like cl_gui_alv_grid or cl_salv_table in your modal dialog screen. This will generate an ALV based on the data table that is passed to the object. It will be something like :
data :
lo_cont1 type ref to cl_gui_custom_container,
lo_alv type ref to cl_salv_table.
**Create container on modal screen
CREATE OBJECT lo_cont1
EXPORTING
container_name = 'CC_ALV1'.
**..Create ALV Grid in container
cl_salv_table=>factory( EXPORTING r_container = cont1
IMPORTING r_salv_table = lo_alv
CHANGING t_table = your_dynamic_table ).
lo_alv->display( ).
Regards,
Freek
‎2013 Sep 12 6:33 AM
Hi,
You can use RTTI i,e run time type identification to identify the line type of the table and then loop at it to display the fields.
example code :
type-pools: abap.
*Declare the type of the internal table
types: begin of x_final,
matnr type matnr,
werks type werks_d,
flag type c length 1,
value type p length 10 decimals 2,
end of x_final.
data:
*The Internal table whose components are to found
i_data type sorted table of x_final with unique key matnr,
*Table to hold the components
tab_return type abap_compdescr_tab,
*Work area for the component table
components like line of tab_return.
*Call Perform to get the Int. Table Components
perform get_int_table_fields using i_data
changing tab_return.
*Display Components
loop at tab_return into components.
write: / components-name, components-type_kind,
components-length,components-decimals.
endloop.
*&---------------------------------------------------------------------*
*& Form get_int_table_fields
*&---------------------------------------------------------------------*
* Get the Components of an internal table
*----------------------------------------------------------------------*
* -->T_DATA text
* -->T_RETURN text
*----------------------------------------------------------------------*
form get_int_table_fields using t_data type any table
changing t_return type abap_compdescr_tab.
data:
oref_table type ref to cl_abap_tabledescr,
oref_struc type ref to cl_abap_structdescr,
oref_error type ref to cx_root,
text type string.
*Get the description of data object type
try.
oref_table ?=
cl_abap_tabledescr=>describe_by_data( t_data ).
catch cx_root into oref_error.
text = oref_error->get_text( ).
write: / text.
exit.
endtry.
*Get the line type
try.
oref_struc ?= oref_table->get_table_line_type( ).
catch cx_root into oref_error.
text = oref_error->get_text( ).
write: / text.
exit.
endtry.
append lines of oref_struc->components to t_return.
endform. " GET_INT_TABLE_FIELDS
regards,
Ashish Rawat