Using the logical database through the Ldb_process function

Source: Internet
Author: User

1. Overview
The Ldb_process function allows any program to access the logical database, allow one program to access multiple logical databases, and, of course, allow multiple successive accesses to the same logical database. When using the Ldb_process function to access the logical database, the selection screen is not displayed and its selection parameters are passed in by the field_selection parameter.

2. ldb_process parameter description
Ldbname
Name of the logical database want to call.

VARIANT
Name of a Variant to fill the selection screen of the logical database. The variant must already is assigned to the database program of the logical database. The data is passed in the same-in-the-selection-table addition in a SUBMIT statement.

EXPRESSIONS
In this parameter, can pass extra selections for the nodes of the logical database for which dynamic selections is Al lowed. The data type of the parameter rsds_texpr is defined in the type group RSDS. The data is passed in the same-in-the-same-the-when-you-use-SELECTION addition in a SUBMIT statement.

Field_selection
Can use this parameter to pass a list of the required fields for the nodes of the logical database for which dynamic s Elections is allowed. The data type of the parameter is the deep internal table rsfs_fields, defined in the type group RSFS. The component TABLENAME contains the name of the node and the Deep component fields contains the names of the You want to read.

The function module has the following tables parameters:

CALLBACK
parameter to assign callback routines to the names of nodes and events. The parameter determines the nodes of the logical database for which data are read, and when the data was passed back to the Program and in which callback routine.

Selections
You can use this parameter-pass input values for the fields of the selection screen of the logical database. The data type of the parameter corresponds to the structure rsparams in the ABAP Dictionary. The data is passed in the same-in-the-selection-table addition in a SUBMIT statement.


3. Description of the specific field of the Ldb_process callback callback parameter
Ldbnode
Name of the node of the logical database to is read.

GET
A Flag (contents X or SPACE), to call the corresponding callback routine at the GET event.

Get_late
A Flag (contents X or SPACE), to call the corresponding callback routine at the GET late event.

Cb_prog
The Name of the ABAP program in which the callback routine is defined.

Cb_form
Name of the callback routine.


4, write the callback function
Standard form of the callback procedure
FORM <subr> USING <node> like Ldbcb-ldbnode
<wa> [TYPE <t>]
<evt>
<check>.
......
EndForm.
Where parameter description function:
<node> contains the name of the node.
<wa> is the work area of the data read for the node. The program is calls the function module ldb_process and the program containing the callback routine does not has to decl is interface work areas using NODES or TABLES. If the callback routine is only used for one node, you can use a type reference to refer to the data type of the node in T He ABAP Dictionary. Only then can you address the individual, the structured nodes directly in the subroutine. If you use the callback routine for more than one node, you cannot use a TYPE reference. In this case, you would has to address the components of structured nodes by assigning them one by one to a field symbol.
<evt> contains G or L, for Get or get late respectively. This means, the subroutine can direct the program flow using the contents of <evt>
<check> allows the callback routine to influence what the program was processed further (but only if <evt> conta Ins the value G). The value X is assigned to the parameter when the subroutine is called. If it has the value SPACE then the subroutine ends, this flags that the subordinate nodes of the logical database should n OT be processed in the function module ldb_process. This is the same as leaving a GET event block using CHECK with an executable program. If This prevents unnecessary data from being read, it would improve the performance of your program.

5. Sample code and description

1 TABLESSpfli.2 select-optionsS_carr forspfli-Carrid.3 4 Type-pools: Rsds, Rsfs.5 6 DATA: CallbackTYPE TABLE  ofLDBCB,7Callback_wa like  Line  ofcallback.8 9 DATA: SeltabTYPE TABLE  ofRsparams,TenSeltab_wa like  Line  ofSeltab. One  A DATA: texprTYPErsds_texpr, -FselTYPERsfs_fields. -  the *to set the data node and the callback corresponding subroutine for the callback -Callback_wa-ldbnode ='Spfli'. -Callback_wa-get ='X'. -Callback_wa-get_late ='X'. +Callback_wa-cb_prog = sy-repid. -Callback_wa-cb_form ='Callback_spfli'. + APPENDCallback_wa tocallback. A  at CLEARCallback_wa. -Callback_wa-ldbnode ='Sflight'. -Callback_wa-get ='X'. -Callback_wa-cb_prog = sy-repid. -Callback_wa-cb_form ='Callback_sflight'. - APPENDCallback_wa tocallback. in  - *sets the incoming value of the parameter for the corresponding selection screen toSeltab_wa-kind ='S'. +Seltab_wa-selname ='Carrid'. -  the LOOP  atS_carr. *   move-correspondingS_carr toSeltab_wa. $   APPENDSeltab_wa toSeltab.Panax Notoginseng Endloop. -  the *calling Functions + Pager FUNCTION 'ldb_process' A   Exporting theLdbname ='F1s' +Variant =' ' -expressions =texpr $Field_selection =Fsel $   TABLES -callback =Callback -Selections =Seltab the   EXCEPTIONS -Ldb_not_reentrant =1WuyiLdb_incorrect =2 theLdb_already_running =3 -Ldb_error =4 WuLdb_selections_error =5 -ldb_selections_not_accepted =6 AboutVariant_not_existent =7 $Variant_obsolete =8 -Variant_error =9 -Free_selections_error =Ten -Callback_no_event = One ACallback_node_duplicate = A +OTHERS = -. the  - IFSY-SUBRC <>0. $   WRITE:'Exception with SY-SUBRC', sy-SUBRC. the ENDIF. the  the *SPFLI node corresponding callback handler function the FORMCallback_spfliUSINGNameTYPEldbn-Ldbnode -WaTYPESpfli inEvtTYPEC theCheckTYPEc. the    Caseevt. AboutWhen'G'. the       WRITE:/Wa-carrid, Wa-connid, Wa-cityfrom, wa-Cityto. the       Uline. theWhen'L'. +       Uline. -   Endcase. the EndForm."Callback_spfliBayi  the *sfight node corresponding callback handler function the FORMCallback_sflightUSINGNameTYPEldbn-Ldbnode -WaTYPESflight -EvtTYPEC theCheckTYPEc. the   WRITE:/Wa-fldate, WA-SEATSOCC, wa-Seatsmax. the EndForm."Callback_sflight

Note: When accessing a logical database through the ' ldb_process ' function, do not bind the logical database in the program properties, otherwise there will be a ldb_already_running error.

Data source SAP Library.

Using the logical database through the Ldb_process function

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.