‎2008 Nov 17 5:51 PM
Please,
Do you know how to read a internal table columns and assign it a fixed value (for exemple '/')?
I have a structure like LFA1 where i need to fill every field with value '/'. But i don't want to do: LFA1-LIFNR = '/', LFA1-LAND1 = '/', LFA1-NAME1 = '/'....
Best Regards,
David Escofet.
‎2008 Nov 17 6:06 PM
Hi,
You need to use field symbols like below:
FIELD-SYMBOLS <fs_comp> type any.
"in the loop assign each component of your LFA1 strucutre
DO.
ASSIGN COMPONENT sy-index OF STRUCTURE lfa1 TO <fs_comp>.
IF sy-subrc ne 0. "exit the loop the no more components left
EXIT.
ELSE.
<fs_comp> = '/'. "assign your desired value to each component
ENDIF.
ENDDO.
That's all you need.
M.
‎2008 Nov 17 6:06 PM
Hi,
You need to use field symbols like below:
FIELD-SYMBOLS <fs_comp> type any.
"in the loop assign each component of your LFA1 strucutre
DO.
ASSIGN COMPONENT sy-index OF STRUCTURE lfa1 TO <fs_comp>.
IF sy-subrc ne 0. "exit the loop the no more components left
EXIT.
ELSE.
<fs_comp> = '/'. "assign your desired value to each component
ENDIF.
ENDDO.
That's all you need.
M.
‎2008 Nov 17 6:15 PM
Hi
tables: lfa1.
DATA: l_descr_tab_std TYPE REF TO cl_abap_structdescr.
field-symbols: <wa> TYPE abap_compdescr,
<field> type any.
l_descr_tab_std ?= cl_abap_typedescr=>DESCRIBE_BY_DATA( LFA1 ).
loop at l_descr_tab_std->components ASSIGNING <wa>.
if <wa>-name <> ' .....'.
assign component <wa>-name of structure lfa1 to <field>.
<field> = '/'.
endif.
endloop.U make sure the field of LFA1 is type char
Max
‎2008 Nov 17 6:26 PM
>
> Please,
>
> Do you know how to read a internal table columns and assign it a fixed value (for exemple '/')?
>
> I have a structure like LFA1 where i need to fill every field with value '/'. But i don't want to do: LFA1-LIFNR = '/', LFA1-LAND1 = '/', LFA1-NAME1 = '/'....
>
>
> Best Regards,
> David Escofet.
Hi David,
Marcin Pciak solution is the most optimal solution. But i have an alternate solution for you problem. We can first find all the FIELDS of the given structure into an internal table and later loop and fill values in it. The fields of a table can be obtained from the Database Table DD03L.
FIELD-SYMBOLS: <fld> TYPE ANY.
DATA: gt_field TYPE TABLE OF dd03l-fieldname,
gs_field LIKE LINE OF gt_field,
l_fa1 TYPE {STRUCTURE}.
SELECT fieldname FROM dd03l INTO TABLE gt_field
WHERE tabname = {STRUCTURE}.
LOOP AT gt_field INTO gs_field.
ASSIGN COMPONENT gs_field OF STRUCTURE l_fa1 TO <fld>.
<fld> = '/'.
ENDLOOP.
*Replace {STRUCTURE} with your own structure's name.Regards,
Ravi.