SAP/ABAP
loop at ... -> M1
DrkLion
2007. 11. 12. 09:42
CLASS c1 DEFINITION.
PUBLIC SECTION.
METHODS M1 IMPORTING NAME TYPE S_CARRNAME
RETURNING VALUE(CARR) TYPE S_CARR_ID.
ENDCLASS.
CLASS c1 IMPLEMENTATION.
METHOD M1.
SELECT CARRID UP TO 1 ROWS
FROM SCARR
INTO CARR
WHERE CARRNAME = NAME.
ENDSELECT.
ENDMETHOD.
ENDCLASS.
DATA: JTAB TYPE STANDARD TABLE OF SPFLI,
LINE TYPE SPFLI.
DATA: OREF TYPE REF TO C1.
START-OF-SELECTION.
SELECT * FROM SPFLI INTO TABLE JTAB.
CREATE OBJECT oref TYPE c1.
LOOP AT JTAB INTO LINE
WHERE CARRID = OREF-> M1( 'Lufthansa' ).
WRITE: / LINE-CARRID, LINE-CONNID,
LINE-CITYFROM, LINE-CITYTO.
ENDLOOP.
PUBLIC SECTION.
METHODS M1 IMPORTING NAME TYPE S_CARRNAME
RETURNING VALUE(CARR) TYPE S_CARR_ID.
ENDCLASS.
CLASS c1 IMPLEMENTATION.
METHOD M1.
SELECT CARRID UP TO 1 ROWS
FROM SCARR
INTO CARR
WHERE CARRNAME = NAME.
ENDSELECT.
ENDMETHOD.
ENDCLASS.
DATA: JTAB TYPE STANDARD TABLE OF SPFLI,
LINE TYPE SPFLI.
DATA: OREF TYPE REF TO C1.
START-OF-SELECTION.
SELECT * FROM SPFLI INTO TABLE JTAB.
CREATE OBJECT oref TYPE c1.
LOOP AT JTAB INTO LINE
WHERE CARRID = OREF-> M1( 'Lufthansa' ).
WRITE: / LINE-CARRID, LINE-CONNID,
LINE-CITYFROM, LINE-CITYTO.
ENDLOOP.
The actual paraemters are passed to the IMPORTING parameters of the method as described under variants 2 and 3 of the CALL METHOD statement.
If the line type of the internal table contains object reference variables as components, or the entire line type is a reference variable, you can use the attributes of the object to which the reference in a line is pointing as the first field in a comparison.
loop 돌리면서 Parameter 를 이용해 call method 를 실행 할 수도 있다!