‎2007 May 18 1:42 PM
Hello Friends ,
I am using 4.6c version, while creating the dynamic internal table its giving the problem mentioned below.
my main internal table is having 5 fields depends upon the paramers (column positions in the main internal table)on the slection screen i have to keep the corresponding columns data of main table in to the dynamic internal table:
if parmeters 3 and 5 have given means i should keep 3rd and 5th field form the main internal table to dynamic internal table .
my main table is ITAB_MAIN which is having 5 fields
I declared the as follows.
DATA : ITAB_SUB TYPE REF TO DATA,
NEW_LINE TYPE REF TO DATA,
IT_FIELDCATALOG TYPE LVC_T_FCAT,
WA_FIELDCATALOG TYPE LVC_S_FCAT.
FIELD-SYMBOLS :<IT_FINAL> TYPE STANDARD TABLE,
<WA_FINAL> TYPE ANY,
<W_FIELD> TYPE ANY .
I created the field catalog according to the parmeters given on the selection screen
i.e IT_FIELDCATALOG
CLEAR IT_FIELDCATALOG.
WA_FIELDCATALOG-ROW_POS = 1.
WA_FIELDCATALOG-COL_POS = 1.
WA_FIELDCATALOG-FIELDNAME = P_FIRST.
WA_FIELDCATALOG-TABNAME = 'ITAB_MAIN'.
WA_FIELDCATALOG-INTLEN = 10.
WA_FIELDCATALOG-OUTPUTLEN = 10.
APPEND WA_FIELDCATALOG TO IT_FIELDCATALOG.
WA_FIELDCATALOG-ROW_POS = 1.
WA_FIELDCATALOG-COL_POS = 2.
WA_FIELDCATALOG-FIELDNAME = P_SECOND.
WA_FIELDCATALOG-TABNAME = 'ITAB_MAIN'.
WA_FIELDCATALOG-INTLEN = 10.
WA_FIELDCATALOG-OUTPUTLEN = 10.
APPEND WA_FIELDCATALOG TO IT_FIELDCATALOG.
*--Create the table dynamically
CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE
EXPORTING
I_STYLE_TABLE =
IT_FIELDCATALOG = IT_FIELDCATALOG
IMPORTING
EP_TABLE = ITAB_SUB
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.
ASSIGN ITAB_SUB->* TO <IT_FINAL>.
CREATE DATA NEW_LINE LIKE LINE OF <IT_FINAL>.
ASSIGN NEW_LINE->* TO <WA_FINAL>.
i am inserting the entries to final internal table as follows
LOOP AT ITAB_MAIN.
MOVE-CORRESPONDING ITAB_MAIN TO <WA_FINAL>.
APPEND <WA_FINAL> TO <IT_FINAL>.
ENDLOOP.
But here MOVE-CORRESPONDING is not working and its giving error as follows
<WA_FINAL> is not a structure or internal table with header line.
In 4.7c its working fine but in 4.6c its not working and i am getting the above mentioned error .
So could you please give me possible solution .
Thanks in advance,
Arvind.
‎2007 May 18 2:06 PM
Hi,
DATA WA_FIELDCATALOG TYPE LVC_S_FCAT.
DATA IT_FIELDCATALOG TYPE LVC_T_FCAT.
DATA:DYN_ITAB TYPE REF TO DATA,
WA TYPE REF TO DATA.
FIELD-SYMBOLS: <DISP_TABLE> TYPE TABLE,
<WA> TYPE ANY.
WA_FIELDCATALOG-COL_POS = 1.
WA_FIELDCATALOG-FIELDNAME = 'P_FIRST'.
APPEND WA_FIELDCATALOG TO IT_FIELDCATALOG.
WA_FIELDCATALOG-COL_POS = 2.
WA_FIELDCATALOG-FIELDNAME = 'P_SECOND'.
APPEND WA_FIELDCATALOG TO IT_FIELDCATALOG.
CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE EXPORTING
IT_FIELDCATALOG = IT_FIELDCATALOG[]
IMPORTING
EP_TABLE = DYN_ITAB.
ASSIGN DYN_ITAB->* TO <DISP_TABLE>.
CREATE DATA WA LIKE LINE OF <DISP_TABLE>.
ASSIGN WA->* TO <WA>.
<b>reward if helpful</b>
rgds,
bharat.
Message was edited by:
Bharat Kalagara
‎2007 May 18 2:16 PM
try with this
LOOP AT ITAB_MAIN.
ITAB_MAIN-field1 = <WA_FINAL>-field1.
ITAB_MAIN-field2 = <WA_FINAL>-field2.
ITAB_MAIN-field3 = <WA_FINAL>-field3.
APPEND <WA_FINAL> TO <IT_FINAL>.
ENDLOOP.
‎2007 May 21 7:57 AM
Hello,
Here if i am doing like this
<WA_FINAL>-field1 = ITAB_MAIN-field1 .
<WA_FINAL>-field2 = ITAB_MAIN-field2 .
<WA_FINAL>-field3 = ITAB_MAIN-field3 .
its not working its giving an error message like as follows.
<WA_FINAL> has no structure and therfore no component called field1.
That too i would like to have in my final internal table IT_FINAL only the fileds that have given in the selection screen dynamically.
Could you please give me possible solution.
Thanks,
Arvind.
‎2007 May 18 2:16 PM
Hi,
Try this coding.
if u know the no. of fields in itab_main (say n).
LOOP AT ITAB_MAIN.
*for this u can maintain another loop.
ASSIGN COMPONENT 1 OF STRUCTURE <WA_FINAL> TO <l_field>.
ASSIGN COMPONENT 2 OF STRUCTURE <WA_FINAL> TO <l_field>..
.
append <wa_final> to <it_final>.
ENDLOOP
with regards,
Vamsi
‎2007 May 21 8:07 AM
Hello Arvind
Based on the way you build the fieldcatalog I assume that your "dynamic" has the same structure as your ITAB_MAIN but only certain columns should be displayed depending on the selection criteria.
If this is correct then you do not need a dynamic itab at all but you can use ITAB_MAIN directly as output for your ALV list. In order to hide certain columns simply adjust the <b>fieldcatalog</b>, e.g.:
" (1) Build fieldcatalog for all 5 fields
" Depending on the selection criteria columns 3 & 5 should be hidden
LOOP AT gt_fcat INTO ls_fcat
WHERE ( fieldname = 'P_THIRD' OR
fieldname = 'P_FIFTH' ).
ls_fcat-tech = 'X'. " hidden on ALV list and layout
" ls_fcat-no_out = 'X' " only hidden on list, but can be choosen from layout
MODIFY gt_fcat FROM ls_fcat.
ENDLOOP.Regards
Uwe
‎2007 May 21 8:15 AM
Hello ,
Displaying is not my requirment,i would like to use the it_final which having the data according to the selection screen parameters for further processing in my program .
So could you please advice me.
Arvind.