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

Ranges problem

kesavadas_thekkillath
Active Contributor
0 Likes
1,170

Hi friends im pasting my code below.

The problem is the select Query is not returning any records when in pass the material input as 'F*' in my function module

Here pi_material holds the material No as F*


*Local internal tables Declaration
data: lr_matnr  TYPE RANGE OF mara-matnr,
      lr_batch  TYPE RANGE OF mch1-charg.

*Local WorkAreas
  DATA: wa_matnr like LINE OF lr_matnr,
        wa_batch like line of lr_batch.


  wa_matnr-sign = wa_batch-sign = zdic_pd_cl_common=>gc_sign_i.

  IF pi_material IS NOT INITIAL.
    MOVE pi_material TO wa_matnr-low.
    IF wa_matnr-low CA '*'.
      wa_matnr-option = zdic_pd_cl_common=>gc_option_cp.
      REPLACE ALL OCCURRENCES OF '*' IN wa_matnr-low WITH '%'.
    ELSE.
      wa_matnr-option = zdic_pd_cl_common=>gc_option_eq.
    ENDIF.
    APPEND wa_matnr TO lr_matnr.
  ENDIF.

  IF pi_batch IS NOT INITIAL.
    MOVE pi_batch TO wa_batch-low.
    IF wa_batch-low CA '*'.
      wa_batch-option = zdic_pd_cl_common=>gc_option_cp.
      REPLACE ALL OCCURRENCES OF '*' IN wa_batch-low WITH '%'.
    ELSE.
      wa_batch-option = zdic_pd_cl_common=>gc_option_eq.
    ENDIF.
    APPEND wa_batch TO lr_batch.
  ENDIF.


*Fetch Batch Data
  SELECT charg INTO TABLE et_batch FROM mch1 WHERE matnr in lr_matnr
                                             AND charg in lr_batch
                                             AND lvorm = space.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,063

may it be you forgot "corresponding fields of", between into and table?

8 REPLIES 8
Read only

Former Member
0 Likes
1,064

may it be you forgot "corresponding fields of", between into and table?

Read only

Former Member
0 Likes
1,063

HI,

You have not update the ranges completly.

For a range you must have the following fields to update

SIGN and OPTION

LR_MATNR-SIGN = 'I'.

LR_MATNR-OPTION = 'EQ'.

APPEND LR_MATNR.

LR_BATCH-SIGN = 'I'.

LR_BATCH-OPTION = 'EQ'.

APPEND LR_BATCH.

With the ranges data capturing, you must have to append these values.

After that you can use in your queries.

Regds,

Anil

Read only

0 Likes
1,063

Hey anil he gave thos values, just have a closer look at his code. it is all there.

Read only

Former Member
0 Likes
1,063

THE % USED IN LIKE STATMENT NOT IN IN STATEMENT

IF pi_material IS NOT INITIAL.
    MOVE pi_material TO wa_matnr-low.
    IF wa_matnr-low CA '*'.
      wa_matnr-option = zdic_pd_cl_common=>gc_option_cp.
*      REPLACE ALL OCCURRENCES OF '*' IN wa_matnr-low WITH '%'. "COMMENT THIS LINE
    ELSE.
      wa_matnr-option = zdic_pd_cl_common=>gc_option_eq.
    ENDIF.
    APPEND wa_matnr TO lr_matnr.
  ENDIF.
 
  IF pi_batch IS NOT INITIAL.
    MOVE pi_batch TO wa_batch-low.
    IF wa_batch-low CA '*'.
      wa_batch-option = zdic_pd_cl_common=>gc_option_cp.
*      REPLACE ALL OCCURRENCES OF '*' IN wa_batch-low WITH '%'. "COMMENT THIS LINE
    ELSE.
      wa_batch-option = zdic_pd_cl_common=>gc_option_eq.
    ENDIF.
    APPEND wa_batch TO lr_batch.
  ENDIF.

Read only

Pawan_Kesari
Active Contributor
0 Likes
1,063

do not replace * with %

Read only

0 Likes
1,063

Hi since im passing CP in the ranges i should give '%'.

But Even i tried without it but still no use

Read only

0 Likes
1,063

Hi,

Check this.

wa_matnr-sign = wa_batch-sign = 'I'.


  IF pi_material IS NOT INITIAL.
    MOVE pi_material TO wa_matnr-low.
    IF wa_matnr-low CA '*'.
      wa_matnr-option = 'CP'.
     ELSE.
      wa_matnr-option = 'EQ'.
    ENDIF.
    APPEND wa_matnr TO lr_matnr.
  ENDIF.
 
  IF pi_batch IS NOT INITIAL.
    MOVE pi_batch TO wa_batch-low.
    IF wa_batch-low CA '*'.
      wa_batch-option = 'CP'.
    ELSE.
      wa_batch-option = 'EQ'.
    ENDIF.
    APPEND wa_batch TO lr_batch.
  ENDIF.

Other way is simply comment above code.

Declare ur parameters as select-options with no intervals and No extention and use IN operator in the select query.

Thanks,

Vinod.

Read only

kesavadas_thekkillath
Active Contributor
0 Likes
1,063

Hi GTREN the solution was correct but it was due my stupidity ...

there was a wrong view of data comparison with table and data from Query..

Any ways Thanks Guys...