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 internal table

Former Member
0 Likes
568

Hi all,

I have the following code



FORM time_division.

  help = 1.

  LOOP AT datum.

    CONCATENATE 'itab-datum' help INTO feld_datum.
    CONCATENATE 'itab-menge' help INTO feld_menge.
    ASSIGN:
        (feld_datum) TO <field1>,
        (feld_menge) TO <field2>.


    READ TABLE b_tab WITH KEY gltrp = datum-low BINARY SEARCH.
    IF sy-subrc EQ 0.---> working fine
      MOVE-CORRESPONDING b_tab TO itab.
      <field1> = datum-low.
      <field2> = b_tab-menge.
*      MOVE datum-low TO itab-datum1.
*      MOVE b_tab-menge TO itab-menge1.
      COLLECT itab.
      clear itab.
    ELSE.--> not working
      MOVE-CORRESPONDING b_tab TO itab.
      <field1> = datum-low.
      <field2> = 0.
      collect itab.
      clear itab.
    ENDIF.
    help = help + 1.
  ENDLOOP.
  clear itab.
ENDFORM.                    " time_division

the problem ín the code is if the read statement is successfull then the program working fine. but when not successfull(move-corresponding not working) its appending new lines instead of modifying (bcoz its not successfull).

Please anybody tell me how to work with this problem.

Any help will be highly appreciated.

Thanks and regards

chandu.

4 REPLIES 4
Read only

Former Member
0 Likes
554

Hi,

IF sy-subrc = 0. then U'lll definitely have some

values in the internal table.

But If sy-subrc fails then <b>b_tab</b> will not have

any values. and UR doing the same below which appends a

blank line.

Your coding.

ELSE.--> not working

MOVE-CORRESPONDING b_tab TO itab.

<field1> = datum-low.

<field2> = 0.

collect itab.

clear itab.

ENDIF.

Regards,

GSR.

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
554

If you don't get a hit from B_TAB.....



  ELSE.--> not working   
    <b>MOVE-CORRESPONDING b_tab TO itab. </b>  
    <field1> = datum-low.     
    <field2> = 0.     
    collect itab.   
    clear itab.  
  ENDIF.


What exactly to you expect to move to ITAB. If its not found what to you want to put into ITAB./

Regards,

Rich Heilman

Read only

Former Member
0 Likes
554

hi,

As there is no

<b>clear: b_tab.</b> prior to

read table b_tab....

values are moving to itab from b_tab though read statement is unsuccessful.

MOVE-CORRESPONDING b_tab TO itab.

So, you might be getting wrong results.

Regards,

Sailaja.

Read only

Former Member
0 Likes
554

Hi Sai,

What exactly is your requiremnt ? What u want to do if the read statement fails. Currently ur program is coded to append blank lines and its doing it correctly !

ELSE.--> not working

MOVE-CORRESPONDING b_tab TO itab.

Here b_tab will have no value coz sy-surc <> 0 , so its appending a blank line. If you want the program to modify b_tab based on the datum (since u are looping at datum) u might have to use modify index or modify using statment.