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 statement problem

Former Member
0 Likes
2,144

TYPES : BEGIN OF itab,
         matnr LIKE eban-matnr,
         menge LIKE eban-menge,
       END OF itab.
TYPES : BEGIN OF itab2,
          maktx LIKE makt-maktx,
        END OF itab2.

DATA : it_eban TYPE STANDARD TABLE OF itab.
DATA : it_makt TYPE STANDARD TABLE OF itab2.

DATA : wa_eban TYPE itab.
DATA : wa_makt TYPE itab2.

START-OF-SELECTION.

  SELECT matnr menge INTO CORRESPONDING FIELDS OF TABLE
                        it_eban FROM eban.
  SELECT maktx INTO  CORRESPONDING FIELDS OF TABLE
                       it_makt from makt.

PERFORM display TABLES it_eban it_makt.

FORM display TABLES eban_tab makt_tab.
LOOP AT eban_tab INTO wa_eban.
  WRITE :/ wa_eban-matnr, wa_eban-menge.
  READ TABLE makt_tab with key matnr = wa_eban-matnr.
  "here I'm getting error like 
  "the specified type has no structure and therefore no component called "MATNR"
  "How can I write READ statement here to read makt_tab.
ENDLOOP.
ENDFORM.
1 ACCEPTED SOLUTION
Read only

jayanthi_jayaraman
Active Contributor
0 Likes
1,338

Hi,

Execute the below code.I checked and it is working fine.

TYPES : BEGIN OF itab,

matnr LIKE eban-matnr,

menge LIKE eban-menge,

END OF itab.

TYPES : BEGIN OF itab2,

<b>matnr like mara-matnr,</b>maktx LIKE makt-maktx,

END OF itab2.

DATA : it_eban TYPE STANDARD TABLE OF itab.

DATA : it_makt TYPE STANDARD TABLE OF itab2.

DATA : wa_eban TYPE itab.

DATA : wa_makt TYPE itab2.

START-OF-SELECTION.

SELECT matnr menge INTO CORRESPONDING FIELDS OF TABLE

it_eban FROM eban.

SELECT <b>matnr</b> maktx INTO CORRESPONDING FIELDS OF TABLE

it_makt from makt.

PERFORM display TABLES it_eban it_makt.

FORM display <b>TABLES eban_tab structure wa_eban

makt_tab structure wa_makt</b>.

LOOP AT eban_tab INTO wa_eban.

WRITE 😕 wa_eban-matnr, wa_eban-menge.

READ TABLE makt_tab <b>into wa_makt</b> with key matnr = wa_eban-matnr.

ENDLOOP.

ENDFORM.

Jayanthi Jayaraman

9 REPLIES 9
Read only

naimesh_patel
Active Contributor
0 Likes
1,338

You need to use explicit work area for this:

READ TABLE makt_tab into WA_MAKT with key matnr = wa_eban-matnr.

Regards,

Naimesh Patel

Read only

0 Likes
1,338

Hi Naimesh,

READ TABLE makt_tab INTO wa_makt WITH KEY matnr = wa_eban-matnr.
Problem is same I'm getting same error.
"The specified type has no structure and therefore no component called "MATNR"

Hi Matthew,

I'm getting error like,
"Field "ITAB2" is unknown.
and actually I wrote this simple program to illustarte my problem. In my actual program I must use global parameters..so please help me

Hi Jacek,

I've changed my code according to your suggetions.. but i'm getting same error
"The specified type has no structure and therefore no component called "MATNR"
Read only

matt
Active Contributor
0 Likes
1,338
FORM display TABLES eban_tab STRUCTURE itab
                    makt_tab STRUCTURE itab2.

And DON'T use global defined variables inside forms unless you really have to. Define local variables.

matt

Read only

Former Member
0 Likes
1,338

Try that

TYPES : BEGIN OF itab,

matnr LIKE eban-matnr,

menge LIKE eban-menge,

END OF itab.

TYPES : BEGIN OF itab2,

<b>matnr like mara-matnr,</b>

maktx LIKE makt-maktx,

END OF itab2.

DATA : it_eban TYPE STANDARD TABLE OF itab.

DATA : it_makt TYPE STANDARD TABLE OF itab2.

DATA : wa_eban TYPE itab.

DATA : wa_makt TYPE itab2.

START-OF-SELECTION.

SELECT matnr menge INTO CORRESPONDING FIELDS OF TABLE

it_eban FROM eban.

SELECT <b>matnr</b> maktx INTO CORRESPONDING FIELDS OF TABLE

it_makt from makt.

PERFORM display TABLES it_eban it_makt.

FORM display TABLES eban_tab makt_tab.

LOOP AT eban_tab INTO wa_eban.

WRITE 😕 wa_eban-matnr, wa_eban-menge.

READ TABLE makt_tab into <b>wa_makt</b> with key matnr = wa_eban-matnr.

"here I'm getting error like

"the specified type has no structure and therefore no component called "MATNR"

"How can I write READ statement here to read makt_tab.

ENDLOOP.

ENDFORM.

Message was edited by:

Jacek Slowikowski

Read only

Former Member
0 Likes
1,338

Hi Sudha,

This is a common problem where in the FORM routine parameters are not typed. ABAP allows declaring parameters without typing it to some datatype. Your problem is that the table you want to access is EBAN but inside the FORM routine there is no mention of the structure. So it should look like:


FORM DISPLAY
    TABLES eban_tab STRUCTURE eban " the dictionary structure or table 
                  makt_tab STRUCTURE makt. " the dictionary structure or table 

* your code here accessing different components of eban and makt

ENDFORM.

Hope this helps.

<b><i>FYI, using TABLES addition in FORM routines (and elsewhere like function modules) is obsolete in ABAP Objects context. So, better try using CHANGING addition instead!</i></b>

Thanks

Sanjeev

Read only

former_member191735
Active Contributor
0 Likes
1,338

you are missing into work area.

Read only

Former Member
0 Likes
1,338

hi,

In perform stmt u have the sequence as it_eban it_makt.

and it_makt doesn/t have field matnr.

in form the sequence is eban_tab makt_tab.

so makt_tab will be like it_makt .

hence makt_tab also lacks the field matnr.

thats why u get this error.

try changing the sequence or include the field matnr in structure itab2.

hope this helps.

Read only

jayanthi_jayaraman
Active Contributor
0 Likes
1,340

Hi,

Execute the below code.I checked and it is working fine.

TYPES : BEGIN OF itab,

matnr LIKE eban-matnr,

menge LIKE eban-menge,

END OF itab.

TYPES : BEGIN OF itab2,

<b>matnr like mara-matnr,</b>maktx LIKE makt-maktx,

END OF itab2.

DATA : it_eban TYPE STANDARD TABLE OF itab.

DATA : it_makt TYPE STANDARD TABLE OF itab2.

DATA : wa_eban TYPE itab.

DATA : wa_makt TYPE itab2.

START-OF-SELECTION.

SELECT matnr menge INTO CORRESPONDING FIELDS OF TABLE

it_eban FROM eban.

SELECT <b>matnr</b> maktx INTO CORRESPONDING FIELDS OF TABLE

it_makt from makt.

PERFORM display TABLES it_eban it_makt.

FORM display <b>TABLES eban_tab structure wa_eban

makt_tab structure wa_makt</b>.

LOOP AT eban_tab INTO wa_eban.

WRITE 😕 wa_eban-matnr, wa_eban-menge.

READ TABLE makt_tab <b>into wa_makt</b> with key matnr = wa_eban-matnr.

ENDLOOP.

ENDFORM.

Jayanthi Jayaraman

Read only

0 Likes
1,338

Thank you all....