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: 

Can I Use Time in WHERE condition of SELECT statement?

Former Member
0 Kudos
93

Hi Experts,

Can I use the Time field value HH:MM:SS to pull a key field value from a table?

e.g.

I wanna to pull MBLNR from MKPF table.

But MBLNR is a key field in MKPF and its becoming very difficult to find out the (other fields) comibination to treate as Uniuqe, which is supposed to be used in WHERE condition in SELECT statement!

So, in this case, Can I use CPUTM-Document Created Time of MKPF table to fetch the MBLNR value?

If, so, What r the constraints?

ThanQ.

1 ACCEPTED SOLUTION

Former Member
0 Kudos
60

You can have a look at the indexes created on MKPF to see which would suit you best. Selection by any fields outside of the index may cause performance issues, esp. since the time field may not be unique.

In SE11, display the table and choose Goto > Indexes. This should give you a list of the avbl indexes on MKPF. I saw one with created date on it, maybe that will help?

PS: Selection with the created time does not seem like a good idea, since many documents may be created at the same time on various days.. it will be difficult to manage the list and get the document you need.

Hope this helps.

Sudha

9 REPLIES 9

Former Member
0 Kudos
60

Hi,

Yes, You can use CPUTM as a search criteria to pull the records from MKPF

But you will get only a single daya records.

So it is not a good practice to use this single field alsone.

for that also declare this fields as select-options,

so that you enter some range an d it will pickup the records in that range.

Because if we give a single record then it is difficult to fetch that single record.

reward if useful

regards,

ANJI

0 Kudos
60

ThanQ Anji Reddy,

I understand ur response.

But, my requirement is, just to fetch a single MBLNR of a single record (here, one single BDC prgram is creating 123, and 124 goods mvmnt types immediately one after other i.e. with seconds difference) which is created just before!

So, What r ur comments?

ThanQ.

Former Member
0 Kudos
60

i guess u have to give CPUDT also along with CPUTM...

Former Member
0 Kudos
61

You can have a look at the indexes created on MKPF to see which would suit you best. Selection by any fields outside of the index may cause performance issues, esp. since the time field may not be unique.

In SE11, display the table and choose Goto > Indexes. This should give you a list of the avbl indexes on MKPF. I saw one with created date on it, maybe that will help?

PS: Selection with the created time does not seem like a good idea, since many documents may be created at the same time on various days.. it will be difficult to manage the list and get the document you need.

Hope this helps.

Sudha

0 Kudos
60

ThanQ Sudha Mohan,

UR right.

ur cooment 1- performance:

But, I can create(if situation demands) a secondary index for time field.

ur 2 nd comment: multilplr records fetched:

To avoide milptiple record fetching( i wanna a single MBLNR value of a single record) I use Date filed value also(any how u said, that there is key for date)

ur comments welcome.

ThanQ.

0 Kudos
60

Not quite sure where this discussion is going - are you asking for comments regarding the creation of a secondary index on Creation time?

Anyway.. creation time does not seem like a good idea at all, but then again this is my view. I would think you should go with the creation date as far as possible.

On reading through your response to Anji, I gathered that you need to capture the document number of the doucment created for the first movement type just before you launch the second BDC.. if that is the requirement, you can possibly read the parameter ID MBN, which should have the document number stored in it.

F1 on the GET PARAMETER statement should tell you how to do so.

Of course, here the assumption would be that no other documents have been created after the first BDC run, as the MBN parameter will only store the last document number..

Hope this helps.

Sudha

0 Kudos
60

ThanQ Sudha Mohan,

Ur right. I can use the ID MBN. Ur assumption is correct, no other mblnr wuld b created, bfor launching second mvmnt type.

ThanQ.

0 Kudos
60

Hi Sudha Mohan,

A - section of my_bdc_prog wuld create a material doc. with mvmnt type 123.

Immediately next moment,

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

B- section of my_bdc_prog wuld create a material doc. with mvmnt type 124.

So,

1) Can I use directly (with out using SET PARAMETER ID MBN FILED store_my_mblnr_123 i.e. I mean, Is it that, automatically, the SAP stores the just created MBLNR in its MBN parameter ID ) as,

GET PARAMETER ID MBN FIELD MY_MBLNR_123_FOR_USE_IN_124,

in the place above, where I noted as 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'

The, i wanna use this MY_MBLNR_123_FOR_USE_IN_124 for further program code!

note - The same thing is posted in my thread as '' GET PARA ID with out SET PARA ID''

Is it works out?

ThanQ.

Former Member
0 Kudos
60

Hi Sridhar,

Its always better to use all key fields in select statement so that the process and the performance will be good.

Regards,

Suresh