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

Offset problem in select query

satish_kumar127
Participant
0 Kudos
1,217

Hi experts,

I have a select query , in my where condition , comparing fields types are different

following is my select query

SELECT spras  prctr  ktext FROM cepct INTO CORRESPONDING FIELDS OF TABLE it_cepct FOR ALL ENTRIES IN it_vbsegd

                                                           WHERE prctr = it_vbsegd-bupla .

here prctr length = 10

and bupla length = 4.

we can give offset after "=" sign, but i want to use on prctr field,  could anybody please give me some idea to achieve this.

thanks in advance

1 ACCEPTED SOLUTION
Read only

Former Member
0 Kudos
649

Hi satish,

You can't do that, you can't control field length in the ABAP SQL side, at least not without HANA or native SQL.

I'd probably add a new column to table it_vbsegd, like PRCTR with your value. And then:

loop at it_vbsegd assigning <fs>.

     <fs>-prctr = <fs>-bupla.

endloop.

your sql instruction:

SELECT spras  prctr  ktext FROM cepct INTO CORRESPONDING FIELDS OF TABLE it_cepct FORALL ENTRIES IN it_vbsegd

                                                           WHERE prctr = it_vbsegd-prctr .

regards,

Edgar

9 REPLIES 9
Read only

Former Member
0 Kudos
649

Hi Satish,

use as follws;

WHERE prctr(4) = it_vbsegd-bupla .

Regards,

Ritesh

Read only

0 Kudos
649

hi ritesh,

thanks for the reply, but it will not work, it's throwing error like

field prctr(4) is unknown.

Regards

satish

Read only

former_member196651
Contributor
0 Kudos
649

Hi,

Whether your field it_vbsegd-bupla is containing both PRCTR and BUPLA? Then you can use it in 2 ways.

If PRCTR is first in it_vbsegd-bupla, then use like it_vbsegd-bupla+0(10).

If PRCTR is after BUPLA, then use like it_vbsegd-bupla+4(10).

Regards,

Abijith

Read only

0 Kudos
649

Hi Abijith,

here it_vbsegd is an internal table

as i know when we are comparing with internal table field, we can use  "=" sign only.  any other alternate please

thanks & regards

satish

Read only

Former Member
0 Kudos
649

If  zeros alone will be there in prctr when it compare to bupla(prctr = 0000001000 & bupla = 1000 ). If that is the the problem. then you can add zeros to the bupla field and put it in one variable. and u an use that to compare to prctr.

like ,

where prctr = v_bupla

Regards,

Poornima

Read only

Former Member
0 Kudos
650

Hi satish,

You can't do that, you can't control field length in the ABAP SQL side, at least not without HANA or native SQL.

I'd probably add a new column to table it_vbsegd, like PRCTR with your value. And then:

loop at it_vbsegd assigning <fs>.

     <fs>-prctr = <fs>-bupla.

endloop.

your sql instruction:

SELECT spras  prctr  ktext FROM cepct INTO CORRESPONDING FIELDS OF TABLE it_cepct FORALL ENTRIES IN it_vbsegd

                                                           WHERE prctr = it_vbsegd-prctr .

regards,

Edgar

Read only

0 Kudos
649

Oh, like Poornima mentioned, you might need to add zeros in left. Something like:

     call function 'CONVERTION_EXIT_ALPHA_INPUT'

             exporting input = <fs>-bupla importing output = <fs>-prctr.

Read only

Former Member
0 Kudos
649

Dear Satish Kumar,

Try this

SELECT spras  prctr  ktext FROM cepct

                            INTO CORRESPONDING FIELDS OF TABLE IT_CEPCT

                            WHERE prctr cs it_vbsegd-bupla

                              AND SPRAS EQ 'E'.


Regards,

Read only

Former Member
0 Kudos
649

Hi,

created another internal table it_tab to get the result which you wanted.

DATA : it_cepct TYPE TABLE OF cepct,

           it_vbsegd TYPE TABLE OF vbsegd,

           wa_vbsegd type vbsegd.

TYPES : BEGIN OF ty_tab,

         bupla(10),

         END OF ty_tab.

         DATA : it_tab TYPE TABLE OF ty_tab,

                lv_bupla(10).

   select * UP TO 2 ROWS  FROM vbsegd INTO TABLE it_vbsegd.

   loop at it_vbsegd INTO wa_vbsegd.

     UNPACK wa_vbsegd-bupla to lv_bupla.

     append lv_bupla to it_tab.

     CLEAR : lv_bupla,wa_vbsegd.

   ENDLOOP.

   SELECT spras  prctr  ktext FROM cepct INTO CORRESPONDING FIELDS OF TABLE it_cepct FOR ALL ENTRIES IN it_tab

                                                            WHERE prctr = it_tab-bupla.