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

interpret Field-Content

0 Likes
1,264

Hello,

I have in a table-field (Tab-Text for example) any Text like 'BSEG-BELNR'.

With the command "WRITE TABLE-FIELD.", the displayed result is 'BESG-BELNR'.

It is possible to see as result instead the text 'BESG-BELNR', the content from BESG-BELNR with a write command?

Thank You for your answer.

Marc

1 ACCEPTED SOLUTION
Read only

0 Likes
1,244

so, i test your solution, and it's work in one combination: here is my code.

==============================================

DATA table_field TYPE string.

FIELD-SYMBOLS <fs> TYPE ANY.

SELECT SINGLE text FROM dbtab INTO table_field

WHERE key EQ '123'.

ASSIGN (table_field) TO <fs>.

WRITE <fs>.

==============================================

if in text, i have 'BSEG-BELNR', it works fine.

but if in text, i habe 'BESG-BELNR BSEG-BUKRS' or 'BSEG-BELNR, BSEG-BUKRS', the programm dump and say that the field-symbol isn't assign.

the reason from this question is that we have actually in an programm this instruction:

CONCATENATE BSEG-BELNR BSEG-BUKRS into table_field SEPARATED BY space.

CALL FUNTION 'FUNCTION'

EXPORTING

param = table_field.

In the future, we wan't have the table_field dynamik, and then define it as text in dbtab.

Do you think it's possible?

11 REPLIES 11
Read only

Former Member
0 Likes
1,244

Use this code:


DATA table_field value 'BSEG-BELNR'.
FIELD-SYMBOLS: <fs> TYPE ANY
ASSIGN (table_field) TO <fs>.
WRITE : <fs>.

Please mark points if the solution was useful.

Regards,

Manoj

Read only

dhorions
Contributor
0 Likes
1,244

I think you should use a field symbol.

Documentation here : http://help.sap.com/saphelp_nw70/helpdata/en/fc/eb3860358411d1829f0000e829fbfe/frameset.htm

Some (untested) example code


FIELD-SYMBOLS: <fs> TYPE ANY.
ASSIGN (TABLE-FIELD) TO <fs>.

Read only

Former Member
0 Likes
1,244
Read only

0 Likes
1,244

Thanks to all for your help.

Read only

0 Likes
1,245

so, i test your solution, and it's work in one combination: here is my code.

==============================================

DATA table_field TYPE string.

FIELD-SYMBOLS <fs> TYPE ANY.

SELECT SINGLE text FROM dbtab INTO table_field

WHERE key EQ '123'.

ASSIGN (table_field) TO <fs>.

WRITE <fs>.

==============================================

if in text, i have 'BSEG-BELNR', it works fine.

but if in text, i habe 'BESG-BELNR BSEG-BUKRS' or 'BSEG-BELNR, BSEG-BUKRS', the programm dump and say that the field-symbol isn't assign.

the reason from this question is that we have actually in an programm this instruction:

CONCATENATE BSEG-BELNR BSEG-BUKRS into table_field SEPARATED BY space.

CALL FUNTION 'FUNCTION'

EXPORTING

param = table_field.

In the future, we wan't have the table_field dynamik, and then define it as text in dbtab.

Do you think it's possible?

Read only

0 Likes
1,244

Isn't that kind of logical?

if you read the link I posted in my original reply : http://help.sap.com/saphelp_nw70/helpdata/en/fc/eb3860358411d1829f0000e829fbfe/frameset.htm

you would have noticed that a field symbol is a symbol pointing to <b>a field</b>.

If you want to use space separated field names, you can use the split statement to get all the different field names out of your string and then assign each one of them to a field symbol.

Untested example code


data : itab type table of string, wa type string.
SPLIT table_field AT space INTO TABLE itab. 
loop at itab into wa.
  ASSIGN (wa) TO <fs>.
endloop.

Message was edited by:

Dries Horions

removed unfriendly stuff from reply

Read only

0 Likes
1,244

Hello Dries,

Yes, i have, in the meantime tested a simular solution to yours and it's works fine.

The link was very helpful and your message confirm that i have the correct solution.

Thank you very much.

Read only

former_member194669
Active Contributor
0 Likes
1,244

Hi,

Try this way


data : v_field like dd03;-fieldname.
v_field =  'BSEG-BELNR'.
condense   : v_field.
write : (v_field) to v_result no-zero

aRs

Read only

0 Likes
1,244

Hello aRs,

Does your solution only works with numerics fields?

Marc

Read only

former_member194669
Active Contributor
0 Likes
1,244

Hi,

No it will work with character /Numeric field also.


data : v_field like dd03;-fieldname.
v_field =  'BSEG-BELNR'.
condense   : v_field.
write : (v_field) to v_result  "<< You can write without No zero also

aRs

Read only

0 Likes
1,244

Hello aRs,

yes, i understand your solution. It's another way to resolve my problem.

Thanks to the community for your help.

Marc