06-04-2008 10:51 PM
Hi experts:
I have a dynamic work area but before doing an append to the dynamic table, I need to do some validation on some fields of the work area in order to decide to append it or not, but I don't know how...
More or less this is the example
loop at so_kschl.
field = so_kschl-low.
if <t_dyntable>-field = 0. "if the value of this field in dinamic table is 0.
don't append
else.
APPEND <fs_dyntable> TO <t_dyntable>.
endif.
endloop.
Thank you very much for your help.
Miriam
06-04-2008 11:11 PM
Check this example, you read the component of the dynamic work area and assign it to a field-symbols. In this case, I validate that the entry is always 'a'.
DATA: i_lvc TYPE lvc_t_fcat WITH HEADER LINE,
i_table TYPE REF TO data,
l_style TYPE lvc_fname,
l_warea TYPE REF TO data,
l_name(7) VALUE 'VARCHAR'..
FIELD-SYMBOLS: <fs> TYPE table,
<fs2> TYPE ANY,
<fs3> TYPE ANY.
PARAMETERS p_char TYPE c LOWER CASE.
START-OF-SELECTION.
i_lvc-fieldname = 'Varchar'.
i_lvc-inttype = 'C'.
i_lvc-intlen = 1.
APPEND i_lvc.
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = i_lvc[]
IMPORTING
ep_table = i_table
e_style_fname = l_style.
ASSIGN i_table->* TO <fs>.
CREATE DATA l_warea LIKE LINE OF <fs>.
ASSIGN l_warea->* TO <fs2>.
<fs2> = p_char.
ASSIGN COMPONENT l_name OF STRUCTURE <fs2> TO <fs3>.
IF <fs3> = 'a'.
WRITE: 'Component VARCHAR is a'.
* APPEND <fs2> TO <fs>.
ELSE.
WRITE: 'Component VARCHAR is not a'.
ENDIF.
06-05-2008 4:04 PM
I think we're very close, in your example the append is done before, and I need to read the work area before been inserted. Here my code trying to use your code:
IF NOT so_kschl IS INITIAL.
LOOP AT so_kschl WHERE option = 'EQ'.
ASSIGN COMPONENT so_kschl-low OF STRUCTURE <fs_dyntable>
TO <fs_field>.
ENDLOOP.
ENDIF.
The column name I want to read from de work area <fs_dyntable> is in so_kschl-low, and I need to know the value of this field.
Normally with an internal table I would do this:
lv_value = itab-pb00.
if lv_value = 0.
do something
endif.
I hope my explanation is clear. 😃
06-05-2008 4:08 PM
fs_dyntable is the work area? Looks like the name of a table O_o
If fs_dyntable has a component called LOW, then this is the code, but I don't think I'm understanding your requirement
IF NOT so_kschl IS INITIAL.
LOOP AT so_kschl WHERE option = 'EQ'.
ASSIGN COMPONENT 'LOW' OF STRUCTURE <fs_dyntable>
TO <fs_field>.
ENDLOOP.
ENDIF.
06-05-2008 4:54 PM
so_kschl is a select option and supose so_kschl-low has the value = 'PB00'
And the structure <fs_dyntable> has a column PB00, and I want to get the value of this column, something like this:
lv_value = <fs_dyntable>-PB00
Thank you very much for your replies, it's helping me.
06-05-2008 4:58 PM