Skip to Content
author's profile photo Former Member
Former Member

debug read....also please explain wat ty_mara , itab and itab1 are

tables: mara, marc, makt.

TYPES : begin of ty_mara,

matnr type mara-matnr,

werks type marc-werks,

maktx type makt-maktx,

end of ty_mara.

DATA : itab type table of ty_mara, i,

itab1 type ty_mara.

select-options : s_matnr for mara-matnr,

s_werks for marc-werks,

s_maktx for makt-maktx.

select amatnr bwerks c~maktx into table itab

from mara as a

inner join marc as b on amatnr = bmatnr

inner join makt as c on amatnr = cmatnr

where a~matnr in s_matnr and

b~werks in s_werks and

c~maktx in s_maktx.

if sy-subrc ne 0.

message 'not right' type 'I'.

endif.

read table itab into itab1 index i.

if sy-subrc eq 0.

message 'success' type 'S'.

else.

message 'fail' type 'S'.

endif.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Best Answer
    Posted on Jun 17, 2006 at 05:46 PM

    I am not sure what you are trying but am assuming you are trying to read the first record of your internal table. I would suggest the following

    Non- OO way of programming

    If you define a table with header line, you dont need to define a work area to access its fields. This however, is not suggested way of programming in OO world.

    DATA : itab type table of ty_mara with header line.

    Your Selection Crieteria

    if not itab[] is initial.

    read table itab index 1.

    endif.

    2nd way

    DATA : itab type table of ty_mara.

    DATA : wa_mara type ty_mara.

    Your Selection Crieteria

    if not itab is initial.

    read table itab index 1 into wa_mara.

      • access the fields wa_mara-feild1

      endif.

      If however, you are trying to access a record, lets say 10th record. Do the following to avoid dumps:

      DATA : tot_records type i.

      describe table itab lines tot_records.

      check the above against the index you are trying to access if the index you are accessing is greater than the records, handle the exceptions or throw an error.

      hith

      Sunil Achyut

      Add a comment
      10|10000 characters needed characters exceeded

    • Posted on Jun 17, 2006 at 04:08 PM

      ty_mara <-- you are defining a <u>internal type</u> which has 'matnr, werks, maktx' fields.

      itab <-- you are defining an <u>internal table</u> without header line that is of the type ty_mara, meaning it has the same fields.

      itab1 <-- you are defining a <u>work area</u> for reading the contents of itab into.

      Add a comment
      10|10000 characters needed characters exceeded

    • author's profile photo Former Member
      Former Member
      Posted on Jun 17, 2006 at 06:24 PM
      Add a comment
      10|10000 characters needed characters exceeded

    Before answering

    You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
    You must be Logged in to submit an answer.

    Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.