‎2009 Apr 07 11:15 AM
Hi All,
I am facing very strange problem in my program.
First I have to download the structure of marketing program.For that I have declear one internal table say itab in which there are three fields.
Now I have to upload data in XD03,in which number of fields will be equal to number of entries in ITAB plus one.
and number of entries in doenloading structure (ITAB) may be varry.So How can I define internal table for uploading.
ITAB
xyz 1 y
abc 2 n
and uploading structure like
111 y n
222 y y
333 n
Regards,
Amar
‎2009 Apr 07 11:26 AM
Hi,
you can try this:
DATA: new_table TYPE REF TO data.
FIELD-SYMBOLS: <l_table> TYPE ANY TABLE.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_INTERNAL_TABNAME =
i_structure_name = itab
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.
*append another field same in the loop.
*then create the internal table
Create a new Table
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = it_fieldcat
IMPORTING
ep_table = new_table.
ASSIGN new_table->* TO <l_table>.
Regards,
Leo
Edited by: Ierardi Leo on Apr 7, 2009 12:26 PM
‎2009 Apr 07 11:23 AM
‎2009 Apr 07 11:26 AM
Hi,
you can try this:
DATA: new_table TYPE REF TO data.
FIELD-SYMBOLS: <l_table> TYPE ANY TABLE.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_INTERNAL_TABNAME =
i_structure_name = itab
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.
*append another field same in the loop.
*then create the internal table
Create a new Table
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = it_fieldcat
IMPORTING
ep_table = new_table.
ASSIGN new_table->* TO <l_table>.
Regards,
Leo
Edited by: Ierardi Leo on Apr 7, 2009 12:26 PM
‎2009 Apr 07 11:29 AM
Hi Amar,
I see that Uplaoding and downloading structures are same in your post,
Only there is an extra row,
Can you post it clearly,
Thansk & regards,
Dileep .C
‎2009 Apr 07 11:29 AM
Hi..
I would try that:
1. create a fieldcat
2. use that FM:
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = gt_fieldcatalog
IMPORTING
ep_table = gz_table
EXCEPTIONS
generate_subpool_dir_full = 1
OTHERS = 2.
3. now you can use that table.....
bestreg Robert
‎2009 Apr 07 11:51 AM
Try Following Code...!
REPORT ZPP_FS_CHINTAN_2.
TYPES : BEGIN OF TYP_HARDCODED,
L_COUNT TYPE I,
LT_SFLIGHT TYPE SFLIGHT.
TYPES : END OF TYP_HARDCODED.
DATA : LT_HARDCODED TYPE TABLE OF TYP_HARDCODED.
TYPES: TYP_COUNT TYPE I.
FIELD-SYMBOLS : <LT_DYNAMIC> TYPE ANY TABLE.
DATA: DREF TYPE REF TO DATA,
ITAB_TYPE TYPE REF TO CL_ABAP_TABLEDESCR,
STRUCT_TYPE TYPE REF TO CL_ABAP_STRUCTDESCR,
ELEM_TYPE TYPE REF TO CL_ABAP_ELEMDESCR,
COMP_TAB TYPE CL_ABAP_STRUCTDESCR=>COMPONENT_TABLE,
COMP_FLD TYPE CL_ABAP_STRUCTDESCR=>COMPONENT.
STRUCT_TYPE ?= CL_ABAP_TYPEDESCR=>DESCRIBE_BY_NAME( 'MARA' ).
ELEM_TYPE ?= CL_ABAP_ELEMDESCR=>DESCRIBE_BY_NAME( 'TYP_COUNT' ).
COMP_TAB = STRUCT_TYPE->GET_COMPONENTS( ).
COMP_FLD-NAME = 'L_COUNT'.
COMP_FLD-TYPE = ELEM_TYPE.
INSERT COMP_FLD INTO COMP_TAB INDEX 1.
STRUCT_TYPE = CL_ABAP_STRUCTDESCR=>CREATE( COMP_TAB ).
ITAB_TYPE = CL_ABAP_TABLEDESCR=>CREATE( STRUCT_TYPE ).
CREATE DATA DREF TYPE HANDLE ITAB_TYPE.
ASSIGN DREF->* TO <LT_DYNAMIC>.
BREAK-POINT.