legacy와 interface 하는 fuction예제
FUNCTION z_rfc_save_table_zmespij.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" EXPORTING
*" VALUE(RETURN) TYPE ZSDSRETURN
*" TABLES
*" I_TABLE STRUCTURE ZMESPIJ
*"----------------------------------------------------------------------
* Global data declarations
*-Check data
READ TABLE i_table INDEX 1.
IF i_table IS INITIAL.
return-msgty = 'E'.
return-msgv1 = 'No data exists'.
EXIT.
ENDIF.
*-Check P.K.
IF i_table-liner IS INITIAL
OR i_table-ifkdt IS INITIAL
OR i_table-serno IS INITIAL
OR i_table-matnr IS INITIAL
OR i_table-pdtyp IS INITIAL.
return-msgty = 'E'.
return-msgv1 = 'Check your entries. Primary Key missing'.
EXIT.
ENDIF.
CHECK return-msgty <> 'E'.
LOOP AT i_table.
covert_char_to_numc i_table-serno.
ENDLOOP.
LOOP AT i_table.
DATA : ddateend TYPE D.
DATA : C_TIME TYPE SY-DATUM.
ddateend = I_TABLE-PDFDT - 1.
IF I_TABLE-pdftm > '052959' .
I_TABLE-POSDT = I_TABLE-PDFDT.
ELSE.
I_TABLE-POSDT = DDATEEND.
ENDIF.
modify : I_TABLE.
CLEAR : I_TABLE.
ENDLOOP.
*-Insert
INSERT zmespij FROM TABLE i_table ACCEPTING DUPLICATE KEYS.
IF sy-subrc IS INITIAL.
COMMIT WORK AND WAIT.
return-msgty = 'S'.
return-msgv1 = 'Data saved'.
ELSE.
ROLLBACK WORK.
return-msgty = 'E'.
return-msgv1 = 'You cannot save...!'.
ENDIF.
ENDFUNCTION.