‎2008 Nov 04 11:06 AM
Hi experts,
PARAMETERS:
P_TABLE LIKE DD03L-TABNAME.
DATA: BEGIN OF XTABLE OCCURS 10,
string(3000),
END OF XTABLE.
SELECT * FROM (P_TABLE) INTO TABLE XTABLE ORDER BY PRIMARY KEY.
The above code is working in 4.6 but not in ECC6.0 because the type of p_table and xtable are not convertable each other.
Kindly give a solution how to declare the internal table to store the data coming from the table which we entered on selection-screen.
Thanks & Regards,
Sweta.
‎2008 Nov 04 11:13 AM
HI
this is a unicode error..
you can go for a dynamic internal tables...
Regards
Deepak
‎2008 Nov 04 11:13 AM
HI
this is a unicode error..
you can go for a dynamic internal tables...
Regards
Deepak
‎2008 Nov 04 11:22 AM
Hi,
Can you please tell me how to declare that. We tried using field symbols.
‎2008 Nov 04 11:33 AM
Hi
Try this code:
PARAMETERS: P_TABLE LIKE DD03L-TABNAME.
DATA: XTABLE TYPE REF TO DATA.
FIELD-SYMBOLS: <FS_TABLE> TYPE TABLE,
<WA_TABLE> TYPE ANY.
CREATE DATA XTABLE type TABLE OF (p_table).
assign xtable->* to <fs_table>.
SELECT * FROM (P_TABLE) INTO TABLE <fs_table> ORDER BY PRIMARY KEY.
loop at <fs_table> ASSIGNING <wa_table>.
ENDLOOP.Max
‎2008 Nov 04 12:48 PM
Hi max bianchi ,
Thank u . Its working fine upto select statement.
After that we are reading internal table using index .
READ TABLE xtable INDEX 1.
In above statement instead of xtable using your code we replaced it with <fs_table> .
Can u plaease tell me how to read the <fs_table> using index.
Thank & Regards,
Sweta
‎2008 Nov 04 3:15 PM
Hi
Just like the LOOP, so
READ TABLE <fs_table> ASSIGNING <wa_table> INDEX 1.Max
‎2008 Nov 05 5:38 AM
Hi Bianchi,
Thank tou very much. It is woring fine.
Now we are moving the data in <fs_table> to KNA1.
field-symbols: <KNA1> type c.
CASE P_TABLE.
WHEN 'KNA1'.
MOVE XTABLE TO KNA1.
Instead of that we tried like this.......
field-symbols: <KNA1> type any.
CASE P_TABLE.
WHEN 'KNA1'.
assign KNA1 to <KNA1> .
Store data in container
<KNA1> = <fs_table>.(here it is giving dump as Conversion of type "h" to type "KNA1" not supported).
So can you please guide us to solve this problem.It is very helpful for us.....
Thanks & Regards,
Swetha.
‎2008 Nov 05 10:33 AM
Hi
KNA1 is a flat structure, so u can't assign <FS_TABLE> because it's defined as internal table, but u can assign the work area WA_TABLE.
If you're using my code, WA_TABLE should be just arranged like the dictionary table (so I suppose KNA1):
PARAMETERS: P_TABLE LIKE DD03L-TABNAME.
DATA: XTABLE TYPE REF TO DATA.
FIELD-SYMBOLS: <FS_TABLE> TYPE TABLE,
<WA_TABLE> TYPE ANY.
CREATE DATA XTABLE type TABLE OF (p_table).
assign xtable->* to <fs_table>.
SELECT * FROM (P_TABLE) INTO TABLE <fs_table> ORDER BY PRIMARY KEY.
IF SY-SUBRC = 0.
READ TABLE <fs_table> ASSIGNING <wa_table> INDEX 1.
CASE P_TABLE.
WHEN 'KNA1'. KNA1 = <WA_TABLE>.
ENDIF.
‎2008 Nov 04 11:32 AM
REPORT ZSRK_024 .
TYPE-POOLS : ABAP.
PARAMETERS: P_TABLE LIKE DD03L-TABNAME.
DATA: BEGIN OF XTABLE OCCURS 10,
STRING(3000),
END OF XTABLE.
FIELD-SYMBOLS: <DYN_TABLE> TYPE STANDARD TABLE,
<DYN_WA>,
<DYN_FIELD>,
<DYN_WA1> TYPE C,
<DYN_XTABLE> TYPE C.
DATA: DY_TABLE TYPE REF TO DATA,
DY_LINE TYPE REF TO DATA,
XFC TYPE LVC_S_FCAT,
IFC TYPE LVC_T_FCAT.
PERFORM GET_STRUCTURE.
PERFORM CREATE_DYNAMIC_ITAB.
PERFORM GET_DATA.
LOOP AT <DYN_TABLE> INTO <DYN_WA>.
ASSIGN <DYN_WA> TO <DYN_WA1> CASTING.
ASSIGN XTABLE TO <DYN_XTABLE> CASTING.
<DYN_XTABLE> = <DYN_WA1>.
APPEND <DYN_XTABLE> TO XTABLE.
CLEAR <DYN_XTABLE>.
ENDLOOP.
&----
*& Form get_structure
&----
text
----
FORM GET_STRUCTURE.
DATA : IDETAILS TYPE ABAP_COMPDESCR_TAB,
XDETAILS TYPE ABAP_COMPDESCR.
DATA : REF_TABLE_DES TYPE REF TO CL_ABAP_STRUCTDESCR.
Get the structure of the table.
REF_TABLE_DES ?=
CL_ABAP_TYPEDESCR=>DESCRIBE_BY_NAME( P_TABLE ).
IDETAILS[] = REF_TABLE_DES->COMPONENTS[].
LOOP AT IDETAILS INTO XDETAILS.
CLEAR XFC.
XFC-FIELDNAME = XDETAILS-NAME .
XFC-DATATYPE = XDETAILS-TYPE_KIND.
XFC-INTTYPE = XDETAILS-TYPE_KIND.
XFC-INTLEN = XDETAILS-LENGTH.
XFC-DECIMALS = XDETAILS-DECIMALS.
APPEND XFC TO IFC.
ENDLOOP.
ENDFORM. "get_structure
&----
*& Form create_dynamic_itab
&----
text
----
FORM CREATE_DYNAMIC_ITAB.
Create dynamic internal table and assign to FS
CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE
EXPORTING
IT_FIELDCATALOG = IFC
IMPORTING
EP_TABLE = DY_TABLE.
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>.
ENDFORM. "create_dynamic_itab
&----
*& Form get_data
&----
text
----
FORM GET_DATA.
Select Data from table.
SELECT * INTO TABLE <DYN_TABLE>
FROM (P_TABLE) ORDER BY PRIMARY KEY.
ENDFORM. "get_data
Edited by: sreekanth reddy on Nov 4, 2008 5:03 PM
Edited by: sreekanth reddy on Nov 4, 2008 5:04 PM