Duplicate dynamic table in - cl_alv_table_create= create_dynamic_table
Hi Gurus,
I have done the following code, but it is not treating <alv_table> and <alv_table_new> as different tables.
How can I create a duplicate table of <alv_table> in the below context ??
DATA : ldtab TYPE REF TO data,
ldtab_NEW TYPE REF TO data.
FIELD-SYMBOLS: <alv_table> TYPE table,
<alv_table_NEW> TYPE table.
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = gt_fcat
IMPORTING
ep_table = ldtab.
IF sy-subrc = 0.
ldtab_new = ldtab.
ASSIGN ldtab->* TO <alv_table>.
ASSIGN ldtab_new->* TO <alv_table_new>.
ENDIF.
Regards,
Sandip.
hi,
Both field symbols i.e. <alv_table> and <alv_table_new> are pointing to same memory area because of the statements
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = gt_fcat
IMPORTING
ep_table = ldtab.
IF sy-subrc = 0.
ldtab_new = ldtab. <----
do not perform this step
ASSIGN ldtab->* TO <alv_table>.
ASSIGN ldtab_new->* TO <alv_table_new>.
endif.
instead write -
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = gt_fcat
IMPORTING
ep_table = ldtab.
IF sy-subrc = 0.
ASSIGN ldtab->* TO <alv_table>.
endif.
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = gt_fcat
IMPORTING
ep_table = ldtab_new.
IF sy-subrc = 0.
ASSIGN ldtab_new->* TO <alv_table_new>.
endif.
try the above mentioned code.
I hope this will resolve your issue.
Regards,
Sambaran Ray
Similar Messages
-
Global binding with duplicate, dynamic tables
Hi there,
Hope someone can give me a hand. I have a dynamic form that contains an invisible duplicate so that there will be two copies printed - one for the form filler and another for another dept. Only one field on the form changes on each copy -- the copy indentifier.
I have placed global binding for all fields on the "visible" form, so that the data will be ported into the invisible copy. However, there are two dynamic tables where the fields in the rows simply copy whatever is placed in the first row.
How do I (in the XML or Javascript) create a link so that each row's fields can contain different data and be copied to the invisible version?
Thanks in advance for your help.Yeah global binding won't work on repeating elements, you need to write a script to loop through the table and copy the data to another table.
Check out this sample:
http://www.assuredynamics.com/index.php/portfolio/duplicating-table-data/ -
Dynamic table with field type table
Hi,
I´m using "cl_alv_table_create=>create_dynamic_table" to create a dynamic table for ALV Grid.
But...I need to use colors in ALV, then I need to declare a field type LVC_S_SCOL in dynamic table from "cl_alv_table_create=>create_dynamic_table".
How can I declare this in fieldcat?
The code:
Creating dynamic table
DATA: table_agrup TYPE REF TO data,
line_agrup TYPE REF TO data.
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = t_fieldcat
IMPORTING
ep_table = table_agrup
EXCEPTIONS
generate_subpool_dir_full = 1
OTHERS = 2.
ASSIGN table_agrup->* TO .
Printing ALV
CALL METHOD obj_grid->set_table_for_first_display
EXPORTING
is_variant = w_variant
i_save = 'A'
is_layout = w_layout
CHANGING
it_outtab =
it_fieldcatalog = t_fieldcat
it_sort = t_sort
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.
Thanks.It is not possible with the METHOD cl_alv_table_create=>create_dynamic_table to include another table inside that newly generated table.
I have tried to do it with the code and I got the dynamic table created after at the end of the program.
In the code,
<DYN_TABLE> has same effect as your <table> variable
<DYN_WA> has same effect as your <HEADER>
REPORT ZTEST_NP_DYNAMIC.
DATA: DY_TABLE TYPE REF TO DATA,
DY_LINE TYPE REF TO DATA.
FIELD-SYMBOLS: <DYN_TABLE> TYPE STANDARD TABLE,
<DYN_WA>,
<DYN_FIELD>.
FIELD-SYMBOLS: <FS> TYPE ANY.
* To generate the Dyanmic table with the COLOR
DATA: LS_SOURCE TYPE STRING.
DATA: LT_SOURCE LIKE STANDARD TABLE OF LS_SOURCE WITH HEADER LINE.
DATA: L_NAME LIKE SY-REPID.
DATA: L_MESSAGE(240) TYPE C,
L_LINE TYPE I,
L_WORD(72) TYPE C.
DATA: L_FORM(30) TYPE C VALUE 'TABLE_CREATE'.
LT_SOURCE = 'REPORT ZTEST_SUBROUTINE_POOL.'.
APPEND LT_SOURCE.
LT_SOURCE = 'FORM TABLE_CREATE USING I_FS TYPE ANY.'.
APPEND LT_SOURCE.
LT_SOURCE = 'DATA: BEGIN OF LT_GENTAB OCCURS 0.'.
APPEND LT_SOURCE.
LT_SOURCE = 'DATA: BUKRS TYPE BUKRS. '.
APPEND LT_SOURCE.
LT_SOURCE = 'DATA: BKTXT TYPE BKTXT. '.
APPEND LT_SOURCE.
* you can add your fields here.....
LT_SOURCE = 'DATA: COLOR TYPE lvc_t_scol. '.
APPEND LT_SOURCE.
LT_SOURCE = 'DATA: END OF LT_GENTAB.'.
APPEND LT_SOURCE.
LT_SOURCE = 'DATA: POINTER TYPE REF TO DATA.'.
APPEND LT_SOURCE.
LT_SOURCE = 'CREATE DATA POINTER LIKE STANDARD TABLE OF LT_GENTAB.'.
APPEND LT_SOURCE.
LT_SOURCE = 'I_FS = POINTER.'.
APPEND LT_SOURCE.
LT_SOURCE = 'ENDFORM. '.
APPEND LT_SOURCE.
L_NAME = 'ZTEST_SUBROUTINE_POOL'.
CATCH SYSTEM-EXCEPTIONS GENERATE_SUBPOOL_DIR_FULL = 9.
GENERATE SUBROUTINE POOL LT_SOURCE NAME L_NAME
MESSAGE L_MESSAGE LINE L_LINE WORD L_WORD. "#EC CI_GENERATE
ENDCATCH.
IF NOT L_MESSAGE IS INITIAL.
MESSAGE E000(0K) WITH L_MESSAGE L_LINE L_WORD.
ENDIF.
ASSIGN DY_TABLE TO <FS>.
PERFORM (L_FORM) IN PROGRAM (L_NAME) USING <FS>.
ASSIGN DY_TABLE->* TO <DYN_TABLE>.
* Create dynamic work area and assign to FS
CREATE DATA DY_LINE LIKE LINE OF <DYN_TABLE>.
ASSIGN DY_LINE->* TO <DYN_WA>.
Write: 'bye'.
Regards,
Naimesh Patel -
Hello everybody,
im tried to create a dynamic table with cl_alv_table_create=>create_dynamic_table, but that doesnt work for the table i need. I need a table with a changing number of columns of type "type ref to CL_DD_INPUT_ELEMENT", but the fieldcat only takes normal Data-Types.
So my question is, is there any way to create a dynamic table or structure with components of type ref to CL_DD_INPUT_ELEMENT?
Thank you very much for any help.
CheersI generally use Factory methods of RTTS classes to create dynamic tables. Check my reply (Step 1) in this thread getting column headers dynamically from input parameters in alv..
-
Dear Expers
I created a ABAP with dynamic internal table using cl_alv_table_create=>create_dynamic_table more or less according to this example here:
cl_alv_table_create=>create_dynamic_table error
Now I need a second dynamic internal table in the same program. So in a first try I just process the same code a second time (copy+paste) with new variables and new fieldsymbols. But when the program runs and the method is called a second time there is this error: "LT_GENTAB-xyz has laready been declared 7 xyz".
I believe I must free/initialize/delete/undeclare LT_GENTAB before calling the method a second time. Can anybody tell me how to do that? Or is there any other advice on how to create 2 internal tables dynamically in the same program (if possible using the same approach)?
Many thanksHi,
Here is the sample code from the link in your message :
Filling a table for field declarations :
loop at it_details into wa_details.
clear wa_it_fldcat.
wa_it_fldcat-fieldname = wa_details-name .
wa_it_fldcat-datatype = wa_details-type_kind.
wa_it_fldcat-inttype = wa_details-type_kind.
wa_it_fldcat-intlen = wa_details-length.
wa_it_fldcat-decimals = wa_details-decimals.
append wa_it_fldcat to it_fldcat .
endloop.
Call the method for dynamic creation :
call method cl_alv_table_create=>create_dynamic_table
exporting
it_fieldcatalog = it_fldcat
importing
ep_table = new_table
I meant you didn't refresh table it_fldcat as you fields declaration table.
Did u refresh this table before your second copy code? -
Hi gurus i have a problem i have created a dinamic internal table but the lenght of the internal table fields is 10 i need longer fields
here is my code thanks
data: begin of it_campos OCCURS 0,
campo1(12) type c,
END OF it_campos.
do n times.
clear nocamptmp.
add 1 to incont.
CONDENSE incont NO-GAPS.
cont = incont.
CONCATENATE nocamp cont into nocamptmp.
wa_campos-campo1 = nocamptmp.
append wa_campos to it_campos.
enddo .
loop at it_campos into wa_campos.
t_fieldcat_wa-col_pos = SY-TABIX.
t_fieldcat_wa-fieldname = wa_campos-campo1.
APPEND t_fieldcat_wa TO t_fieldcat.
endloop .
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = t_fieldcat
IMPORTING
ep_table = tabla
EXCEPTIONS
GENERATE_SUBPOOL_DIR_FULL = 1
others = 2.
ASSIGN tabla->* TO <l_table>.
CREATE DATA ep_line LIKE LINE OF <l_table>.
all is fine but the fields of <l_table> are char(10) and my data is longer than 10 how can i increase the lenght of the table fields
any idea thanksModify the fieldcatalog accordingly for e.g.,
LOOP AT it_campos INTO wa_campos.
t_fieldcat_wa-col_pos = sy-tabix.
t_fieldcat_wa-fieldname = wa_campos-campo1.
t_fieldcat_wa-inttype = 'C'. " Character Type
t_fieldcat_wa-intlen = '50'. "50 character length
APPEND t_fieldcat_wa TO t_fieldcat.
ENDLOOP .
BR,
Suhas -
Table Type in cl_alv_table_create= create_dynamic_table
Hi guys,
The method create_dynamic_table from cl_alv_table_create has as exporting parameter a fielcatalog table. I want to insert a table type in this table, basically the field INTTYPE from LVC_S_FCAT can do that if u put the value 'h' in it. But I notice, that in method implementations all the cases are considered:
C
Character String
N
Character String with Digits Only
D
Date (Date: YYYYMMDD)
T
Time (Time: HHMMSS)
X
Byte Sequence (heXadecimal)
I
Integer number (4-byte integer with sign)
b
1-byte integer, integer number <= 254
s
2-byte integer, only for length field before LCHR or LRAW
P
Packed number
F
Floating point number to accuracy of 8 bytes
and other, but not 'h'.
Does anybody knows how create a dynamic table with a table type inside ? The table type has the structure from data dictionary lvc_t_scol.
Ionut.cl_alv_table_create=>create_dynamic_table( ) is no longer recommended to build dynamic tables.
RTTC classes are very intuitive and quite easy to maintain.
DATA:
gt_struct_fields TYPE cl_abap_structdescr=>component_table,
gwa_struct_field TYPE cl_abap_structdescr=>component.
DATA:
goref_table TYPE REF TO cl_abap_tabledescr,
gdref_table TYPE REF TO data.
FIELD-SYMBOLS <gt_dynamic> TYPE STANDARD TABLE.
TRY.
* f1 TYPE c LENGTH 10
gwa_struct_field-name = `F1`.
gwa_struct_field-type = cl_abap_elemdescr=>get_c( 10 ).
APPEND gwa_struct_field TO gt_struct_fields.
CLEAR gwa_struct_field.
* f2 TYPE bukrs
gwa_struct_field-name = `F2`.
gwa_struct_field-type ?= cl_abap_typedescr=>describe_by_name( `BUKRS` ).
APPEND gwa_struct_field TO gt_struct_fields.
CLEAR gwa_struct_field.
* f3 TYPE flighttab
gwa_struct_field-name = `F3`.
gwa_struct_field-type ?= cl_abap_typedescr=>describe_by_name( `FLIGHTTAB` ).
APPEND gwa_struct_field TO gt_struct_fields.
CLEAR gwa_struct_field.
* Use the structure object to build the table
goref_table = cl_abap_tabledescr=>get(
cl_abap_structdescr=>get( gt_struct_fields )
CREATE DATA gdref_table TYPE HANDLE goref_table.
ASSIGN gdref_table->* TO <gt_dynamic>.
CATCH ##no_handler
cx_sy_struct_creation
cx_parameter_invalid_range
cx_sy_table_creation.
ENDTRY.
BR,
Suhas -
Reference comp in dynamic internal table using CL_ALV_TABLE_CREATE
Hi,
I am using CL_ALV_TABLE_CREATE to create a dynamic internal table. Everything works fine, but there is one problem with it. How can i create a component in the internal table that is actually a REF TO a certain data type. i.e. later i would like to store a reference to some dataobj in this component of the internal table.
I cannot use cl_abap_*descr classes to create internal table because of some other reasons, otherwise it would have been easy to do it.
Any kind of help would be highly appreciated.
Thanks and best regards,
GhufranHi Ghufran,
I do have an idea about the class <b>CL_ALV_TABLE_CREATE</b> , but i have writen an exmaple code to create a Dynamic Iternal table, please have a look, it may help you
*& Report Z_DYNAMIC_INTERNALTABLE *
report z_dynamic_internaltable .
data: d_ref type ref to data,
d_ref2 type ref to data ,
i_alv_cat type table of lvc_s_fcat,
ls_alv_cat like line of i_alv_cat.
types tabname like dcobjdef-name .
parameter: p_tablen type tabname.
data: begin of itab occurs 0.
include structure dntab.
data: end of itab.
field-symbols : <f_fs> type table,
<f_fs1> type table,
<f_fs2> type any,
<f_fs3> type table,
<f_fs4> type any.
refresh itab.
call function 'NAMETAB_GET'
exporting
langu = sy-langu
tabname = p_tablen
tables
nametab = itab
exceptions
no_texts_found = 1.
loop at itab .
ls_alv_cat-fieldname = itab-fieldname.
ls_alv_cat-ref_table = p_tablen.
ls_alv_cat-ref_field = itab-fieldname.
append ls_alv_cat to i_alv_cat.
endloop.
internal table build
call method cl_alv_table_create=>create_dynamic_table
exporting it_fieldcatalog = i_alv_cat
importing ep_table = d_ref .
assign d_ref->* to <f_fs>.
select * from (p_tablen) into corresponding fields of table <f_fs>.
loop at <f_fs> assigning <f_fs2>.
assign itab-fieldname to <f_fs4>.
loop at itab.
write: / <f_fs4>.
endloop.
endloop.
Thanks
Sudheer -
Problem using DELETE ADJACENT DUPLICATES with dynamic table
Hello All,
In my program i have to delete duplicate records from dynamic table.
I tried using DELETE ADJACENT DUPLICATES FROM <DYN_TABLE> COMPARING <fieldname1> <fieldname2> but it fails in syntax check, then i tried like below:
DATA string type string.
string = '<fieldname1> <fieldname2>.........'.
DELETE ADJACENT DUPLICATES FROM <DYN_TABLE> COMPARING (string).
It also got failed at runtime.
Please suggest how can i achieve this....
Regards
Munish GargHi,
this code is worked truly.
You can try this.
Regards.
DATA itab LIKE STANDARD TABLE OF mard.
SELECT * FROM mard INTO TABLE itab UP TO 100 ROWS.
* You define max number of the field that you need
data : cmp01 TYPE string,
cmp02 TYPE string,
cmp03 TYPE string,
cmp04 TYPE string,
cmp05 TYPE string.
* You fill the fields that you need, others is clear.
cmp01 = 'MATNR'.
cmp02 = 'WERKS'.
CLEAR : cmp03,cmp04,cmp05.
SORT itab BY (cmp01) (cmp02) (cmp03) (cmp04) (cmp05).
DELETE ADJACENT DUPLICATES FROM itab COMPARING (cmp01) (cmp02) (cmp03)
(cmp04) (cmp05). -
Delete adjacent duplicates from dynamic table
Hi all,
How to do delete adjacent <tab> comparing f1 f2 f3 for a dynamic table.
Thx in advance
Edited by: Misha Denis on Feb 14, 2010 9:28 AM
Moderator message - Cross post locked
Edited by: Rob Burbank on Feb 14, 2010 3:45 PMyou can use a function GET_COMPONENT_LIST to get all the fields' name after the dynamic table generated. then you can use the field name in the statement "DELETE....COMPARE "
CALL FUNCTION 'GET_COMPONENT_LIST'
EXPORTING
program = SY-REPID
fieldname = THE_NAME_OF_THE_DYNAMIC_INTERNAL_TABLE
tables
components = ITAB
LOOP AT ITAB.
*ASSIGN THE ITAB-COMPNAME TO SOME VARIANTS:FIELD1,FIELD2,FIELD3.
ENDLOOP.
SORT THE_NAME_OF_THE_DYNAMIC_INTERNAL_TABLE BY FIELD1 FIELD2 FIELD3.
DELETE ADJACENT DUPLICATES FROM THE_NAME_OF_THE_DYNAMIC_INTERNAL_TABLE COMPARING FIELD1 FIELD2 FIELD3. -
How to show multiple dynamic tables on a single screen?
right now im displaying alv for singlr attribute of dimension.
eg for dimension PRODUCT attribute PROFITCENTER im displaying in alv when user executes it.
but the requirement is that multiple attributes can be there so multiple tables is to be displayed on a single screen.
User basically wants to see data of all attributes. if there are 10 attributes hee wants to see 10 tables as every attribute has a different table.
what i have achieved is below in snapshots. only one attribute table PRODUCT im able to display. since i believe multiple headers cant be displyed in alv so even if i display multiple dynamically populated tables on a single screen then it will be fine.
i have also ADDED my code below: ZMDREPORT
this report is for SAP BPC.
*& Report ZMDREPORT
REPORT zmdreport.
TABLES /1cpmb/bfrdp3rp.
DATA: gw_datatbl TYPE tabname,
gw_datatbl1 TYPE tabname,
gw_descrptbl TYPE tabname,
gw_attribute TYPE tabname.
DATA:
BEGIN OF gw_attr,
appset_id TYPE uja_dim_attr-appset_id,
dimension TYPE uja_dim_attr-dimension,
tech_name TYPE uja_dim_attr-tech_name,
attribute_name TYPE uja_dim_attr-attribute_name,
caption TYPE uja_dim_attr-caption,
END OF gw_attr,
gt_attr LIKE TABLE OF gw_attr.
DATA: gt_slis_fcat1 TYPE slis_t_fieldcat_alv,
gw_slis_fcat1 LIKE LINE OF gt_slis_fcat1.
DATA : gt_except TYPE TABLE OF zbpcbt007,
gw_except LIKE LINE OF gt_except,
gt_except_t TYPE TABLE OF zbpcbt007,
gt_attrib TYPE TABLE OF tabname,
gw_attrib LIKE LINE OF gt_attrib.
DATA: gr_r_ref TYPE REF TO data.
DATA:BEGIN OF gw_mdr,
appset_id TYPE uj_appset_id,
dimension TYPE uj_dim_name,
reasoncd TYPE zmdreason,
refdimension TYPE uj_dim_name,
attrib TYPE uj_attr_name,
END OF gw_mdr,
gt_mdr1 LIKE TABLE OF gw_mdr,
gt_mdr2 LIKE TABLE OF gw_mdr,
gt_mdtable1 TYPE zbpctt_attr,
gt_mdtable2 TYPE zbpctt_attr,
gw_mdtable2 LIKE LINE OF gt_mdtable2,
gt_mdtable3 TYPE zbpctt_attr,
gt_mdtable4 TYPE zbpctt_attr,
gw_mdtable4 LIKE LINE OF gt_mdtable4,
BEGIN OF gw_finalattr,
dim(32) TYPE c,
END OF gw_finalattr,
gt_finalattr LIKE TABLE OF gw_finalattr,
gt_tab1 LIKE TABLE OF gw_finalattr,
gw_tab1 LIKE LINE OF gt_tab1,
gt_tab2 LIKE TABLE OF gw_finalattr,
gw_tab2 LIKE LINE OF gt_tab2.
FIELD-SYMBOLS: <gfs_tab1> TYPE STANDARD TABLE.
FIELD-SYMBOLS: <gfs_tab2> TYPE STANDARD TABLE,
<gfs_tab3> TYPE STANDARD TABLE,
<gfs_tab4> TYPE STANDARD TABLE.
FIELD-SYMBOLS:<gfs_attr> TYPE any,
<gfs_field3> TYPE any,
<gfs_field4> TYPE any.
DATA: gw_sortcond TYPE string.
FIELD-SYMBOLS: <gfs_t_final> TYPE STANDARD TABLE.
FIELD-SYMBOLS: <gfs_final> TYPE any.
FIELD-SYMBOLS: <gfs_data> TYPE any .
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
PARAMETERS: p_env TYPE uja_dimension-appset_id OBLIGATORY.
PARAMETERS: p_dim TYPE uja_dimension-dimension OBLIGATORY.
SELECT-OPTIONS: s_member FOR /1cpmb/bfrdp3rp-mbr_name .
PARAMETERS: p_hir TYPE /1cpmb/bfrdp3rp-/cpmb/hir.
PARAMETERS:p_attr TYPE uj_attr_name MODIF ID m1.
SELECTION-SCREEN END OF BLOCK b1.
SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-002.
PARAMETERS: p_radio1 RADIOBUTTON GROUP g1 USER-COMMAND abc DEFAULT 'X',
p_radio2 RADIOBUTTON GROUP g1.
SELECTION-SCREEN END OF BLOCK b2.
SELECTION-SCREEN BEGIN OF BLOCK b3 WITH FRAME TITLE text-003.
PARAMETERS: p_reason TYPE zbpcbt007-reasoncd MODIF ID m1.
SELECTION-SCREEN END OF BLOCK b3.
*********************************************************************alv
DATA :gt_fcat TYPE lvc_t_fcat.
DATA: gw_ok_code TYPE sy-ucomm,
gw_okcode TYPE sy-ucomm.
DATA: go_custom_container TYPE REF TO cl_gui_custom_container,
gw_g_container TYPE scrfname VALUE 'CC1',
go_grid1 TYPE REF TO cl_gui_alv_grid.
DATA:BEGIN OF gw_table,
dimension TYPE uja_dimension-dimension,
END OF gw_table,
gt_tab LIKE TABLE OF gw_table ,
BEGIN OF gw_member,
mbr_name TYPE uj_dim_member,
END OF gw_member ,
gt_member LIKE TABLE OF gw_member,
BEGIN OF gw_hir ,
hir TYPE /1cpmb/bfrdp3rp-/cpmb/hir,
END OF gw_hir,
gt_hir LIKE TABLE OF gw_hir.
DATA:gt_slis_fcat2 TYPE slis_t_fieldcat_alv,
gw_slis_fcat2 LIKE LINE OF gt_slis_fcat2 .
DATA: lr_data TYPE REF TO data.
DATA :gt_fcat1 TYPE lvc_t_fcat,
gt_fcat2 TYPE lvc_t_fcat,
gt_fcat3 TYPE lvc_t_fcat,
gt_fcat2_t TYPE lvc_t_fcat,
gw_fcat LIKE LINE OF gt_fcat2,
gw_fcat3 LIKE LINE OF gt_fcat3.
DATA: gt_fcat3_t LIKE gt_fcat3.
DATA: gw_desc TYPE uj_desc.
DATA : gw_string TYPE string,
gw_str TYPE string.
DATA: gw_len TYPE string,
BEGIN OF gw_refdim,
dimension TYPE uja_dimension-dimension,
END OF gw_refdim,
gt_refdim LIKE TABLE OF gw_refdim,
gt_refdim_t LIKE TABLE OF gw_refdim,
BEGIN OF gw_refdata,
data_table TYPE tabname,
desc_table TYPE tabname,
END OF gw_refdata,
gt_refdata LIKE TABLE OF gw_refdata,
BEGIN OF gw_techattr,
tech_name TYPE uja_dim_attr-tech_name,
END OF gw_techattr,
gt_techattr LIKE TABLE OF gw_techattr,
gw_cond TYPE string.
DATA:gw_hircond TYPE string.
DATA: gt_dynpread TYPE TABLE OF dynpread,
gw_dynpread LIKE LINE OF gt_dynpread,
gw_dynpread2 LIKE LINE OF gt_dynpread,
gw_dim TYPE string,
gw_env TYPE string.
FIELD-SYMBOLS: <gfs_w_tab1> TYPE any,
<gfs_w_tab2> TYPE any,
<gfs_w_tab3> TYPE any,
<gfs_field> TYPE any,
<gfs_field2> TYPE any,
<gfs_field_final> TYPE any,
<gfs_s_fcat> TYPE lvc_s_fcat,
<gfs_s_fcat2> TYPE lvc_s_fcat,
<gfs_s_fcat3> TYPE lvc_s_fcat
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_dim.
REFRESH gt_dynpread.
gw_dynpread-fieldname = 'P_ENV'.
APPEND gw_dynpread TO gt_dynpread.
CALL FUNCTION 'DYNP_VALUES_READ'
EXPORTING
dyname = sy-repid
dynumb = sy-dynnr
* TRANSLATE_TO_UPPER = ' '
* REQUEST = ' '
* PERFORM_CONVERSION_EXITS = ' '
* PERFORM_INPUT_CONVERSION = ' '
* DETERMINE_LOOP_INDEX = ' '
* START_SEARCH_IN_CURRENT_SCREEN = 'X'
* start_search_in_main_screen = ' '
* START_SEARCH_IN_STACKED_SCREEN = ' '
* START_SEARCH_ON_SCR_STACKPOS = ' '
* SEARCH_OWN_SUBSCREENS_FIRST = ' '
* SEARCHPATH_OF_SUBSCREEN_AREAS = ' '
TABLES
dynpfields = gt_dynpread
EXCEPTIONS
invalid_abapworkarea = 1
invalid_dynprofield = 2
invalid_dynproname = 3
invalid_dynpronummer = 4
invalid_request = 5
no_fielddescription = 6
invalid_parameter = 7
undefind_error = 8
double_conversion = 9
stepl_not_found = 10
OTHERS = 11.
IF sy-subrc EQ 0.
READ TABLE gt_dynpread INTO gw_dynpread INDEX 1.
IF sy-subrc EQ 0.
TRY .
REFRESH gt_tab.
SELECT dimension
FROM uja_dimension CLIENT SPECIFIED
INTO TABLE gt_tab
WHERE mandt EQ sy-mandt
AND appset_id EQ gw_dynpread-fieldvalue.
IF sy-subrc EQ 0.
SORT gt_tab BY dimension.
DELETE ADJACENT DUPLICATES FROM gt_tab COMPARING dimension.
IF gt_tab IS NOT INITIAL.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST' "#EC CI_SUBRC
EXPORTING
* DDIC_STRUCTURE = ''
retfield = 'DIMENSION'
* PVALKEY = ' '
dynpprog = sy-repid
dynpnr = sy-dynnr
dynprofield = 'P_DIM'(004)
* STEPL = 0
* WINDOW_TITLE =
* VALUE = ' '
value_org = 'S'
* MULTIPLE_CHOICE = ' '
* display = ''
* CALLBACK_PROGRAM = ' '
* CALLBACK_FORM = ' '
* CALLBACK_METHOD =
* MARK_TAB =
* IMPORTING
* USER_RESET =
TABLES
value_tab = gt_tab
* FIELD_TAB =
* RETURN_TAB =
* DYNPFLD_MAPPING =
EXCEPTIONS
parameter_error = 1
no_values_found = 2
OTHERS = 3
IF sy-subrc NE 0.
ENDIF.
ENDIF.
ENDIF.
CATCH cx_root.
ENDTRY.
ENDIF.
ENDIF.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_member-low.
REFRESH gt_dynpread.
gw_dynpread-fieldname = 'P_ENV'.
APPEND gw_dynpread TO gt_dynpread.
gw_dynpread-fieldname = 'P_DIM'.
APPEND gw_dynpread TO gt_dynpread.
CALL FUNCTION 'DYNP_VALUES_READ'
EXPORTING
dyname = sy-repid
dynumb = sy-dynnr
* TRANSLATE_TO_UPPER = ' '
* REQUEST = ' '
* PERFORM_CONVERSION_EXITS = ' '
* PERFORM_INPUT_CONVERSION = ' '
* DETERMINE_LOOP_INDEX = ' '
* START_SEARCH_IN_CURRENT_SCREEN = 'X'
* start_search_in_main_screen = ' '
* START_SEARCH_IN_STACKED_SCREEN = ' '
* START_SEARCH_ON_SCR_STACKPOS = ' '
* SEARCH_OWN_SUBSCREENS_FIRST = ' '
* SEARCHPATH_OF_SUBSCREEN_AREAS = ' '
TABLES
dynpfields = gt_dynpread
EXCEPTIONS
invalid_abapworkarea = 1
invalid_dynprofield = 2
invalid_dynproname = 3
invalid_dynpronummer = 4
invalid_request = 5
no_fielddescription = 6
invalid_parameter = 7
undefind_error = 8
double_conversion = 9
stepl_not_found = 10
OTHERS = 11.
IF sy-subrc EQ 0.
SORT gt_dynpread BY fieldname.
DELETE ADJACENT DUPLICATES FROM gt_dynpread COMPARING fieldname.
IF gt_dynpread IS NOT INITIAL.
LOOP AT gt_dynpread INTO gw_dynpread.
IF gw_dynpread-fieldname EQ 'P_ENV'.
gw_env = gw_dynpread-fieldvalue.
ELSEIF gw_dynpread-fieldname EQ 'P_DIM'.
gw_dim = gw_dynpread-fieldvalue.
ENDIF.
ENDLOOP.
IF sy-subrc EQ 0.
CLEAR: gw_datatbl1, gt_member.
SELECT SINGLE data_table
INTO (gw_datatbl1)
FROM uja_dimension CLIENT SPECIFIED
WHERE mandt EQ sy-mandt
AND appset_id EQ gw_env
AND dimension EQ gw_dim.
IF sy-subrc EQ 0.
TRY .
REFRESH gt_member.
SELECT mbr_name
INTO TABLE gt_member
FROM (gw_datatbl1) CLIENT SPECIFIED
WHERE mandt EQ sy-mandt .
IF sy-subrc EQ 0.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
* DDIC_STRUCTURE = ' '
retfield = 'MBR_NAME'
* PVALKEY = ' '
dynpprog = sy-repid
dynpnr = sy-dynnr
dynprofield = 'S_MEMBER'
* STEPL = 0
* WINDOW_TITLE =
* VALUE = ' '
value_org = 'S'
* MULTIPLE_CHOICE = ' '
* DISPLAY = ' '
callback_program = sy-repid
callback_form = 'F4CALLBACK'
* CALLBACK_METHOD =
* MARK_TAB =
* IMPORTING
* USER_RESET =
TABLES
value_tab = gt_member
* FIELD_TAB =
* RETURN_TAB =
* DYNPFLD_MAPPING =
EXCEPTIONS
parameter_error = 1
no_values_found = 2
OTHERS = 3
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
ENDIF.
CATCH cx_root.
ENDTRY.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_member-high.
REFRESH gt_dynpread.
gw_dynpread-fieldname = 'P_ENV'.
APPEND gw_dynpread TO gt_dynpread.
gw_dynpread-fieldname = 'P_DIM'.
APPEND gw_dynpread TO gt_dynpread.
CALL FUNCTION 'DYNP_VALUES_READ'
EXPORTING
dyname = sy-repid
dynumb = sy-dynnr
* TRANSLATE_TO_UPPER = ' '
* REQUEST = ' '
* PERFORM_CONVERSION_EXITS = ' '
* PERFORM_INPUT_CONVERSION = ' '
* DETERMINE_LOOP_INDEX = ' '
* START_SEARCH_IN_CURRENT_SCREEN = 'X'
* start_search_in_main_screen = ' '
* START_SEARCH_IN_STACKED_SCREEN = ' '
* START_SEARCH_ON_SCR_STACKPOS = ' '
* SEARCH_OWN_SUBSCREENS_FIRST = ' '
* SEARCHPATH_OF_SUBSCREEN_AREAS = ' '
TABLES
dynpfields = gt_dynpread
EXCEPTIONS
invalid_abapworkarea = 1
invalid_dynprofield = 2
invalid_dynproname = 3
invalid_dynpronummer = 4
invalid_request = 5
no_fielddescription = 6
invalid_parameter = 7
undefind_error = 8
double_conversion = 9
stepl_not_found = 10
OTHERS = 11.
IF sy-subrc EQ 0.
SORT gt_dynpread BY fieldname.
DELETE ADJACENT DUPLICATES FROM gt_dynpread COMPARING fieldname.
IF gt_dynpread IS NOT INITIAL.
LOOP AT gt_dynpread INTO gw_dynpread.
IF gw_dynpread-fieldname EQ 'P_ENV'.
gw_env = gw_dynpread-fieldvalue.
ELSEIF gw_dynpread-fieldname EQ 'P_DIM'.
gw_dim = gw_dynpread-fieldvalue.
ENDIF.
ENDLOOP.
IF sy-subrc EQ 0.
CLEAR: gw_datatbl1.
SELECT SINGLE data_table
INTO (gw_datatbl1)
FROM uja_dimension CLIENT SPECIFIED
WHERE mandt EQ sy-mandt
AND appset_id EQ gw_env
AND dimension EQ gw_dim.
IF sy-subrc EQ 0.
TRY .
REFRESH gt_member.
SELECT mbr_name
INTO TABLE gt_member
FROM (gw_datatbl1) CLIENT SPECIFIED
WHERE mandt EQ sy-mandt.
IF sy-subrc EQ 0.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
* DDIC_STRUCTURE = ' '
retfield = 'MBR_NAME'
* PVALKEY = ' '
dynpprog = sy-repid
dynpnr = sy-dynnr
dynprofield = 'S_MEMBER'
* STEPL = 0
* WINDOW_TITLE =
* VALUE = ' '
value_org = 'S'
* MULTIPLE_CHOICE = ' '
* DISPLAY = ' '
callback_program = sy-repid
callback_form = 'F4CALLBACK'
* CALLBACK_METHOD =
* MARK_TAB =
* IMPORTING
* USER_RESET =
TABLES
value_tab = gt_member
* FIELD_TAB =
* RETURN_TAB =
* DYNPFLD_MAPPING =
EXCEPTIONS
parameter_error = 1
no_values_found = 2
OTHERS = 3
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
ENDIF.
CATCH cx_root.
ENDTRY.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
*& Form F4CALLBACK
* text
* -->RECORD_TAB text
* -->SHLP text
* -->CALLCONTROL text
FORM f4callback TABLES record_tab STRUCTURE seahlpres
CHANGING shlp TYPE shlp_descr
callcontrol TYPE ddshf4ctrl.
callcontrol-no_maxdisp = ''.
ENDFORM. "F4CALLBACK
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_hir.
REFRESH gt_dynpread.
CLEAR gw_dynpread.
gw_dynpread-fieldname = 'P_ENV'.
APPEND gw_dynpread TO gt_dynpread.
gw_dynpread-fieldname = 'P_DIM'.
APPEND gw_dynpread TO gt_dynpread.
CALL FUNCTION 'DYNP_VALUES_READ'
EXPORTING
dyname = sy-repid
dynumb = sy-dynnr
* TRANSLATE_TO_UPPER = ' '
* REQUEST = ' '
* PERFORM_CONVERSION_EXITS = ' '
* PERFORM_INPUT_CONVERSION = ' '
* DETERMINE_LOOP_INDEX = ' '
* START_SEARCH_IN_CURRENT_SCREEN = 'X'
* start_search_in_main_screen = ' '
* START_SEARCH_IN_STACKED_SCREEN = ' '
* START_SEARCH_ON_SCR_STACKPOS = ' '
* SEARCH_OWN_SUBSCREENS_FIRST = ' '
* SEARCHPATH_OF_SUBSCREEN_AREAS = ' '
TABLES
dynpfields = gt_dynpread
EXCEPTIONS
invalid_abapworkarea = 1
invalid_dynprofield = 2
invalid_dynproname = 3
invalid_dynpronummer = 4
invalid_request = 5
no_fielddescription = 6
invalid_parameter = 7
undefind_error = 8
double_conversion = 9
stepl_not_found = 10
OTHERS = 11.
IF sy-subrc EQ 0.
SORT gt_dynpread BY fieldname.
DELETE ADJACENT DUPLICATES FROM gt_dynpread COMPARING fieldname.
LOOP AT gt_dynpread INTO gw_dynpread.
IF gw_dynpread-fieldname EQ 'P_ENV'.
gw_env = gw_dynpread-fieldvalue.
ELSEIF gw_dynpread-fieldname EQ 'P_DIM'.
gw_dim = gw_dynpread-fieldvalue.
ENDIF.
ENDLOOP.
IF sy-subrc EQ 0.
CLEAR: gw_datatbl1.
SELECT SINGLE data_table
INTO (gw_datatbl1)
FROM uja_dimension CLIENT SPECIFIED
WHERE mandt EQ sy-mandt
AND appset_id EQ gw_env
AND dimension EQ gw_dim.
IF sy-subrc EQ 0.
REFRESH gt_member.
TRY .
SELECT /cpmb/hir
INTO TABLE gt_hir
FROM (gw_datatbl1) CLIENT SPECIFIED
WHERE mandt EQ sy-mandt.
IF sy-subrc EQ 0.
SORT gt_hir BY hir.
DELETE ADJACENT DUPLICATES FROM gt_hir COMPARING hir.
IF gt_hir IS NOT INITIAL.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
* DDIC_STRUCTURE = ' '
retfield = '/CPMB/HIR'
* PVALKEY = ' '
dynpprog = sy-repid
dynpnr = sy-dynnr
dynprofield = 'P_HIR'
* STEPL = 0
* WINDOW_TITLE =
* VALUE = ' '
value_org = 'S'
* MULTIPLE_CHOICE = ' '
* DISPLAY = ' '
* CALLBACK_PROGRAM = ' '
* CALLBACK_FORM = ' '
* CALLBACK_METHOD =
* MARK_TAB =
* IMPORTING
* USER_RESET =
TABLES
value_tab = gt_hir
* FIELD_TAB =
* RETURN_TAB =
* DYNPFLD_MAPPING =
EXCEPTIONS
parameter_error = 1
no_values_found = 2
OTHERS = 3
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
ENDIF.
ENDIF.
CATCH cx_root.
ENDTRY.
ENDIF.
ENDIF.
ENDIF.
* CLASS lcl_main DEFINITION
CLASS lcl_main DEFINITION.
PUBLIC SECTION.
CLASS-METHODS:
create_alv1,
create_alv2,
create_alv3,
create_fieldcatalog,
create_dynamicalv,
merge_tables,
show_alv1
ENDCLASS. "lcl_main DEFINITION
* CLASS lcl_main IMPLEMENTATION
CLASS lcl_main IMPLEMENTATION.
METHOD create_fieldcatalog.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE' "#EC CI_SUBRC
EXPORTING
i_structure_name = gw_datatbl
CHANGING
ct_fieldcat = gt_fcat1
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE' "#EC CI_SUBRC
EXPORTING
i_structure_name = gw_descrptbl
CHANGING
ct_fieldcat = gt_fcat2
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
ENDMETHOD. "create_fieldcatalog
METHOD create_dynamicalv.
* DATA: lr_data TYPE REF TO data.
CLEAR lr_data.
CALL METHOD cl_alv_table_create=>create_dynamic_table
"#EC CI_SUBRC
EXPORTING
* i_style_table =
it_fieldcatalog = gt_fcat2
* i_length_in_byte =
IMPORTING
ep_table = lr_data
* e_style_fname =
EXCEPTIONS
generate_subpool_dir_full = 1
OTHERS = 2.
IF sy-subrc <> 0.
*MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDMETHOD. "create_dynamicalv
METHOD merge_tables.
SORT gt_fcat2 BY col_pos.
ASSIGN lr_data->* TO <gfs_t_final>.
LOOP AT <gfs_tab1> ASSIGNING <gfs_w_tab1>.
APPEND INITIAL LINE TO <gfs_t_final> ASSIGNING <gfs_final>.
LOOP AT gt_fcat2 ASSIGNING <gfs_s_fcat>. "#EC CI_NESTED
ASSIGN COMPONENT <gfs_s_fcat>-fieldname OF STRUCTURE
<gfs_w_tab1> TO <gfs_field>.
IF sy-subrc EQ 0 AND <gfs_field> IS ASSIGNED.
ASSIGN COMPONENT <gfs_s_fcat>-fieldname OF STRUCTURE
<gfs_final> TO <gfs_field_final>.
IF sy-subrc EQ 0 AND <gfs_field_final> IS ASSIGNED.
<gfs_field_final> = <gfs_field>.
ENDIF.
*** Creating dynamic where clause for the key fields
IF <gfs_s_fcat>-key = 'X'.
READ TABLE gt_fcat2_t ASSIGNING <gfs_s_fcat2>
WITH KEY
key = abap_true
fieldname = <gfs_s_fcat>-fieldname.
IF sy-subrc EQ 0.
IF gw_string IS INITIAL.
*Putting value into quotes
CONCATENATE `'` <gfs_field> `'` INTO gw_str.
*Concatenating first field into string
CONCATENATE <gfs_s_fcat>-fieldname '=' gw_str
INTO gw_string SEPARATED BY space.
CLEAR gw_str.
ELSE.
*Concatenating rest all key fields
CONCATENATE `'` <gfs_field> `'` INTO gw_str.
CONCATENATE gw_string 'AND' <gfs_s_fcat>-fieldname
'=' gw_str INTO gw_string SEPARATED BY space.
CLEAR gw_str.
ENDIF.
ENDIF.
*** End of Creation
ENDIF.
ENDIF.
ENDLOOP.
IF NOT gw_string IS INITIAL.
*Concatenating sy-langu (-> always present)
CONCATENATE gw_string 'AND LANGU = SY-LANGU'
INTO gw_string SEPARATED BY space.
ENDIF.
*** Filling Description field based on dynamically created where clause
LOOP AT <gfs_tab2> ASSIGNING <gfs_w_tab2> WHERE (gw_string).
"#EC CI_NESTED
ASSIGN COMPONENT 'TXTLG' OF STRUCTURE <gfs_w_tab2>
TO <gfs_field>.
IF sy-subrc EQ 0 AND <gfs_field> IS ASSIGNED.
ASSIGN COMPONENT 'TXTLG' OF STRUCTURE <gfs_final>
TO <gfs_field_final>.
IF sy-subrc EQ 0 AND <gfs_field_final> IS ASSIGNED.
<gfs_field_final> = <gfs_field>.
ENDIF.
ENDIF.
ENDLOOP.
CLEAR gw_string.
ENDLOOP.
ENDMETHOD. "merge_tables
METHOD create_alv3.
CREATE DATA gr_r_ref TYPE TABLE OF (gw_datatbl).
ASSIGN gr_r_ref->* TO <gfs_tab1>.
SELECT *
INTO TABLE <gfs_tab1>
FROM (gw_datatbl) CLIENT SPECIFIED
WHERE mandt EQ sy-mandt
AND mbr_name IN s_member
AND /cpmb/calc EQ 'N'.
IF sy-subrc EQ 0.
IF p_hir IS NOT INITIAL.
CLEAR gw_hircond.
CONCATENATE '/CPMB/HIR' 'NE' 'P_HIR' INTO gw_hircond
SEPARATED BY space.
DELETE <gfs_tab1> WHERE (gw_hircond).
ENDIF.
CLEAR: gr_r_ref.
CREATE DATA gr_r_ref TYPE TABLE OF (gw_descrptbl).
ASSIGN gr_r_ref->* TO <gfs_tab2>.
SELECT *
FROM (gw_descrptbl) CLIENT SPECIFIED
INTO TABLE <gfs_tab2>
WHERE mandt EQ sy-mandt
AND langu EQ sy-langu.
IF sy-subrc EQ 0.
READ TABLE gt_refdata INTO gw_refdata INDEX 1.
IF sy-subrc EQ 0.
CLEAR gr_r_ref.
CREATE DATA gr_r_ref TYPE TABLE OF (gw_refdata-data_table).
ASSIGN gr_r_ref->* TO <gfs_tab3>.
SELECT *
INTO TABLE <gfs_tab3>
FROM (gw_refdata-data_table) CLIENT SPECIFIED
WHERE mandt EQ sy-mandt
AND /cpmb/calc EQ 'N'.
IF sy-subrc EQ 0.
CLEAR gr_r_ref.
CREATE DATA gr_r_ref TYPE TABLE OF (gw_refdata-desc_table).
ASSIGN gr_r_ref->* TO <gfs_tab4>.
SELECT *
INTO TABLE <gfs_tab4>
FROM (gw_refdata-desc_table) CLIENT SPECIFIED
WHERE mandt EQ sy-mandt
AND langu EQ sy-langu.
lcl_main=>create_fieldcatalog( ).
gt_fcat2_t[] = gt_fcat2[].
DELETE gt_fcat2 WHERE fieldname NE 'TXTLG'.
APPEND LINES OF gt_fcat1 TO gt_fcat2.
gw_len = lines( gt_fcat2 ).
gw_len = gw_len + 1.
gw_fcat-fieldname = 'TXTLG1'.
gw_fcat-reptext = 'Attribute Description'.
gw_fcat-col_pos = gw_len.
gw_fcat-outputlen = 60.
APPEND gw_fcat TO gt_fcat2.
SORT gt_fcat2 BY fieldname.
READ TABLE gt_techattr INTO gw_techattr INDEX 1.
LOOP AT gt_fcat2 INTO gw_fcat.
READ TABLE gt_attr INTO gw_attr
WITH KEY tech_name = gw_fcat-fieldname.
IF sy-subrc EQ 0.
gw_fcat-reptext = gw_attr-caption.
ENDIF.
IF gw_fcat-fieldname = 'TXTLG'.
gw_fcat-outputlen = 60.
ENDIF.
MODIFY gt_fcat2 FROM gw_fcat TRANSPORTING
outputlen reptext .
IF gw_fcat-fieldname NE 'MBR_NAME'
AND gw_fcat-fieldname NE 'TXTLG'
AND gw_fcat-fieldname NE 'TXTLG1'
AND gw_fcat-fieldname NE gw_techattr-tech_name."gw_attrib.
gw_fcat-no_out = 'X'.
MODIFY gt_fcat2 FROM gw_fcat TRANSPORTING no_out.
ENDIF.
ENDLOOP.
lcl_main=>create_dynamicalv( ).
lcl_main=>merge_tables( ).
CLEAR gw_cond.
READ TABLE gt_techattr INTO gw_techattr INDEX 1.
* CONCATENATE 'MBR_NAME =' '<Gfs_field>' INTO Gw_cond
* SEPARATED BY space.
TRANSLATE gw_techattr-tech_name TO UPPER CASE.
CONCATENATE `'` gw_techattr-tech_name `'`
'=' '<Gfs_field>' INTO gw_cond
SEPARATED BY space.
CHECK NOT <gfs_t_final> IS INITIAL.
SORT <gfs_t_final> BY (gw_techattr-tech_name).
LOOP AT <gfs_tab3> ASSIGNING <gfs_w_tab3>.
ASSIGN COMPONENT 'MBR_NAME' OF STRUCTURE <gfs_w_tab3>
TO <gfs_field>.
IF sy-subrc EQ 0 AND <gfs_field> IS ASSIGNED.
DELETE <gfs_t_final> WHERE (gw_cond).
ENDIF.
IF <gfs_t_final> IS INITIAL.
EXIT.
ENDIF.
ENDLOOP.
*adding attribute description
DATA gw_cond1 TYPE string.
DATA gw_cond2 TYPE string.
CLEAR gw_cond1.
CONCATENATE `'` gw_techattr-tech_name `'` 'eq' '<gfs_field>'
INTO gw_cond1 SEPARATED BY space.
CLEAR gw_cond2.
CONCATENATE 'TXTLG1' 'eq' 'SPACE'
INTO gw_cond2 SEPARATED BY space.
CLEAR gw_cond.
CONCATENATE 'TXTLG' 'NE' 'SPACE' INTO gw_cond SEPARATED BY
space.
gw_sortcond = 'TXTLG'.
SORT <gfs_tab4> BY (gw_sortcond).
LOOP AT <gfs_t_final> ASSIGNING <gfs_final> WHERE
(gw_cond2).
ASSIGN COMPONENT gw_techattr-tech_name OF STRUCTURE
<gfs_final> TO <gfs_field>.
IF sy-subrc EQ 0 AND <gfs_field> IS ASSIGNED.
ASSIGN COMPONENT 'TXTLG1' OF STRUCTURE
<gfs_final> TO <gfs_field4>.
IF sy-subrc EQ 0 AND <gfs_field4> IS ASSIGNED.
LOOP AT <gfs_tab4> ASSIGNING <gfs_attr>
WHERE (gw_cond).
ASSIGN COMPONENT 2 OF STRUCTURE <gfs_attr> TO
<gfs_field2>.
IF sy-subrc EQ 0 AND <gfs_field2> IS ASSIGNED.
ASSIGN COMPONENT 5 OF STRUCTURE <gfs_attr>
TO <gfs_field3>.
IF sy-subrc EQ 0 AND <gfs_field3> IS ASSIGNED.
IF <gfs_field> EQ <gfs_field2>.
<gfs_field4> = <gfs_field3>.
MODIFY <gfs_t_final> FROM <gfs_final>
TRANSPORTING ('TXTLG1') WHERE (gw_cond1).
EXIT.
ENDIF.
ENDIF.
ENDIF.
ENDLOOP.
ENDIF.
ENDIF.
ENDLOOP.
* LOOP AT <gfs_tab4> ASSIGNING <gfs_attr> WHERE (gw_cond) .
* ASSIGN COMPONENT 2 OF STRUCTURE <gfs_attr> TO
* <gfs_field2>.
* IF sy-subrc EQ 0 AND <gfs_field2> IS ASSIGNED.
* ASSIGN COMPONENT 5 OF STRUCTURE <gfs_attr> TO
* <gfs_field3>.
* IF sy-subrc EQ 0 AND <gfs_field3> IS ASSIGNED.
* LOOP AT <gfs_t_final> ASSIGNING <gfs_final>
* WHERE (gw_cond2).
* ASSIGN COMPONENT gw_techattr-tech_name OF STRUCTURE
* <gfs_final> TO <gfs_field>.
* IF sy-subrc EQ 0 AND <gfs_field> IS ASSIGNED.
* ASSIGN COMPONENT 'TXTLG1' OF STRUCTURE <gfs_final>
* TO <gfs_field4>.
* IF sy-subrc EQ 0 AND <gfs_field4> IS ASSIGNED.
* IF <gfs_field> EQ <gfs_field2>.
* <gfs_field4> = <gfs_field3>.
* MODIFY <gfs_t_final> FROM <gfs_final>
* TRANSPORTING ('TXTLG1') WHERE (gw_cond1).
* EXIT.
* ENDIF.
* ENDIF.
* ENDIF.
* ENDLOOP.
* ENDIF.
* ENDIF.
* ENDLOOP.
IF <gfs_t_final> IS NOT INITIAL.
CALL SCREEN 9000.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDMETHOD. "create_alv3
METHOD create_alv2.
READ TABLE gt_techattr INTO gw_techattr INDEX 1.
CONCATENATE gw_techattr-tech_name 'EQ' 'space' INTO gw_cond
SEPARATED
BY
space.
CREATE DATA gr_r_ref TYPE TABLE OF (gw_datatbl).
ASSIGN gr_r_ref->* TO <gfs_tab1>.
SELECT *
INTO TABLE <gfs_tab1>
FROM (gw_datatbl) CLIENT SPECIFIED
WHERE mandt EQ sy-mandt
AND mbr_name IN s_member
AND /cpmb/calc EQ 'N'
AND (gw_cond).
IF sy-subrc EQ 0.
IF p_hir IS NOT INITIAL.
CLEAR gw_hircond.
CONCATENATE '/CPMB/HIR' 'NE' 'P_HIR' INTO gw_hircond
SEPARATED BY space.
DELETE <gfs_tab1> WHERE (gw_hircond).
ENDIF.
CLEAR: gr_r_ref.
CREATE DATA gr_r_ref TYPE TABLE OF (gw_descrptbl).
ASSIGN gr_r_ref->* TO <gfs_tab2>.
SELECT *
FROM (gw_descrptbl) CLIENT SPECIFIED
INTO TABLE <gfs_tab2>
WHERE mandt EQ sy-mandt
AND langu EQ sy-langu.
IF sy-subrc EQ 0.
lcl_main=>create_fieldcatalog( ).
gt_fcat2_t[] = gt_fcat2[].
DELETE gt_fcat2 WHERE fieldname NE 'TXTLG'.
APPEND LINES OF gt_fcat1 TO gt_fcat2.
SORT gt_fcat2 BY fieldname.
LOOP AT gt_fcat2 INTO gw_fcat.
READ TABLE gt_attr INTO gw_attr WITH KEY
tech_name = gw_fcat-fieldname.
IF sy-subrc EQ 0.
gw_fcat-reptext = gw_attr-caption.
ENDIF.
IF gw_fcat-fieldname = 'TXTLG'.
gw_fcat-outputlen = 60.
ENDIF.
MODIFY gt_fcat2 FROM gw_fcat TRANSPORTING outputlen reptext.
* READ TABLE gt_attrib INTO gw_attrib INDEX 1.
* IF sy-subrc EQ 0.
IF gw_fcat-fieldname NE 'MBR_NAME'
AND gw_fcat-fieldname NE 'TXTLG'
AND gw_fcat-fieldname NE gw_techattr-tech_name."gw_attrib.
gw_fcat-no_out = 'X'.
MODIFY gt_fcat2 FROM gw_fcat TRANSPORTING no_out.
ENDIF.
* ENDIF.
ENDLOOP.
lcl_main=>create_dynamicalv( ).
lcl_main=>merge_tables( ).
CHECK NOT <gfs_t_final> IS INITIAL.
SORT <gfs_t_final> BY ('MBR_NAME').
CALL SCREEN 9000.
ENDIF.
ENDIF.
ENDMETHOD. "create_alv2
METHOD create_alv1.
CREATE DATA gr_r_ref TYPE TABLE OF (gw_datatbl).
ASSIGN gr_r_ref->* TO <gfs_tab1>.
SELECT *
FROM (gw_datatbl) CLIENT SPECIFIED
INTO TABLE <gfs_tab1>
WHERE mandt EQ sy-mandt
AND mbr_name IN s_member.
IF sy-subrc EQ 0.
IF p_hir IS NOT INITIAL.
CLEAR gw_hircond.
CONCATENATE '/CPMB/HIR' 'NE' 'P_HIR'
INTO gw_hircond SEPARATED BY
space.
DELETE <gfs_tab1> WHERE (gw_hircond).
ENDIF.
CLEAR: gr_r_ref.
CREATE DATA gr_r_ref TYPE TABLE OF (gw_descrptbl).
ASSIGN gr_r_ref->* TO <gfs_tab2>.
SELECT *
FROM (gw_descrptbl) CLIENT SPECIFIED
INTO TABLE <gfs_tab2>
WHERE mandt EQ sy-mandt
AND langu EQ sy-langu.
IF sy-subrc EQ 0.
lcl_main=>create_fieldcatalog( ).
SORT gt_fcat2 BY col_pos fieldname.
gt_fcat2_t[] = gt_fcat2[].
DELETE gt_fcat2 WHERE fieldname NE 'TXTLG'.
APPEND LINES OF gt_fcat1 TO gt_fcat2.
SORT gt_fcat2 BY fieldname.
SORT gt_attr BY tech_name.
LOOP AT gt_fcat2 INTO gw_fcat .
IF gw_fcat-reptext IS INITIAL.
READ TABLE gt_attr INTO gw_attr
WITH KEY tech_name = gw_fcat-fieldname BINARY SEARCH.
IF sy-subrc EQ 0.
gw_fcat-reptext = gw_attr-caption.
ELSE.
gw_fcat-reptext = gw_fcat-fieldname.
ENDIF.
ENDIF.
IF gw_fcat-fieldname EQ 'OBJVERS'.
gw_fcat-no_out = 'X'.
ELSEIF gw_fcat-fieldname EQ 'ROWFLAG'.
gw_fcat-no_out = 'X'.
ELSEIF gw_fcat-fieldname EQ 'MBR_NAME'.
gw_fcat-no_out = 'X'.
ELSEIF gw_fcat-fieldname EQ '/CPMB/CALC'.
gw_fcat-no_out = 'X'.
ELSEIF gw_fcat-fieldname EQ 'TXTLG'.
gw_fcat-outputlen = 70.
ELSEIF gw_fcat-fieldname EQ '/CPMB/HIR'.
gw_fcat-outputlen = 20.
ENDIF.
MODIFY gt_fcat2 FROM gw_fcat
TRANSPORTING reptext no_out outputlen.
ENDLOOP.
lcl_main=>create_dynamicalv( ).
lcl_main=>merge_tables( ).
CHECK NOT <gfs_t_final> IS INITIAL.
* SORT <gfs_t_final> BY ('TXTLG').
CALL SCREEN 9000.
ENDIF.
ENDIF.
ENDMETHOD. "show_alv1
METHOD show_alv1.
IF go_custom_container IS INITIAL.
CREATE OBJECT go_custom_container
EXPORTING
* parent =
container_name = gw_g_container
* style =
* lifetime = lifetime_default
* repid =
* dynnr =
* no_autodef_progid_dynnr =
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5
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 go_grid1
EXPORTING
* i_shellstyle = 0
* i_lifetime =
i_parent = go_custom_container
* i_appl_events = 'X'
* i_parentdbg =
* i_applogparent =
* i_graphicsparent =
* i_name =
* i_fcat_complete = SPACE
EXCEPTIONS
error_cntl_create = 1
error_cntl_init = 2
error_cntl_link = 3
error_dp_create = 4
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.
CALL METHOD go_grid1->set_table_for_first_display "#EC CI_SUBRC
* EXPORTING
* i_buffer_active =
* i_bypassing_buffer =
* i_consistency_check =
* i_structure_name =
* is_variant =
* i_save = 'X'
** i_default = 'X'
* is_layout =
** is_print =
** it_special_groups =
* it_toolbar_excluding =
* it_hyperlink =
* it_alv_graphics =
* it_except_qinfo =
* ir_salv_adapter =
CHANGING
it_outtab = <gfs_t_final>
it_fieldcatalog = gt_fcat2
* it_sort =
* it_filter =
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
ENDIF.
ENDMETHOD. "SHOW_alv1
ENDCLASS. "lcl_main IMPLEMENTATION
AT SELECTION-SCREEN OUTPUT.
IF p_radio1 EQ 'X'.
LOOP AT SCREEN.
IF screen-group1 = 'M1'.
screen-active = 0.
MODIFY SCREEN.
ENDIF.
* IF screen-group1 = 'M'.
* screen-active = 0.
* MODIFY SCREEN.
* ENDIF.
ENDLOOP.
ENDIF.
* IF p_radio2 EQ 'X'.
* LOOP AT SCREEN.
* IF p_reason EQ 30.
* IF screen-group1 = 'M2'.
* screen-active = 0.
* MODIFY SCREEN.
* ENDIF.
* ENDIF.
* ENDLOOP.
* ENDIF.
START-OF-SELECTION.
IF p_radio1 EQ 'X'.
SELECT SINGLE data_table desc_table
INTO (gw_datatbl , gw_descrptbl)
FROM uja_dimension CLIENT SPECIFIED
WHERE mandt EQ sy-mandt
AND appset_id EQ p_env
AND dimension EQ p_dim.
IF sy-subrc EQ 0.
SELECT appset_id dimension tech_name attribute_name caption
INTO TABLE gt_attr
FROM uja_dim_attr CLIENT SPECIFIED
WHERE mandt EQ sy-mandt
AND appset_id EQ p_env
AND dimension EQ p_dim.
IF sy-subrc EQ 0.
lcl_main=>create_alv1( ).
ENDIF.
ENDIF.
ELSE.
IF p_reason NE 30.
SELECT *
INTO TABLE gt_except
FROM zbpcbt007 CLIENT SPECIFIED
WHERE mandt EQ sy-mandt
AND appset_id EQ p_env
AND dimension EQ p_dim
AND reasoncd EQ p_reason.
IF sy-subrc EQ 0.
SELECT SINGLE data_table desc_table
INTO (gw_datatbl,gw_descrptbl)
FROM uja_dimension CLIENT SPECIFIED
WHERE mandt EQ sy-mandt
AND appset_id EQ p_env
AND dimension EQ p_dim.
IF sy-subrc EQ 0.
SELECT appset_id dimension tech_name attribute_name caption
INTO TABLE gt_attr
FROM uja_dim_attr CLIENT SPECIFIED
WHERE mandt EQ sy-mandt
AND appset_id EQ p_env
AND dimension EQ p_dim.
IF sy-subrc EQ 0.
gt_except_t[] = gt_except[].
SORT gt_except_t.
DELETE ADJACENT DUPLICATES FROM gt_except_t.
IF gt_except_t IS NOT INITIAL.
SELECT tech_name
INTO TABLE gt_techattr
FROM uja_dim_attr CLIENT SPECIFIED
FOR ALL ENTRIES IN gt_except_t
WHERE mandt EQ sy-mandt
AND appset_id EQ p_env
AND dimension EQ p_dim
AND attribute_name EQ gt_except_t-attrib.
IF sy-subrc EQ 0.
lcl_main=>create_alv2( ).
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ELSEIF p_reason EQ 30.
SELECT SINGLE data_table desc_table
INTO (gw_datatbl,gw_descrptbl)
FROM uja_dimension CLIENT SPECIFIED
WHERE mandt EQ sy-mandt
AND appset_id EQ p_env
AND dimension EQ p_dim.
IF sy-subrc EQ 0.
* gt_except_t[] = gt_except[].
* SORT gt_except_t BY attrib.
* DELETE ADJACENT DUPLICATES FROM gt_except_t COMPARING attrib.
* IF gt_except_t IS NOT INITIAL.
SELECT refdimension
INTO TABLE gt_refdim
FROM zbpcbt009 CLIENT SPECIFIED
* FOR ALL ENTRIES IN gt_except_t
WHERE mandt EQ sy-mandt
AND appset_id EQ p_env
AND dimension EQ p_dim
AND attrib EQ p_attr."gt_except_t-attrib.
IF sy-subrc EQ 0.
gt_refdim_t[] = gt_refdim[].
SORT gt_refdim_t BY dimension.
DELETE ADJACENT DUPLICATES FROM gt_refdim_t COMPARING
dimension.
IF gt_refdim_t IS NOT INITIAL.
SELECT data_table desc_table
INTO TABLE gt_refdata
FROM uja_dimension CLIENT SPECIFIED
FOR ALL ENTRIES IN gt_refdim_t
WHERE mandt EQ sy-mandt
AND appset_id EQ p_env
AND dimension EQ gt_refdim_t-dimension.
IF sy-subrc EQ 0.
SELECT appset_id dimension tech_name attribute_name
caption
INTO TABLE gt_attr
FROM uja_dim_attr CLIENT SPECIFIED
WHERE mandt EQ sy-mandt
AND appset_id EQ p_env
AND dimension EQ p_dim.
IF sy-subrc EQ 0.
SELECT tech_name
INTO TABLE gt_techattr
FROM uja_dim_attr CLIENT SPECIFIED
* FOR ALL ENTRIES IN gt_except_t
WHERE mandt EQ sy-mandt
AND appset_id EQ p_env
AND dimension EQ p_dim
AND attribute_name EQ p_attr."gt_except_t-attrib.
IF sy-subrc EQ 0.
REFRESH: gt_refdim_t.",gt_except_t.
lcl_main=>create_alv3( ).
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
* ENDIF.
* ENDIF.
ENDIF.
ENDIF.
*& Module SHOW_ALV1 OUTPUT
*&-------Yes you can, although you need to do it slightly differently, depending on what your 'original' form is doing.
You end up having to do two things:
1. In your second tabular form, you need to explicitly identify the relevant form fields using calls to the relevant APEX_ITEM functions - as well as this, you need to 'manually' specify the array number in the arguments for the function call, ensuring it doesn't overlap with your original form. Normally, this aspect is done for you.
2. Create your own custom CRUD processes, referencing the above elements. There are a few threads floating around the forum relating to how to deal with this. Do a search for "APEX_APPLICATION.G_F" or "HTMLDB_APPLICATION.G_F" for pointers.
Happy hunting! -
Hello All,
I want to Create Dynamic Header of the Table and according to the Header have to filter the data. Kindly give me the
Suggestion how shd i resolve the problem.
Ex. Run time I will create the Heder as 4%, 5%, 12.5% and filter the amount as per %, the No of columns will be depend on the type of INvoice.Hi,
Check this sample code
DEFINE dy_fields.
clear gs_fields.
gs_fields-fieldname = &1.
gs_fields-datatype = &2.
gs_fields-intlen = &3.
gs_fields-coltext = &4.
gs_fields-quantity = '3'.
append gs_fields to git_fields.
END-OF-DEFINITION. "add_field
DEFINE add_field.
gs_fcat-tabname = &1.
gs_fcat-fieldname = &2.
gs_fcat-ref_field = &3.
gs_fcat-ref_table = &4.
gs_fcat-inttype = &5.
gs_fcat-coltext = &6.
gs_fcat-col_pos = &7.
gs_fcat-quantity = '3'.
gs_fcat-col_opt = 'X'.
append gs_fcat to git_fcat.
END-OF-DEFINITION. "add_field
form form_fieldcatalog .
dy_fields 'MATNR' 'CHAR' '18' 'Material'(015).
dy_fields 'KTEXTMAT' 'CHAR' '40' 'Material Description'(003).
dy_fields 'PRUEFLOS' 'NUMC' '12' 'Inspection Lot Number'(004).
dy_fields 'ENSTEHDAT' 'DATS' '8' 'Date of Inspection'(005).
dy_fields 'ARBPL' 'CHAR' '8' 'Blast Fur. No.'(006).
dy_fields 'USERC1' 'CHAR' '18' 'Plnt No'(007).
dy_fields 'USERC2' 'CHAR' '10' 'Shift'(008).
dy_fields 'USERN1' 'NUMC' '10' 'Sample'(009).
LOOP AT git_qamv ASSIGNING <fs_qamv>.
TRANSLATE <fs_qamv>-kurztext TO UPPER CASE.
ENDLOOP.
refresh git_qamv_temp.
git_qamv_temp[] = git_qamv[].
sort git_qamv_temp by kurztext.
v_count = 8.
sort git_output by prueflos.
delete ADJACENT DUPLICATES FROM git_qamv_temp comparing kurztext.
LOOP AT git_qamv_temp into gs_qamv.
v_count = v_count + 1.
read table git_output ASSIGNING <fs_output> with key PRUEFLOS = gs_qamv-PRUEFLOS BINARY SEARCH.
IF sy-subrc = 0.
dy_fields gs_qamv-merknr 'QUAN' '25' gs_qamv-kurztext.
add_field 'GIT_FINAL' gs_qamv-merknr '' '' 'C' gs_qamv-kurztext v_count.
ENDIF.
ENDLOOP.
data v_cnt(4) type n.
clear v_cnt.
LOOP AT git_fcat ASSIGNING <fs_fcat>.
v_cnt = v_cnt + 10.
<fs_fcat>-fieldname = v_cnt.
READ TABLE git_fields ASSIGNING <fs_fields> WITH key coltext = <fs_fcat>-coltext.
if sy-subrc = 0.
move <fs_fcat>-fieldname to <fs_fields>-fieldname.
ENDIF.
ENDLOOP.
clear v_cnt.
sort GIT_QAMV by PRUEFLOS MERKNR.
LOOP AT GIT_QASR ASSIGNING <FS_QASR>.
READ TABLE GIT_QAMV ASSIGNING <fs_qamv> WITH KEY PRUEFLOS = <FS_QASR>-PRUEFLOS
MERKNR = <FS_QASR>-MERKNR BINARY SEARCH.
IF SY-SUBRC = 0.
MOVE <FS_QAMV>-KURZTEXT TO <FS_QASR>-PRUEFBEMKT.
ENDIF.
ENDLOOP.
*-> create dynamic internal table and assign to fs
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = git_fields
IMPORTING
ep_table = git_dy_final.
*-> Assigning The Referencing Pointer To The Field Symbol
ASSIGN git_dy_final->* TO <git_dy_final>.
Creating Dynamic Work Area And Assigning It To The Field Symbol.
CREATE DATA gs_dy_final LIKE LINE OF <git_dy_final>.
ASSIGN gs_dy_final->* TO <gs_dy_final>.
Regards
Ansari -
Field names for cl_alv_table_create= create_dynamic_table
Morning All
My client is currently implementing SAP QM at one of the labs and I have come across a situation where the fieldnames required for a dynamic table creation can potentially contain spaces and special characters. So far I have urged them to remove all such characters as the call to the cl_alv_table_create=>create_dynamic_table method will dump if they are present.
My question therefore is, is there a definitive list of characters that cannot be used as part of a fieldname? I intend to use such a list to then search and replace the special characters to enable me to match fieldnames.
For those of you that know QM, we cannot use internally assigned numbers for master characteristics (client decision) and special characters are frequently used as names in the lab. My client sees it as a limitation to remove the spaces and special characters from the names but unfortunately it causes problems for me if they don't.
I need to match the names to determine results for a report so substition seems to be the way forward - unless some else has another suggestion?
Thanks in advance
IanThere is a form called SAACHECK in module pool RDDU0001 that the data dictionary program uses to check the validity of field names. You should probably have a look at the logic.
But why use the Master characteristics as the field name anyway? Why not instead create a cross reference in an internal table and generate a simple sequence for each unique master characteristic. That way your field names are just the sequence number, but you can still match up your data with a binary read on the cross reference internal table. -
How can i insert into dynamic table ?
i have regular internal table with data .
i have dynamic table <dyn_tab>
i insert the data from itab
MOVE-CORRESPONDING ITAB TO <LS_LINE>.
INSERT <LS_LINE> INTO TABLE <DYN_TABLE>.
OK , NOW I WANT TO ADD THE DATA FROM OTHER TABLE
THAT HOLD THE DATA THAT ALL THE DYNAMIC TAB BUILD FOR
HOW CAN I DO THIS INSERT ?
I NEED TO INSERT "KOSTL" TO MATCH LINE in <DYN_TABLE>
THIS WHAT I TRIED TO DO :
SHIFT INDX1 LEFT DELETING LEADING SPACE.
CONCATENATE 'KOSTL' INDX1 INTO FIELD .
ASSIGN COMPONENT FIELD OF STRUCTURE <DYN_TABLE> TO <FS>.
<FS> = IT_EKKN-KOSTL.
but i get dump that <FS> not been assign .hi,
pls chk the sample code below.
REPORT zmaschl_create_data_dynamic .
TYPE-POOLS: slis.
DATA: it_fcat TYPE slis_t_fieldcat_alv,
is_fcat LIKE LINE OF it_fcat.
DATA: it_fieldcat TYPE lvc_t_fcat,
is_fieldcat LIKE LINE OF it_fieldcat.
DATA: new_table TYPE REF TO data.
DATA: new_line TYPE REF TO data.
FIELD-SYMBOLS: <l_table> TYPE ANY TABLE,
<l_line> TYPE ANY,
<l_field> TYPE ANY.
* Build fieldcat
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = 'SYST'
CHANGING
ct_fieldcat = it_fcat[].
LOOP AT it_fcat INTO is_fcat WHERE NOT reptext_ddic IS initial.
MOVE-CORRESPONDING is_fcat TO is_fieldcat.
is_fieldcat-fieldname = is_fcat-fieldname.
is_fieldcat-ref_field = is_fcat-fieldname.
is_fieldcat-ref_table = is_fcat-ref_tabname.
APPEND is_fieldcat TO it_fieldcat.
ENDLOOP.
* Create a new Table
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = it_fieldcat
IMPORTING
ep_table = new_table.
* Create a new Line with the same structure of the table.
ASSIGN new_table->* TO <l_table>.
CREATE DATA new_line LIKE LINE OF <l_table>.
ASSIGN new_line->* TO <l_line>.
* Test it...
DO 30 TIMES.
ASSIGN COMPONENT 'SUBRC' OF STRUCTURE <l_line> TO <l_field>.
<l_field> = sy-index.
INSERT <l_line> INTO TABLE <l_table>.
ENDDO.
LOOP AT <l_table> ASSIGNING <l_line>.
ASSIGN COMPONENT 'SUBRC' OF STRUCTURE <l_line> TO <l_field>.
WRITE <l_field>.
ENDLOOP.
Regards
Anver
<i>if hlped pls mark points</i> -
Here's how to use DYNAMIC tables for almost any structure (4.6C onwards)
Hi guys
I'm describing a feature here that has been around since 4.6C that is not really well known but can really simplfy programming where you need to get data into some sort of internal table and then display it either as a classical list or as al ALV grid.
This feature is RTTI which allows you to retrieve your structure, build a dynamic FCAT (Field catalog) and a Dynamic table.
Here's a really quick little program which reads 200 entries from VAPMA into a dynamic table. Any structure will work if you use the code sample shown.
To pass it to an ALV GRID is then really simple as you've already got the Field Catalog, Table and Data.
The method I'm showing below will work for almost ANY structure you care to name whether or not the fields are in the data dictionary.
I create a dynamic FCAT and dynamic table based on the FCAT and then populate it.
You can create field catalogs dynamically quite simply by using the new RTTI facility available from 4.6C onwards.
(From here it's only a small step to dynamic tables and EASY ALV grid displays)
Example to create dynamic FCAT and table and populate it with 200 entries from VAPMA
PROGRAM ZZ_BUILD_FLDCATALOG.
tables: vapma.
Define any structure
types: begin of s_elements,
vbeln type vapma-vbeln,
posnr type vapma-posnr,
matnr type vapma-matnr,
kunnr type vapma-kunnr,
werks type vapma-werks,
vkorg type vapma-vkorg,
vkbur type vapma-vkbur,
status type c,
end of s_elements.
end of your structure
data lr_rtti_struc type ref to cl_abap_structdescr .
data:
zog like line of lr_rtti_struc->components .
data:
zogt like table of zog,
wa_it_fldcat type lvc_s_fcat,
it_fldcat type lvc_t_fcat ,
dy_line type ref to data,
dy_table type ref to data.
data: dref type ref to data.
field-symbols: <fs> type any,
<dyn_table> type standard table,
<dyn_wa>.
*now I want to build a field catalog
*First get your data structure into a field symbol
create data dref type s_elements.
assign dref->* to <fs>.
lr_rtti_struc ?= cl_abap_structdescr=>describe_by_data( <fs> ).
zogt[] = lr_rtti_struc->components.
Now build the field catalog. zogt has the structure in it from RTTI.
loop at zogt into zog.
clear wa_it_fldcat.
wa_it_fldcat-fieldname = zog-name .
wa_it_fldcat-datatype = zog-type_kind.
wa_it_fldcat-inttype = zog-type_kind.
wa_it_fldcat-intlen = zog-length.
wa_it_fldcat-decimals = zog-decimals.
wa_it_fldcat-coltext = zog-name.
wa_it_fldcat-lowercase = 'X'.
append wa_it_fldcat to it_fldcat .
endloop.
Let's create a dynamic table and populate it
call method cl_alv_table_create=>create_dynamic_table
exporting
it_fieldcatalog = it_fldcat
importing
ep_table = dy_table.
assign dy_table->* to <dyn_table>.
create data dy_line like line of <dyn_table>.
assign dy_line->* to <dyn_wa>.
select vbeln posnr matnr kunnr werks vkorg vkbur
up to 200 rows
from vapma
into corresponding fields of table <dyn_table>.
from here you can pass your table to a GRID for display etc etc.
Cheers
JimboThanks for the info.
I went to their web site and also Googled.
I found a great review on their photographer's books on nikonians.org
They use an HP/Indigo Ultrastream 3000 digital offset press for all hardcover books, which is GREAT!
I did sign up and requested the 45 day trial "photographer" account.
I am curious if Shared Ink offers a size that matches the ONLY current book size from Aperture, the odd 8.5x11.
In the above review, I saw that Shared Ink offers a 12x12 book.. very nice! Except you will need to design that one in CS2
So then, all that Apple really needs to do is simply add the ability to select/create custom book sizes. Then we don't need a printing service from Apple, as there are plenty of options out there, and more arriving on the market each month!
Maybe you are looking for
-
Huge headache, ArrayList from Txt File
I'm trying to generate an ArrayList from a text file. But the problem is I have no idea how to go about it properly. This is what I've gotten so far. import java.io.*; import java.util.*; public class reader try FileReader in
-
Strange behaviour in alv output display for a date column!
hi friends, my alv output list display contains a column for budat (posting date), if this field has no value, then it displays a blank cell (space) in the output in my user login...but when the same report is run in another user login, even though t
-
How to remove/install hard drive?
Hi, Does anyone know how to remove a hard disk from the 15" 1.67ghz Powerbook? I can't find instructions anywhere. If anyone can point me to a service manual or something similar I would be most greatful. I know this voids warranty, it doesn't matter
-
All, I am interested in the functionality of the Document Viewer region described in the user manual. What we are looking to do is display the PDF output from a page in the Document Viewer region in OAF. The question is, is there functionality to all
-
How do I make Firefox start up when I start my computer?
Is there a way to have FF start automatically when I start my pc? ty, magvan