2010 Jan 06 10:12 AM
Hi All,
I have a internal table as shown below.
Data : Begin of itab occurs 0,
w1 type i
w2 type i,
w3 type i,
w4 type i,
end of itab.
data : temp type i.
My query is I want to assign a numeric to the fields in ITAB depending upon the value of temp.
If temp = 1
itab-w1 = 1.
elseif temp = 2
itab-w2 = 1
elseif temp = 3
itab-w3 = 1.
endif.
I have 72 fields like this.
I want to concatenate a 'W' & temp into a character and pass this as parameter to Internal Table field.
Please let me know if the above scenario is possible.
Thank you all in advance
2010 Jan 06 10:20 AM
Hello Sandy,
Using Field symbols, this can be achieved very easily
Try this:
DATA:
TEMP TYPE N,
FNAME TYPE CHAR3.
FIELD-SYMBOLS: <FVAL> TYPE ANY.
CONCATENATE 'W' TEMP INTO FNAME. CONDENSE FNAME NO-GAPS.
ASSIGN COMPONENT FNAME OF STRUCTURE ITAB INTO <FVAL>.
IF SY-SUBRC = 0.
<FVAL> = 1.
ENDIF.Hope i am clear.
BR,
Suhas
Hi All,
I have a internal table as shown below.
Data : Begin of itab occurs 0,
w1 type i
w2 type i,
w3 type i,
w4 type i,
end of itab.
data : temp type i.
My query is I want to assign a numeric to the fields in ITAB depending upon the value of temp.
If temp = 1
itab-w1 = 1.
elseif temp = 2
itab-w2 = 1
elseif temp = 3
itab-w3 = 1.
endif.
I have 72 fields like this.
I want to concatenate a 'W' & temp into a character and pass this as parameter to Internal Table field.
Please let me know if the above scenario is possible.
Thank you all in advance
2010 Jan 06 10:20 AM
Hello Sandy,
Using Field symbols, this can be achieved very easily
Try this:
DATA:
TEMP TYPE N,
FNAME TYPE CHAR3.
FIELD-SYMBOLS: <FVAL> TYPE ANY.
CONCATENATE 'W' TEMP INTO FNAME. CONDENSE FNAME NO-GAPS.
ASSIGN COMPONENT FNAME OF STRUCTURE ITAB INTO <FVAL>.
IF SY-SUBRC = 0.
<FVAL> = 1.
ENDIF.Hope i am clear.
BR,
Suhas
2010 Jan 06 10:23 AM
yes you can...
Initially the value of temp will be 0.
now if you are increasing the value of temp (counter increament )
check for temp value before assigning as you did
ie :
If temp = 1
itab-w1 = 1.
elseif temp = 2
itab-w2 = 1
elseif temp = 3
itab-w3 = 1.
endif.
Regards
Satish Boguda
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |