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

Trimming Field/String Length

Former Member
0 Likes
1,787

Hi:

I an SQL statement in which I have a where clause in which I am comparing/matching 2 fields. I get the error message "...the fields *A and B* must have the same length and type". I know that the types are same but how do I reduce the length of field A to match field B. Field A is 18 characters and field B is 40 chars. Thanks in advance.

B

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,489

Hi,

If you use DP_XX9...

The field DP_XX9 will always have only one value..If the values are different in the internal table DATA_PACKAGE then you have to use the technique that I suggested.

Thanks,

Naren

8 REPLIES 8
Read only

Former Member
0 Likes
1,489

Hi,

if it is possible then take the same TYPE or else,

Move the Field to another field using the offset and use the new field in the where condition

Regards

Sudheer

Read only

LucianoBentiveg
Active Contributor
0 Likes
1,489

WHERE A EQ B(18).

Regards.

Read only

Former Member
0 Likes
1,489

Hi,

If you are using FOR ALL ENTRIES in your SQL..Move the values to an internal table that matches the data type and length..And use that internal table for the FOR ALL ENTRIES..

Thanks,

Naren

Read only

0 Likes
1,489

Okay here's a little more details. Also can you be a little more detailed (exact Syntax) as I'm not an ABAP programmer. Thanks

SELECT /BIC/XX1

/BIC/XX2

/BIC/XX3

FROM /BIC/ODS1

INTO TABLE ITAB_ODS1

FOR ALL ENTRIES IN DATA_PACKAGE

WHERE /BIC/XX1 = DATA_PACKAGE-/BIC/XX1

AND /BIC/XX2 = DATA_PACKAGE-/BIC/XX9.

Note: /BIC/XX2 length is 18 and /BIC/XX9 length is 40. Thanks

null

Read only

Former Member
0 Likes
1,489

Hi,

Check this solution..

TYPES: BEGIN OF TYPE_DATA,

/BIC/XX1 TYPE /BIC/ODS1-/BIC/XX1,

/BIC/XX2 TYPE /BIC/ODS1-/BIC/XX2,

END OF TYPE_DATA.

DATA: T_DATA TYPE STANDARD TABLE OF TYPE_DATA.

DATA: S_DATA TYPE TYPE_DATA.

LOOP AT DATA_PACKAGE.

S_DATA-/BIC/XX1 = DATA_PACKAGE-/BIC/XX1.

S_DATA-/BIC/XX2 = DATA_PACKAGE-/BIC/XX9.

APPEND S_DATA TO T_DATA.

ENDLOOP.

SELECT /BIC/XX1

/BIC/XX2

/BIC/XX3

FROM /BIC/ODS1

INTO TABLE ITAB_ODS1

<b>FOR ALL ENTRIES IN T_DATA

WHERE /BIC/XX1 = T_DATA-/BIC/XX1

AND /BIC/XX2 = T_DATA-/BIC/XX2</b>.

Thanks,

Naren

Read only

0 Likes
1,489

What do you think of this solution. Do you think this is workable? I like your solution but in the meanwhile I had worked up this one so I thought I might as well check with you. Thanks for your help sir.

DATA DP_XX9 LIKE DATA_PACKAGE-/BIC/XX9.

DP_XX9 = DATA_PACKAGE-/BIC/XX9.

DP_XX9 = DP_XX9(18). -


>I may be wrong but I'm trying to trim it------

  • (Fill Internal Table)

SELECT /BIC/XX1

/BIC/XX2

/BIC/XX3

FROM /BIC/ODS1

INTO TABLE ITAB_ODS1

FOR ALL ENTRIES IN DATA_PACKAGE

WHERE /BIC/XX1 = DATA_PACKAGE-/BIC/XX1

AND /BIC/XX2 = DP_XX9.

Read only

0 Likes
1,489

Thanks

Read only

Former Member
0 Likes
1,490

Hi,

If you use DP_XX9...

The field DP_XX9 will always have only one value..If the values are different in the internal table DATA_PACKAGE then you have to use the technique that I suggested.

Thanks,

Naren