Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

abap objects

hi,

how we can write a code in abap objects for retrievin the data from database table..the follwing code contains error..help me please..

TABLES:MARA.

SELECT-OPTIONS:SMATNR FOR MARA-MATNR.

CLASS SELECT DEFINITION.

PUBLIC SECTION.

DATA:BEGIN OF ITAB,

matnr like mara-matnr,

ersda like mara-ersda,

END OF ITAB.

data:itab1 like standard table of itab .

*data:wa like itab1.

METHODS:READ.

ENDCLASS.

CLASS SELECT IMPLEMENTATION.

METHOD READ.

SELECT matnr ersda FROM MARA INTO TABLE itab1

WHERE MATNR IN SMATNR.

*loop at itab1 .

write:itab1-matnr,itab1-ersda.

*endloop.

ENDMETHOD.

ENDCLASS.

START-OF-SELECTION.

DATA OBJ TYPE REF TO SELECT.

CREATE OBJECT OBJ.

CALL METHOD OBJ->read.

Tags:
Former Member
Former Member replied

hi,

check this code.

REPORT ZZTEST2.

TABLES:MARA.

SELECT-OPTIONS:SMATNR FOR MARA-MATNR.

CLASS SELECT DEFINITION.

PUBLIC SECTION.

types: BEGIN OF ty_mara,

matnr type matnr,

matkl type matkl,

end of ty_mara.

data:itab type standard table of ty_mara INITIAL SIZE 0,

wa_mara type ty_mara.

*data:wa like itab1.

METHODS:READ.

ENDCLASS.

CLASS SELECT IMPLEMENTATION.

METHOD READ.

SELECT matnr matkl FROM MARA INTO TABLE itab

WHERE MATNR IN SMATNR.

*loop at itab1 .

loop at itab into wa_mara.

write:wa_mara-matnr,wa_mara-matkl.

endloop.

*endloop.

ENDMETHOD.

ENDCLASS.

START-OF-SELECTION.

DATA OBJ TYPE REF TO SELECT.

CREATE OBJECT OBJ.

CALL METHOD OBJ->read.

Rewards points if it is useful

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question