‎2009 Jan 28 2:19 PM
HI Gurus,
i have a function module that gives me the table name from where the selection should be done as this table name changes dynamically.
now i want to define a itab from this variable that holds the table name but im getting syntax error.
data: table_name(16) type c.
call function 'RSAR_CHANGELOG_NAME_GET'
Exporting
i_odsobject = odsname
i_logsys = logsys
Importing
e_odsname_db = table_name
it_clog_r type standard table of *table_name*.can you please help how to solve this.
thanks,
regards,
Younes
‎2009 Jan 28 2:35 PM
Hi, Younes
do as following hope will solve your problem,
data: it_clog_r TYPE STANDARD TABLE OF RSTSODS.Kind Regards,
Faisal
‎2009 Jan 28 2:35 PM
Hi, Younes
do as following hope will solve your problem,
data: it_clog_r TYPE STANDARD TABLE OF RSTSODS.Kind Regards,
Faisal
‎2009 Jan 28 2:36 PM
Hi,
Try this.
DATA: table_name(16) TYPE c,
odsname TYPE rsdodsobject,
logsys TYPE tbdls-logsys.
CALL FUNCTION 'RSAR_CHANGELOG_NAME_GET'
EXPORTING
i_odsobject = odsname
i_logsys = logsys
IMPORTING
e_odsname_db = table_name.
DATA:
it_clog_r TYPE STANDARD TABLE OF table_name.
Let me further.
Cheers,
Parth Parikh
‎2009 Jan 28 3:09 PM
Hi Thank you all,
but this i tried already but i get the error:
E: Type table_name is unknown
is there a possibility to create these table dynamically?
thanks,
regards,
Younes
‎2009 Jan 28 3:17 PM
data: table_name(16) type c.
data: lp_data TYPE REF TO DATA.
FIELD-SYMBOLS: <lt_table> TYPE STANDARD TABLE.
call function 'RSAR_CHANGELOG_NAME_GET'
Exporting
i_odsobject = odsname
i_logsys = logsys
Importing
e_odsname_db = table_name
CREATE DATA lp_data TYPE STANDARD TABLE OF (table_name) WITH NON-UNIQUE KEY TABLE_LINE.
ASSIGN lp_data->* TO <lt_table>.
<lt_table> is an internal table of type "table_name".
matt
‎2009 Jan 28 3:23 PM
Hi Matt,
thanks yes this is working.
now i have a problem when i want to loop into the internal table.
i have done this code:
loop at <fs_clog_r> into <wa_clog_r>.
assign component sy-tabix of structure <wa_clog_r> to <fd_clog_a>.
*here i want to make a select statement to compare some data
select * from (tablename) into table <fs_clog_a>
where deliv_numb = <fd_clog_a>-deliv_numb.
*This is not working do you have a workaround here??
if sy-subrc <> 0.
.....
endif.
endloop.thanks,
regards,
Younes
‎2009 Jan 28 4:46 PM
HI Anbody can Help ? it would be great.
thanks,
regards,
Younes
‎2009 Jan 28 5:02 PM
I'm not sure what's your flow ...
Is itab <fs_clog_r> a list of fields? I'm asking this because you are assigning component sy-tabix, what means that in each row you assign a diferent component ... what's your goal?
Anyways,
where deliv_numb = <fd_clog_a>-deliv_numbcannot be right. use
where deliv_numb = <fd_clog_a>because <fd_clog_a> is a field (from structure <wa_clog_r>), not a structure. Is deliv_numb a field of <wa_clog_r>?
Regards,
Valter Oliveira.
‎2009 Jan 28 5:30 PM
HI Valter Oliveira,
thanks,
i'm not so familiar with this kein of structure. so do you mean is sy-index better to use instead of sy-tabix?
and yes "deliv_numb" is a field of <wa_clog_r> so is this correct?
where deliv_numb = <fd_clog_a>regards,
Younes
‎2009 Jan 28 5:41 PM
No, I'm not saying that you should use sy-index. I could not say that because I'm not sure about what you want to do.
Now, lets say that in your loop, you are in the first row. Sy-tabix will be 1.
You are using:
assign component sy-tabix of structure <wa_clog_r> to <fd_clog_a>.This means: assign the first field of the structure <wa_clog_r> to the field-symbol <fd_clog_a>. If the first field of structure <wa_clog_r> is deliv_numb, you can say:
where deliv_numb = <fd_clog_a>.
In the second row it will mean: assign the second field of the structure <wa_clog_r> to the field-symbol <fd_clog_a>.
Check this example:
TYPES: BEGIN OF ty_data,
string TYPE char255,
END OF ty_data.
DATA: itab TYPE STANDARD TABLE OF ty_data.
DATA: fields TYPE STANDARD TABLE OF ty_data.
DATA: count TYPE i.
DATA: wa TYPE ty_data.
DATA: wa2 TYPE ty_data.
DATA: wa_bsis TYPE bsis.
FIELD-SYMBOLS: <fs> TYPE any.
wa-string = '100;INCM;20000001;...'. "mandt-bukrs-hkont-...
APPEND wa TO itab.
LOOP AT itab INTO wa.
SPLIT wa-string AT ';' INTO TABLE fields.
CLEAR count.
LOOP AT fields INTO wa2.
ADD 1 TO count.
ASSIGN COMPONENT count OF STRUCTURE wa_bsis TO <fs>.
<fs> = wa2-string.
ENDLOOP.
INSERT zbsis FROM wa_bsis.
ENDLOOP.
Regards,
Valter Oliveira.
‎2009 Jan 28 6:32 PM
Hi
U need to create the WHERE condtions dynamically:
DATA: T_WHERE(100) TYPE C OCCURS 0 WITH HEADER LINE..
DATA: VALUE(30) TYPE C.
DATA: DEL(10) TYPE C.
loop at <fs_clog_r> into <wa_clog_r>.
assign component sy-tabix of structure <wa_clog_r> to <fd_clog_a>.
move <fd_clog_a> to DEL.
REFRESH T_WHERE.
CONCATENATE '''' DEL '''' INTO VALUE.
CONCATENATE 'DELIV_NUMB =' VALUE INTO T_WHERE SEPARATED BY SPACE.
APPEND T_WHERE
select * from (tablename) into table <fs_clog_a>
where (T_WHERE).
if sy-subrc 0.
.....
endif.Max
‎2009 Jan 29 10:20 AM
As Max said, but I wonder if this would work:
CONCATENATE 'DELIV_NUMB = ''' <fd_clog_a>-deliv_num '''' INTO where_clause.
select * from (tablename) into table <fs_clog_a>
where (where_clause).
‎2009 Jan 29 12:31 PM
Hello Max.
The code you provided is "more correct" regarding the dynamic "where condition". But I must say that (at least in 7.10) this also works:
TRY.
CREATE DATA gv_dref TYPE (wa_profiles-table).
* Assign work area
ASSIGN gv_dref->* TO <wa>.
IF sy-subrc NE 0.
EXIT.
ENDIF.
* Dynamic SELECT
SELECT SINGLE * FROM (wa_profiles-table) INTO <wa>
WHERE data_file = wa_pin-data_ficheiro
AND seq_fileo = wa_pin-seq_ficheiro.
* Error handing
CATCH cx_sy_create_data_error.
ENDTRY.
Is the problem solved?
Regards,
Valter Oliveira.