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

Field Symbol Assignment ?

Former Member
0 Likes
729

Hello All,

I have a variable in which the value will be a FIELDNAME.

Now I want to create a fieldsymbol of the type of the FIELDNAME,

How can I do that ?



Data : gv_value type string.
Field-symbols: <fs_field> type any.

gv_value = 'TIMESTAMP'.

Now I want the fieldsymol <fs_field> to be created with the type 'TIMESTAMP'.

Regards,

Deepu.k

Hello All,

I have a variable in which the value will be a FIELDNAME.

Now I want to create a fieldsymbol of the type of the FIELDNAME,

How can I do that ?



Data : gv_value type string.
Field-symbols: <fs_field> type any.

gv_value = 'TIMESTAMP'.

Now I want the fieldsymol <fs_field> to be created with the type 'TIMESTAMP'.

Regards,

Deepu.k

5 REPLIES 5
Read only

Former Member
0 Likes
708

Use this code.

assign <fs_field> to gv_value.

this will point to gv_value and the value of it will be 'TIMESTAMP'.

Regards,

Siddarth

Read only

dev_parbutteea
Active Contributor
0 Likes
708

Hi,

what do you actually want to do with the field symbol?

If you wan to declare the field symbol of the type of the variable, TYPE ANY will do.

Edited by: Dev Parbutteea on Feb 7, 2009 8:34 AM

Read only

Former Member
0 Likes
708

hi...

you can use statment...

assign gv_value to <fs_field>.

infact if you are using

type any it takes generic type and you can assign any field of any data type to the field string.

now <fs_field> will point to memory address value of gv_value and along with this you can chage value of gv_field by assigning some value to <fs_field>.

regards

Edited by: Mohit Kumar on Feb 7, 2009 8:23 AM

Read only

0 Likes
708

Hello All,

Actually I'm writing a Query which is Dynamic :


  DATA: lv_count        TYPE p,
        lv_ddtext       TYPE ddtext,
        lv_field_value  TYPE string,
        lv_field_list   TYPE string.

  FIELD-SYMBOLS : <fs_field> TYPE ANY.

* Populate the Dynamic Clause for the Total number of Records Data
  CLEAR gv_value.
* Get the Dynamic Field and Value of the Key Field of the SON Table
  ASSIGN gwa_znrows_def-kfldname TO <fs_value>.  "FIeldname
* Populate field for Dynamic Where condition
  CONCATENATE '' <fs_value> '' INTO gv_value.
  CONDENSE gv_value.
* Fetch the Data from the SON table
  CLEAR: lv_count,gv_count.
* Populate the dynamic fetch clause
  CONCATENATE '' <fs_value> '' INTO lv_field_list.
  CONCATENATE lv_field_list 'COUNT( * ) AS COUNT' INTO lv_field_list
              SEPARATED BY space.
* Fetch the Count from the SON DBT
  CLEAR lv_field_value.
  SELECT (lv_field_list) FROM (gwa_znrows_def-son)
                         INTO (lv_field_value,lv_count)
*                         INTO (<fs_field>,lv_count)
                         GROUP BY (gv_value).

The above Select Query is working fine for all the type of Fields except the Types RAW and DEC21 (TIMESTAMP).

SO, I've decided to change the type of the Into fieldlist (lv_field_value).

Now, the type of lv_field_value is string.

If I make it to the type of the fieldname , then I'll not have any problems in the select query.

So my point is how to create the fieldsymbol with the type of the Fieldname which is available in gv_value.

when I say --> assign gv_value to <fs_field>.

The value of the <fs_field> is 'TIMESTAMP'.

But the type is C of length 1000.

But I want the type of Timestamp i.e DEC 21.

How can I do this ?

Regards,

Deepu.k

Read only

0 Likes
708

Hello All,

I solved the issue.

I used the Create Data Syntax.


Data:         lv_dyn_data     TYPE REF TO data.

* Create the FieldSymbol type Dynamically
  CREATE DATA lv_dyn_data TYPE (gv_value).
  ASSIGN lv_dyn_data->* TO <fs_field>.

Now, everything is working fine.

Regards,

Deepu.k