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

How to select by Range?

Former Member
0 Likes
2,030

Hi Experts,

I want to get the data when people log in and  this data was save in two tables A and B.

A has the information but without the user_name

so I need to select the A table first and get the user_name in table B

And I also try to set a 5 sec buffer just in case

so here comes the problem!!!!!!!!!!

I use Range to set the buffer

r_utime-sign = 'I'.

r_utime-option = 'BT'.

r_utime-low = icd-utime.

r_utime-high = icd-utime + 000005.

   SELECT SINGLE * FROM B

   WHERE clas = icd-clas

   AND   id = icd-id

   AND   udate = icd-udate

   AND   utime IN r_utime

   .

For Example.

I have a data like below

   sign = I

    option = BT

   low = 141430

    high = 141435

But after execute the program,I still get a data which it's time = 141152

it should not in this report.Because 141152  not between  141430~141435.

Is any wrong happen in my program?

Hi Experts,

I want to get the data when people log in and  this data was save in two tables A and B.

A has the information but without the user_name

so I need to select the A table first and get the user_name in table B

And I also try to set a 5 sec buffer just in case

so here comes the problem!!!!!!!!!!

I use Range to set the buffer

r_utime-sign = 'I'.

r_utime-option = 'BT'.

r_utime-low = icd-utime.

r_utime-high = icd-utime + 000005.

   SELECT SINGLE * FROM B

   WHERE clas = icd-clas

   AND   id = icd-id

   AND   udate = icd-udate

   AND   utime IN r_utime

   .

For Example.

I have a data like below

   sign = I

    option = BT

   low = 141430

    high = 141435

But after execute the program,I still get a data which it's time = 141152

it should not in this report.Because 141152  not between  141430~141435.

Is any wrong happen in my program?

14 REPLIES 14
Read only

Former Member
0 Likes
1,971

Hi,

Try to add the last line just in to position where i addded:

r_utime-sign = 'I'.

r_utime-option = 'BT'.

r_utime-low = icd-utime.

r_utime-high = icd-utime + 000005.

APPEND r_utime.

Read only

0 Likes
1,971

hey Solc,

thanks your respond, I try to add append but in vain.....

Read only

arindam_m
Active Contributor
0 Likes
1,971

Hi,

In your case r_utime is like an work area. You need to append it to a internal table with similar structure as r_utime. then use the same in SELECT query after IN, it will work.

Cheers,

Arindam

Read only

Former Member
0 Likes
1,971

Hi,

Below statement missed in your code before select query.

APPEND R_UTIME[].

Regards,

Shaiksha Vali.

Read only

Former Member
0 Likes
1,971

Hi,

like Jiri Solc allready said the append is Missing.

Additional be sure that you have defined:

1st.)     The range where you add the  Values for the Select.

2nd.)    The Line of the Range where you set the Values.

The SAP Example is this here:

In your case spfli-carrid would be B-utime

DATA: spfli_wa TYPE spfli,
      r_carrid TYPE RANGE OF spfli-carrid, 

      r_carrid_line LIKE LINE OF r_carrid.

r_carrid_line-sign   = 'I'.
r_carrid_line-option = 'BT'.
r_carrid_line-low    = 'AA'.
r_carrid_line-high   = 'LH'.
APPEND r_carrid_line TO r_carrid.

SELECT *
       FROM spfli
       INTO spfli_wa
       WHERE carrid IN r_carrid.
  ...
ENDSELECT.

Greets,

Lars

Read only

matt
Active Contributor
0 Likes
1,971

Run in debug. Check the contents of r_utime.

Read only

Former Member
0 Likes
1,971

Hi Matthew,

the content is right,I run in debug mode many times

R_UTIME=IBT141430141435

But when I use R_UTIME to select,it still get the data not in this section

(141430~141435).

Ex.141152



Read only

Former Member
0 Likes
1,971

There's a difference between workarea and internal table.

I bet you checked

  r_utime

But you should check:

r_utime[1] or

r_utime[1]-sign

r_utime[1]-option
and so on.

If those there is nothing then your range is empty.

Read only

arindam_m
Active Contributor
0 Likes
1,971

Hi,

Please check the definition and the way you populate the data.

The following code is and working example where the ranges tab is populated ok.

DATA: x_utime TYPE sy-uzeit.

RANGES r_utime FOR x_utime.


START-OF-SELECTION.

  r_utime-sign = 'I'.
  r_utime-option = 'BT'.
  r_utime-low = sy-uzeit.
  r_utime-high = sy-uzeit + 000005.

  APPEND r_utime.

Also check the time representation fo the entries that get selected. Might be that the SELECT query fails due to a mismatch in Time format in table and your Ranges.

Cheers,

Arindam

Read only

Former Member
0 Likes
1,971

Hi, or you can post your code inluding declarations. J.S.

Read only

jayakrishnan86
Explorer
0 Likes
1,971

Hi ,

Can you please post your code here..

Your logic seems to be ok..

but still lets see the complete code written

Read only

Former Member
0 Likes
1,971

Hi jack,

follow this SCN thread:

http://scn.sap.com/message/5164121

http://scn.sap.com/message/4601722

Thanks

Sabyasachi

Read only

Former Member
0 Likes
1,971

Hi ,

ranges: bukrs for zstock-bukrs.

bukrs-sign = 'E'.             "Exclude

bukrs-option = 'CP'.        "Pattern

bukrs-low = 'AB*'.            "Low Value

bukrs-high = ''.                "High Value

append bukrs.

Always remember to APPEND your range when you fill it, as the WHERE clause checks against the lines of the range table, not against the header line.

Hope this explains it well enough.

Thanks

Sabyasachi

Read only

Former Member
0 Likes
1,971

Hi Jack,

I guess you have not appended your RANGE, thats why wrong data is fetched from table B.

Write the code as mentioned below:

r_utime-sign = 'I'.

r_utime-option = 'BT'.

r_utime-low = icd-utime.

r_utime-high = icd-utime + 000005.

APPEND r_utime.

Now write down your Select query.

   SELECT SINGLE * FROM B

   WHERE clas = icd-clas

   AND   id = icd-id

   AND   udate = icd-udate

   AND   utime IN r_utime