‎2009 Nov 04 10:37 AM
Hello Experts ,
Requirement : I have a multiple value selection Drop down which gives me an option to select "table names"
based on the selected table name i need to get the data from those tables into itab and then into a file.
Now we know the table structure & i have to do "select * " on the tables selected.
i want to create dynamically internal tables for every table selected in the drop down
Better ideas are always welcome
Im using ABAP Release 4.7
Thanks
Regards Renu
‎2009 Nov 04 10:48 AM
Hi
This code should work on your release:
PARAMETERS: P_TABLE(30).
DATA: MY_TABLE TYPE REF TO DATA.
FIELD-SYMBOLS: <WA> TYPE ANY.
START-OF-SELECTION.
CREATE DATA MY_TABLE TYPE (P_TABLE).
ASSIGN MY_TABLE->* TO <WA>.
SELECT * FROM (P_TABLE) INTO <WA>.
" Here move <WA> to file
ENDSELECT.Max
‎2009 Nov 04 10:45 AM
‎2009 Nov 04 10:45 AM
Im using ABAP Release 4.7
Check if the statement is supported in 4.7:
CREATE DATA dref TYPE STANDARD TABLE OF (P_TABLE).If yes, then your work is cut short
BR,
Suhas
‎2009 Nov 04 10:48 AM
Hi
This code should work on your release:
PARAMETERS: P_TABLE(30).
DATA: MY_TABLE TYPE REF TO DATA.
FIELD-SYMBOLS: <WA> TYPE ANY.
START-OF-SELECTION.
CREATE DATA MY_TABLE TYPE (P_TABLE).
ASSIGN MY_TABLE->* TO <WA>.
SELECT * FROM (P_TABLE) INTO <WA>.
" Here move <WA> to file
ENDSELECT.Max
‎2009 Nov 04 11:07 AM
Thanks Max ,
One issue is i cant create "my_table" of "table type" in 4.7 ..
can u please help me with inputs on how i would be able to put the value from <wa> into a file ..
Thanks
Regards Renu
‎2009 Nov 04 11:13 AM
Thanks Max ,
One issue is i cant create "my_table" of "table type" in 4.7 ..
can u please help me with inputs on how i would be able to put the value from <wa> into a file ..
Thanks
Regards Renu
‎2009 Nov 04 11:30 AM
Hi
I don't think u need to create a dynamic table, but a work are only, so the comand
CREATE DATA MY_TABLE TYPE (P_TABLE)should be enough...doesn't work in 4.7?
TYPES: TY_RECORD TYPE STRING.
PARAMETERS: P_TABLE(30).
DATA: WA_DYN TYPE REF TO DATA.
FIELD-SYMBOLS: <WA> TYPE ANY.
DATA: W_RECORD TYPE STRING,
T_FILE TYPE TABLE OF TY_RECORD.
START-OF-SELECTION.
CREATE DATA WA_DYN TYPE (P_TABLE).
ASSIGN WA_DYN->* TO <WA>.
SELECT * FROM (P_TABLE) INTO <WA>.
MOVE <WA> TO W_RECORD.
APPEND W_RECORD TO T_FILE.
ENDSELECT.
IF SY-SUBRC = 0.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>GUI_DOWNLOAD
EXPORTING
FILENAME = 'C:\test.txt'
CHANGING
DATA_TAB = T_FILE.
ENDIF.Max
‎2009 Nov 09 5:50 AM
Hi Max
Thanks for the inputs from your side .
Im facing a problem of "Data objects in a Unicode program are not convertible."
when im trying to
TYPES: TY_RECORD TYPE STRING.
DATA: W_RECORD TYPE STRING,
T_FILE TYPE TABLE OF TY_RECORD.
SELECT * FRom (WA_RETURN-FIELDVAL) INTO <WA>.
bold MOVE <WA> TO W_RECORD. "Error on this line"
APPEND W_RECORD TO T_FILE.
ENDSELECT.
Can You please help me with this .
Regards
Renu
‎2009 Nov 09 8:01 AM
In unicode programs it is no longer possible to just move data back and forth like you are trying to do now. You could consider do use statement ASSIGN COMPONENT x OF STRUCTURE .... and then CONCATENATE all separate fields into the string workarea. BUT the concatenate statement is only valid for character type fields. That's something you have to keep in mind. Otherwise you have to move them to char type field first and then concatenate them.
Your exact requirement eludes me, so not sure why you want to move data to internal table of type string??
‎2009 Nov 09 2:10 PM
Hi Renu,
SELECT * FRom (WA_RETURN-FIELDVAL) INTO <WA>.
bold MOVE <WA> TO W_RECORD. "Error on this line"
APPEND W_RECORD TO T_FILE.
ENDSELECT.
For the above problem, you need to change the code as below
SELECT * FRom (WA_RETURN-FIELDVAL) INTO <WA>.
APPEND <wa> TO <itab>.
ENDSELECT.
Internal table also should be dynamic, as workarea structure is dynamic.
You can create dynamic itab by calling the method create_dynamic_table of cl_alv_table_create.
Let us know if you still face any issues.
Regards,
NIsha Vengal.
‎2009 Nov 04 10:52 AM
‎2009 Nov 04 10:53 AM
hi,
a F1 help on select will bring you this code:
PARAMETERS: p_cityfr TYPE spfli-cityfrom,
p_cityto TYPE spfli-cityto.
DATA: BEGIN OF wa,
fldate TYPE sflight-fldate,
carrname TYPE scarr-carrname,
connid TYPE spfli-connid,
END OF wa.
DATA itab LIKE SORTED TABLE OF wa
WITH UNIQUE KEY fldate carrname connid.
DATA: column_syntax TYPE string,
dbtab_syntax TYPE string.
column_syntax = `c~carrname p~connid f~fldate`.
dbtab_syntax = `( ( scarr AS c `
& ` INNER JOIN spfli AS p ON p~carrid = c~carrid`
& ` AND p~cityfrom = p_cityfr`
& ` AND p~cityto = p_cityto )`
& ` INNER JOIN sflight AS f ON f~carrid = p~carrid `
& ` AND f~connid = p~connid )`.
SELECT (column_syntax)
FROM (dbtab_syntax)
INTO CORRESPONDING FIELDS OF TABLE itab.
LOOP AT itab INTO wa.
WRITE: / wa-fldate, wa-carrname, wa-connid.
ENDLOOP.
i think this will be usefull for your case.
ags.