SAP NetWeaver AS ABAP Release 740, ©Copyright 2014 SAP AG. All rights reserved.
ABAP Keyword Documentation → ABAP − Reference → Obsolete Language Elements → Obsolete Processing of External Data → Logical Databases (Obsolete) → Logical Databases - Examples →Logical Database, Call by Function Module
This example demonstrates calling a logical database using the function module LDB_PROCESS.
Source Code
REPORT demo_logical_database.
DATA wa_spfli TYPE spfli.
SELECTION-SCREEN BEGIN OF SCREEN 1100.
SELECT-OPTIONS s_carr FOR wa_spfli-carrid.
SELECTION-SCREEN END OF SCREEN 1100.
CLASS demo DEFINITION.
PUBLIC SECTION.
CLASS-METHODS main.
ENDCLASS.
CLASS demo IMPLEMENTATION.
METHOD main.
DATA callback TYPE TABLE OF ldbcb.
DATA: seltab TYPE TABLE OF rsparams,
seltab_wa LIKE LINE OF seltab,
scarr_wa LIKE LINE OF s_carr.
CALL SELECTION-SCREEN 1100 STARTING AT 10 10.
IF sy-subrc <> 0.
RETURN.
ENDIF.
callback = VALUE #( ( ldbnode = 'SPFLI'
get = 'X'
get_late = 'X'
cb_prog = sy-repid
cb_form = 'CALLBACK_SPFLI' )
( ldbnode = 'SFLIGHT'
get = 'X'
cb_prog = sy-repid
cb_form = 'CALLBACK_SFLIGHT' ) ).
seltab_wa-kind = 'S'.
seltab_wa-selname = 'CARRID'.
LOOP AT s_carr INTO scarr_wa.
MOVE-CORRESPONDING scarr_wa TO seltab_wa.
APPEND seltab_wa TO seltab.
ENDLOOP.
CALL FUNCTION 'LDB_PROCESS'
EXPORTING
ldbname = 'F1S'
variant = ' '
TABLES
callback = callback
selections = seltab
EXCEPTIONS
OTHERS = 4.
IF sy-subrc <> 0.
WRITE: 'Exception with SY-SUBRC', sy-subrc.
ENDIF.
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
demo=>main( ).
FORM callback_spfli USING name TYPE ldbn-ldbnode
wa TYPE spfli
evt TYPE c
check TYPE c.
CASE evt.
WHEN 'G'.
WRITE: / wa-carrid, wa-connid, wa-cityfrom, wa-cityto.
ULINE.
WHEN 'L'.
ULINE.
ENDCASE.
ENDFORM.
FORM callback_sflight USING name TYPE ldbn-ldbnode
wa TYPE sflight
evt TYPE c
check TYPE c.
WRITE: / wa-fldate, wa-seatsocc, wa-seatsmax.
ENDFORM.
Description
The program reads data using the logical database F1S. First a program-specific selection screen is defined. The data object wa_spfli is only required here. Next, suitable variables for the interface are declared.
The internal table callback is filled in such a way that, for the two nodes SPFLI and SFLIGHT, different callback routines in the calling program are called. For the node SPFLI, the corresponding routine for GET and GET LATE is only to be called for GET in the case of SFLIGHT.
The internal table seltab is filled with values from the selection table s_carr of the independent selection screen 1100 for the selections of node SPFLI.
The function module LDB_PROCESS is called with these parameters.
The subroutines callback_spfli and callback_sflight are used as callback routines. Since the interface parameter wa is completely typed, the individual components of the work area can be accessed. In callback_spfli, the events GET and GET LATE are handled differently.