2010 Jun 09 10:20 AM
Hi all,
I have an internal table that is filled with data to update business partners. We want it also to be possible to clear a certain field when updating fields. Those fields are filled with an #.
How can I search/find which table entries are filled with #?
I already tried the
find all occurrances....
method, but that returns only the offset. I rather would see the fieldname of the internal table, so I can clear it.
regards,
Ron.
2010 Jun 09 11:48 AM
Hi,
In order to find the field where '#' is present, you can follow the following steps:
1. Loop at the internal table.
2. Assign each field of the table line to a field symbol.
3. Search for '#' in the field-symbol.
See the following example:
field-symbols: <fs_field> type any.
data: begin of itab occurs 0,
fld1 type char10,
fld2 type char5,
fld3 type char6,
end of itab.
DATA: PATT TYPE CHAR1 VALUE '#'.
data: ls_line like line of itab.
ls_line-fld1 = 'NAME1'.
LS_LINE-FLD2 = 'E#EC'.
APPEND LS_LINE TO ITAB.
CLEAR LS_LINE.
LOOP AT ITAB INTO LS_LINE.
DO.
ASSIGN COMPONENT SY-INDEX OF STRUCTURE LS_LINE TO <FS_FIELD>.
IF SY-SUBRC <> 0.
EXIT.
ENDIF.
FIND PATT IN <FS_FIELD>.
IF SY-SUBRC = 0.
* '#' found in this field with field number as sy-index and line number as sy-tabix.
ELSE.
CONTINUE.
ENDIF.
ENDDO.
ENDLOOP.
Regards,
Jayesh
2010 Jun 09 11:58 AM
TYPES: BEGIN OF address,
NAME TYPE c,
CODE TYPE c,
TOWN TYPE c,
STR TYPE c,
END OF address.
data:itab type table of address.
data:wa type sddress.
DATA wa TYPE address.
DATA: typ(1) TYPE c,
n TYPE i.
DESCRIBE FIELD wa type typ COMPONENTS n.
loop at itab into wa.
do n times.
assign component sy-index of structure wa to <fs>.
if <fs> ca '#'.
clear <fs>.
endif.
enddo.
endloop.
2010 Jun 09 12:38 PM
Thanks Gentlemen,
I solved it using a bit of both your coding!
best regards,
Ron.