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

Need a generic data type to hold any string

Former Member
0 Likes
517

Hi,

I m trying to write a program which can log data from any table into a Trace Z table.

I have used

FIELD-SYMBOLS: <line>.

to get the line of that table. But now I want to dynamically know what are the field names of this line structure and the data in it. And then write it as a string to the trace Z table

form log_table_data tables rt_any_table

using rv_statement type string.

data: v_line type string,

v_char_line type char255.

FIELD-SYMBOLS: <line>.

loop at rt_table ASSIGNING <LINE>.

v_char_line = <LINE>. - Terminating at this statement

  • ASSIGN <LINE> to v_line casting type string.

endloop.

endform.

Thanks for reading

1 ACCEPTED SOLUTION
Read only

mvoros
Active Contributor
0 Likes
424

Hi,

if you are interested in generic programming in ABAP then this [presentation|https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/b332e090-0201-0010-bdbd-b735e96fe0ae] is full of information. There is a class CL_ABAP_STRUCTDESCR with method GET_COMPONENTS. This method returns a list of components of table or structure. So you will be able to loop over every field in the table and convert each field into string.

Cheers

Hi,

I m trying to write a program which can log data from any table into a Trace Z table.

I have used

FIELD-SYMBOLS: <line>.

to get the line of that table. But now I want to dynamically know what are the field names of this line structure and the data in it. And then write it as a string to the trace Z table

form log_table_data tables rt_any_table

using rv_statement type string.

data: v_line type string,

v_char_line type char255.

FIELD-SYMBOLS: <line>.

loop at rt_table ASSIGNING <LINE>.

v_char_line = <LINE>. - Terminating at this statement

  • ASSIGN <LINE> to v_line casting type string.

endloop.

endform.

Thanks for reading

1 REPLY 1
Read only

mvoros
Active Contributor
0 Likes
425

Hi,

if you are interested in generic programming in ABAP then this [presentation|https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/b332e090-0201-0010-bdbd-b735e96fe0ae] is full of information. There is a class CL_ABAP_STRUCTDESCR with method GET_COMPONENTS. This method returns a list of components of table or structure. So you will be able to loop over every field in the table and convert each field into string.

Cheers