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

Read stmt problem in ECC 6.0

Former Member
0 Likes
904

My read stmt is not working in ECC 6.0

READ TABLE gt_zadi_matnr_conv WITH KEY

mandt = sy-mandt zadi_key_type = 'WERKS'

zadi_key_value = gs_zadi_m_2017_gm02-plant BINARY SEARCH.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
877
  • SORT gt_zadi_matnr_conv BY zadi_key_value.

LOOP AT gt_zadi_m_2017_gm02 INTO gs_zadi_m_2017_gm02.

READ TABLE gt_zadi_matnr_conv WITH KEY zadi_key_type = 'WERKS'

zadi_key_value = gs_zadi_m_2017_gm02-plant BINARY SEARCH.

IF sy-subrc = 0 .

gv_reebok_monitor = 'X'.

PERFORM convert_number_rbk_vs_adi USING gs_zadi_m_2017_gm02-plant

gs_zadi_m_2017_gm02-material

CHANGING gs_zadi_m_2017_gm02-material.

ENDIF.

Ihave commented sort stmt like

  • SORT gt_zadi_matnr_conv BY zadi_key_value.

Now my code is working ..

Now my doubt is Can I comment my sort ?????????

Or is there any issu ue?

If so please suggest me what to do ?

7 REPLIES 7
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
877

Pretty sure you don't need the MANDT in there, but not sure that is causing your problem. Do you mean you are getting a syntax error? What is the error? Or is it simply not returning anything?

READ TABLE gt_zadi_matnr_conv WITH KEY
                         zadi_key_type  = 'WERKS'      "<--- is this value correct?
                         zadi_key_value = gs_zadi_m_2017_gm02-plant
                                                        BINARY SEARCH.
if sy-subrc = 0.
...
endif.

Regards,

Rich Heilman

Read only

Former Member
0 Likes
877

I am getting sy-subrc = 4.

Read only

0 Likes
877

Is gs_zadi_m_2017_gm02 a table with Header line?

Can you post the code for the entire loop where you are performing this read?

Read only

Former Member
0 Likes
878
  • SORT gt_zadi_matnr_conv BY zadi_key_value.

LOOP AT gt_zadi_m_2017_gm02 INTO gs_zadi_m_2017_gm02.

READ TABLE gt_zadi_matnr_conv WITH KEY zadi_key_type = 'WERKS'

zadi_key_value = gs_zadi_m_2017_gm02-plant BINARY SEARCH.

IF sy-subrc = 0 .

gv_reebok_monitor = 'X'.

PERFORM convert_number_rbk_vs_adi USING gs_zadi_m_2017_gm02-plant

gs_zadi_m_2017_gm02-material

CHANGING gs_zadi_m_2017_gm02-material.

ENDIF.

Ihave commented sort stmt like

  • SORT gt_zadi_matnr_conv BY zadi_key_value.

Now my code is working ..

Now my doubt is Can I comment my sort ?????????

Or is there any issu ue?

If so please suggest me what to do ?

Read only

0 Likes
877

For using binnary search option you have to sort the table first with the same key. Did you try:


SORT gt_zadi_matnr_conv BY zadi_key_type zadi_key_value. 

Read only

Former Member
0 Likes
877

Hi,

If you are using BINARY SEARCH, then please use SORT on the fields which are getting used in the READ STATEMENT WITH KEY, else it will be huge performance issue.

SORT will sought out your problem.

Thanks,

Kartavya.

Read only

Former Member
0 Likes
877

Aparna Sekahar and Karthavaya THANK S FOR YOUR TIMELY REPLY.....!