Application Development 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: 

Doubt in Internal table

Former Member
0 Kudos
197

HI All

I need fetch all matnr ,ersda,ernam and mtart from table MARA,Iam using as follows but iam getting only one records.please i need all records from mara as my requirement.

DATA: BEGIN OF wa_MARA,

MATNR TYPE MARA-MATNR,

ERSDA TYPE MARA-ERSDA,

ERNAM TYPE MARA-ERNAM,

MTART TYPE MARA-MTART,

END OF wa_mara.

DATA:it_MARA LIKE TABLE OF wa_MARA WITH HEADER LINE.

select MATNR ERSDA ERNAM MTART from MARA into table it_mara.

please help me.

Thanks.

jay

1 ACCEPTED SOLUTION

Former Member
0 Kudos
162

Hi Jay


DATA: BEGIN OF wa_MARA,
           MATNR TYPE MARA-MATNR,
           ERSDA TYPE MARA-ERSDA,
           ERNAM TYPE MARA-ERNAM,
           MTART TYPE MARA-MTART,
     END OF wa_mara.


DATA: IT_MARA LIKE TABLE OF MARA occurs with 0                  header line.



select * from MARA into table it_mara.

this is the sample code for ur reference

DATA:
      wa_ekko LIKE ekko,
      wa_ekbe LIKE ekbe,
      wa_ekkn LIKE ekkn,
      wa_konp LIKE konp,
      wa_ekpo LIKE ekpo,
      wa_rbkp LIKE rbkp,
      wa_j_1ipart1 LIKE j_1ipart1,
      wa_j_1igrxref LIKE j_1igrxref,
      wa_rseg LIKE rseg OCCURS 0 WITH HEADER LINE.
**********************************
*internal tables
*********************************
DATA: BEGIN OF int_konh OCCURS 0,
      knumh LIKE konh-knumh,
      kschl LIKE konh-kschl,
      vakey LIKE konh-vakey,
      END OF int_konh.
SELECT  ebeln ebelp kostl ps_psp_pnr  FROM ekkn INTO int_ekkn
  FOR ALL ENTRIES IN int_outtab
  WHERE ebeln = int_outtab-ebeln AND
        ebelp = int_outtab-ebelp.
    APPEND int_ekkn.
  ENDSELECT.

Reward all helpfull answers

Regards

Pavan

10 REPLIES 10

Former Member
0 Kudos
162

Code correct, Sorry.

Erwan

Former Member
0 Kudos
162

Hi Jay,

Can u please try this code:

DATA:it_MARA LIKE wa_MARA OCCURS 0 WITH HEADER LINE.

Best Regards,

Victor.

Former Member
0 Kudos
162

you have defined the work area not an internal table

DATA: BEGIN OF wa_MARA ,

MATNR TYPE MARA-MATNR,

ERSDA TYPE MARA-ERSDA,

ERNAM TYPE MARA-ERNAM,

MTART TYPE MARA-MTART,

END OF wa_mara.

change ther statement has below.

<b>data:It_mara like wa_mara occurs 0 with header line.</b>

thanks and regardss

pavankumar

S0025444845
Active Participant
0 Kudos
162

Hi,

instead of data

DATA: BEGIN OF wa_MARA,

MATNR TYPE MARA-MATNR,

ERSDA TYPE MARA-ERSDA,

ERNAM TYPE MARA-ERNAM,

MTART TYPE MARA-MTART,

END OF wa_mara.

use

Types: BEGIN OF wa_MARA,

MATNR TYPE MARA-MATNR,

ERSDA TYPE MARA-ERSDA,

ERNAM TYPE MARA-ERNAM,

MTART TYPE MARA-MTART,

END OF wa_mara.

and then

DATA:it_MARA LIKE TABLE OF wa_MARA WITH HEADER LINE.

regards,

sudha

Former Member
0 Kudos
162

Hi Jay ,

Did you check in your table MARA how many entries are there , becuase i pasted your code in my system and executed it and it retrieved all the data.

Regards

Arun

Former Member
0 Kudos
162

YOUR CODE IS CORRECT ONLY WHAT IS YOUR PROBLEM?

REGARDS

SHIBA DUTTA

Former Member
0 Kudos
162

hi use this,

select * from MARA into INTO CORRESPONDING FIELDS OF it_mara.

append it_mara.

endselect.

Former Member
0 Kudos
163

Hi Jay


DATA: BEGIN OF wa_MARA,
           MATNR TYPE MARA-MATNR,
           ERSDA TYPE MARA-ERSDA,
           ERNAM TYPE MARA-ERNAM,
           MTART TYPE MARA-MTART,
     END OF wa_mara.


DATA: IT_MARA LIKE TABLE OF MARA occurs with 0                  header line.



select * from MARA into table it_mara.

this is the sample code for ur reference

DATA:
      wa_ekko LIKE ekko,
      wa_ekbe LIKE ekbe,
      wa_ekkn LIKE ekkn,
      wa_konp LIKE konp,
      wa_ekpo LIKE ekpo,
      wa_rbkp LIKE rbkp,
      wa_j_1ipart1 LIKE j_1ipart1,
      wa_j_1igrxref LIKE j_1igrxref,
      wa_rseg LIKE rseg OCCURS 0 WITH HEADER LINE.
**********************************
*internal tables
*********************************
DATA: BEGIN OF int_konh OCCURS 0,
      knumh LIKE konh-knumh,
      kschl LIKE konh-kschl,
      vakey LIKE konh-vakey,
      END OF int_konh.
SELECT  ebeln ebelp kostl ps_psp_pnr  FROM ekkn INTO int_ekkn
  FOR ALL ENTRIES IN int_outtab
  WHERE ebeln = int_outtab-ebeln AND
        ebelp = int_outtab-ebelp.
    APPEND int_ekkn.
  ENDSELECT.

Reward all helpfull answers

Regards

Pavan

jayanthi_jayaraman
Active Contributor
0 Kudos
162

Hi,

The code looks correct.I executed the same code and found I am getting all the records.

Check anywhere in the coding whether you are deleting records from it_mara.

Check the table contents whether it is having more than one record.

Kindly reward points by selecting the star on the left of reply,if it helps.

Former Member
0 Kudos
162

Thanks for All