How can a default a constant for multiple feild of a table

Question: Hello,

I have an internal table of 300 fields. i need to default a constant in all the fileds...say 'X".

How can this be achived without having to assign each field individually.

I cannot do this during declaration too as i have include structures for this internal table.

can this be done by some statement within the program ??

Best regards,
Sam007

Answer:
I remember I tried and failed to find a quick way of doing something similar, so wrote a bit of code to set up a template structure with a / in every field. The structure referenced, in this case BBKPF, must be defined in the data dictionary.

suppose itab is the name of your internal table
     
  DATA: N TYPE I.                                   
  FIELD-SYMBOLS <F>.                               
  DO.                                               
    ADD 1 TO N.                                     
    ASSIGN COMPONENT N OF STRUCTURE itab TO <F>. 
    IF SY-SUBRC NE 0. EXIT. ENDIF.                 
    MOVE 'X' TO <F>.                       
  ENDDO.                                                                                   

That would be the quick way of doing it that I failed to find. A lot better. Have now read up on ASSIGN COMPONENT...

Answer:
Caution:
CLEAR itab with 'X'.
puts 'X' in all positions of each fields; the other method puts only 'X' in the first character of each field (padded at right with blanks).

Answer:
What type are the fields? Are they all Char?

Answer:
if I try to clear all fields in an internal table I get this error.


CLEAR with an explicitly specified initial value may not have a table,
a reference or a string as its first operand. It may not contain these
structures either.
Copyright ?2007 - 2008 www.jt77.com