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

Read structure FIELD Dynamically

Former Member
0 Likes
6,972

Hi All Experts,

I am working on CO-PA exit EXIT_SAPLKEAB_001.

In this exit we have a structure EP_SOURCE. This structure gets its structure dynamically. In my case this is of type CE1SN00. These CE1 tables gets generated in SAP dynamically when you maintain any Operating Concern in CO-PA. In my case Operating concern SN00 has been maintained. And in this CE1SN00 there are multiple Value fields. I have to apply a formula on one of the fields.

The problem is that I have to apply a formula on different fields everytime. I have a Z table which has fields 'Operating Concern', 'Field' and 'Active Indicator'. I have to read this Z table based on the Operating Concern and get the 'Field' name.

For example in my Z table if I have a Operating Concern 'S_AL' and field 'KWBLOK_ME'. And the EP_SOURCE structure has got an entry from table 'CE1S_AL'. I have to read 'EP_SOURCE-KWBLOK_ME' and apply the formula on it.

And next time if I have a Operating Concern 'S_AL' and field 'KWFLHR_ME'. I have to read 'EP_SOURCE-KWFLHR_ME' and apply the formula on it.

What I have done so far is I have defined a structure IT_CE1S_AL as type CE1S_AL and moving all the values from EPSOURCE to IT_CE1S_AL. Now I have to read the value of only that field which is there in 'Z' table.

I hope I have explained this well. Please help me in solving this problem.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,584

hi Rajesh

You need to use field symbols for this...

here is the sample code.

field-symbols <fs1>.

loop at itab.

itab-field1 = 'KWBLOK_ME' .

Assign the itab-field1 of structure CE1S_AL to <f1>.

  • You have the values in <f1> as

value = <f1>.

*You can apply the formula here..

endloop.

Hope this will help you.

Regards,

Richa

8 REPLIES 8
Read only

Laxmana_Appana_
Active Contributor
0 Likes
2,584

Hi,

Check this FM : DYNP_VALUES_READ to read the field values.

Regards

Appana

Read only

0 Likes
2,584

Hi Appana,

Thanks for your reply, but this won't solve my problem, here I am trying to read a structure in a user-exit and want to read one field only from that structure and this one field could be anything.

For example: I have a structure called MARA. In first instance I want to read MARA-ERSDA because ERSDA is there in my 'Z' table and in second instance I might have to read field MARA-LAEDA because the ERSDA field has been replced by LAEDA now in the 'Z' table.

Cheers!!

Read only

Former Member
0 Likes
2,584

Try this:

FIELD-SYMBOLS: <f1> TYPE ANY, <f2> TYPE ANY, <f3> TYPE ANY.

ASSIGN EP_SOURCE TO <f1>.

ASSIGN 'S_AL' TO <f2>.

ASSIGN COMPONENT <f2> OF STRUCTURE <f1> TO <f3>.

<f3> contains the required value

Read only

naimesh_patel
Active Contributor
0 Likes
2,584

Hello,

Take your all fields into an internal table from your Ztable.

field-symbols:<f1> type any.

Loop at itab.

  • itab-fld = 'KWBLOK_ME' .

assign component itab-fld of structure CE1S_AL to <f1>.

  • now you have values in the <f1> as

f_value = <f1>.

endloop.

regards,

Naimesh

Read only

Former Member
0 Likes
2,585

hi Rajesh

You need to use field symbols for this...

here is the sample code.

field-symbols <fs1>.

loop at itab.

itab-field1 = 'KWBLOK_ME' .

Assign the itab-field1 of structure CE1S_AL to <f1>.

  • You have the values in <f1> as

value = <f1>.

*You can apply the formula here..

endloop.

Hope this will help you.

Regards,

Richa

Read only

0 Likes
2,584

Hi Richa,

Thanks for ur reply. But my requirement is something different. I have tried the field symbols but getting an error message - "Data object 'EP_SOURCE' does not have a component called <FS1>".

Once again my requirement is:

I have a Z table ZCO_VALUE. The structure of the table is:

_______________________________________

MANDT | OP_CON | FIELD | A_IND |

-


And there 2 two entries in this table:

_______________________________________

100 | S_AL |KWBLOK_ME | A |

100 | S_AL |KWBLHR_ME | A |

-


And I have a structure EP_SOURCE in user-exit which is just like CE1S_AL. KWBLOK_ME & KWBLHR_ME are technical field names in CE1S_AL. I want to read the value of either CE1S_AL-KWBLOK_ME or CE1S_AL-KWBLHR_ME.

Now in my first instance I want to read

EP_SOURCE-KWBLOK_ME, but I have KWBLOK_ME as a value in ITAB_ZCO_VALUE. I have defined a field-symbol <fs1> to get values KWBLOK_ME or KWBLHR_ME. And trying to read by write the code as:

get_value = EP_SOURCE-<fs1> or

Assign ep_source-<fs1> to get_value.

But because ep_source is not referenced to any structure I can't use any of the above statement.

Thanks

Read only

0 Likes
2,584

Hi,

Thanks a lot.

This Assign component statement solved my problem.

Many Thanks.

Have a Nice Day

Read only

0 Likes
2,584

Hi Vijay, Naimesh, Richa:

Thanks to All.

I have got my code working now.

I was using ASSIGN statement only. Silly Me.

By using ASSIGN COMPONENT I got what I want.

Many Thanks to All of YOU who replied to my post.