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

Structure mismatch error

Former Member
0 Likes
1,244

Hi All,

I am getting below error in a program -

"LS_BAPICUSGEN" and "T_BAPISTRUCT-DATA" are not mutually convertible in a Unicode program.

The code extract is -

MOVE t_bapistruct-data to ls_bapicusgen.

Here,

t_bapistruct-data is a charcter field of length 4000 and ls_bapicusgen is a work area of type BAPICUSGEN which contains 111 fields.

Please let me know how to fix this error and how to pass a string to the work area.

Thanks in advance.

Amogh

1 ACCEPTED SOLUTION
Read only

jayanthi_jayaraman
Active Contributor
0 Likes
1,123

Hi,

Try using fieldsymbols.

field-symbols <fs> type t_bapistruct-data.

assign t_bapistruct-data to <fs> casting BAPICUSGEN.

Check and let me know if it works.

If so,kindly reward points by clicking the star on the left of reply and close the thread.

8 REPLIES 8
Read only

Former Member
0 Likes
1,123

Hi,

you try with Move corresponding..

regards

Sandeep

Read only

Former Member
0 Likes
1,123

MOVE-corresponding t_bapistruct-data to ls_bapicusgen.

Read below info.

MOVE-CORRESPONDING sourcestruct TO destinationstruct.

This statement assigns the contents of the components of structure sourcestruct to the components of the destinationstruct structure that have identical names.

When it is executed, it is broken down into a set of MOVEstatements, one for each pair of fields with identical names, as follows:

MOVE sourcestruct-comp1 TO destinationstruct-comp1.

MOVE sourcestruct-comp2 TO destinationstruct-comp2.

...

Any necessary type conversions are performed individually.

http://help.sap.com/saphelp_nw2004s/helpdata/en/fc/eb3260358411d1829f0000e829fbfe/content.htm

I hope it helps.

Best Regards,

Vibha

*Please mark all the helpful answers

Read only

0 Likes
1,123

Hi,

I cant use MOVE-CORRESPONDING here because my source structure is a string (t_bapistruct-data). The field data is string of 4000 character length.

Is there any other way of doing it?

Read only

Former Member
0 Likes
1,123

You cannot assign the 4000 character field to a table with different fields .. because that table may contain numeric or non charecter fields.

to achieve the functionality you have to divide the field

t_bapistruct-data manually into different parts you can do that as

ls_bapicusgen-field1 = t_bapistruct-data(0)+10.

hope ths helps.

Read only

0 Likes
1,123

Yes... surely this is one method... But not feasible when you have 150 fields in your target structure. Need to calculate offset for all 150 fields...

Is there any other simple and more accurate method of achiving this.

Amogh

Read only

jayanthi_jayaraman
Active Contributor
0 Likes
1,124

Hi,

Try using fieldsymbols.

field-symbols <fs> type t_bapistruct-data.

assign t_bapistruct-data to <fs> casting BAPICUSGEN.

Check and let me know if it works.

If so,kindly reward points by clicking the star on the left of reply and close the thread.

Read only

0 Likes
1,123

Hi Jayanthi,

It is working with slight modifications....

I did it in this way...

field-symbols <fs> type Target structure.

assign source structure to <fs> casting.

No need to add structure name after Casting addition.

Thanks a lot for solving the problem....

Full points to u

Amogh

Read only

Former Member
0 Likes
1,123

Hi Amogh,

Using offset values you can transfer data from T_BAPISTRUCT-DATA to LS_BAPICUSGEN.

For e.g

data: T_BAPISTRUCT-DATA like line of T_BAPISTRUCT-DATA.

LOOP AT T_BAPISTRUCT-DATA into S_BAPISTRUCT-DATA

LS_BAPICUSGEN-CUSTOMER = S_BAPISTRUCT-DATA+1(10).

LS_BAPICUSGEN-ACC_1_TIME = S_BAPISTRUCT-DATA+11(1).

LS_BAPICUSGEN-ORDR_BLK_G = S_BAPISTRUCT-DATA+ 12(2).

. . . . .

. . . . .

append LS_BAPICUSGEN to LT_BAPICUSGEN.

ENDLOOP.

If helpful reward points.

Regards

Bhupal Reddy