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: 

Read from sap tables

Former Member
0 Kudos
111

Hello,

I want to read data from sap tables (e.g. mm01). Can you get me some tutorials for that? And can you tell me where I can find the specific name of a sap table, that I need to read from it (I guess using a SELECT statement)? Maybe you know some example code that could help me out, cause in my abap basics book I didn't find a chapter about getting data from sap standard tables.

thank you.

1 ACCEPTED SOLUTION

Former Member
0 Kudos
81

Hi,

Please refer this program

REPORT ZSAMPLE..

tables : mara , makt.

data : begin of itab occurs 4,

matnr like mara-matnr,

mbrsh like mara-mbrsh,

mtart like mara-mtart,

meins like mara-meins,

end of itab.

data : begin of jtab occurs 4,

matnr like makt-matnr,

spras like makt-spras,

maktx like makt-maktx,

maktg like makt-maktg,

end of jtab.

selection-screen : begin of block b1 with frame title text-001.

select-options material for mara-matnr.

*selection-screen position pos_low.

parameters sector like mara-mbrsh.

selection-screen : end of block b1.

initialization.

material-low = 'net'.

material-high ='zeee'.

append material.

start-of-selection.

select matnr mbrsh mtart meins from mara into table itab where matnr in material.

end-of-selection.

loop at itab.

format hotspot on.

write : / itab-matnr.

hide : itab-matnr.

format hotspot off.

write : itab-mbrsh, itab-mtart, itab-meins.

skip 1.

endloop.

top-of-page.

write : / 'hiding matnr field'.

end-of-page.

at line-selection.

  • case sy-ucomm.

  • when 'sy-lsind'.

*endcase.

select matnr spras maktx maktg from makt into table jtab where matnr = itab-matnr.

loop at jtab.

write : / jtab-matnr, jtab-spras, jtab-maktx, jtab-maktg.

endloop.

Please reward points if helpful

4 REPLIES 4

Former Member
0 Kudos
81

Hi,

Please refer tables MARA (Matrerial master) and MAKT (Material Description).

Thanks,

Sriram Ponna.

ak_upadhyay
Contributor
0 Kudos
81

Hi,

Check this....


                                                                                REPORT  ZPRO1     LINE-COUNT 50(3).                              .

TABLES: VBAK.

SELECT-OPTIONS: A_VBELN FOR VBAK-VBELN.


DATA: BEGIN OF IT OCCURS 0,

      VBELN LIKE VBAK-VBELN,
      ERDAT LIKE VBAK-ERDAT,

      END OF IT.


START-OF-SELECTION.

  SELECT VBELN ERDAT FROM VBAK INTO TABLE IT WHERE VBELN IN A_VBELN  .


END-OF-SELECTION.


  FORMAT COLOR 7.

  LOOP AT IT.

    WRITE:/ sy-vline,IT-VBELN,
            16 sy-vline, IT-ERDAT,
            34 sy-vline             .
    WRITE:/ SY-ULINE(34).

  ENDLOOP.

  FORMAT RESET.


TOP-OF-PAGE.
  WRITE:/ 'THIS IS MY TOP OF PAGE'.


END-OF-PAGE.

  WRITE:/ 'THIS IS MY END OF PAGE'.

Same u can do with Tbale MARA.

Reward points if useful....

Regards

AK

Former Member
0 Kudos
81

Just click the below link and you will find all MM realated tables and also link between them.

http://www.erpgenie.com/abap/tables_mm.htm

Former Member
0 Kudos
82

Hi,

Please refer this program

REPORT ZSAMPLE..

tables : mara , makt.

data : begin of itab occurs 4,

matnr like mara-matnr,

mbrsh like mara-mbrsh,

mtart like mara-mtart,

meins like mara-meins,

end of itab.

data : begin of jtab occurs 4,

matnr like makt-matnr,

spras like makt-spras,

maktx like makt-maktx,

maktg like makt-maktg,

end of jtab.

selection-screen : begin of block b1 with frame title text-001.

select-options material for mara-matnr.

*selection-screen position pos_low.

parameters sector like mara-mbrsh.

selection-screen : end of block b1.

initialization.

material-low = 'net'.

material-high ='zeee'.

append material.

start-of-selection.

select matnr mbrsh mtart meins from mara into table itab where matnr in material.

end-of-selection.

loop at itab.

format hotspot on.

write : / itab-matnr.

hide : itab-matnr.

format hotspot off.

write : itab-mbrsh, itab-mtart, itab-meins.

skip 1.

endloop.

top-of-page.

write : / 'hiding matnr field'.

end-of-page.

at line-selection.

  • case sy-ucomm.

  • when 'sy-lsind'.

*endcase.

select matnr spras maktx maktg from makt into table jtab where matnr = itab-matnr.

loop at jtab.

write : / jtab-matnr, jtab-spras, jtab-maktx, jtab-maktg.

endloop.

Please reward points if helpful