Application Development 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: 

how to assign structure fild to a structure

Former Member
0 Kudos

my req is to make unicode enabled ..in ecc6.10.

code is:

TYPES: BEGIN OF xs_pa0007,

country(2),

national_id(20),

schkz type pa0007-schkz, "work schd rule

teilk(3), "type pa0007-teilk Part time EE yes/no

empct type pa0007-empct, "Emp percent

wostd(6). "Weekly work hours

TYPES: END OF xs_pa0007.

TYPES: BEGIN OF gs_paxxxx,

fill1,

begda TYPE pa0000-begda,

fill2,

seqnr TYPE pa0000-seqnr,

infty(4),

fill3,

subty TYPE pa0000-subty,

fill4,

pernr TYPE pa0000-pernr,

fill5,

copied,

fill6,

rec(1500),

END OF gs_paxxxx.

data: gw_pa0007 type xs_pa0007,

ga_paxxxx type gs_paxxxx.

gw_pa0007 = ga_paxxxx-rec.

in this line im getting error that

gw_pa0007 and ga_paxxxx-rec are not mutualy compatible in unicode program.

please tell me how to solve this ..

16 REPLIES 16

jayanthi_jayaraman
Active Contributor
0 Kudos

Hi,

Try

gw_pa0007-country = ga_paxxxx-rec+0(2).

gw_pa0007-national_id = ga_paxxxx-rec+2(20).

0 Kudos

Hi Yayanthi..

thxs its not gving error but how i need to knw only country n nation id.

is it like conssidering only type c flds from str..?

how u hv taken only country n nation id.. inthis ex?

please clear me..

0 Kudos

HI,

Try this

FIELD-SYMBOLS: <fs> TYPE ANY.

ASSIGN ga_paxxxx-rec to <fs> CASTING TYPE xs_pa0007.

gw_pa0007 = <fs>.

Regards,

Sesh

0 Kudos

HI sesha,

is it like casting to different structure..

ASSIGN ga_paxxxx-rec to <fs> CASTING TYPE xs_pa0007.

this statement is casting to structure of gw_pa0007 how it will take at run time?

0 Kudos

Hi,

This is like you have come data and you have the Address of the data in the memory in your field symbol and you are CASTING it to your type.

Then once it is casted to your type you can assign it to your normal data variable.

I hope it is working I have used this before.

Regards,

Sesh

Former Member
0 Kudos

Hi,

Use the WRITE TO Statment

WRITE ga_paxxxx-rec TO gw_pa0007.

Regards

Sudheer

jayanthi_jayaraman
Active Contributor
0 Kudos

Hi,

gw_pa0007-country = ga_paxxxx-rec+0(2).

gw_pa0007-national_id = ga_paxxxx-rec+2(20).

gw_pa0007-schkz = ga_paxxxx-rec+22(8).

gw_pa0007-teilk = ga_paxxxx-rec+30(3).

gw_pa0007-empct = ga_paxxxx-rec+33(5)."Check this,I am not very sure abt the values.Otherwise, change offset 5 accordingly to 6 or whateever

gw_pa0007-wostd = ga_paxxxx-rec+33(6)."accordingly change 33 to 34 or whatever

0 Kudos

hi thxs can u gv me ur id...

im still not clear ..

how u hv taken offset .. off all flds...

jayanthi_jayaraman
Active Contributor
0 Kudos

Hi,

It is based on declaration.If it is declared by database field other than character, go to that field and find the length of the field and then use it for offset.

field+starting_position(no. of characters)

and then add accordingly

0 Kudos

gw_pa0007-wostd = ga_paxxxx-rec+33(6)."accordingly change 33 to 34 or whatever

im didnt get this..

as this fld is declared as char then

i need to define its offset as 6 n lenght aslo 6..

0 Kudos

Hi,

For the previous field,I am not sure whether decimals will also be displayed.If it is displayed,then the length will be 6 for the previous field.Then you need to change starting position of this field to 34.If the decimal is not displayed,output of the previous field will be 5.Then the starting position of this field is 33.

0 Kudos

1....gw_pa0007-country = ga_paxxxx-rec+0(2).

2....gw_pa0007-national_id = ga_paxxxx-rec+2(20).

3....gw_pa0007-schkz = ga_paxxxx-rec+22(8).

4....gw_pa0007-teilk = ga_paxxxx-rec+30(3).

5....gw_pa0007-empct = ga_paxxxx-rec+33(5)."Check this,I am not very sure abt

the values.Otherwise, change offset 5 accordingly to 6 or whateever

6....gw_pa0007-wostd = ga_paxxxx-rec+33(6)."accordingly change 33 to 34 or

whatever

Hi Jayanthi,

im not getting y its offset is 33 in line 6.. as prev 5th line's offset is 33 already .. n we need to add accoundingly rite?

then 6th line wold be 37(6) ...?

0 Kudos

Hi,

Yes, you should add 33 and no. of characters.So it should be 38.

0 Kudos

Hi Jayanthi..

thanxs thanxu very much Jayanthi....

0 Kudos

Hi,

Can you please reward points by clicking the star for all useful answers and then close the thread.

0 Kudos

HI Jayanthi,,

any other way to solve this problem.

bcz in my req i have some many stru to define like this in many programs..

if aother way please let me knw...