Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Internal Table Field as a Parameter

Former Member
0 Likes
493

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

1 ACCEPTED SOLUTION
Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
448

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

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

2 REPLIES 2
Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
449

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

Read only

Former Member
0 Likes
448

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